public override void run()
 {
     try
     {
         Account player = this._client._player;
         if (player == null)
         {
             return;
         }
         ItemsModel  itemsModel = player._inventory.getItem(this.objId);
         PlayerBonus bonus      = player._bonus;
         if (itemsModel == null)
         {
             this.erro = 2147483648U;
         }
         else if (ComDiv.getIdStatics(itemsModel._id, 1) == 12)
         {
             if (bonus == null)
             {
                 this._client.SendPacket((SendPacket) new INVENTORY_ITEM_EXCLUDE_PAK(2147483648U, 0L));
                 return;
             }
             if (!bonus.RemoveBonuses(itemsModel._id))
             {
                 if (itemsModel._id == 1200014000)
                 {
                     if (ComDiv.updateDB("player_bonus", "sightcolor", (object)4, "player_id", (object)player.player_id))
                     {
                         bonus.sightColor = 4;
                         this._client.SendPacket((SendPacket) new BASE_USER_EFFECTS_PAK(0, bonus));
                     }
                     else
                     {
                         this.erro = 2147483648U;
                     }
                 }
                 else if (itemsModel._id == 1200010000)
                 {
                     if (bonus.fakeNick.Length == 0)
                     {
                         this.erro = 2147483648U;
                     }
                     else if (ComDiv.updateDB("accounts", "player_name", (object)bonus.fakeNick, "player_id", (object)player.player_id) && ComDiv.updateDB("player_bonus", "fakenick", (object)"", "player_id", (object)player.player_id))
                     {
                         player.player_name = bonus.fakeNick;
                         bonus.fakeNick     = "";
                         this._client.SendPacket((SendPacket) new BASE_USER_EFFECTS_PAK(0, bonus));
                         this._client.SendPacket((SendPacket) new AUTH_CHANGE_NICKNAME_PAK(player.player_name));
                     }
                     else
                     {
                         this.erro = 2147483648U;
                     }
                 }
                 else if (itemsModel._id == 1200009000)
                 {
                     if (ComDiv.updateDB("player_bonus", "fakerank", (object)55, "player_id", (object)player.player_id))
                     {
                         bonus.fakeRank = 55;
                         this._client.SendPacket((SendPacket) new BASE_USER_EFFECTS_PAK(0, bonus));
                     }
                     else
                     {
                         this.erro = 2147483648U;
                     }
                 }
                 else if (itemsModel._id == 1200006000)
                 {
                     if (ComDiv.updateDB("accounts", "name_color", (object)0, "player_id", (object)player.player_id))
                     {
                         player.name_color = 0;
                         this._client.SendPacket((SendPacket) new BASE_2612_PAK(player));
                         Room room = player._room;
                         if (room != null)
                         {
                             using (ROOM_GET_NICKNAME_PAK roomGetNicknamePak = new ROOM_GET_NICKNAME_PAK(player._slotId, player.player_name, player.name_color))
                                 room.SendPacketToPlayers((SendPacket)roomGetNicknamePak);
                         }
                     }
                     else
                     {
                         this.erro = 2147483648U;
                     }
                 }
             }
             else
             {
                 PlayerManager.updatePlayerBonus(player.player_id, bonus.bonuses, bonus.freepass);
             }
             CupomFlag cupomEffect = CupomEffectManager.getCupomEffect(itemsModel._id);
             if (cupomEffect != null && cupomEffect.EffectFlag > (CupomEffects)0 && player.effects.HasFlag((Enum)cupomEffect.EffectFlag))
             {
                 player.effects -= cupomEffect.EffectFlag;
                 PlayerManager.updateCupomEffects(player.player_id, player.effects);
             }
         }
         if (this.erro == 1U && itemsModel != null)
         {
             if (PlayerManager.DeleteItem(itemsModel._objId, player.player_id))
             {
                 player._inventory.RemoveItem(itemsModel);
             }
             else
             {
                 this.erro = 2147483648U;
             }
         }
         this._client.SendPacket((SendPacket) new INVENTORY_ITEM_EXCLUDE_PAK(this.erro, this.objId));
     }
     catch (Exception ex)
     {
         Logger.info("[INVENTORY_ITEM_EXCLUDE_REC] " + ex.ToString());
         this._client.SendPacket((SendPacket) new INVENTORY_ITEM_EXCLUDE_PAK(2147483648U, 0L));
     }
 }
