private static void PlayerSpawnedInWorld(ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _pos)//Spawning player { try { if (_cInfo != null) { if (_respawnReason == RespawnType.EnterMultiplayer)//New player spawned { PersistentContainer.Instance.Players[_cInfo.playerId].PlayerName = _cInfo.playerName; PersistentContainer.Instance.Save(); PersistentOperations.SessionTime(_cInfo); Timers.NewPlayerExecTimer(_cInfo); } else if (_respawnReason == RespawnType.JoinMultiplayer)//Old player spawned { PersistentContainer.Instance.Players[_cInfo.playerId].PlayerName = _cInfo.playerName; PersistentContainer.Instance.Save(); PersistentOperations.SessionTime(_cInfo); if (!PersistentContainer.Instance.Players[_cInfo.playerId].OldPlayer) { Timers.NewPlayerExecTimer(_cInfo); } else { if (Hardcore.IsEnabled && !Hardcore.Optional) { string _sql = string.Format("SELECT * FROM Hardcore WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result = SQL.TypeQuery(_sql); if (_result.Rows.Count == 0) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { int _deaths = XUiM_Player.GetDeaths(_player); string _playerName = SQL.EscapeString(_cInfo.playerName); SQL.FastQuery(string.Format("INSERT INTO Hardcore (steamid, playerName, deaths) VALUES ('{0}', '{1}', {2})", _cInfo.playerId, _playerName, _deaths), null); } } _result.Dispose(); } if (LoginNotice.IsEnabled && LoginNotice.dict.ContainsKey(_cInfo.playerId)) { LoginNotice.PlayerNotice(_cInfo); } if (Motd.IsEnabled) { Motd.Send(_cInfo); } if (Bloodmoon.IsEnabled) { Bloodmoon.Exec(_cInfo); } if (AutoShutdown.IsEnabled && AutoShutdown.Alert_On_Login) { AutoShutdown.NextShutdown(_cInfo); } if (Hardcore.IsEnabled) { if (!Hardcore.Optional) { Hardcore.Alert(_cInfo); } else if (PersistentContainer.Instance.Players[_cInfo.playerId].Hardcore) { Hardcore.Alert(_cInfo); } } if (BattleLogger.IsEnabled) { BattleLogger.AlertPlayer(_cInfo); } if (PollConsole.IsEnabled) { string _sql = "SELECT pollOpen FROM Polls WHERE pollOpen = 'true'"; if (!string.IsNullOrEmpty(_sql)) { DataTable _result = SQL.TypeQuery(_sql); if (_result.Rows.Count > 0 && !PollConsole.PolledYes.Contains(_cInfo.playerId) && !PollConsole.PolledNo.Contains(_cInfo.playerId)) { PollConsole.Message(_cInfo); } _result.Dispose(); } } if (Event.Open) { if (Event.PlayersTeam.ContainsKey(_cInfo.playerId)) { string _sql = string.Format("SELECT eventRespawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId); if (!string.IsNullOrEmpty(_sql)) { DataTable _result1 = SQL.TypeQuery(_sql); bool _eventRespawn = false; if (_result1.Rows.Count > 0) { bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventRespawn); } _result1.Dispose(); if (_eventRespawn) { Event.Died(_cInfo); } else { _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result2 = SQL.TypeQuery(_sql); bool _return1 = false, _return2 = false; if (_result2.Rows.Count > 0) { bool.TryParse(_result2.Rows[0].ItemArray.GetValue(0).ToString(), out _return1); bool.TryParse(_result2.Rows[0].ItemArray.GetValue(1).ToString(), out _return2); } _result2.Dispose(); if (_return1) { if (_return2) { _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "API"); } _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "API"); Event.EventSpawn(_cInfo); } else if (_return2) { Event.EventSpawn(_cInfo); } } } } } if (ClanManager.IsEnabled) { List <string[]> _clanRequests = PersistentContainer.Instance.Players[_cInfo.playerId].ClanRequestToJoin; if (_clanRequests != null && _clanRequests.Count > 0) { string[] _request = _clanRequests[0]; string _playerName = _request[1]; ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "There is a request to join the group from " + _playerName + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } } else if (_respawnReason == RespawnType.Died)//Player Died { PersistentOperations.SessionTime(_cInfo); if (Bloodmoon.IsEnabled && Bloodmoon.Show_On_Respawn) { Bloodmoon.Exec(_cInfo); } if (BattleLogger.IsEnabled) { BattleLogger.AlertPlayer(_cInfo); } if (Event.Open) { if (!Event.PlayersTeam.ContainsKey(_cInfo.playerId)) { string _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId); if (!string.IsNullOrEmpty(_sql)) { DataTable _result1 = SQL.TypeQuery(_sql); bool _return1 = false, _return2 = false; if (_result1.Rows.Count > 0) { bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _return1); bool.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _return2); } _result1.Dispose(); if (_return1) { if (_return2) { _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "API"); } _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "API"); Event.EventSpawn(_cInfo); return; } } } else { string _sql = string.Format("SELECT eventRespawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId); if (!string.IsNullOrEmpty(_sql)) { DataTable _result = SQL.TypeQuery(_sql); bool _eventRespawn = false; if (_result.Rows.Count > 0) { bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _eventRespawn); } _result.Dispose(); if (_eventRespawn) { Event.Died(_cInfo); return; } else { _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result1 = SQL.TypeQuery(_sql); bool _return1 = false, _return2 = false; if (_result1.Rows.Count > 0) { bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _return1); bool.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _return2); } _result1.Dispose(); if (_return1) { if (_return2) { _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "API"); } _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "API"); Event.EventSpawn(_cInfo); return; } else if (_return2) { Event.EventSpawn(_cInfo); return; } } } } } else { string _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId); if (!string.IsNullOrEmpty(_sql)) { DataTable _result1 = SQL.TypeQuery(_sql); bool _return1 = false, _return2 = false; if (_result1.Rows.Count > 0) { bool.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _return1); bool.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _return2); } _result1.Dispose(); if (_return1) { if (_return2) { _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "API"); } _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "API"); Event.EventSpawn(_cInfo); return; } } } if (Wallet.IsEnabled) { if (Wallet.Lose_On_Death) { Wallet.ClearWallet(_cInfo); } else if (Wallet.Deaths > 0) { Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Wallet.Deaths); } } if (Hardcore.IsEnabled) { if (!Hardcore.Optional) { Hardcore.Check(_cInfo); } else if (PersistentContainer.Instance.Players[_cInfo.playerId].Hardcore) { Hardcore.Check(_cInfo); } } if (Zones.IsEnabled && Zones.Victim.ContainsKey(_cInfo.entityId)) { string _response = " type {CommandPrivate}{Command50} to teleport back to your death position. There is a time limit."; _response = _response.Replace("{CommandPrivate}", ChatHook.Command_Private); _response = _response.Replace("{Command50}", Zones.Command50); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _response + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); PersistentContainer.Instance.Players[_cInfo.playerId].ZoneDeathTime = DateTime.Now; PersistentContainer.Instance.Save(); if (Zones.Forgive.ContainsKey(_cInfo.entityId)) { string _response2 = " type {CommandPrivate}{Command55} to release your killer from jail."; _response2 = _response2.Replace("{CommandPrivate}", ChatHook.Command_Private); _response2 = _response2.Replace("{Command55}", Jail.Command55); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _response2 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } else if (_respawnReason == RespawnType.Teleport) { } string _ip = _cInfo.ip; if (_ip.Contains(":")) { _ip = _ip.Split(':').First(); } if (!string.IsNullOrEmpty(_ip) && BattleLogger.IsEnabled && BattleLogger.LogFound && !StopServer.StopServerCountingDown && !StopServer.Shutdown && GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo.playerId).PermissionLevel > BattleLogger.Admin_Level) { if (!BattleLogger.Players.ContainsKey(_cInfo.playerId)) { BattleLogger.Players.Add(_cInfo.playerId, _cInfo.ip); } else { string _recordedIp; BattleLogger.Players.TryGetValue(_cInfo.playerId, out _recordedIp); if (_recordedIp != _ip) { BattleLogger.Players[_cInfo.playerId] = _ip; } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerSpawnedInWorld: {0}.", e.Message)); } }
public static void OldPlayerJoined(ClientInfo _cInfo, EntityPlayer _player) { try { if (Hardcore.IsEnabled) { if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { if (Hardcore.Optional) { if (PersistentContainer.Instance.Players[_cInfo.playerId].HardcoreEnabled) { Hardcore.Check(_cInfo, _player); } } else if (!PersistentContainer.Instance.Players[_cInfo.playerId].HardcoreEnabled) { string[] _hardcoreStats = { _cInfo.playerName, XUiM_Player.GetDeaths(_player).ToString(), "0" }; PersistentContainer.Instance.Players[_cInfo.playerId].HardcoreStats = _hardcoreStats; PersistentContainer.Instance.Players[_cInfo.playerId].HardcoreEnabled = true; PersistentContainer.DataChange = true; Hardcore.Check(_cInfo, _player); } } } if (LoginNotice.IsEnabled && LoginNotice.dict.ContainsKey(_cInfo.playerId)) { LoginNotice.PlayerNotice(_cInfo); } if (Motd.IsEnabled) { Motd.Send(_cInfo); } if (Bloodmoon.IsEnabled) { Bloodmoon.Exec(_cInfo); } if (Shutdown.IsEnabled && Shutdown.Alert_On_Login) { Shutdown.NextShutdown(_cInfo); } if (ExitCommand.IsEnabled) { ExitCommand.AlertPlayer(_cInfo); } if (Poll.IsEnabled && PersistentContainer.Instance.PollOpen && !PersistentContainer.Instance.PollVote.ContainsKey(_cInfo.playerId)) { Poll.Message(_cInfo); } if (ClanManager.IsEnabled) { Dictionary <string, string> _clanRequests = PersistentContainer.Instance.Players[_cInfo.playerId].ClanRequestToJoin; if (_clanRequests != null && _clanRequests.Count > 0) { ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + "New clan requests from:[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); foreach (var _request in _clanRequests) { ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _request.Value + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } //If they are in a clan, check if we should get them into a party ClanManager.checkClanParty(_cInfo, _player); if (Event.Open && Event.Teams.ContainsKey(_cInfo.playerId) && PersistentContainer.Instance.Players[_cInfo.playerId].EventSpawn) { Event.Spawn(_cInfo); } else if (PersistentContainer.Instance.Players[_cInfo.playerId].EventSpawn) { PersistentContainer.Instance.Players[_cInfo.playerId].EventSpawn = false; PersistentContainer.DataChange = true; } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.OldPlayerJoined: {0}", e.Message)); } }
public static void OldPlayerJoined(ClientInfo _cInfo) { if (Hardcore.IsEnabled) { if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { if (Hardcore.Optional) { if (PersistentContainer.Instance.Players[_cInfo.playerId].HardcoreEnabled) { Hardcore.Check(_cInfo, _player); } } else if (!PersistentContainer.Instance.Players[_cInfo.playerId].HardcoreEnabled) { string[] _hardcoreStats = { _cInfo.playerName, XUiM_Player.GetDeaths(_player).ToString(), "0" }; PersistentContainer.Instance.Players[_cInfo.playerId].HardcoreStats = _hardcoreStats; PersistentContainer.Instance.Players[_cInfo.playerId].HardcoreEnabled = true; Hardcore.Check(_cInfo, _player); } } } } if (LoginNotice.IsEnabled && LoginNotice.dict.ContainsKey(_cInfo.playerId)) { LoginNotice.PlayerNotice(_cInfo); } if (Motd.IsEnabled) { Motd.Send(_cInfo); } if (Bloodmoon.IsEnabled) { Bloodmoon.Exec(_cInfo); } if (Shutdown.IsEnabled && Shutdown.Alert_On_Login) { Shutdown.NextShutdown(_cInfo); } if (BattleLogger.IsEnabled) { BattleLogger.AlertPlayer(_cInfo); } if (Poll.IsEnabled && PersistentContainer.Instance.PollOpen && !PersistentContainer.Instance.PollVote.ContainsKey(_cInfo.playerId)) { Poll.Message(_cInfo); } if (ClanManager.IsEnabled) { Dictionary <string, string> _clanRequests = PersistentContainer.Instance.Players[_cInfo.playerId].ClanRequestToJoin; if (_clanRequests != null && _clanRequests.Count > 0) { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "New clan requests from:[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); foreach (var _request in _clanRequests) { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _request.Value + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } if (Event.Open && Event.Teams.ContainsKey(_cInfo.playerId) && PersistentContainer.Instance.Players[_cInfo.playerId].EventSpawn) { Event.Spawn(_cInfo); } else if (PersistentContainer.Instance.Players[_cInfo.playerId].EventSpawn) { PersistentContainer.Instance.Players[_cInfo.playerId].EventSpawn = false; PersistentContainer.Instance.Save(); } }
public static void OldPlayerJoined(ClientInfo _cInfo, EntityPlayer _player) { try { string id = _cInfo.CrossplatformId.CombinedString; if (Hardcore.IsEnabled && PersistentContainer.Instance.Players[id] != null) { if (Hardcore.Optional) { if (PersistentContainer.Instance.Players[id].HardcoreEnabled) { Hardcore.Check(_cInfo, _player); } } else if (!PersistentContainer.Instance.Players[id].HardcoreEnabled) { string[] hardcoreStats = { _cInfo.playerName, "0", "0" }; PersistentContainer.Instance.Players[id].HardcoreStats = hardcoreStats; PersistentContainer.Instance.Players[id].HardcoreEnabled = true; PersistentContainer.DataChange = true; Hardcore.Check(_cInfo, _player); } } if (LoginNotice.IsEnabled && LoginNotice.Dict1.ContainsKey(_cInfo.PlatformId.CombinedString) || LoginNotice.Dict1.ContainsKey(id)) { LoginNotice.PlayerNotice(_cInfo); } if (Motd.IsEnabled) { Motd.Send(_cInfo); } if (Bloodmoon.IsEnabled) { Bloodmoon.Exec(_cInfo); } if (Shutdown.IsEnabled && Shutdown.Alert_On_Login) { Shutdown.NextShutdown(_cInfo); } if (ExitCommand.IsEnabled) { ExitCommand.AlertPlayer(_cInfo); } if (Poll.IsEnabled && PersistentContainer.Instance.PollOpen && !PersistentContainer.Instance.PollVote.ContainsKey(id)) { Poll.Message(_cInfo); } if (ClanManager.IsEnabled && PersistentContainer.Instance.Players[id] != null) { Dictionary <string, string> clanRequests = PersistentContainer.Instance.Players[id].ClanRequestToJoin; if (clanRequests != null && clanRequests.Count > 0) { ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + "New clan requests from:[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); foreach (var request in clanRequests) { ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + request.Value + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } if (PersistentContainer.Instance.Players[id] != null) { if (PersistentContainer.Instance.Players[id].EventSpawn) { PersistentContainer.Instance.Players[id].EventSpawn = false; PersistentContainer.DataChange = true; } if (Wallet.IsEnabled && PersistentContainer.Instance.Players[id].PlayerWallet > 0) { Wallet.AddCurrency(id, PersistentContainer.Instance.Players[id].PlayerWallet); PersistentContainer.Instance.Players[id].PlayerWallet = 0; PersistentContainer.DataChange = true; } if (PersistentContainer.Instance.Players[id].JailRelease) { PersistentContainer.Instance.Players[id].JailRelease = false; PersistentContainer.DataChange = true; Vector3[] _pos = GameManager.Instance.World.GetRandomSpawnPointPositions(1); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_pos[0].x, _pos[0].y + 1, _pos[0].z), null, false)); Phrases.Dict.TryGetValue("Jail2", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } if (AutoPartyInvite.IsEnabled) { AutoPartyInvite.Exec(_cInfo, _player); } if (Event.Open && Event.Teams.ContainsKey(id) && PersistentContainer.Instance.Players[id] != null && PersistentContainer.Instance.Players[id].EventSpawn) { Event.Spawn(_cInfo); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.OldPlayerJoined: {0}", e.Message)); } }