DarkEmu_GameServer.Systems.DeSpawnMe C# (CSharp) Метод

DeSpawnMe() публичный Метод

public DeSpawnMe ( ) : void
Результат void
        void DeSpawnMe()
        {
            //Wrap our function inside a catcher
            try
            {
                //Checks before continuing
                if (this.Character.Network.Exchange.Window) Exchange_Close();
                if (this.Character.Action.nAttack) StopAttackTimer();
                if (this.Character.Action.sAttack) StopAttackTimer();
                if (this.Character.Action.sCasting) StopAttackTimer();
                if (this.Character.Stall.Stallactive) StallClose();
                //Clients
                #region Client spawns
                for (int b = 0; b < Systems.clients.Count; b++)
                {
                    if (Systems.clients[b] != null && Systems.clients[b].Character.Spawned(this.Character.Information.UniqueID) && Systems.clients[b] != this)
                    {
                        if (Systems.clients[b].Character.Information.UniqueID != 0)
                        {
                            Systems.clients[b].Character.Spawn.Remove(this.Character.Information.UniqueID);
                            Systems.clients[b].client.Send(Packet.ObjectDeSpawn(this.Character.Information.UniqueID));
                        }
                    }
                }
                this.Character.Spawn.Clear();
                #endregion
                //Helper objects
                #region Helper objects
                for (int i = 0; i < Systems.HelperObject.Count; i++)
                {
                    if (Systems.HelperObject[i] != null && Systems.HelperObject[i].Spawned(this.Character.Information.UniqueID))
                    {
                        if (Character.Information.UniqueID != 0 && Systems.HelperObject[i].UniqueID != 0)
                        {
                            Systems.HelperObject[i].Spawn.Remove(this.Character.Information.UniqueID);
                        }
                    }
                }
                #endregion
                //Objects
                #region Objects
                for (int i = 0; i < Systems.Objects.Count; i++)
                {
                    if (Systems.Objects[i] != null && Systems.Objects[i].Spawned(this.Character.Information.UniqueID))
                    {
                        if (Character.Information.UniqueID != 0 && Systems.Objects[i].UniqueID != 0)
                        {
                            Systems.Objects[i].Spawn.Remove(Character.Information.UniqueID);
                        }
                    }
                }
                #endregion
                //Drops
                #region Drops
                for (int i = 0; i < Systems.WorldItem.Count; i++)
                {
                    if (Systems.WorldItem[i] != null && Systems.WorldItem[i].Spawned(Character.Information.UniqueID) && Systems.WorldItem[i].UniqueID != 0)
                    {
                        if (Systems.WorldItem[i].Spawned(Character.Information.UniqueID))
                        {
                            if (Character.Information.UniqueID != 0 && Systems.WorldItem[i].UniqueID != 0)
                            {
                                Systems.WorldItem[i].Spawn.Remove(Character.Information.UniqueID);
                            }
                        }
                    }
                }
                #endregion
                //Char spawns
                #region Char spawns
                for (int i = 0; i < Systems.clients.Count; i++)
                {
                    if (Systems.clients[i] != this && Systems.clients[i] != null)
                    {
                        if (Character.Spawned(Systems.clients[i].Character.Information.UniqueID))
                        {
                            if (Character.Information.UniqueID != 0 && Systems.clients[i].Character.Information.UniqueID != 0)
                            {
                                Character.Spawn.Remove(Systems.clients[i].Character.Information.UniqueID);
                            }
                        }
                    }
                }
                #endregion
                //Check if our character is not null
                if (Character.Information.UniqueID != 0)
                {
                    //Check if we have transport active
                    if (Character.Transport.Right)
                    {
                        //Set bools for despawning
                        Character.Transport.Spawned = false;
                        Character.Transport.Horse.Information = false;
                        Character.Transport.Horse.DeSpawnMe(true);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Despawn me error {0}", ex);
                Systems.Debugger.Write(ex);
            }
        }

Usage Example

Пример #1
0
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
        // 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);
            }
        }
All Usage Examples Of DarkEmu_GameServer.Systems::DeSpawnMe
Systems