示例#1
0
 private static void PlayerSpawnedInWorld(ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _pos)//Spawning player
 {
     try
     {
         if (_cInfo != null)
         {
             string       id     = _cInfo.CrossplatformId.CombinedString;
             EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId);
             if (player != null)
             {
                 if (_respawnReason == RespawnType.NewGame)
                 {
                     if (player.distanceWalked < 1 && player.totalTimePlayed <= 1 && !PersistentOperations.NewPlayerQue.Contains(_cInfo))
                     {
                         PersistentOperations.NewPlayerQue.Add(_cInfo);
                     }
                 }
                 else if (_respawnReason == RespawnType.LoadedGame)
                 {
                 }
                 else if (_respawnReason == RespawnType.EnterMultiplayer)
                 {
                     PersistentOperations.SessionTime(_cInfo);
                     PersistentContainer.Instance.Players[id].PlayerName = _cInfo.playerName;
                     PersistentContainer.Instance.Players[id].LastJoined = DateTime.Now;
                     PersistentContainer.DataChange = true;
                     if (player.AttachedToEntity != null)
                     {
                         player.Detach();
                     }
                     if (player.distanceWalked < 1 && player.totalTimePlayed <= 1 && !PersistentOperations.NewPlayerQue.Contains(_cInfo))
                     {
                         PersistentOperations.NewPlayerQue.Add(_cInfo);
                     }
                     else
                     {
                         OldPlayerJoined(_cInfo, player);
                     }
                 }
                 else if (_respawnReason == RespawnType.JoinMultiplayer)
                 {
                     PersistentOperations.SessionTime(_cInfo);
                     PersistentContainer.Instance.Players[id].PlayerName = _cInfo.playerName;
                     PersistentContainer.Instance.Players[id].LastJoined = DateTime.Now;
                     PersistentContainer.DataChange = true;
                     if (player.AttachedToEntity != null)
                     {
                         player.Detach();
                     }
                     if (player.distanceWalked < 1 && player.totalTimePlayed <= 1 && !PersistentOperations.NewPlayerQue.Contains(_cInfo))
                     {
                         PersistentOperations.NewPlayerQue.Add(_cInfo);
                     }
                     else
                     {
                         OldPlayerJoined(_cInfo, player);
                     }
                 }
                 else if (_respawnReason == RespawnType.Died)
                 {
                     if (player.AttachedToEntity != null)
                     {
                         player.Detach();
                     }
                     if (Zones.IsEnabled && Zones.ZonePlayer.ContainsKey(_cInfo.entityId))
                     {
                         Zones.ZonePlayer.TryGetValue(player.entityId, out string[] zone);
                         Zones.ZonePlayer.Remove(player.entityId);
                         Zones.Reminder.Remove(player.entityId);
                         if (zone[9] != PersistentOperations.Player_Killing_Mode.ToString())
                         {
                             _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageConsoleCmdClient>().Setup(string.Format("sgs PlayerKillingMode {0}", PersistentOperations.Player_Killing_Mode), true));
                         }
                         if (Zones.Zone_Message && zone[5] != "")
                         {
                             ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + zone[5] + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null);
                         }
                         if (zone[7] != "")
                         {
                             Zones.ProcessCommand(_cInfo, zone[7]);
                         }
                     }
                     if (InfiniteAmmo.IsEnabled && InfiniteAmmo.Dict.ContainsKey(_cInfo.entityId))
                     {
                         InfiniteAmmo.Dict.Remove(_cInfo.entityId);
                     }
                     if (Bloodmoon.IsEnabled && Bloodmoon.Show_On_Respawn)
                     {
                         Bloodmoon.Exec(_cInfo);
                     }
                 }
                 else if (_respawnReason == RespawnType.Teleport)
                 {
                     if (Teleportation.Teleporting.Contains(_cInfo.entityId))
                     {
                         Teleportation.Teleporting.Remove(_cInfo.entityId);
                     }
                 }
                 if (PlayerChecks.TwoSecondMovement.ContainsKey(_cInfo.entityId))
                 {
                     PlayerChecks.TwoSecondMovement.Remove(_cInfo.entityId);
                 }
                 if (FlyingDetector.Flags.ContainsKey(_cInfo.entityId))
                 {
                     FlyingDetector.Flags.Remove(_cInfo.entityId);
                 }
                 if (SpeedDetector.Flags.ContainsKey(_cInfo.entityId))
                 {
                     SpeedDetector.Flags.Remove(_cInfo.entityId);
                 }
             }
             if (ExitCommand.IsEnabled && !ExitCommand.Players.ContainsKey(_cInfo.entityId) && (GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo.PlatformId) > ExitCommand.Admin_Level &&
                                                                                                GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo.CrossplatformId) > ExitCommand.Admin_Level))
             {
                 ExitCommand.Players.Add(_cInfo.entityId, player.position);
             }
         }
     }
     catch (Exception e)
     {
         Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerSpawnedInWorld: {0}", e.Message));
     }
 }