public override void run()
 {
     try
     {
         Account player = this._client._player;
         if (player == null)
         {
             return;
         }
         PlayerTitles titles = player._titles;
         TitleQ       title  = TitlesXML.getTitle((int)this.titleId, true);
         TitleQ       title1;
         TitleQ       title2;
         TitleQ       title3;
         TitlesXML.get3Titles(titles.Equiped1, titles.Equiped2, titles.Equiped3, out title1, out title2, out title3, false);
         if (this.slotIdx >= (byte)3 || this.titleId >= (byte)45 || (titles == null || title == null) || (title._classId == title1._classId && this.slotIdx != (byte)0 || title._classId == title2._classId && this.slotIdx != (byte)1) || (title._classId == title3._classId && this.slotIdx != (byte)2 || (!titles.Contains(title._flag) || titles.Equiped1 == (int)this.titleId) || (titles.Equiped2 == (int)this.titleId || titles.Equiped3 == (int)this.titleId)))
         {
             this.erro = 2147483648U;
         }
         else if (TitleManager.getInstance().updateEquipedTitle(titles.ownerId, (int)this.slotIdx, (int)this.titleId))
         {
             titles.SetEquip((int)this.slotIdx, (int)this.titleId);
         }
         else
         {
             this.erro = 2147483648U;
         }
         this._client.SendPacket((SendPacket) new BASE_TITLE_USE_PAK(this.erro));
     }
     catch (Exception ex)
     {
         Logger.info("BASE_TITLE_USE_REC: " + ex.ToString());
     }
 }
 public override void run()
 {
     try
     {
         Account player = this._client._player;
         if (player == null || this.slotIdx >= 3 || player._titles == null)
         {
             return;
         }
         PlayerTitles titles = player._titles;
         int          equip  = titles.GetEquip(this.slotIdx);
         if (equip > 0 && TitleManager.getInstance().updateEquipedTitle(titles.ownerId, this.slotIdx, 0))
         {
             titles.SetEquip(this.slotIdx, 0);
             if (TitleAwardsXML.Contains(equip, player._equip._beret) && ComDiv.updateDB("accounts", "char_beret", (object)0, "player_id", (object)player.player_id))
             {
                 player._equip._beret = 0;
                 Room room = player._room;
                 if (room != null)
                 {
                     AllUtils.updateSlotEquips(player, room);
                 }
             }
         }
         else
         {
             this.erro = 2147483648U;
         }
         this._client.SendPacket((SendPacket) new BASE_TITLE_DETACH_PAK(this.erro));
     }
     catch (Exception ex)
     {
         Logger.info("BASE_TITLE_DETACH_REC: " + ex.ToString());
     }
 }