Exemplo n.º 2
0
        public void DiscountPlayerItems()
        {
            bool          updEffect = false;
            uint          data_atual = uint.Parse(DateTime.Now.ToString("yyMMddHHmm"));
            List <object> removedItems = new List <object>();
            int           bonuses = _bonus != null ? _bonus.bonuses : 0, freepass = _bonus != null ? _bonus.freepass : 0;

            lock (_inventory._items)
            {
                for (int i = 0; i < _inventory._items.Count; i++)
                {
                    ItemsModel item = _inventory._items[i];
                    if (item._count <= data_atual & item._equip == 2)
                    {
                        if (item._category == 3)
                        {
                            if (_bonus == null)
                            {
                                continue;
                            }
                            bool changed = _bonus.RemoveBonuses(item._id);
                            if (!changed)
                            {
                                if (item._id == 1200014000)
                                {
                                    ComDiv.updateDB("player_bonus", "sightcolor", 4, "player_id", player_id);
                                    _bonus.sightColor = 4;
                                }
                                else if (item._id == 1200006000)
                                {
                                    ComDiv.updateDB("contas", "name_color", 0, "player_id", player_id);
                                    name_color = 0;
                                }
                                else if (item._id == 1200009000)
                                {
                                    ComDiv.updateDB("player_bonus", "fakerank", 55, "player_id", player_id);
                                    _bonus.fakeRank = 55;
                                }
                                else if (item._id == 1200010000)
                                {
                                    if (_bonus.fakeNick.Length > 0)
                                    {
                                        ComDiv.updateDB("player_bonus", "fakenick", "", "player_id", player_id);
                                        ComDiv.updateDB("contas", "player_name", _bonus.fakeNick, "player_id", player_id);
                                        player_name     = _bonus.fakeNick;
                                        _bonus.fakeNick = "";
                                    }
                                }
                            }
                            CupomFlag cupom = CupomEffectManager.getCupomEffect(item._id);
                            if (cupom != null && cupom.EffectFlag > 0 && effects.HasFlag(cupom.EffectFlag))
                            {
                                effects  -= cupom.EffectFlag;
                                updEffect = true;
                            }
                        }
                        removedItems.Add(item._objId);
                        _inventory._items.RemoveAt(i--);
                    }
                    else if (item._count == 0)
                    {
                        removedItems.Add(item._objId);
                        _inventory._items.RemoveAt(i--);
                    }
                }
                ComDiv.deleteDB("player_items", "id", removedItems.ToArray(), "owner_id", player_id);
            }
            removedItems = null;
            if (_bonus != null && (_bonus.bonuses != bonuses || _bonus.freepass != freepass))
            {
                PlayerManager.updatePlayerBonus(player_id, _bonus.bonuses, _bonus.freepass);
            }
            if (effects < 0)
            {
                effects = 0;
            }
            if (updEffect)
            {
                PlayerManager.updateCupomEffects(player_id, effects);
            }
            _inventory.LoadBasicItems();
            int type = PlayerManager.CheckEquipedItems(_equip, _inventory._items);

            if (type > 0)
            {
                DBQuery query = new DBQuery();
                if ((type & 2) == 2)
                {
                    PlayerManager.updateWeapons(_equip, query);
                }
                if ((type & 1) == 1)
                {
                    PlayerManager.updateChars(_equip, query);
                }
                ComDiv.updateDB("contas", "player_id", player_id, query.GetTables(), query.GetValues());
                query = null;
            }
        }
Exemplo n.º 3
0
        public override void run()
        {
            try
            {
                Account p = _client._player;
                if (p == null)
                {
                    return;
                }
                ItemsModel  item  = p._inventory.getItem(objId);
                PlayerBonus bonus = p._bonus;
                if (item == null)
                {
                    erro = 0x80000000;
                }
                else if (ComDiv.getIdStatics(item._id, 1) == 12)
                {
                    if (bonus == null)
                    {
                        _client.SendPacket(new INVENTORY_ITEM_EXCLUDE_PAK(0x80000000));
                        return;
                    }
                    bool changed = bonus.RemoveBonuses(item._id);
                    if (!changed)
                    {
                        if (item._id == 1200014000)
                        {
                            if (ComDiv.updateDB("player_bonus", "sightcolor", 4, "player_id", p.player_id))
                            {
                                bonus.sightColor = 4;
                                _client.SendPacket(new BASE_USER_EFFECTS_PAK(0, bonus));
                            }
                            else
                            {
                                erro = 0x80000000;
                            }
                        }
                        else if (item._id == 1200010000)
                        {
                            if (bonus.fakeNick.Length == 0)
                            {
                                erro = 0x80000000;
                            }
                            else
                            {
                                if (ComDiv.updateDB("contas", "player_name", bonus.fakeNick, "player_id", p.player_id) &&
                                    ComDiv.updateDB("player_bonus", "fakenick", "", "player_id", p.player_id))
                                {
                                    p.player_name  = bonus.fakeNick;
                                    bonus.fakeNick = "";
                                    _client.SendPacket(new BASE_USER_EFFECTS_PAK(0, bonus));
                                    _client.SendPacket(new AUTH_CHANGE_NICKNAME_PAK(p.player_name));
                                }
                                else
                                {
                                    erro = 0x80000000;
                                }
                            }
                        }
                        else if (item._id == 1200009000)
                        {
                            if (ComDiv.updateDB("player_bonus", "fakerank", 55, "player_id", p.player_id))
                            {
                                bonus.fakeRank = 55;
                                _client.SendPacket(new BASE_USER_EFFECTS_PAK(0, bonus));
                            }
                            else
                            {
                                erro = 0x80000000;
                            }
                        }
                        else if (item._id == 1200006000)
                        {
                            if (ComDiv.updateDB("contas", "name_color", 0, "player_id", p.player_id))
                            {
                                p.name_color = 0;
                                _client.SendPacket(new BASE_2612_PAK(p));
                                Room room = p._room;
                                if (room != null)
                                {
                                    using (ROOM_GET_NICKNAME_PAK packet = new ROOM_GET_NICKNAME_PAK(p._slotId, p.player_name, p.name_color))
                                        room.SendPacketToPlayers(packet);
                                }
                            }
                            else
                            {
                                erro = 0x80000000;
                            }
                        }
                    }
                    else
                    {
                        PlayerManager.updatePlayerBonus(p.player_id, bonus.bonuses, bonus.freepass);
                    }

                    CupomFlag cupom = CupomEffectManager.getCupomEffect(item._id);
                    if (cupom != null && cupom.EffectFlag > 0 && p.effects.HasFlag(cupom.EffectFlag))
                    {
                        p.effects -= cupom.EffectFlag;
                        PlayerManager.updateCupomEffects(p.player_id, p.effects);
                    }
                }
                if (erro == 1 && item != null)
                {
                    if (PlayerManager.DeleteItem(item._objId, p.player_id))
                    {
                        p._inventory.RemoveItem(item);
                    }
                    else
                    {
                        erro = 0x80000000;
                    }
                }
                _client.SendPacket(new INVENTORY_ITEM_EXCLUDE_PAK(erro, objId));
            }
            catch (Exception ex)
            {
                SaveLog.fatal(ex.ToString());
                Printf.b_danger("[INVENTORY_ITEM_EXCLUDE_REC.INVENTORY_ITEM_EXCLUDE_REC] Erro fatal!");
                _client.SendPacket(new INVENTORY_ITEM_EXCLUDE_PAK(0x80000000));
            }
        }
