コード例 #1
0
        internal void ProcessCommand(string data)
        {
            if (!data.Contains(((char)1).ToString()))
            {
                return;
            }

            var parts  = data.Split((char)1);
            var header = parts[1].ToLower();

            if (header == string.Empty)
            {
                return;
            }
            parts = parts.Skip(1).ToArray();

            GameClient clientByUserId;
            uint       userId;

            switch (header)
            {
            case "addtoinventory":
                userId = Convert.ToUInt32(parts[0]);
                var furniId = Convert.ToInt32(parts[1]);

                clientByUserId = Azure.GetGame().GetClientManager().GetClientByUserId(userId);
                if (clientByUserId == null || clientByUserId.GetHabbo() == null ||
                    clientByUserId.GetHabbo().GetInventoryComponent() == null)
                {
                    return;
                }

                clientByUserId.GetHabbo().GetInventoryComponent().UpdateItems(true);
                clientByUserId.GetHabbo().GetInventoryComponent().SendNewItems((uint)furniId);

                break;

            case "updatecredits":
                userId = Convert.ToUInt32(parts[0]);
                var credits = Convert.ToInt32(parts[1]);

                clientByUserId = Azure.GetGame().GetClientManager().GetClientByUserId(userId);
                if (clientByUserId != null && clientByUserId.GetHabbo() != null)
                {
                    clientByUserId.GetHabbo().Credits = credits;
                    clientByUserId.GetHabbo().UpdateCreditsBalance();
                }
                return;

            case "updatesubscription":
                userId = Convert.ToUInt32(parts[0]);

                clientByUserId = Azure.GetGame().GetClientManager().GetClientByUserId(userId);
                if (clientByUserId == null || clientByUserId.GetHabbo() == null)
                {
                    return;
                }
                clientByUserId.GetHabbo().GetSubscriptionManager().ReloadSubscription();
                clientByUserId.GetHabbo().SerializeClub();
                break;
            }
        }