Exemple #3
0
 public override void RunImplement()
 {
     try
     {
         Account player = client.SessionPlayer;
         if (player == null || slotIdx >= 3)
         {
             return;
         }
         PlayerTitles titles  = player.titles;
         int          titleId = titles.GetEquip(slotIdx);
         if (titleId > 0 && player.UpdateEquipedTitle(slotIdx, 0))
         {
             titles.SetEquip(slotIdx, 0);
             if (TitlesManager.Contains(titleId, player.equipments.beret) && player.ExecuteQuery($"UPDATE accounts SET character_beret='0' WHERE id='{player.playerId}'"))
             {
                 player.equipments.beret = 0;
                 Room room = player.room;
                 if (room != null && room.GetSlot(player.slotId, out Slot slot))
                 {
                     slot.equipment = player.equipments;
                 }
             }
             client.SendCompletePacket(PackageDataManager.BASE_TITLE_DETACH_SUCCESS_PAK);
         }
         else
         {
             client.SendCompletePacket(PackageDataManager.BASE_TITLE_DETACH_ERROR_PAK);
         }
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }
Exemple #4
0
 public override void RunImplement()
 {
     try
     {
         Account player = client.SessionPlayer;
         if (player == null)
         {
             return;
         }
         PlayerTitles titles = player.titles;
         TitleQ       titleQ = TitlesManager.GetTitle(titleId);
         if (slotIdx >= 3 || titleId >= 45 || titleQ == null || titles.Equiped1 == titleId || titles.Equiped2 == titleId || titles.Equiped3 == titleId)
         {
             client.SendCompletePacket(PackageDataManager.BASE_TITLE_USE_ERROR_PAK);
             return;
         }
         TitlesManager.GetTitlesEquipped(titles.Equiped1, titles.Equiped2, titles.Equiped3, out TitleQ titleEquiped1, out TitleQ titleEquiped2, out TitleQ titleEquiped3);
         if (titleQ.classId == titleEquiped1.classId && slotIdx != 0 || titleQ.classId == titleEquiped2.classId && slotIdx != 1 || titleQ.classId == titleEquiped3.classId && slotIdx != 2 || !titles.Contains(titleQ.flag))
         {
             client.SendCompletePacket(PackageDataManager.BASE_TITLE_USE_ERROR_PAK);
             return;
         }
         if (player.UpdateEquipedTitle(slotIdx, titleId))
         {
             titles.SetEquip(slotIdx, titleId);
             client.SendCompletePacket(PackageDataManager.BASE_TITLE_USE_SUCCESS_PAK);
         }
         else
         {
             client.SendCompletePacket(PackageDataManager.BASE_TITLE_USE_ERROR_PAK);
         }
     }
     catch (Exception ex)
     {
         PacketLog(ex);
     }
 }
 public override void run()
 {
     try
     {
         Account p = _client._player;
         if (p == null || slotIdx >= 3 || p._titles == null)
         {
             return;
         }
         PlayerTitles t       = p._titles;
         int          titleId = t.GetEquip(slotIdx);
         if (titleId > 0 &&
             TitleManager.getInstance().updateEquipedTitle(t.ownerId, slotIdx, 0))
         {
             t.SetEquip(slotIdx, 0);
             if (TitleAwardsXML.Contains(titleId, p._equip._beret) && ComDiv.updateDB("contas", "char_beret", 0, "player_id", p.player_id))
             {
                 p._equip._beret = 0;
                 Room room = p._room;
                 if (room != null)
                 {
                     AllUtils.updateSlotEquips(p, room);
                 }
             }
         }
         else
         {
             erro = 0x80000000;
         }
         _client.SendPacket(new BASE_TITLE_DETACH_PAK(erro));
     }
     catch (Exception ex)
     {
         SaveLog.fatal(ex.ToString());
         Printf.b_danger("[BASE_TITLE_DETACH_REC.run] Erro fatal!");
     }
 }
 public override void run()
 {
     try
     {
         Account p = _client._player;
         if (p == null)
         {
             return;
         }
         PlayerTitles t = p._titles;
         TitleQ       titleQ = TitlesXML.getTitle(titleId),
                      eq1, eq2, eq3;
         TitlesXML.get3Titles(t.Equiped1, t.Equiped2, t.Equiped3, out eq1, out eq2, out eq3, false);
         if (slotIdx >= 3 || titleId >= 45 || t == null || titleQ == null || titleQ._classId == eq1._classId && slotIdx != 0 || titleQ._classId == eq2._classId && slotIdx != 1 || titleQ._classId == eq3._classId && slotIdx != 2 || !t.Contains(titleQ._flag) || t.Equiped1 == titleId || t.Equiped2 == titleId || t.Equiped3 == titleId)
         {
             erro = 0x80000000;
         }
         else
         {
             if (TitleManager.getInstance().updateEquipedTitle(t.ownerId, slotIdx, titleId))
             {
                 t.SetEquip(slotIdx, titleId);
             }
             else
             {
                 erro = 0x80000000;
             }
         }
         _client.SendPacket(new BASE_TITLE_USE_PAK(erro));
     }
     catch (Exception ex)
     {
         SaveLog.fatal(ex.ToString());
         Printf.b_danger("[BASE_TITLE_USE_REC.run] Erro fatal!");
     }
 }