ChatPacket() public static method

public static ChatPacket ( byte type, int id, string text, string name ) : byte[]
type byte
id int
text string
name string
return byte[]
コード例 #1
0
        private void doCommand(string command, List <string> parameters)
        {
            try
            {
                Console.WriteLine("[EVENT] Command: {0}, Parameters: {1}", command, listToString(parameters));

                switch (NameToEnum(command))
                {
                case ScriptCommandType.Sleep:
                    Thread.Sleep(Int32.Parse(parameters[0]));
                    break;

                case ScriptCommandType.SpawnUnique:
                    this.SpawnUnique(parameters);
                    break;

                case ScriptCommandType.Notice:
                    Systems.SendAll(Packet.ChatPacket(7, 0, listToString(parameters, false), ""));
                    break;

                case ScriptCommandType.SpawnMob:
                    this.spawnMob(parameters);
                    break;

                default:
                    break;
                }
            }
            catch (Exception)
            {
                Console.WriteLine("exception at handling command: Type = {0} ::: Parameters = {1}", command, listToString(parameters));
            }
        }
コード例 #2
0
        /////////////////////////////////////////////////////////////////////////////////
        // Expand warehouse
        /////////////////////////////////////////////////////////////////////////////////
        void HandleWareHouse(int itemid)
        {
            try
            {
                //First we check the itemid (To make sure its not altered!).
                //TOD: Add anti item hack check(Class for itemid check).

                //If the user allready used one of these items before.
                if (Character.Account.StorageSlots > 151)
                {
                    //Need to check error message if item allready used.
                    //TMP message
                    client.Send(Packet.ChatPacket(7, Character.Information.UniqueID, "Allready expanded.", ""));
                }
                //If not continue to expand the storage
                else
                {
                    //We dont use reader info since we use static info 30 slots increase.
                    byte warehouseslots = Character.Account.StorageSlots += 30;
                    //Update sql database information
                    MsSQL.UpdateData("UPDATE users SET warehouse_slots='" + warehouseslots + "' WHERE id='" + Player.AccountName + "'");
                    //Need to check official message
                    client.Send(Packet.ChatPacket(7, Character.Information.UniqueID, "Your storage has been upgraded.", ""));
                    //Reload characters
                    PlayerDataLoad();
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
コード例 #3
0
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 // Inventory expansion
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 void HandleInventoryExp(int ItemID)
 {
     try
     {
         //Set new slots
         int newslots = Character.Information.Slots + 32;
         //If item has been used before
         if (Character.Information.ExpandedStorage == 1)
         {
             //Need to get official message for this
             string full = "You allready used this item";
             Send(Packet.ChatPacket(7, Character.Information.UniqueID, full, ""));
         }
         //Continue to update inventory
         else
         {
             MsSQL.UpdateData("UPDATE character SET Slots='" + newslots + "',Storage_Expanded='1' WHERE Name='" + Character.Information.Name + "'");
             //Reload character(Teleport same location)
             //Todo relocate user after usage
             //TMP teleport player to update.
             Character.Information.Scroll = true;
             StartScrollTimer(500);
         }
     }
     catch (Exception ex)
     {
         Systems.Debugger.Write(ex);
     }
 }
コード例 #4
0
ファイル: PlayerState.cs プロジェクト: uvbs/DarkEmu
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Player Disconnect
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        public void KickPlayer(Systems Target)
        {
            try
            {
                Target.client.Send((Packet.ChatPacket(7, Target.Character.Information.UniqueID, "You Have been kicked!", "")));
                if (Player != null)
                {
                    MsSQL.UpdateData("UPDATE users SET online='" + 0 + "' WHERE id='" + Target.Player.AccountName + "'");
                    MsSQL.UpdateData("UPDATE character SET online=" + 0 + "' WHERE id='" + Target.Character.Information.UniqueID + "'");
                    Target.Player.Dispose();
                    Target.Player = null;
                }
                if (Target.Character != null)
                {
                    if (Target.Character.Transport.Right)
                    {
                        Target.Character.Transport.Horse.DeSpawnMe();
                    }
                    if (Target.Character.Grabpet.Active)
                    {
                        Target.Character.Grabpet.Details.DeSpawnMe();
                    }
                    if (Target.Character.Network.Exchange.Window)
                    {
                        Target.Exchange_Close();
                    }
                    if (Target.Character.State.Sitting)
                    {
                        Target.StopSitDownTimer();
                    }
                    Target.StopAttackTimer();
                    Target.BuffAllClose();
                    Target.DeSpawnMe();
                    Target.StopMPRegen();
                    Target.StopHPRegen();
                    Target.SavePlayerPosition();
                    Target.SavePlayerInfo();
                    Target.Character.InGame = false;

                    client.Disconnect(Target.client.clientSocket);
                    Target.client.Close();
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
コード例 #5
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // Berserk Items
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        void HandleRegenZerk(int style, int ItemID)
        {
            try
            {
                if (Character.Information.Berserking)
                {
                    return;
                }
                if (style == 1)
                {
                    Character.Information.BerserkBar = 0;
                    client.Send(Packet.InfoUpdate(4, 0, Character.Information.BerserkBar));
                    Character.Information.Berserking = true;
                    if (Character.Information.Title != 0)
                    {
                        Character.Information.BerserkOran = 200;
                    }
                    else
                    {
                        Character.Information.BerserkOran = 200;
                    }
                    Send(Packet.StatePack(Character.Information.UniqueID, 4, 1, false));

                    Character.Speed.Updateded[20] = 150;
                    Character.Speed.RunSpeed     += Character.Speed.Updateded[20];
                    //Player_SetNewSpeed();
                    Send(Packet.SetSpeed(Character.Information.UniqueID, Character.Speed.WalkSpeed, Character.Speed.RunSpeed));

                    MsSQL.UpdateData("update character set berserkbar='" + Character.Information.BerserkBar + "' where id='" + Character.Information.CharacterID + "'");
                    StartBerserkerTimer(60000);
                    string info2 = "You have 60 seconds until the scroll ends! Triple speed!";
                    client.Send(Packet.ChatPacket(7, Character.Information.UniqueID, info2, ""));
                }
                else if (style == 2)
                {
                    Character.Information.BerserkBar = 0;
                    client.Send(Packet.InfoUpdate(4, 0, Character.Information.BerserkBar));
                    Character.Information.Berserking = true;
                    if (Character.Information.Title != 0)
                    {
                        Character.Information.BerserkOran = 200;
                    }
                    else
                    {
                        Character.Information.BerserkOran = 230;
                    }
                    Send(Packet.StatePack(Character.Information.UniqueID, 4, 2, false));

                    Character.Speed.Updateded[20] = 100;
                    Character.Speed.RunSpeed     += Character.Speed.Updateded[20];

                    Send(Packet.SetSpeed(Character.Information.UniqueID, Character.Speed.WalkSpeed, Character.Speed.RunSpeed));

                    MsSQL.UpdateData("update character set berserkbar='" + Character.Information.BerserkBar + "' where id='" + Character.Information.CharacterID + "'");
                    StartBerserkerTimer(100000);
                    string info2 = "You have 100 seconds until the scroll ends!";
                    client.Send(Packet.ChatPacket(7, Character.Information.UniqueID, info2, ""));
                }
            }
            catch (Exception ex)
            {
                Systems.Debugger.Write(ex);
            }
        }
コード例 #6
0
ファイル: ItemUsage.cs プロジェクト: uvbs/DarkEmu
        void Handle()
        {
            try
            {
                //Read packet information
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                byte         iSlot  = Reader.Byte();
                //Get global item information
                Global.slotItem uItemID = GetItem((uint)Character.Information.CharacterID, iSlot, 0);
                //Checks before continuing
                if (uItemID.ID != 0 || !Character.State.Die)
                {
                    //###########################################################################################
                    // Grabpets
                    //###########################################################################################
                    #region Pets (PET OBJECTS)

                    // Grabpets
                    #region Grabpets
                    if (Data.ItemBase[uItemID.ID].Pettype == Global.item_database.PetType.GRABPET)
                    {
                        //Check if we have pet active allready.
                        if (!Character.Grabpet.Active && Character.Action.MonsterID.Count == 0)
                        {
                            //If not active , add new pet object.
                            HandleGrabPet(iSlot, uItemID.ID);
                            //Need to change this to active effect on slot.
                            HandleUpdateSlotn(iSlot, uItemID, Reader.Int32());
                        }
                    }
                    #endregion
                    // Attackpets
                    #region Attackpets
                    else if (Data.ItemBase[uItemID.ID].Pettype == Global.item_database.PetType.ATTACKPET)
                    {
                        //Check if we have pet active allready.
                        if (!Character.Attackpet.Active && Character.Action.MonsterID.Count == 0 || !Character.Attackpet.Active && Character.Action.MonsterID == null)
                        {
                            //If not active , add new pet object.
                            if (!Character.Attackpet.Active)
                            {
                                HandleUpdateSlotn(iSlot, uItemID, Reader.Int32());
                                HandleAttackPet(iSlot, uItemID.ID);
                                client.Send(Packet.Update2(iSlot));
                                client.Send(Packet.ChangeStatus(Character.Information.UniqueID, 5, 0));
                            }
                        }
                    }
                    #endregion
                    #endregion
                    // Horses (NOTE: Detail error messages per if statement (if level, summoned etc).
                    #region Horses
                    if (Data.ItemBase[uItemID.ID].Pettype == Global.item_database.PetType.TRANSPORT)
                    {
                        //Checks before we continue
                        if (!Character.Stall.Stallactive && !Character.Transport.Right && Character.Action.MonsterID.Count == 0 && !Character.State.Sitting && !Character.Information.Scroll)
                        {
                            //Check if level is high enough
                            if (this.Character.Information.Level >= Data.ItemBase[uItemID.ID].Level)
                            {
                                HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                                HandleHorseScroll(uItemID.ID);
                            }
                            //Else
                            else
                            {
                                client.Send(Packet.IngameMessages(SERVER_PLAYER_UPTOHORSE, IngameMessages.UIIT_MSG_COSPETERR_CANT_PETSUM_HIGHLEVEL));
                            }
                        }
                    }
                    #endregion
                    // Special transport
                    #region Special transport
                    else if (Data.ItemBase[uItemID.ID].Pettype == Global.item_database.PetType.ATTACKPET)
                    {
                    }
                    #endregion
                    // Job Transport
                    #region Job Transport
                    else if (Data.ItemBase[uItemID.ID].Pettype == Global.item_database.PetType.JOBTRANSPORT)
                    {
                        //HandleJobTransport(uItemID.ID);
                    }
                    #endregion
                    //###########################################################################################
                    // Potions
                    //###########################################################################################
                    #region Potions
                    #region HP potion
                    if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.HP_POTION && Data.ItemBase[uItemID.ID].Etctype != Global.item_database.EtcType.HPSTATPOTION)
                    {
                        HandlePotion(1, uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    else if (Data.ItemBase[uItemID.ID].Name.Contains("_HP_") && Data.ItemBase[uItemID.ID].Name.Contains("_SUPERSET_"))
                    {
                        HandlePotion(1, uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    #region HP STAT Potions
                    else if (Data.ItemBase[uItemID.ID].Etctype != Global.item_database.EtcType.HP_POTION && Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.HPSTATPOTION)
                    {
                    }
                    #endregion
                    #region MP potions
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.MP_POTION && Data.ItemBase[uItemID.ID].Etctype != Global.item_database.EtcType.MPSTATPOTION)
                    {
                        HandlePotion(2, uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    else if (Data.ItemBase[uItemID.ID].Name.Contains("_MP_") && Data.ItemBase[uItemID.ID].Name.Contains("_SUPERSET_"))
                    {
                        HandlePotion(1, uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    #region HP STAT Potions
                    else if (Data.ItemBase[uItemID.ID].Etctype != Global.item_database.EtcType.HP_POTION && Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.MPSTATPOTION)
                    {
                    }
                    #endregion
                    #region Vigor potions

                    /*
                     *  else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.VIGOR_POTION)
                     *  {
                     *      HandlePotion(5, uItemID.ID);
                     *      HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                     *  }
                     */
                    else if (Data.ItemBase[uItemID.ID].Name.Contains("ITEM_ETC_ALL_"))
                    {
                        HandlePotion(5, uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    #region Speed potions
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.SPEED_POTION)
                    {
                        if (Character.Speed.DefaultSpeed == Character.Speed.RunSpeed ||
                            Character.Speed.DefaultSpeed + Character.Speed.Updateded[20] != Character.Speed.RunSpeed && Character.Information.Berserking)
                        {
                            this.SpecialBuff(Data.ItemBase[uItemID.ID].SkillID);
                            HandleUpdateSlot(iSlot, uItemID, Reader.UInt16());
                        }
                    }
                    #endregion
                    #region Berserk Potion
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.BERSERKPOTION)
                    {
                        if (Character.Information.BerserkBar < 5)
                        {
                            if (Character.Information.Berserking == false)
                            {
                                this.Character.Information.BerserkBar = 5;
                                client.Send(Packet.InfoUpdate(4, 0, Character.Information.BerserkBar));
                                HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                            }
                        }
                    }
                    #endregion
                    #endregion
                    //###########################################################################################
                    // Tickets
                    //###########################################################################################
                    #region Tickets
                    //Forgotten world
                    #region Forgotten world
                    else if (Data.ItemBase[uItemID.ID].Ticket == Global.item_database.Tickets.DUNGEON_FORGOTTEN_WORLD)
                    {
                        //Must add check if user location currently is forgotten world.
                        //Must add level check of portal.
                        ForgottenWorld(uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    #endregion
                    //###########################################################################################
                    // Global chat
                    //###########################################################################################
                    #region Global Chat
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.GLOBALCHAT)
                    {
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                        byte   something = Reader.Byte();
                        string text      = Reader.Text3();
                        Reader.Close();
                        SendAll(Packet.ChatPacket(6, 0, text, Character.Information.Name));
                    }
                    #endregion
                    //###########################################################################################
                    // Stall decoration
                    //###########################################################################################
                    #region Stall decoration
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.STALLDECORATION)
                    {
                        StallDeco(uItemID.ID, iSlot);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    //###########################################################################################
                    // Monster masks
                    //###########################################################################################
                    #region Monster masks
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.MONSTERMASK)
                    {
                        //If character monster mask isnt enabled allready.
                        if (!Character.Transformed)
                        {
                            if (Character.Information.Level >= Data.ItemBase[uItemID.ID].Level)
                            {
                                //Load Mask
                                MonsterMasks(uItemID.ID, iSlot);
                                HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                            }
                            else
                            {
                                //Send msg level to low
                            }
                        }
                        else
                        {
                            //Send msg allready in use
                        }
                    }
                    #endregion
                    //###########################################################################################
                    // Return scrolls
                    //###########################################################################################
                    #region Return scrolls
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.RETURNSCROLL && Data.ItemBase[uItemID.ID].Etctype != Global.item_database.EtcType.REVERSESCROLL)
                    {
                        if (Character.Information.Scroll)
                        {
                            return;
                        }
                        if (Timer.Movement != null)
                        {
                            Timer.Movement.Dispose();
                            Character.Position.Walking = false;
                        }
                        HandleReturnScroll(uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    //###########################################################################################
                    // Reverse scrolls
                    //###########################################################################################
                    #region Reverse scrolls
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.REVERSESCROLL)
                    {
                        if (Character.Information.Scroll)
                        {
                            return;
                        }
                        if (Character.Position.Walking)
                        {
                            return;
                        }
                        //Read item id
                        int itemid = Reader.Int32();
                        //Our switch byte
                        byte type = Reader.Byte();
                        //locations for reverse
                        int locid = 0;
                        if (type == 7)
                        {
                            locid = Reader.Int32();
                        }
                        //Start our handle
                        HandleReverse(itemid, type, locid);
                        //Update slot
                        HandleUpdateSlot(iSlot, uItemID, itemid);
                    }
                    #endregion
                    //###########################################################################################
                    // Thief scrolls
                    //###########################################################################################
                    #region Thief scrolls
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.BANDITSCROLL)
                    {
                        if (Character.Information.Scroll)
                        {
                            return;
                        }
                        HandleThiefScroll(uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    //###########################################################################################
                    // Summon scrolls
                    //###########################################################################################
                    #region Summon scrolls
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.SUMMONSCROLL)
                    {
                        HandleSummon(Character.Information.Level);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    //###########################################################################################
                    // Skin change scrolls
                    //###########################################################################################
                    #region Skin change scrolls
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.CHANGESKIN)
                    {
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                        int skinmodel = Reader.Int32();
                        HandleSkinScroll(skinmodel, uItemID.ID);
                    }
                    #endregion
                    //###########################################################################################
                    // Item change tool
                    //###########################################################################################
                    #region Skin change scrolls
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.ITEMCHANGETOOL)
                    {
                        int  itemid     = Reader.Int32();
                        byte targetslot = Reader.Byte();
                        //Make sure the item target is not equiped.
                        if (targetslot < 13)
                        {
                            return;
                        }
                        //Continue
                        HandleUpdateSlot(iSlot, uItemID, itemid);
                        HandleItemChange(uItemID.ID, iSlot, targetslot);
                    }
                    #endregion
                    //###########################################################################################
                    // Dungeon items
                    //###########################################################################################
                    #region Forgotten world
                    else if (Data.ItemBase[uItemID.ID].Ticket == Global.item_database.Tickets.DUNGEON_FORGOTTEN_WORLD)
                    {
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                        ForgottenWorld(uItemID.ID);
                    }
                    #endregion
                    //###########################################################################################
                    // Inventory expansion
                    //###########################################################################################
                    #region Inventory expansion
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.INVENTORYEXPANSION)
                    {
                        HandleInventoryExp(uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    //###########################################################################################
                    // Warehouse expansion
                    //###########################################################################################
                    #region Warehouse expansion
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.WAREHOUSE)
                    {
                        HandleWareHouse(uItemID.ID);
                        HandleUpdateSlot(iSlot, uItemID, Reader.Int32());
                    }
                    #endregion
                    //###########################################################################################
                    // Guild related
                    //###########################################################################################
                    #region Guild Icon
                    else if (Data.ItemBase[uItemID.ID].Etctype == Global.item_database.EtcType.GUILD_ICON)
                    {
                        HandleRegisterIcon();
                    }
                    #endregion
                    //###########################################################################################
                    // Non coded types
                    //###########################################################################################
                    else
                    {
                        //Need to make message in progress or such
                        Console.WriteLine("Non Coded Item ID: " + Data.ItemBase[uItemID.ID].ID + " Name: " + Data.ItemBase[uItemID.ID].Name + "");
                    }
                }
                // Close our packet reader
                Reader.Close();
            }
            catch (Exception ex)
            {
                Console.WriteLine("Item usage error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }
コード例 #7
0
        void Chat()
        {
            /*
             *  We use for each now, to make sure there wont be any issues
             *  Incase the list we send the packet to can have none connected clients.
             *  To prevent bugging of chat we repeat and check each client before sending.
             */
            try
            {
                //Set our list of ranged players
                List <int> Rangedplayers = Character.Spawn;
                //Create new packet reader for reading packet data
                PacketReader Reader = new PacketReader(PacketInformation.buffer);
                //Chat type byte (for our switch case).
                byte chatType = Reader.Byte();
                //Byte chat index
                byte chatIndex = Reader.Byte();
                //Link count byte
                byte linkCount = Reader.Byte();
                //Create switch to switch on type of chat (normal party etc).
                switch (chatType)
                {
                //--------------------------------- [Normal chat] ---------------------------------//
                case 1:
                    //Read written text from packet data
                    string Text = Reader.Text3();
                    //Close packet reader
                    Reader.Close();

                    // .additem 111 12
                    if (Character.Information.GM == 1 && Text[0] == '.')
                    {
                        gmCommands(Text);
                    }

                    //Repeat for each in range player
                    foreach (int member in Rangedplayers)
                    {
                        //Make sure the member is not null
                        if (member != 0)
                        {
                            //Make sure its not sending to our client
                            if (member != Character.Information.UniqueID)
                            {
                                //Get member detail
                                Systems memberinfo = GetPlayer(member);
                                //Send packet to the in range player
                                memberinfo.client.Send(Packet.ChatPacket(chatType, Character.Information.UniqueID, Text, null));
                            }
                        }
                    }
                    //Send chatindex packet to ourselfs
                    client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                    break;

                //--------------------------------- [Normal chat pink] ---------------------------------//
                case 3:
                    //Check if our character has gm rights or not
                    if (Character.Information.GM == 1)
                    {
                        //Read packet information (text typed).
                        Text = Reader.Text3();
                        //Close packet reader
                        Reader.Close();
                        //Repeat for each player in our range list
                        foreach (int member in Rangedplayers)
                        {
                            //Check if the member is not null
                            if (member != 0)
                            {
                                //Make sure its not sending to our own client
                                if (member != Character.Information.UniqueID)
                                {
                                    //Get member detail
                                    Systems memberinfo = GetPlayer(member);
                                    //Send packet to the member
                                    memberinfo.client.Send(Packet.ChatPacket(chatType, Character.Information.UniqueID, Text, null));
                                }
                            }
                        }
                        //Send chat index to our client
                        client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                        break;
                    }
                    //If character tried to use pink chat but isnt a gm
                    else
                    {
                        //We ban the player for hacking attempt.
                        Disconnect("ban");
                    }
                    break;

                //--------------------------------- [Private chat] ---------------------------------//
                case 2:
                    //Read from packet data who we are sending the message to
                    string Target = Reader.Text();
                    //Get information from the given player we send to
                    Systems Targetplayer = GetPlayerName(Target);
                    //Make sure the player sending to is not null
                    if (Targetplayer != null)
                    {
                        //Make sure the player is ingame (Not teleporting or such).
                        if (Targetplayer.Character.InGame)
                        {
                            //Read the message from the packet data
                            Text = Reader.Text3();
                            //Close the packet reader
                            Reader.Close();
                            //Send packet to our target
                            Targetplayer.client.Send(Packet.ChatPacket(chatType, 0, Text, this.Character.Information.Name));
                            //Send chatindex packet to ourselfs
                            client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                        }
                    }
                    break;

                //--------------------------------- [Party chat] ---------------------------------//
                case 4:
                    //Make sure the player is in a party
                    if (Character.Network.Party != null)
                    {
                        //Read the text the player has typed from packet data
                        Text = Reader.Text3();
                        //Close packet reader
                        Reader.Close();
                        //Repeat for each member in the party member list
                        foreach (int member in Character.Network.Party.Members)
                        {
                            //Make sure the member isnt null (0)
                            if (member != 0)
                            {
                                //Get detailed info for the player
                                Systems memberinfo = GetPlayer(member);
                                //Send packet information to the member for chat
                                memberinfo.client.Send(Packet.ChatPacket(chatType, Character.Information.UniqueID, Text, this.Character.Information.Name));
                            }
                        }
                        //Finally send chatindex packet to ourselfs
                        client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                    }

                    break;

                //--------------------------------- [Guild chat] ---------------------------------//
                case 5:
                    //Read message beeing send from packet data
                    Text = Reader.Text3();
                    //Close packet reader
                    Reader.Close();
                    //Repeat for each member in the guild member list
                    foreach (int member in Character.Network.Guild.Members)
                    {
                        //Make sure the member is not null (0)
                        if (member != 0)
                        {
                            //Get guild member detailed information
                            Systems Guildmember = GetPlayerMainid(member);
                            //Again check if the guild member is not null
                            if (Guildmember != null)
                            {
                                //Send chat packet to the member
                                Guildmember.client.Send(Packet.ChatPacket(chatType, Character.Information.UniqueID, Text, this.Character.Information.Name));
                            }
                        }
                    }
                    //Send chat index packet to our client
                    client.Send(Packet.ChatIndexPacket(chatType, chatIndex));

                    break;

                //--------------------------------- [Global chat] ---------------------------------//
                case 6:
                    //Get sender name from packet data
                    string Sender = Reader.Text();
                    //Get message from packet data
                    Text = Reader.Text3();
                    //Send to every client connected and logged in
                    SendAll(Packet.ChatPacket(chatType, Character.Information.UniqueID, " " + Text, Sender));
                    break;

                //--------------------------------- [Notice chat] ---------------------------------//
                case 7:
                    //Make sure the character sending is a gm
                    if (Character.Information.GM == 1)
                    {
                        //Get message from packet data
                        Text = Reader.Text3();
                        //Close packet reader
                        Reader.Close();
                        //Send to everyone ingame (using void sendnoticecon).
                        SendAll(sendnoticecon(chatType, Character.Information.UniqueID, Text, null));
                    }
                    //If the character is not a gm
                    else
                    {
                        //Disconnect and ban the player for hack attempt
                        Disconnect("ban");
                    }
                    break;

                //--------------------------------- [Stall chat] ---------------------------------//
                case 9:
                    //Read message from packet data
                    Text = Reader.Text3();
                    //Close packet reader
                    Reader.Close();
                    //Repeat for each member in the stall
                    foreach (int stallmember in Character.Network.Stall.Members)
                    {
                        //Make sure the stall member isnt null 0
                        if (stallmember != 0)
                        {
                            //Get stall member details
                            Systems member = GetPlayer(stallmember);
                            //Make sure the member isnt null
                            if (member != null)
                            {
                                //Send chat packet to the member
                                member.client.Send(Packet.ChatPacket(chatType, Character.Network.Stall.ownerID, Text, this.Character.Information.Name));
                            }
                        }
                    }
                    //Send chat index to ourselfs
                    client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                    break;

                //--------------------------------- [Academy chat] ---------------------------------//
                case 10:
                    //Todo academy system then chat.
                    break;

                //--------------------------------- [Union chat] ---------------------------------//
                case 11:
                    //Read message from packet data
                    Text = Reader.Text3();
                    //Close packet reader
                    Reader.Close();
                    //If the character has no union
                    if (!Character.Network.Guild.UnionActive)
                    {
                        //Return
                        return;
                    }
                    //Else for each member in the union
                    foreach (int member in Character.Network.Guild.UnionMembers)
                    {
                        //Make sure the union member is not null 0
                        if (member != 0)
                        {
                            //Get member detailed information
                            Systems tomember = GetPlayerMainid(member);
                            //Make sure the member is not null
                            if (tomember != null)
                            {
                                //Make sure the member isnt ourself
                                if (tomember.Character.Information.CharacterID != Character.Information.CharacterID)
                                {
                                    //Send packet to the union member
                                    tomember.client.Send(Packet.ChatPacket(chatType, Character.Information.UniqueID, Text, Character.Information.Name));
                                }
                            }
                        }
                    }
                    //Repeat for each member in the guild
                    foreach (int member in Character.Network.Guild.Members)
                    {
                        //Make sure the member isnt null 0
                        if (member != 0)
                        {
                            //Get member detailed information
                            Systems tomember = GetPlayerMainid(member);
                            //Make sure the member isnt null
                            if (tomember != null)
                            {
                                //Make sure the member isnt ourself
                                if (tomember.Character.Information.CharacterID != Character.Information.CharacterID)
                                {
                                    //Send packet to the member
                                    tomember.Character.Network.Guild.SingleSend = false;
                                }
                            }
                        }
                    }
                    //Finally send chat index packet to ourself
                    client.Send(Packet.ChatIndexPacket(chatType, chatIndex));
                    break;
                }
            }
            //If an exception error happens
            catch (Exception errorinformation)
            {
                //Write the information to the console
                Console.WriteLine("Chat error {0}", errorinformation);
                //Write the information to the log system
                Systems.Debugger.Write(errorinformation);
            }
        }