Exemplo n.º 4
0
 public override void RunImplement()
 {
     try
     {
         Account player = client.SessionPlayer;
         if (player == null)
         {
             return;
         }
         ItemsModel item = player.inventory.GetItem(objectId);
         if (item == null)
         {
             client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
             return;
         }
         else if (Utilities.GetIdStatics(item.id, 1) == 12)
         {
             PlayerBonus bonus = player.bonus;
             if (bonus == null)
             {
                 client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
                 return;
             }
             bool changed = bonus.RemoveBonuses(item.id);
             if (!changed)
             {
                 if (item.id == 1200014000)
                 {
                     if (player.ExecuteQuery($"UPDATE player_bonus SET sightcolor='4' WHERE player_id='{player.playerId}'"))
                     {
                         bonus.sightColor = 4;
                         client.SendPacket(new PROTOCOL_BASE_USER_EFFECTS_ACK(0, bonus));
                     }
                     else
                     {
                         client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
                         return;
                     }
                 }
                 else if (item.id == 1200010000)
                 {
                     if (bonus.fakeNick.Length == 0)
                     {
                         client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
                         return;
                     }
                     if (player.ExecuteQuery($"UPDATE accounts SET nickname='{bonus.fakeNick}' WHERE id='{player.playerId}'") &&
                         player.ExecuteQuery($"UPDATE player_bonus SET fakenick='{""}' WHERE player_id='{player.playerId}'"))
                     {
                         player.nickname = bonus.fakeNick;
                         bonus.fakeNick  = "";
                         client.SendPacket(new PROTOCOL_BASE_USER_EFFECTS_ACK(0, bonus));
                         client.SendPacket(new PROTOCOL_AUTH_CHANGE_NICKNAME_ACK(player.nickname));
                     }
                     else
                     {
                         client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
                         return;
                     }
                 }
                 else if (item.id == 1200009000)
                 {
                     if (player.ExecuteQuery($"UPDATE player_bonus SET fakerank='55' WHERE player_id='{player.playerId}'"))
                     {
                         bonus.fakeRank = 55;
                         client.SendPacket(new PROTOCOL_BASE_USER_EFFECTS_ACK(0, bonus));
                     }
                     else
                     {
                         client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
                         return;
                     }
                 }
                 else if (item.id == 1200006000)
                 {
                     if (player.ExecuteQuery($"UPDATE accounts SET nickcolor='0' WHERE id='{player.playerId}'"))
                     {
                         player.nickcolor = 0;
                         client.SendPacket(new BASE_2612_PAK(player));
                         Room room = player.room;
                         if (room != null)
                         {
                             using (PROTOCOL_ROOM_GET_NICKNAME_ACK packet = new PROTOCOL_ROOM_GET_NICKNAME_ACK(player.slotId, player.nickname, player.nickcolor))
                             {
                                 room.SendPacketToPlayers(packet);
                             }
                         }
                     }
                     else
                     {
                         client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
                         return;
                     }
                 }
             }
             else
             {
                 player.UpdatePlayerBonus();
             }
         }
         if (item != null)
         {
             if (player.DeleteItem(item.objectId))
             {
                 player.inventory.RemoveItem(item);
             }
             else
             {
                 client.SendCompletePacket(PackageDataManager.INVENTORY_ITEM_EXCLUDE_0x80000000_PAK);
                 return;
             }
         }
         client.SendPacket(new INVENTORY_ITEM_EXCLUDE_PAK(1, objectId));
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }