Пример #1
0
        private void cupomIncreaseDays(Account p, string originalName)
        {
            int          itemId    = ComDiv.createItemId(12, ComDiv.getIdStatics(this.itemId, 2), ComDiv.getIdStatics(this.itemId, 3), 0);
            int          idStatics = ComDiv.getIdStatics(this.itemId, 4);
            CupomEffects effects   = p.effects;

            if (itemId == 1200065000 && (effects & (CupomEffects.Colete20 | CupomEffects.Colete10 | CupomEffects.Colete5)) > (CupomEffects)0 || itemId == 1200079000 && (effects & (CupomEffects.Colete90 | CupomEffects.Colete10 | CupomEffects.Colete5)) > (CupomEffects)0 || (itemId == 1200044000 && (effects & (CupomEffects.Colete90 | CupomEffects.Colete20 | CupomEffects.Colete5)) > (CupomEffects)0 || itemId == 1200030000 && (effects & (CupomEffects.Colete90 | CupomEffects.Colete20 | CupomEffects.Colete10)) > (CupomEffects)0) || (itemId == 1200078000 && (effects & (CupomEffects.HollowPointF | CupomEffects.HollowPoint | CupomEffects.IronBullet)) > (CupomEffects)0 || itemId == 1200032000 && (effects & (CupomEffects.HollowPointPlus | CupomEffects.HollowPointF | CupomEffects.IronBullet)) > (CupomEffects)0 || (itemId == 1200031000 && (effects & (CupomEffects.HollowPointPlus | CupomEffects.HollowPointF | CupomEffects.HollowPoint)) > (CupomEffects)0 || itemId == 1200036000 && (effects & (CupomEffects.HollowPointPlus | CupomEffects.HollowPoint | CupomEffects.IronBullet)) > (CupomEffects)0)) || (itemId == 1200028000 && effects.HasFlag((Enum)CupomEffects.HP5) || itemId == 1200040000 && effects.HasFlag((Enum)CupomEffects.HP10)))
            {
                this.erro = 2147483648U;
            }
            else
            {
                ItemsModel itemsModel1 = p._inventory.getItem(itemId);
                if (itemsModel1 == null)
                {
                    bool      flag        = p._bonus.AddBonuses(itemId);
                    CupomFlag cupomEffect = CupomEffectManager.getCupomEffect(itemId);
                    if (cupomEffect != null && cupomEffect.EffectFlag > (CupomEffects)0 && !p.effects.HasFlag((Enum)cupomEffect.EffectFlag))
                    {
                        p.effects |= cupomEffect.EffectFlag;
                        PlayerManager.updateCupomEffects(p.player_id, p.effects);
                    }
                    if (flag)
                    {
                        PlayerManager.updatePlayerBonus(p.player_id, p._bonus.bonuses, p._bonus.freepass);
                    }
                    GameClient client   = this._client;
                    int        type     = 1;
                    Account    player   = p;
                    int        id       = itemId;
                    int        category = 3;
                    string     name     = originalName + " [Active]";
                    int        equip    = 2;
                    DateTime   dateTime = DateTime.Now;
                    dateTime = dateTime.AddDays((double)idStatics);
                    int        num         = (int)uint.Parse(dateTime.ToString("yyMMddHHmm"));
                    long       objId       = 0;
                    ItemsModel itemsModel2 = new ItemsModel(id, category, name, equip, (uint)num, objId);
                    INVENTORY_ITEM_CREATE_PAK inventoryItemCreatePak = new INVENTORY_ITEM_CREATE_PAK(type, player, itemsModel2);
                    client.SendPacket((SendPacket)inventoryItemCreatePak);
                }
                else
                {
                    DateTime exact = DateTime.ParseExact(itemsModel1._count.ToString(), "yyMMddHHmm", (IFormatProvider)CultureInfo.InvariantCulture);
                    itemsModel1._count = uint.Parse(exact.AddDays((double)idStatics).ToString("yyMMddHHmm"));
                    ComDiv.updateDB("player_items", "count", (object)(long)itemsModel1._count, "object_id", (object)itemsModel1._objId, "owner_id", (object)p.player_id);
                    this._client.SendPacket((SendPacket) new INVENTORY_ITEM_CREATE_PAK(2, p, itemsModel1));
                }
            }
        }
Пример #2
0
        private void cupomIncreaseDays(Account p, string originalName)
        {
            int cupomId      = ComDiv.createItemId(12, ComDiv.getIdStatics(itemId, 2), ComDiv.getIdStatics(itemId, 3), 0),
                days         = ComDiv.getIdStatics(itemId, 4);
            CupomEffects eff = p.effects;

            if (cupomId == 1200065000 && ((eff & (CupomEffects.Colete5 | CupomEffects.Colete10 | CupomEffects.Colete20)) > 0) ||
                cupomId == 1200079000 && ((eff & (CupomEffects.Colete5 | CupomEffects.Colete10 | CupomEffects.Colete90)) > 0) ||
                cupomId == 1200044000 && ((eff & (CupomEffects.Colete5 | CupomEffects.Colete20 | CupomEffects.Colete90)) > 0) ||
                cupomId == 1200030000 && ((eff & (CupomEffects.Colete20 | CupomEffects.Colete10 | CupomEffects.Colete90)) > 0) ||
                cupomId == 1200078000 && ((eff & (CupomEffects.IronBullet | CupomEffects.HollowPoint | CupomEffects.HollowPointF)) > 0) ||
                cupomId == 1200032000 && ((eff & (CupomEffects.HollowPointF | CupomEffects.HollowPointPlus | CupomEffects.IronBullet)) > 0) ||
                cupomId == 1200031000 && ((eff & (CupomEffects.HollowPointF | CupomEffects.HollowPointPlus | CupomEffects.HollowPoint)) > 0) ||
                cupomId == 1200036000 && ((eff & (CupomEffects.HollowPoint | CupomEffects.HollowPointPlus | CupomEffects.IronBullet)) > 0) ||
                cupomId == 1200028000 && eff.HasFlag(CupomEffects.HP5) ||
                cupomId == 1200040000 && eff.HasFlag(CupomEffects.HP10))
            {
                erro = 0x80000000;
            }
            else
            {
                ItemsModel item = p._inventory.getItem(cupomId);
                if (item == null)
                {
                    bool      changed = p._bonus.AddBonuses(cupomId);
                    CupomFlag cupom   = CupomEffectManager.getCupomEffect(cupomId);
                    if (cupom != null && cupom.EffectFlag > 0 && !p.effects.HasFlag(cupom.EffectFlag))
                    {
                        p.effects |= cupom.EffectFlag;
                        PlayerManager.updateCupomEffects(p.player_id, p.effects);
                    }
                    if (changed)
                    {
                        PlayerManager.updatePlayerBonus(p.player_id, p._bonus.bonuses, p._bonus.freepass);
                    }
                    _client.SendPacket(new INVENTORY_ITEM_CREATE_PAK(1, p, new ItemsModel(cupomId, 3, originalName + " [Active]", 2, uint.Parse(DateTime.Now.AddDays(days).ToString("yyMMddHHmm")))));
                }
                else
                {
                    DateTime data = DateTime.ParseExact(item._count.ToString(), "yyMMddHHmm", CultureInfo.InvariantCulture);
                    item._count = uint.Parse(data.AddDays(days).ToString("yyMMddHHmm"));
                    ComDiv.updateDB("player_items", "count", (long)item._count, "id", item._objId, "owner_id", p.player_id);
                    _client.SendPacket(new INVENTORY_ITEM_CREATE_PAK(2, p, item));
                }
            }
        }
 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));
     }
 }
Пример #4
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));
            }
        }
Пример #5
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;
            }
        }
Пример #6
0
        public void DiscountPlayerItems()
        {
            bool          flag       = false;
            uint          num1       = uint.Parse(DateTime.Now.ToString("yyMMddHHmm"));
            List <object> objectList = new List <object>();
            int           num2       = this._bonus != null ? this._bonus.bonuses : 0;
            int           num3       = this._bonus != null ? this._bonus.freepass : 0;

            lock (this._inventory._items)
            {
                for (int index = 0; index < this._inventory._items.Count; ++index)
                {
                    ItemsModel itemsModel = this._inventory._items[index];
                    if (itemsModel._count <= num1 & itemsModel._equip == 2)
                    {
                        if (itemsModel._category == 3)
                        {
                            if (this._bonus != null)
                            {
                                if (!this._bonus.RemoveBonuses(itemsModel._id))
                                {
                                    if (itemsModel._id == 1200014000)
                                    {
                                        ComDiv.updateDB("player_bonus", "sightcolor", (object)4, "player_id", (object)this.player_id);
                                        this._bonus.sightColor = 4;
                                    }
                                    else if (itemsModel._id == 1200006000)
                                    {
                                        ComDiv.updateDB("accounts", "name_color", (object)0, "player_id", (object)this.player_id);
                                        this.name_color = 0;
                                    }
                                    else if (itemsModel._id == 1200009000)
                                    {
                                        ComDiv.updateDB("player_bonus", "fakerank", (object)55, "player_id", (object)this.player_id);
                                        this._bonus.fakeRank = 55;
                                    }
                                    else if (itemsModel._id == 1200010000 && this._bonus.fakeNick.Length > 0)
                                    {
                                        ComDiv.updateDB("player_bonus", "fakenick", (object)"", "player_id", (object)this.player_id);
                                        ComDiv.updateDB("accounts", "player_name", (object)this._bonus.fakeNick, "player_id", (object)this.player_id);
                                        this.player_name     = this._bonus.fakeNick;
                                        this._bonus.fakeNick = "";
                                    }
                                }
                                CupomFlag cupomEffect = CupomEffectManager.getCupomEffect(itemsModel._id);
                                if (cupomEffect != null && cupomEffect.EffectFlag > (CupomEffects)0 && this.effects.HasFlag((Enum)cupomEffect.EffectFlag))
                                {
                                    this.effects -= cupomEffect.EffectFlag;
                                    flag          = true;
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        objectList.Add((object)itemsModel._objId);
                        this._inventory._items.RemoveAt(index--);
                    }
                    else if (itemsModel._count == 0U)
                    {
                        objectList.Add((object)itemsModel._objId);
                        this._inventory._items.RemoveAt(index--);
                    }
                }
                ComDiv.deleteDB("player_items", "object_id", objectList.ToArray(), "owner_id", (object)this.player_id);
            }
            if (this._bonus != null && (this._bonus.bonuses != num2 || this._bonus.freepass != num3))
            {
                PlayerManager.updatePlayerBonus(this.player_id, this._bonus.bonuses, this._bonus.freepass);
            }
            if (this.effects < (CupomEffects)0)
            {
                this.effects = (CupomEffects)0;
            }
            if (flag)
            {
                PlayerManager.updateCupomEffects(this.player_id, this.effects);
            }
            this._inventory.LoadBasicItems();
            int num4 = PlayerManager.CheckEquipedItems(this._equip, this._inventory._items, false);

            if (num4 <= 0)
            {
                return;
            }
            DBQuery query = new DBQuery();

            if ((num4 & 2) == 2)
            {
                PlayerManager.updateWeapons(this._equip, query);
            }
            if ((num4 & 1) == 1)
            {
                PlayerManager.updateChars(this._equip, query);
            }
            ComDiv.updateDB("accounts", "player_id", (object)this.player_id, query.GetTables(), query.GetValues());
        }