public static void VoteCount() { if (Mute.Count >= Votes_Needed) { MutePlayer.Mutes.Add(_playerMute.playerId); string _name = SQL.EscapeString(_playerMute.playerName); if (_name.Contains("!") || _name.Contains("@") || _name.Contains("#") || _name.Contains("$") || _name.Contains("%") || _name.Contains("^") || _name.Contains("&") || _name.Contains("*") || _name.Contains("'") || _name.Contains(";")) { _name = _name.Replace("!", ""); _name = _name.Replace("@", ""); _name = _name.Replace("#", ""); _name = _name.Replace("$", ""); _name = _name.Replace("%", ""); _name = _name.Replace("^", ""); _name = _name.Replace("&", ""); _name = _name.Replace("*", ""); _name = _name.Replace("'", ""); _name = _name.Replace(";", ""); } string _sql = string.Format("UPDATE Players SET muteTime = 60, muteName = '{0}', muteDate = '{1}' WHERE steamid = '{2}'", _name, DateTime.Now, _playerMute.playerId); SQL.FastQuery(_sql, "MuteVote"); string _phrase777; if (!Phrases.Dict.TryGetValue(777, out _phrase777)) { _phrase777 = "{PlayerName} has been muted for 60 minutes."; } _phrase777 = _phrase777.Replace("{PlayerName}", _playerMute.playerName); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _phrase777 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } VoteOpen = false; Mute.Clear(); }
public static void Mute(ClientInfo _admin, ClientInfo _player) { Mutes.Add(_player.playerId); string _name = SQL.EscapeString(_player.playerName); if (_name.Contains("!") || _name.Contains("@") || _name.Contains("#") || _name.Contains("$") || _name.Contains("%") || _name.Contains("^") || _name.Contains("&") || _name.Contains("*") || _name.Contains("'") || _name.Contains(";")) { _name = _name.Replace("!", ""); _name = _name.Replace("@", ""); _name = _name.Replace("#", ""); _name = _name.Replace("$", ""); _name = _name.Replace("%", ""); _name = _name.Replace("^", ""); _name = _name.Replace("&", ""); _name = _name.Replace("*", ""); _name = _name.Replace("'", ""); _name = _name.Replace(";", ""); } string _sql = string.Format("UPDATE Players SET muteTime = 60, muteName = '{0}', muteDate = '{1}' WHERE steamid = '{2}'", _name, DateTime.Now, _player.playerId); SQL.FastQuery(_sql, "MutePlayer"); string _phrase203; if (!Phrases.Dict.TryGetValue(203, out _phrase203)) { _phrase203 = " you have muted {PlayerName} for 60 minutes."; } _phrase203 = _phrase203.Replace("{PlayerName}", _player.playerName); ChatHook.ChatMessage(_admin, LoadConfig.Chat_Response_Color + _admin.playerName + _phrase203 + "[-]", _admin.entityId, _admin.playerName, EChatType.Whisper, null); }
//------------------------------------------------------------------------------ //remove Loadxml() a few months after everyone has a chance to update the mod private static void Loadxml() { if (File.Exists(filePath)) { XmlDocument xmlDoc = new XmlDocument(); try { xmlDoc.Load(filePath); } catch (XmlException e) { Log.Error(string.Format("[SERVERTOOLS] Failed loading {0}: {1}", file, e.Message)); return; } XmlNode _XmlNode = xmlDoc.DocumentElement; foreach (XmlNode childNode in _XmlNode.ChildNodes) { if (childNode.Name == "immunePlayers") { foreach (XmlNode subChild in childNode.ChildNodes) { if (subChild.NodeType == XmlNodeType.Comment) { continue; } if (subChild.NodeType != XmlNodeType.Element) { Log.Warning(string.Format("[SERVERTOOLS] Unexpected XML node found in 'immunePlayers' section: {0}", subChild.OuterXml)); continue; } XmlElement _line = (XmlElement)subChild; if (!_line.HasAttribute("SteamId")) { Log.Warning(string.Format("[SERVERTOOLS] Ignoring player entry because of missing 'steamid' attribute: {0}", subChild.OuterXml)); continue; } if (!_line.HasAttribute("name")) { Log.Warning(string.Format("[SERVERTOOLS] Ignoring player entry because of missing 'name' attribute: {0}", subChild.OuterXml)); continue; } string _id = SQL.EscapeString(_line.GetAttribute("SteamId")); string _sql = string.Format("SELECT * FROM Players WHERE steamid = '{0}'", _id); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count > 0) { _sql = string.Format("UPDATE Players SET pingimmunity = 'true' WHERE steamid = '{0}'", _id); } else { _sql = string.Format("INSERT INTO Players (steamid, pingimmunity) VALUES ('{0}', 'true')", _id); } _result.Dispose(); SQL.FastQuery(_sql, "HighPingKicker"); } } } File.Delete(filePath); } }
public static void NewPlayerExec3(ClientInfo _cInfo, EntityPlayer _player) { try { if (NewPlayer.IsEnabled) { NewPlayer.Exec(_cInfo); } if (Motd.IsEnabled) { Motd.Send(_cInfo); } if (Bloodmoon.IsEnabled) { Bloodmoon.Exec(_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 (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) { 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); } else { SQL.FastQuery(_sql = string.Format("UPDATE Hardcore SET deaths = {0} WHERE steamid = '{1}'", 0, _cInfo.playerId), "Hardcore"); } _result.Dispose(); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.NewPlayerExec3: {0}.", e.Message)); } PersistentContainer.Instance.Players[_cInfo.playerId].OldPlayer = true; PersistentContainer.Instance.Save(); }
public static void NewPlayerExec() { ClientInfo _cInfo = Que[0]; EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_cInfo != null && _player.IsSpawned()) { if (Motd.IsEnabled & Motd.Show_On_Respawn) { Motd.Send(_cInfo); } if (Bloodmoon.Show_On_Login && Bloodmoon.Show_On_Respawn) { Bloodmoon.GetBloodmoon(_cInfo, false); } if (NewPlayer.IsEnabled) { NewPlayer.Exec(_cInfo); } if (NewSpawnTele.IsEnabled) { NewSpawnTele.TeleNewSpawn(_cInfo); } if (StartingItems.IsEnabled) { if (!NewSpawnTele.IsEnabled) { StartingItems.StartingItemCheck(_cInfo); } else if (NewSpawnTele.IsEnabled && NewSpawnTele.New_Spawn_Tele_Position != "0,0,0") { StartingItems.Que.Add(_cInfo.playerId); } else if (NewSpawnTele.IsEnabled && NewSpawnTele.New_Spawn_Tele_Position == "0,0,0") { StartingItems.StartingItemCheck(_cInfo); } } string _sql = "SELECT pollOpen FROM Polls WHERE pollOpen = 'true'"; DataTable _result1 = SQL.TQuery(_sql); if (_result1.Rows.Count > 0 && !PollConsole.PolledYes.Contains(_cInfo.playerId) && !PollConsole.PolledNo.Contains(_cInfo.playerId)) { PollConsole.Message(_cInfo); } _result1.Dispose(); if (Hardcore.IsEnabled) { Hardcore.Announce(_cInfo); } string _name = SQL.EscapeString(_cInfo.playerName); _name = Regex.Replace(_name, @"[^\u0000-\u007F]+", string.Empty); _sql = string.Format("UPDATE Players SET playername = '{0}', wallet = 0, playerSpentCoins = 0, sessionTime = 0, zkills = 0, kills = 0, deaths = 0 WHERE steamid = '{1}'", _name, _cInfo.playerId); SQL.FastQuery(_sql, "API"); Que.RemoveAt(0); } }
public static void EndGame(ClientInfo _cInfo, EntityPlayer _player, int _deaths, int _extraLives) { DateTime _time = DateTime.Now; PersistentOperations.Session.TryGetValue(_cInfo.playerId, out _time); TimeSpan varTime = DateTime.Now - _time; double fractionalMinutes = varTime.TotalMinutes; int _timepassed = (int)fractionalMinutes; int _oldSession = PersistentContainer.Instance.Players[_cInfo.playerId].SessionTime; int _newSession = _oldSession + _timepassed; int _playerKills = _player.KilledPlayers, _zKills = _player.KilledZombies, _score = _player.Score; string _session = string.Format("{0:00}", _newSession % 60); string _playerName = SQL.EscapeString(_cInfo.playerName); string _sql; SQL.FastQuery(_sql = string.Format("UPDATE Hardcore SET sessionTime = {0}, kills = {1}, zKills = {2}, score = {3}, oldDeaths = {4}, deaths = {5}, playerName = '{6}', extraLives = {7} WHERE steamid = '{8}'", _newSession, _playerKills, _zKills, _score, _deaths + 1, 0, _playerName, _extraLives, _cInfo.playerId), "Hardcore"); Hardcore.DisconnectHardcoreExec(_cInfo, _zKills, _playerKills, _deaths + 1, _score, _session); }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { string _steamId = _senderInfo.RemoteClientInfo.playerId; int _entityId = _senderInfo.RemoteClientInfo.entityId; if (_params[0].ToLower() == ("new")) { if (_params.Count < 2) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2 or more, found {0}.", _params.Count)); return; } string _sql = string.Format("SELECT eventName FROM Events WHERE eventAdmin = '{0}' AND eventName = '{1}'", _steamId, _params[1]); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count == 0) { _result.Dispose(); string _name = SQL.EscapeString(_params[1]); _sql = string.Format("INSERT INTO Events (eventAdmin, eventName) VALUES ('{0}', '{1}')", _steamId, _name); SQL.FastQuery(_sql, "EventCommandsConsole"); if (Event.SetupStage.ContainsKey(_steamId)) { Event.SetupName[_steamId] = _params[1]; Event.SetupStage[_steamId] = 1; } else { Event.SetupName.Add(_steamId, _params[1]); Event.SetupStage.Add(_steamId, 1); } if (Event.Open) { SdtdConsole.Instance.Output(string.Format("There is an event being run by {0}.", Event.Admin)); } SdtdConsole.Instance.Output("You have started to open a new event setup."); SdtdConsole.Instance.Output(string.Format("The event name has been set to {0}.", _params[1])); SdtdConsole.Instance.Output("What would you like the invitation for players to say? Type event \"invitation\"."); return; } else { _result.Dispose(); SdtdConsole.Instance.Output(string.Format("The event name {0} already exists. Use a new name or delete the old event.", _params[1])); return; } } else if (_params[0].ToLower() == ("save")) { if (Event.SetupStage.ContainsKey(_steamId)) { int _stage; Event.SetupStage.TryGetValue(_steamId, out _stage); string _eventName; Event.SetupName.TryGetValue(_steamId, out _eventName); if (_stage == 3) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; string _sposition = x + "," + y + "," + z; string _sql = string.Format("SELECT eventid, eventTeams FROM Events WHERE eventAdmin = '{0}' AND eventName = '{1}'", _steamId, _eventName); DataTable _result1 = SQL.TQuery(_sql); int _eventid; int.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid); int _eventTeams; int.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _eventTeams); _result1.Dispose(); _sql = string.Format("SELECT eventSpawn FROM EventSpawns WHERE eventid = {0}", _eventid); DataTable _result2 = SQL.TQuery(_sql); int _count = _result2.Rows.Count + 1; _result2.Dispose(); string _pos = SQL.EscapeString(_sposition); if (_count == _eventTeams) { _sql = string.Format("INSERT INTO EventSpawns (eventid, eventTeam, eventSpawn) VALUES ({0}, {1}, '{2}')", _eventid, _count, _pos); SQL.FastQuery(_sql, "EventCommandsConsole"); Event.SetupStage[_steamId] = 4; SdtdConsole.Instance.Output(string.Format("The spawn position for team {0} has been set to {1} {2} {3}.", _count, x, y, z)); SdtdConsole.Instance.Output("Stand where you would like the respawn for team 1 if they die during the event, then type event save."); return; } else { _sql = string.Format("INSERT INTO EventSpawns (eventid, eventTeam, eventSpawn) VALUES ({0}, {1}, '{2}')", _eventid, _count, _pos); SQL.FastQuery(_sql, "EventCommandsConsole"); SdtdConsole.Instance.Output(string.Format("The spawn position for team {0} has been set to {1} {2} {3}.", _count, x, y, z)); SdtdConsole.Instance.Output(string.Format("Stand where you would like the spawn for team {0} when the event starts and type event save.", _count + 1)); return; } } else if (_stage == 4) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; string _sposition = x + "," + y + "," + z; string _sql = string.Format("SELECT eventid, eventTeams FROM Events WHERE eventAdmin = '{0}' AND eventName = '{1}'", _steamId, _eventName); DataTable _result1 = SQL.TQuery(_sql); int _eventid; int.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid); int _eventTeams; int.TryParse(_result1.Rows[0].ItemArray.GetValue(1).ToString(), out _eventTeams); _result1.Dispose(); _sql = string.Format("SELECT eventRespawn FROM EventSpawns WHERE eventid = {0} AND eventRespawn != null", _eventid); DataTable _result2 = SQL.TQuery(_sql); int _count = _result2.Rows.Count + 1; _result2.Dispose(); string _pos = SQL.EscapeString(_sposition); if (_count == _eventTeams) { _sql = string.Format("INSERT INTO EventSpawns (eventid, eventTeam, eventRespawn) VALUES ({0}, {1}, '{2}')", _eventid, _count, _pos); SQL.FastQuery(_sql, "EventCommandsConsole"); Event.SetupStage[_steamId] = 5; SdtdConsole.Instance.Output(string.Format("The respawn position for team {0} has been set to {1} {2} {3}.", _count, x, y, z)); SdtdConsole.Instance.Output("Setup is complete. Type event start to send out the invitation to players."); return; } else { _sql = string.Format("INSERT INTO EventSpawns (eventid, eventTeam, eventRespawn) VALUES ({0}, {1}, '{2}')", _eventid, _count, _pos); SQL.FastQuery(_sql, "EventCommandsConsole"); SdtdConsole.Instance.Output(string.Format("The respawn position for team {0} has been set to {1} {2} {3}.", _count, x, y, z)); SdtdConsole.Instance.Output(string.Format("Stand where you would like the respawn for team {0} when the event starts and type event save.", _count + 1)); return; } } else { SdtdConsole.Instance.Output("This command is invalid at this stage of setup."); return; } } } else if (_params[0].ToLower() == ("check")) { if (Event.Open) { if (Event.Admin == _steamId) { string _sql = string.Format("SELECT eventName, eventInvite, eventTeams, eventPlayerCount, eventTime FROM Events WHERE eventAdmin = '{0}' AND eventActive = 'true'", Event.Admin); DataTable _result = SQL.TQuery(_sql); string _eventName = _result.Rows[0].ItemArray.GetValue(0).ToString(); string _eventInvite = _result.Rows[0].ItemArray.GetValue(1).ToString(); int _eventTeams; int.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _eventTeams); int _eventPlayerCount; int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _eventPlayerCount); int _eventTime; int.TryParse(_result.Rows[0].ItemArray.GetValue(4).ToString(), out _eventTime); _result.Dispose(); SdtdConsole.Instance.Output(string.Format("Event: {0}", _eventName)); SdtdConsole.Instance.Output(string.Format("Invitation: {0}", _eventInvite)); SdtdConsole.Instance.Output(string.Format("Info: Teams {0}, Players {1}, Time {2} minutes.", _eventTeams, _eventPlayerCount, _eventTime)); foreach (var _player in Event.PlayersTeam) { ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_player.Key); if (_cInfo != null) { int _team; Event.PlayersTeam.TryGetValue(_player.Key, out _team); SdtdConsole.Instance.Output(string.Format("Player name {0}, Id {1}, is on team {2}.", _cInfo.playerName, _cInfo.playerId, _team)); } else { int _team; Event.PlayersTeam.TryGetValue(_player.Key, out _team); SdtdConsole.Instance.Output(string.Format("Offline player: Player name unknown, Id {0}, is on team {1}.", _player.Key, _team)); } } return; } else { SdtdConsole.Instance.Output(string.Format("You are not the organizer for this event. Contact {0}.", Event.Admin)); return; } } else { SdtdConsole.Instance.Output("There is no event open."); return; } } else if (_params[0].ToLower() == ("cancel")) { if (Event.Admin == _steamId) { if (Event.Open) { if (!Event.Cancel) { Event.Cancel = true; SdtdConsole.Instance.Output("Are you sure you want to cancel the current event? Type event cancel again to stop the event."); return; } else { Event.SetupStage.Remove(_steamId); Event.SetupName.Remove(_steamId); foreach (var _player in Event.PlayersTeam) { ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_player.Key); if (_cInfo != null) { EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player2.IsSpawned()) { string _sql = string.Format("SELECT eventReturn FROM Players WHERE steamid = '{0}'", _steamId); DataTable _result = SQL.TQuery(_sql); string _position = _result.Rows[0].ItemArray.GetValue(0).ToString(); _result.Dispose(); int x, y, z; string[] _cords = _position.Split(','); int.TryParse(_cords[0], out x); int.TryParse(_cords[1], out y); int.TryParse(_cords[2], out z); _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(x, y, z), null, false)); Event.PlayersTeam.Remove(_player.Key); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", the event has ended. Thank you for playing.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { string _sql = string.Format("UPDATE Players SET return = 'true' WHERE steamid = '{0}'", _steamId); SQL.FastQuery(_sql, "EventCommandsConsole"); Event.PlayersTeam.Remove(_player.Key); SdtdConsole.Instance.Output(string.Format("Player with Id {0} was not spawned but they have been removed from the event and set to go back to their return point.", _player.Key)); } } else { string _sql = string.Format("UPDATE Players SET return = 'true' WHERE steamid = '{0}'", _steamId); SQL.FastQuery(_sql, "EventCommandsConsole"); Event.PlayersTeam.Remove(_player.Key); SdtdConsole.Instance.Output(string.Format("Player with Id {0} was offline but they have been removed from the event and set to go back to their return point.", _player.Key)); } } string _sql2 = string.Format("UPDATE Events SET eventAdmin = null, eventActive = 'false' WHERE eventAdmin = '{0}'", Event.Admin); SQL.FastQuery(_sql2, "EventCommandsConsole"); Event.Cancel = false; Event.Open = false; Event.Admin = null; SdtdConsole.Instance.Output("The current event has been cancelled and event players have been sent back to their return points."); } } else { if (Event.Invited) { Event.Invited = false; Event.Admin = null; if (Event.PlayersTeam.Count > 0) { foreach (var _player in Event.PlayersTeam) { ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_player.Key); if (_cInfo != null) { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", the current event has been cancelled.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } Event.PlayersTeam.Remove(_player.Key); } } SdtdConsole.Instance.Output("The current setup has been cancelled and all signed up players were removed."); return; } } } else { SdtdConsole.Instance.Output(string.Format("You are not the organizer for this event. Contact {0}.", Event.Admin)); return; } } else if (_params[0].ToLower() == ("list")) { string _sql = string.Format("SELECT eventid, eventName, eventInvite, eventTeams, eventPlayerCount, eventTime FROM Events WHERE eventAdmin = '{0}'", _steamId); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count > 0) { foreach (DataRow row in _result.Rows) { SdtdConsole.Instance.Output(string.Format("Event Id = {0} Event Name = {1}", row[0].ToString(), row[1].ToString())); SdtdConsole.Instance.Output(string.Format("Event Invite = {0}", row[2].ToString())); SdtdConsole.Instance.Output(string.Format("Team Count = {0} Allowed Players = {1} Allowed Time = {2}", row[3].ToString(), row[4].ToString(), row[5].ToString())); SdtdConsole.Instance.Output("-----------------------------------------------------------------------"); SdtdConsole.Instance.Output("-----------------------------------------------------------------------"); } } else { SdtdConsole.Instance.Output("You have no saved event data."); } _result.Dispose(); if (Event.Open || Event.Invited) { SdtdConsole.Instance.Output(string.Format("An event is running by admin {0}", Event.Admin)); } else { SdtdConsole.Instance.Output("Type event load <eventid> to load that event. After loading, type event start to send the invitation to players."); } } else if (_params[0].ToLower() == ("load")) { if (_params.Count != 2) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}.", _params.Count)); return; } int _id; if (int.TryParse(_params[1], out _id)) { string _sql = string.Format("SELECT eventName, eventInvite, eventTeams, eventPlayerCount, eventTime FROM Events WHERE eventAdmin = '{0}' AND eventid = {1}", _steamId, _id); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count > 0) { string _eventName = _result.Rows[0].ItemArray.GetValue(0).ToString(); string _eventInvite = _result.Rows[0].ItemArray.GetValue(1).ToString(); int _eventTeams; int.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _eventTeams); int _eventPlayerCount; int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _eventPlayerCount); int _eventTime; int.TryParse(_result.Rows[0].ItemArray.GetValue(4).ToString(), out _eventTime); _result.Dispose(); SdtdConsole.Instance.Output(string.Format("Event: {0}", _eventName)); SdtdConsole.Instance.Output(string.Format("Invitation: {0}", _eventInvite)); SdtdConsole.Instance.Output(string.Format("Info: Teams {0}, Players {1}, Time {2} minutes.", _eventTeams, _eventPlayerCount, _eventTime)); if (Event.SetupStage.ContainsKey(_steamId)) { Event.SetupStage[_steamId] = 5; Event.SetupName[_steamId] = _eventName; } else { Event.SetupStage.Add(_steamId, 5); Event.SetupName.Add(_steamId, _eventName); } SdtdConsole.Instance.Output(string.Format("Event id: {0} has been loaded. Type event start to send the invitation out to players.", _id)); return; } else { SdtdConsole.Instance.Output(string.Format("Could not find this event id: {0}", _id)); return; } } else { SdtdConsole.Instance.Output(string.Format("Invalid integer: {0}.", _params[1])); return; } } else if (_params[0].ToLower() == ("extend")) { if (Event.Admin == _steamId) { if (Event.Open) { if (Event.Extend) { Event.Extend = false; int _time; if (int.TryParse(_params[1], out _time)) { int _addTime = Timers._eventTime + (_time * 60); Timers._eventTime = _addTime; SdtdConsole.Instance.Output(string.Format("The event time was extended {0} minutes.", _time)); return; } } else { SdtdConsole.Instance.Output(string.Format("The event can only be extended while five minutes remain in the event. Wait for an alert before using the command.")); return; } } else { SdtdConsole.Instance.Output("There is no event open to extend in time."); return; } } else { SdtdConsole.Instance.Output(string.Format("You are not the organizer for this event. Contact {0}.", Event.Admin)); return; } } else if (_params[0].ToLower() == ("remove")) { if (Event.Admin == _steamId) { if (Event.Open) { if (Event.PlayersTeam.ContainsKey(_params[1])) { ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_params[1]); if (_cInfo != null) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player.IsSpawned()) { string _sql = string.Format("SELECT eventReturn FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result = SQL.TQuery(_sql); string _position = _result.Rows[0].ItemArray.GetValue(0).ToString(); _result.Dispose(); int x, y, z; string[] _cords = _position.Split(','); int.TryParse(_cords[0], out x); int.TryParse(_cords[1], out y); int.TryParse(_cords[2], out z); _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(x, y, z), null, false)); _sql = string.Format("UPDATE Players SET eventReturn = 'Unknown', eventSpawn = 'false', eventRespawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "EventCommandsConsole"); Event.PlayersTeam.Remove(_params[1]); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you have been removed from the event and sent to your return point.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); SdtdConsole.Instance.Output(string.Format("Player with Id {0} was removed from the event and sent to their return point.", _params[1])); return; } else { string _sql = string.Format("UPDATE Players SET return = 'true', eventSpawn = 'false', eventRespawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "EventCommandsConsole"); Event.PlayersTeam.Remove(_params[1]); SdtdConsole.Instance.Output(string.Format("Player with Id {0} was not spawned but they were removed from the event and set to return to their return point.", _params[1])); } } else { string _sql = string.Format("UPDATE Players SET return = 'true', eventSpawn = 'false', eventRespawn = 'false' WHERE steamid = '{0}'", _params[1]); SQL.FastQuery(_sql, "EventCommandsConsole"); Event.PlayersTeam.Remove(_params[1]); SdtdConsole.Instance.Output(string.Format("Player with Id {0} was offline but they have been removed from the event and set to return to their return point.", _params[1])); return; } } else { SdtdConsole.Instance.Output(string.Format("Invalid Id: {0}. They are not signed up for the event.", _params[1])); return; } } else { SdtdConsole.Instance.Output("There is no event open."); return; } } } else if (_params[0].ToLower() == ("start")) { if (!Event.Invited) { if (Event.SetupStage.ContainsKey(_steamId)) { int _stage; if (Event.SetupStage.TryGetValue(_steamId, out _stage)) { string _eventName; if (Event.SetupName.TryGetValue(_steamId, out _eventName)) { if (_stage == 5) { if (!Event.Open) { Event.Invited = true; Event.Admin = _steamId; Event.SetupStage.Remove(_steamId); Event.SetupName.Remove(_steamId); string _sql = string.Format("SELECT eventid, eventInvite FROM Events WHERE eventAdmin = '{0}' AND eventName = '{1}'", _steamId, _eventName); DataTable _result = SQL.TQuery(_sql); int _eventid; int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid); string _eventInvite = _result.Rows[0].ItemArray.GetValue(1).ToString(); _result.Dispose(); _sql = string.Format("UPDATE Events SET eventActive = 'true' WHERE eventid = {0} AND eventAdmin = '{1}'", _eventid, _steamId); SQL.FastQuery(_sql, "EventCommandsConsole"); string _msg1 = "Event: {EventName}[-]"; string _msg2 = _eventInvite; string _msg3 = "Type /event if you want to join the event. You will return to where you are when it ends.[-]"; _msg1 = _msg1.Replace("{EventName}", _eventName); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _msg1, -1, LoadConfig.Server_Response_Name, EChatType.Global, null); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _msg2, -1, LoadConfig.Server_Response_Name, EChatType.Global, null); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _msg3, -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } else { SdtdConsole.Instance.Output("The event has already started."); return; } } else { SdtdConsole.Instance.Output("This command is invalid at this stage of setup."); return; } } } } } else { SdtdConsole.Instance.Output("There is an event invitation open already."); return; } } else if (_params[0].ToLower() == ("delete") || _params[0].ToLower() == ("del")) { int _id; if (int.TryParse(_params[1], out _id)) { string _sql = string.Format("SELECT eventid FROM Events WHERE eventAdmin = '{0}'", _steamId); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count > 0) { _sql = string.Format("Delete FROM Events WHERE eventid = {0}", _id); SQL.FastQuery(_sql, "EventCommandsConsole"); _sql = string.Format("Delete FROM EventSpawns WHERE eventid = {0}", _id); SQL.FastQuery(_sql, "EventCommandsConsole"); SdtdConsole.Instance.Output(string.Format("Deleted the event with id: {0}.", _id)); return; } else { SdtdConsole.Instance.Output(string.Format("Invalid integer: {0}. This id is not attached to you. Can not delete it.", _params[1])); } _result.Dispose(); } else { SdtdConsole.Instance.Output(string.Format("Invalid integer: {0}.", _params[1])); return; } } else { if (Event.SetupStage.ContainsKey(_steamId)) { int _stage; if (Event.SetupStage.TryGetValue(_steamId, out _stage)) { string _eventName; if (Event.SetupName.TryGetValue(_steamId, out _eventName)) { if (_stage == 1) { string _invite = SQL.EscapeString(_params[0]); string _sql = string.Format("UPDATE Events SET eventInvite = '{0}' WHERE eventAdmin = '{1}' AND eventName = '{2}'", _invite, _steamId, _eventName); SQL.FastQuery(_sql, "EventCommandsConsole"); Event.SetupStage[_steamId] = 2; SdtdConsole.Instance.Output(string.Format("The event invitation has been set to {0}.", _params[0])); SdtdConsole.Instance.Output("How many teams, total players, and time in minutes will the event last? Type event <TeamCount> <TotalPlayers> <TimeInMin>."); return; } else if (_stage == 2) { if (_params.Count == 3) { int _teamCount; if (int.TryParse(_params[0], out _teamCount)) { if (_teamCount < 1) { _teamCount = 1; } int _playerCount; if (int.TryParse(_params[1], out _playerCount)) { if (_playerCount < 1) { _playerCount = 1; } int _eventTime; if (int.TryParse(_params[2], out _eventTime)) { if (_eventTime < 1) { _eventTime = 1; } string _sql = string.Format("UPDATE Events SET eventTeams = {0}, eventPlayerCount = {1}, eventTime = {2} WHERE eventAdmin = '{3}' AND eventName = '{4}'", _teamCount, _playerCount, _eventTime, _steamId, _eventName); SQL.FastQuery(_sql, "EventCommandsConsole"); Event.SetupStage[_steamId] = 3; SdtdConsole.Instance.Output(string.Format("The event info has been set: team count {0}, total players {1}, event time {2}.", _teamCount, _playerCount, _eventTime)); if (_teamCount == 1) { SdtdConsole.Instance.Output("Stand where you would like players to spawn when the event starts and type event save."); return; } else { SdtdConsole.Instance.Output("Stand where you would like the team 1 to spawn when the event starts and type event save."); return; } } } } } else { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 3, found {0}.", _params.Count)); return; } } } } } else { SdtdConsole.Instance.Output("You have no event being setup. Setup a new one by typing event new <EventName>."); return; } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in EventCommandsConsole.Run: {0}.", e)); } }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_params.Count < 1 || _params.Count > 2) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1 or 2, found {0}", _params.Count)); return; } if (_params[0].ToLower().Equals("off")) { VoteReward.IsEnabled = false; LoadConfig.WriteXml(); SdtdConsole.Instance.Output(string.Format("Vote reward has been set to off")); return; } else if (_params[0].ToLower().Equals("on")) { VoteReward.IsEnabled = true; LoadConfig.WriteXml(); SdtdConsole.Instance.Output(string.Format("Vote reward has been set to on")); return; } else if (_params[0].ToLower().Equals("reset")) { if (_params.Count != 2) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}", _params.Count)); return; } if (_params[1].ToLower().Equals("online")) { List <ClientInfo> ClientInfoList = ConnectionManager.Instance.Clients.List.ToList(); for (int i = 0; i < ClientInfoList.Count; i++) { ClientInfo _cInfo2 = ClientInfoList[i]; if (_cInfo2 != null) { string _sql = string.Format("SELECT lastVoteReward FROM Players WHERE steamid = '{0}'", _cInfo2.playerId); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count != 0) { DateTime _lastVoteReward; DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _lastVoteReward); if (_lastVoteReward.ToString() != "10/29/2000 7:30:00 AM") { _sql = string.Format("UPDATE Players SET lastVoteReward = '10/29/2000 7:30:00 AM' WHERE steamid = '{0}'", _cInfo2.playerId); SQL.FastQuery(_sql, "VoteConsole"); SdtdConsole.Instance.Output(string.Format("Vote reward delay reset for {0}.", _cInfo2.playerName)); } else { SdtdConsole.Instance.Output(string.Format("Player named {0} does not have a vote reward delay that requires reset.", _cInfo2.playerName)); } } } } return; } if (_params[1].ToLower().Equals("all")) { string _sql = string.Format("UPDATE Players SET lastVoteReward = '10/29/2000 7:30:00 AM' WHERE lastVoteReward != '10/29/2000 7:30:00 AM'"); SQL.FastQuery(_sql, "VoteConsole"); return; } ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); if (_cInfo != null) { string _sql = string.Format("SELECT lastVoteReward FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count != 0) { DateTime _lastVoteReward; DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _lastVoteReward); if (_lastVoteReward.ToString() != "10/29/2000 7:30:00 AM") { _sql = string.Format("UPDATE Players SET lastVoteReward = '10/29/2000 7:30:00 AM' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "VoteConsole"); SdtdConsole.Instance.Output("Vote reward delay reset."); } else { SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a vote reward delay that requires reset.", _params[1])); } } _result.Dispose(); } else { if (_params[1].Length != 17) { SdtdConsole.Instance.Output(string.Format("Can not reset Id: Invalid Id {0}", _params[1])); return; } string _id = SQL.EscapeString(_params[1]); string _sql = string.Format("SELECT lastVoteReward FROM Players WHERE steamid = '{0}'", _id); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count != 0) { DateTime _lastVoteReward; DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _lastVoteReward); if (_lastVoteReward.ToString() != "10/29/2000 7:30:00 AM") { _sql = string.Format("UPDATE Players SET lastVoteReward = '10/29/2000 7:30:00 AM' WHERE steamid = '{0}'", _id); SQL.FastQuery(_sql, "VoteConsole"); SdtdConsole.Instance.Output("Vote reward delay reset."); } else { SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a vote reward delay that requires reset.", _params[1])); } } else { SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a vote reward delay to reset.", _params[1])); } _result.Dispose(); } } else { SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0])); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in VotingConsole.Run: {0}.", e)); } }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_params.Count < 1 || _params.Count > 3) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1 to 3, found {0}.", _params.Count)); return; } if (_params[0].ToLower().Equals("off")) { Jail.IsEnabled = false; SdtdConsole.Instance.Output(string.Format("Jail has been set to off")); return; } else if (_params[0].ToLower().Equals("on")) { Jail.IsEnabled = true; SdtdConsole.Instance.Output(string.Format("Jail has been set to on")); return; } else if (_params[0].ToLower().Equals("add")) { if (_params.Count != 3) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 3, found {0}.", _params.Count)); return; } if (_params[1].Length < 1 || _params[1].Length > 17) { SdtdConsole.Instance.Output(string.Format("Can not add Id: Invalid Id {0}.", _params[1])); return; } if (Jail.Jailed.Contains(_params[1])) { SdtdConsole.Instance.Output(string.Format("Can not add Id. {0} is already in the Jail list.", _params[1])); return; } int _jailTime; if (!int.TryParse(_params[2], out _jailTime)) { SdtdConsole.Instance.Output(string.Format("Jail time is not valid: {0}", _params[2])); return; } if (Jail.Jail_Position == "0,0,0" || Jail.Jail_Position == "0 0 0" || Jail.Jail_Position == "") { SdtdConsole.Instance.Output(string.Format("Can not put a player in jail: Jail position has not been set.")); return; } else { ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); if (_cInfo != null) { if (Jail.Jailed.Contains(_cInfo.playerId)) { SdtdConsole.Instance.Output(string.Format("Player with Id {0} is already in jail.", _params[1])); return; } else { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player.IsSpawned()) { int x, y, z; string[] _cords = Jail.Jail_Position.Split(','); int.TryParse(_cords[0], out x); int.TryParse(_cords[1], out y); int.TryParse(_cords[2], out z); _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(x, y, z), null, false)); } Jail.Jailed.Add(_cInfo.playerId); if (_jailTime >= 0) { string _phrase500; if (!Phrases.Dict.TryGetValue(500, out _phrase500)) { _phrase500 = "you have been sent to jail."; } _phrase500 = _phrase500.Replace("{Minutes}", _jailTime.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase500 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); SdtdConsole.Instance.Output(string.Format("You have put {0} in jail for {1} minutes.", _cInfo.playerName, _jailTime)); } if (_jailTime == -1) { string _phrase500; if (!Phrases.Dict.TryGetValue(500, out _phrase500)) { _phrase500 = "you have been sent to jail."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase500 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); SdtdConsole.Instance.Output(string.Format("You have put {0} in jail for life.", _cInfo.playerName)); } string _sql = string.Format("UPDATE Players SET jailTime = {0}, jailName = '{1}', jailDate = '{2}' WHERE steamid = '{3}'", _jailTime, _cInfo.playerName, DateTime.Now, _cInfo.playerId); SQL.FastQuery(_sql); } } else { string _id = SQL.EscapeString(_params[1]); string _sql = string.Format("UPDATE Players SET jailTime = {0}, jailName = 'Unknown', jailDate = '{1}' WHERE steamid = '{2}'", _jailTime, DateTime.Now, _id); SQL.FastQuery(_sql); SdtdConsole.Instance.Output(string.Format("Player with Id {0} can not be found online but has been set for jail.", _id)); return; } } } else if (_params[0].ToLower().Equals("remove")) { if (_params.Count != 2) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}.", _params.Count)); return; } if (_params[1].Length != 17) { SdtdConsole.Instance.Output(string.Format("Can not remove player Id: Invalid steam Id {0}.", _params[1])); return; } else { if (!Jail.Jailed.Contains(_params[1])) { SdtdConsole.Instance.Output(string.Format("Player with steam Id {0} is not in jail. ", _params[1])); return; } else { ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_params[1]); if (_cInfo != null) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; EntityBedrollPositionList _position = _player.SpawnPoints; Jail.Jailed.Remove(_cInfo.playerId); if (_position.Count > 0) { _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(_position[0].x, -1, _position[0].z), null, false)); } else { Vector3[] _pos = GameManager.Instance.World.GetRandomSpawnPointPositions(1); _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(_pos[0].x, -1, _pos[0].z), null, false)); } string _phrase501; if (!Phrases.Dict.TryGetValue(501, out _phrase501)) { _phrase501 = "you have been released from jail."; } _phrase501 = _phrase501.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase501 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); string _sql = string.Format("UPDATE Players SET jailTime = 0 WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql); SdtdConsole.Instance.Output(string.Format("You have released a player with steam id {0} from jail. ", _params[1])); return; } else { string _id = SQL.EscapeString(_params[1]); string _sql = string.Format("UPDATE Players SET jailTime = 0 WHERE steamid = '{0}'", _id); SQL.FastQuery(_sql); Jail.Jailed.Remove(_cInfo.playerId); SdtdConsole.Instance.Output(string.Format("Player with steam Id {0} has been removed from the jail list.", _params[1])); return; } } } } else if (_params[0].ToLower().Equals("list")) { if (_params.Count != 1) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1, found {0}.", _params.Count)); return; } if (Jail.Jailed.Count == 0) { SdtdConsole.Instance.Output("There are no Ids on the Jail list."); return; } else { for (int i = 0; i < Jail.Jailed.Count; i++) { string _id = Jail.Jailed[i]; string _sql = string.Format("SELECT jailTime, jailName, jailDate FROM Players WHERE steamid = '{0}'", _id); DataTable _result = SQL.TQuery(_sql); int _jailTime; int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _jailTime); DateTime _jailDate; DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _jailDate); if (_jailTime > 0) { TimeSpan varTime = DateTime.Now - _jailDate; double fractionalMinutes = varTime.TotalMinutes; int _timepassed = (int)fractionalMinutes; int _timeleft = _jailTime - _timepassed; SdtdConsole.Instance.Output(string.Format("Jailed player: steam Id {0} named {1} for {2} more minutes.", _id, _result.Rows[0].ItemArray.GetValue(1).ToString(), _timeleft)); } else { SdtdConsole.Instance.Output(string.Format("Jailed player: steam Id {0} named {1} forever.", _id, _result.Rows[0].ItemArray.GetValue(1).ToString())); } _result.Dispose(); } } } else { SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0])); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in CommandJailConsole.Run: {0}.", e)); } }
public static void AddPlayer(ClientInfo _cInfo) { if (!PlayersTeam.ContainsKey(_cInfo.playerId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; string _sposition = x + "," + y + "," + z; string _eventReturn = SQL.EscapeString(_sposition); string _sql = string.Format("UPDATE Players SET eventReturn = '{0}' WHERE steamid = {1}", _eventReturn, _cInfo.playerId); SQL.FastQuery(_sql); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you have signed up for the event and your current location has been saved for return.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); _sql = string.Format("SELECT eventid, eventName, eventTeams, eventPlayerCount, eventTime FROM Events WHERE eventAdmin = '{0}' AND eventActive = 'true'", Admin); DataTable _result1 = SQL.TQuery(_sql); int _eventid; int.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid); string _eventName = _result1.Rows[0].ItemArray.GetValue(1).ToString(); int _eventTeams; int.TryParse(_result1.Rows[0].ItemArray.GetValue(2).ToString(), out _eventTeams); int _eventPlayerCount; int.TryParse(_result1.Rows[0].ItemArray.GetValue(3).ToString(), out _eventPlayerCount); int _time; int.TryParse(_result1.Rows[0].ItemArray.GetValue(4).ToString(), out _time); _result1.Dispose(); PlayersTeam.Add(_cInfo.playerId, TeamCount); string _message = "you are on team {Team}."; _message = _message.Replace("{Team}", TeamCount.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); if (TeamCount == _eventTeams) { TeamCount = 1; } if (PlayersTeam.Count == _eventPlayerCount) { Invited = false; foreach (var _eventPlayer in PlayersTeam) { ClientInfo _cInfo2 = ConnectionManager.Instance.Clients.ForPlayerId(_eventPlayer.Key); if (_cInfo2 != null) { EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId]; if (_player2 != null && _player2.IsAlive()) { int _teamNumber; PlayersTeam.TryGetValue(_eventPlayer.Key, out _teamNumber); _sql = string.Format("SELECT eventSpawn FROM EventSpawns WHERE eventid = {0} AND eventTeam = {1}", _eventid, _teamNumber); DataTable _result2 = SQL.TQuery(_sql); string _spawnPos = _result2.Rows[0].ItemArray.GetValue(0).ToString(); _result2.Dispose(); int _x, _y, _z; string[] _cords = _spawnPos.Split(','); int.TryParse(_cords[0], out _x); int.TryParse(_cords[1], out _y); int.TryParse(_cords[2], out _z); _cInfo2.SendPackage(new NetPackageTeleportPlayer(new Vector3(_x, _y, _z), null, false)); ChatHook.ChatMessage(_cInfo2, LoadConfig.Chat_Response_Color + _cInfo2.playerName + ", you have been sent to your event spawn point.[-]", _cInfo2.entityId, _cInfo2.playerName, EChatType.Global, null); } else { _sql = string.Format("UPDATE Players SET eventSpawn = 'true' WHERE steamid = {0}", _eventPlayer.Key); SQL.FastQuery(_sql); } } else { _sql = string.Format("UPDATE Players SET eventSpawn = 'true' WHERE steamid = {0}", _eventPlayer.Key); SQL.FastQuery(_sql); } } int _eventTime = _time * 60; Timers._eventTime = _eventTime; Open = true; _message = "{EventName} is full and has now started."; _message = _message.Replace("{EventName}", _eventName); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } else { _message = "{EventName} still has space for more players. Type /event."; _message = _message.Replace("{EventName}", _eventName); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); _message = "{Count} of {Total} have signed up."; _message = _message.Replace("{Count}", PlayersTeam.Count.ToString()); _message = _message.Replace("{Total}", _eventPlayerCount.ToString()); ChatHook.ChatMessage(null, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Global, null); } } else { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you are already signed up for this event. It will start when enough players sign up.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); } }
public void PlayerSpawning(ClientInfo _cInfo, int _chunkViewDim, PlayerProfile _playerProfile) { if (_cInfo != null) { if (CountryBan.IsEnabled && _cInfo.ip != "127.0.0.1" && !_cInfo.ip.StartsWith("192.168")) { if (CountryBan.IsCountryBanned(_cInfo)) { return; } } string _sql = string.Format("SELECT steamid FROM Players WHERE steamid = '{0}'", _cInfo.playerId);; DataTable _result = SQL.TQuery(_sql); string _name = SQL.EscapeString(_cInfo.playerName); if (_result.Rows.Count == 0) { _sql = string.Format("INSERT INTO Players (steamid, playername, last_joined) VALUES ('{0}', '{1}', '{2}')", _cInfo.playerId, _name, DateTime.Now); } else { _sql = string.Format("UPDATE Players SET playername = '{0}', last_joined = '{1}' WHERE steamid = '{2}'", _name, DateTime.Now, _cInfo.playerId); } _result.Dispose(); SQL.FastQuery(_sql); if (StopServer.NoEntry) { int _seconds = (60 - Timers._sSCD); string _phrase452; if (!Phrases.Dict.TryGetValue(452, out _phrase452)) { _phrase452 = "Shutdown is in {Minutes} minutes {Seconds} seconds. Please come back after the server restarts."; } _phrase452 = _phrase452.Replace("{Minutes}", Timers._sSC.ToString()); _phrase452 = _phrase452.Replace("{Seconds}", _seconds.ToString()); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.entityId, _phrase452), (ClientInfo)null); } if (ReservedSlots.IsEnabled) { if (ReservedSlots.Kicked.ContainsKey(_cInfo.playerName)) { DateTime _dateTime; ReservedSlots.Kicked.TryGetValue(_cInfo.playerId, out _dateTime); TimeSpan varTime = DateTime.Now - _dateTime; double fractionalMinutes = varTime.TotalMinutes; int _timepassed = (int)fractionalMinutes; if (_timepassed >= 5) { int _timeleft = 5 - _timepassed; string _phrase22; if (!Phrases.Dict.TryGetValue(22, out _phrase22)) { _phrase22 = "Sorry {PlayerName} you have reached the max session time. Please wait {TimeRemaining} minutes before rejoining."; } _phrase22 = _phrase22.Replace("{PlayerName}", _cInfo.playerName); _phrase22 = _phrase22.Replace("{TimeRemaining}", _timeleft.ToString()); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.playerId, _phrase22), (ClientInfo)null); } else { ReservedSlots.CheckReservedSlot(_cInfo); } } else { ReservedSlots.CheckReservedSlot(_cInfo); } } if (CredentialCheck.IsEnabled) { CredentialCheck.AccCheck(_cInfo); } if (Motd.IsEnabled && !Motd.Show_On_Respawn) { Motd.Send(_cInfo); } if (AutoShutdown.IsEnabled) { if (AutoShutdown.Alert_On_Login) { AutoShutdown.CheckNextShutdown(_cInfo, false); } } if (Bloodmoon.Show_On_Login && !Bloodmoon.Show_On_Respawn) { Bloodmoon.GetBloodmoon(_cInfo, false); } if (LoginNotice.IsEnabled) { LoginNotice.PlayerCheck(_cInfo); } Players.SessionTime(_cInfo); } }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { if (MutePlayer.IsEnabled) { try { if (_params.Count < 1 || _params.Count > 3) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1 to 3, found {0}.", _params.Count)); return; } if (_params[0].ToLower().Equals("add")) { if (_params.Count < 2 || _params.Count > 3) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2 or 3, found {0}.", _params.Count)); return; } if (_params[1].Length < 1 || _params[1].Length > 17) { SdtdConsole.Instance.Output(string.Format("Can not add Id: Invalid Id {0}.", _params[1])); return; } int _muteTime = 60; if (_params[2] != null) { int _value; if (int.TryParse(_params[2], out _value)) { _muteTime = _value; } } ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); if (_cInfo != null) { if (MutePlayer.Mutes.Contains(_cInfo.playerId)) { SdtdConsole.Instance.Output(string.Format("Steam Id {0}, player name {1} is already muted.", _cInfo.playerId, _cInfo.playerName)); return; } else { string _name = SQL.EscapeString(_cInfo.playerName); if (_name.Contains("!") || _name.Contains("@") || _name.Contains("#") || _name.Contains("$") || _name.Contains("%") || _name.Contains("^") || _name.Contains("&") || _name.Contains("*") || _name.Contains("'") || _name.Contains(";")) { _name = _name.Replace("!", ""); _name = _name.Replace("@", ""); _name = _name.Replace("#", ""); _name = _name.Replace("$", ""); _name = _name.Replace("%", ""); _name = _name.Replace("^", ""); _name = _name.Replace("&", ""); _name = _name.Replace("*", ""); _name = _name.Replace("'", ""); _name = _name.Replace(";", ""); } string _sql; if (_muteTime == -1) { MutePlayer.Mutes.Add(_cInfo.playerId); _sql = string.Format("UPDATE Players SET muteTime = -1, playername = '{0}', WHERE steamid = '{1}'", _name, _cInfo.playerId); SQL.FastQuery(_sql, "MutePlayerConsole"); SdtdConsole.Instance.Output(string.Format("Steam Id {0}, player name {1} has been muted indefinitely.", _cInfo.playerId, _cInfo.playerName)); return; } MutePlayer.Mutes.Add(_cInfo.playerId); _sql = string.Format("UPDATE Players SET muteTime = {0}, playername = '{1}', muteDate = '{2}' WHERE steamid = '{3}'", _muteTime, _name, DateTime.Now, _cInfo.playerId); SQL.FastQuery(_sql, "MutePlayerConsole"); SdtdConsole.Instance.Output(string.Format("Steam Id {0}, player name {1} has been muted for {2} minutes.", _cInfo.playerId, _cInfo.playerName, _muteTime)); return; } } else { SdtdConsole.Instance.Output(string.Format("Player with Id {0} can not be found.", _params[1])); return; } } else if (_params[0].ToLower().Equals("remove")) { if (_params.Count != 2) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}.", _params.Count)); return; } if (_params[1].Length != 17) { SdtdConsole.Instance.Output(string.Format("Can not add Id: Invalid Id {0}.", _params[1])); return; } string _id = _params[1]; if (MutePlayer.Mutes.Contains(_id)) { ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_id); if (_cInfo != null) { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you have been unmuted.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } MutePlayer.Mutes.Remove(_id); string _sql = string.Format("UPDATE Players SET muteTime = 0 WHERE steamid = '{0}'", _id); SQL.FastQuery(_sql, "MutePlayerConsole"); SdtdConsole.Instance.Output(string.Format("Steam Id {0} has been unmuted.", _id)); return; } else { SdtdConsole.Instance.Output(string.Format("Steam Id {0} is not muted.", _id)); return; } } else if (_params[0].ToLower().Equals("list")) { if (_params.Count != 1) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1, found {0}.", _params.Count)); return; } if (MutePlayer.Mutes.Count > 0) { string _sql = "SELECT steamid, playername, muteTime, muteDate FROM Players WHERE muteTime > 0 OR muteTime = -1"; DataTable _result = SQL.TQuery(_sql); int _steamid; int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _steamid); string playername = _result.Rows[0].ItemArray.GetValue(1).ToString(); int _muteTime; int.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _muteTime); DateTime _muteDate; DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _muteDate); _result.Dispose(); if (_muteTime == -1) { SdtdConsole.Instance.Output(string.Format("Steam id {0}, player name {1} is muted indefinitely", _steamid, playername)); return; } if (_muteTime > 0) { TimeSpan varTime = DateTime.Now - _muteDate; double fractionalMinutes = varTime.TotalMinutes; int _timepassed = (int)fractionalMinutes; int _timeleft = _muteTime - _timepassed; SdtdConsole.Instance.Output(string.Format("Steam id {0}, player name {1} for {2} minutes", _steamid, playername, _timeleft)); return; } } else { SdtdConsole.Instance.Output(string.Format("No players are muted.")); return; } } else { SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0])); return; } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ConsoleCommandMuteConsole.Run: {0}.", e)); } } else { SdtdConsole.Instance.Output("Mute is not enabled."); return; } }
public static void Exec() { foreach (string _id in PersistentContainer.Instance.Players.SteamIDs) { string _sql = string.Format("SELECT steamid FROM Players WHERE steamid = '{0}'", _id); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count == 0) { Player p = PersistentContainer.Instance.Players[_id, false]; DateTime _last_gimme; DateTime _lastkillme; int _bank = p.Bank; int _wallet = p.Wallet; int _playerSpentCoins = p.PlayerSpentCoins; int _hardcoreSessionTime = p.HardcoreSessionTime; int _hardcoreKills = p.HardcoreKills; int _hardcoreZKills = p.HardcoreZKills; int _hardcoreScore = p.HardcoreScore; int _hardcoreDeaths = p.HardcoreDeaths; string _hardcoreName = "Unknown"; int _bounty = p.Bounty; int _bountyHunter = p.BountyHunter; int _sessionTime = p.SessionTime; int _bikeId = p.BikeId; DateTime _lastBike; int _jailTime = p.JailTime; string _jailName = "Unknown"; DateTime _jailDate; int _muteTime = p.MuteTime; string _muteName = "Unknown"; DateTime _muteDate; int _zkills = p.ZKills; int _kills = p.Kills; int _deaths = p.Deaths; string _eventReturn = "Unknown"; string _marketReturn = "Unknown"; string _lobbyReturn = "Unknown"; string _newTeleSpawn = "Unknown"; string _homeposition = "Unknown"; string _homeposition2 = "Unknown"; DateTime _lastsethome; string _lastwhisper = "Unknown"; DateTime _lastWaypoint; DateTime _lastMarket; DateTime _lastStuck; DateTime _lastLobby; DateTime _lastLog; DateTime _lastDied; DateTime _lastFriendTele; DateTime _respawnTime; DateTime _lastTravel; DateTime _lastAnimals; DateTime _lastVoteReward; string _firstClaim = "false"; string _ismuted = "false"; string _isjailed = "false"; string _startingItems = "false"; string _clanname = "Unknown"; string _invitedtoclan = "Unknown"; string _isclanowner = "false"; string _isclanofficer = "false"; DateTime _customCommand1; DateTime _customCommand2; DateTime _customCommand3; DateTime _customCommand4; DateTime _customCommand5; DateTime _customCommand6; DateTime _customCommand7; DateTime _customCommand8; DateTime _customCommand9; DateTime _customCommand10; if (p.LastGimme != null) { _last_gimme = p.LastGimme; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _last_gimme); } if (p.LastKillme != null) { _lastkillme = p.LastKillme; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastkillme); } if (p.HardcoreName != null) { _hardcoreName = p.HardcoreName; } if (p.LastBike != null) { _lastBike = p.LastBike; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastBike); } if (p.JailName != null) { _jailName = p.JailName; } if (p.JailDate != null) { _jailDate = p.JailDate; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _jailDate); } if (p.MuteName != null) { _muteName = p.MuteName; } if (p.MuteDate != null) { _muteDate = p.MuteDate; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _muteDate); } if (p.EventReturn != null) { _eventReturn = p.EventReturn; } if (p.MarketReturn != null) { _marketReturn = p.MarketReturn; } if (p.LobbyReturn != null) { _lobbyReturn = p.LobbyReturn; } if (p.NewTeleSpawn != null) { _newTeleSpawn = p.NewTeleSpawn; } if (p.HomePosition != null) { _homeposition = p.HomePosition; } if (p.HomePosition2 != null) { _homeposition2 = p.HomePosition2; } if (p.LastSetHome != null) { _lastsethome = p.LastSetHome; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastsethome); } if (p.LastWhisper != null) { _lastwhisper = p.LastWhisper; } if (p.LastWaypoint != null) { _lastWaypoint = p.LastWaypoint; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastWaypoint); } if (p.LastMarket != null) { _lastMarket = p.LastMarket; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastMarket); } if (p.LastStuck != null) { _lastStuck = p.LastStuck; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastStuck); } if (p.LastLobby != null) { _lastLobby = p.LastLobby; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastLobby); } if (p.Log != null) { _lastLog = p.Log; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastLog); } if (p.LastDied != null) { _lastDied = p.LastDied; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastDied); } if (p.LastFriendTele != null) { _lastFriendTele = p.LastFriendTele; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastFriendTele); } if (p.RespawnTime != null) { _respawnTime = p.RespawnTime; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _respawnTime); } if (p.LastTravel != null) { _lastTravel = p.LastTravel; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastTravel); } if (p.LastAnimals != null) { _lastAnimals = p.LastAnimals; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastAnimals); } if (p.LastVoteReward != null) { _lastVoteReward = p.LastVoteReward; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _lastVoteReward); } if (p.FirstClaim) { _firstClaim = "true"; } if (p.IsMuted) { _ismuted = "true"; } if (p.IsJailed) { _isjailed = "true"; } if (p.StartingItems) { _startingItems = "true"; } if (p.ClanName != null) { _clanname = p.ClanName; } if (p.InvitedToClan != null) { _invitedtoclan = p.InvitedToClan; } if (p.IsClanOwner) { _isclanowner = "true"; } if (p.IsClanOfficer) { _isclanofficer = "true"; } if (p.CustomCommand1 != null) { _customCommand1 = p.CustomCommand1; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand1); } if (p.CustomCommand2 != null) { _customCommand2 = p.CustomCommand2; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand2); } if (p.CustomCommand3 != null) { _customCommand3 = p.CustomCommand3; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand3); } if (p.CustomCommand4 != null) { _customCommand4 = p.CustomCommand4; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand4); } if (p.CustomCommand5 != null) { _customCommand5 = p.CustomCommand5; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand5); } if (p.CustomCommand6 != null) { _customCommand6 = p.CustomCommand6; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand6); } if (p.CustomCommand7 != null) { _customCommand7 = p.CustomCommand7; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand7); } if (p.CustomCommand8 != null) { _customCommand8 = p.CustomCommand8; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand8); } if (p.CustomCommand9 != null) { _customCommand9 = p.CustomCommand9; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand9); } if (p.CustomCommand10 != null) { _customCommand10 = p.CustomCommand10; } else { DateTime.TryParse("10/29/2000 7:30:00 AM", out _customCommand10); } _hardcoreName = SQL.EscapeString(_hardcoreName); _jailName = SQL.EscapeString(_jailName); _muteName = SQL.EscapeString(_muteName); _clanname = SQL.EscapeString(_clanname); _sql = string.Format("INSERT INTO Players (steamid, last_gimme, lastkillme, bank, wallet, playerSpentCoins, hardcoreSessionTime, hardcoreKills, hardcoreZKills, hardcoreScore, hardcoreDeaths, hardcoreName, bounty, bountyHunter, sessionTime, bikeId, lastBike, jailTime, jailName, jailDate, muteTime, muteName, muteDate, zkills, kills, deaths, eventReturn, marketReturn, lobbyReturn, newTeleSpawn, homeposition, homeposition2, lastsethome, lastwhisper, lastWaypoint, lastMarket, lastStuck, lastLobby, lastLog, lastDied, lastFriendTele, respawnTime, lastTravel, lastAnimals, lastVoteReward, firstClaim, ismuted, isjailed, startingItems, clanname, invitedtoclan, isclanowner, isclanofficer, customCommand1, customCommand2, customCommand3, customCommand4, customCommand5, customCommand6, customCommand7, customCommand8, customCommand9, customCommand10) VALUES ('{0}', '{1}', '{2}', {3}, {4}, {5}, {6}, {7}, {8}, {9}, {10}, '{11}', {12}, {13}, {14}, {15}, '{16}', {17}, '{18}', '{19}', {20}, '{21}', '{22}', {23}, {24}, {25}, '{26}', '{27}', '{28}', '{29}', '{30}', '{31}', '{32}', '{33}', '{34}', '{35}', '{36}', '{37}', '{38}', '{39}', '{40}', '{41}', '{42}', '{43}', '{44}', '{45}', '{46}', '{47}', '{48}', '{49}', '{50}', '{51}', '{52}', '{53}', '{54}', '{55}', '{56}', '{57}', '{58}', '{59}', '{60}', '{61}', '{62}')", _id, _last_gimme, _lastkillme, _bank, _wallet, _playerSpentCoins, _hardcoreSessionTime, _hardcoreKills, _hardcoreZKills, _hardcoreScore, _hardcoreDeaths, _hardcoreName, _bounty, _bountyHunter, _sessionTime, _bikeId, _lastBike, _jailTime, _jailName, _jailDate, _muteTime, _muteName, _muteDate, _zkills, _kills, _deaths, _eventReturn, _marketReturn, _lobbyReturn, _newTeleSpawn, _homeposition, _homeposition2, _lastsethome, _lastwhisper, _lastWaypoint, _lastMarket, _lastStuck, _lastLobby, _lastLog, _lastDied, _lastFriendTele, _respawnTime, _lastTravel, _lastAnimals, _lastVoteReward, _firstClaim, _ismuted, _isjailed, _startingItems, _clanname, _invitedtoclan, _isclanowner, _isclanofficer, _customCommand1, _customCommand2, _customCommand3, _customCommand4, _customCommand5, _customCommand6, _customCommand7, _customCommand8, _customCommand9, _customCommand10); SQL.FastQuery(_sql); if (p.AuctionItem != null) { string _itemName = p.AuctionItem[1]; int _itemCount; int _itemQuality; int _itemPrice; DateTime _cancelTime = p.CancelTime; int.TryParse(p.AuctionItem[0], out _itemCount); int.TryParse(p.AuctionItem[2], out _itemQuality); int.TryParse(p.AuctionItem[3], out _itemPrice); _sql = string.Format("INSERT INTO Auction (steamid, itemName, itemCount, itemQuality, itemPrice, cancelTime) VALUES ('{0}', '{1}', {2}, {3}, {4}, '{5}')", _id, _itemName, _itemCount, _itemQuality, _itemPrice, _cancelTime); SQL.FastQuery(_sql); } } _result.Dispose(); } string _binpath = string.Format("{0}/ServerTools.bin", GameUtils.GetSaveGameDir()); File.Delete(_binpath); LoadProcess.Load(4); }
public static void EndGame(ClientInfo _cInfo, EntityPlayer _player) { DateTime _time; Players.Session.TryGetValue(_cInfo.playerId, out _time); TimeSpan varTime = DateTime.Now - _time; double fractionalMinutes = varTime.TotalMinutes; int _timepassed = (int)fractionalMinutes; int _deaths = XUiM_Player.GetDeaths(_player); string _sql = string.Format("SELECT sessionTime FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result = SQL.TQuery(_sql); int _oldSession; int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _oldSession); _result.Dispose(); int _newSession = _oldSession + _timepassed; string _name = SQL.EscapeString(_cInfo.playerName); _sql = string.Format("UPDATE Hardcore SET sessionTime = {0}, kills = {1}, zKills = {2}, score = {3}, deaths = {4}, playerName = '{5}' WHERE steamid = '{6}'", _newSession, _player.KilledPlayers, _player.KilledZombies, _player.Score, _deaths, _name, _cInfo.playerId); SQL.FastQuery(_sql, "Hardcore"); _sql = string.Format("DELETE FROM Players WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "Hardcore"); _sql = string.Format("DELETE FROM Auction WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "Hardcore"); _sql = string.Format("DELETE FROM Waypoints WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "Hardcore"); _sql = string.Format("DELETE FROM Tracking WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "Hardcore"); _sql = string.Format("DELETE FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "Hardcore"); if (ClanManager.ClanMember.Contains(_cInfo.playerId)) { ClanManager.ClanMember.Remove(_cInfo.playerId); } string _session = string.Format("{0:00}", _newSession % 60); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Hardcore Game Over: Zombie Kills {1}, Player Kills {2}, Deaths {3}, Score {4}, Playtime {5}\"", _cInfo.playerId, _player.KilledZombies, _player.KilledPlayers, _deaths, _player.Score, _newSession), (ClientInfo)null); string _filepath = string.Format("{0}/Player/{1}.map", GameUtils.GetSaveGameDir(), _cInfo.playerId); string _filepath1 = string.Format("{0}/Player/{1}.ttp", GameUtils.GetSaveGameDir(), _cInfo.playerId); if (File.Exists(_filepath)) { File.Delete(_filepath); } if (File.Exists(_filepath1)) { File.Delete(_filepath1); } string _phrase951; if (!Phrases.Dict.TryGetValue(951, out _phrase951)) { _phrase951 = "Hardcore Game Over: Player {PlayerName}, Zombie Kills {ZombieKills}, Player Kills {PlayerKills}, Deaths {Deaths}, Score {Score}, Playtime {Playtime}"; } _phrase951 = _phrase951.Replace("{PlayerName}", _cInfo.playerName); _phrase951 = _phrase951.Replace("{ZombieKills}", _player.KilledZombies.ToString()); _phrase951 = _phrase951.Replace("{PlayerKills}", _player.KilledPlayers.ToString()); _phrase951 = _phrase951.Replace("{Deaths}", _deaths.ToString()); _phrase951 = _phrase951.Replace("{Score}", _player.Score.ToString()); _phrase951 = _phrase951.Replace("{Playtime}", _session); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase951 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); }
private static void SetPoint(ClientInfo _cInfo, string _waypoint) { string _sql = string.Format("SELECT steamid FROM Waypoints WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count > 0) { if (ReservedSlots.IsEnabled && ReservedSlots.Dict.ContainsKey(_cInfo.playerId)) { DateTime _dt; ReservedSlots.Dict.TryGetValue(_cInfo.playerId, out _dt); if (DateTime.Now < _dt) { if (_result.Rows.Count < Donator_Max_Waypoints && Donator_Max_Waypoints > 0) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; string _wposition = x + "," + y + "," + z; _waypoint = SQL.EscapeString(_waypoint); _sql = string.Format("INSERT INTO Waypoints (steamid, wayPointName, position) VALUES ('{0}', '{1}', '{2}')", _cInfo.playerId, _waypoint, _wposition); SQL.FastQuery(_sql, "Waypoints"); string _message = " saved waypoint name as {Name} to {X} {Y} {Z}."; _message = _message.Replace("{Name}", _waypoint); _message = _message.Replace("{X}", x.ToString()); _message = _message.Replace("{Y}", y.ToString()); _message = _message.Replace("{Z}", z.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { string _phrase581; if (!Phrases.Dict.TryGetValue(581, out _phrase581)) { _phrase581 = " you have a maximum {Count} waypoints."; } _phrase581 = _phrase581.Replace("{Count}", Donator_Max_Waypoints.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase581 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } else { if (_result.Rows.Count < Max_Waypoints && Max_Waypoints > 0) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; string _wposition = x + "," + y + "," + z; _waypoint = SQL.EscapeString(_waypoint); _sql = string.Format("INSERT INTO Waypoints (steamid, wayPointName, position) VALUES ('{0}', '{1}', '{2}')", _cInfo.playerId, _waypoint, _wposition); SQL.FastQuery(_sql, "Waypoints"); string _message = " saved waypoint name as {Name} to {X} {Y} {Z}."; _message = _message.Replace("{Name}", _waypoint); _message = _message.Replace("{X}", x.ToString()); _message = _message.Replace("{Y}", y.ToString()); _message = _message.Replace("{Z}", z.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { string _phrase582; if (!Phrases.Dict.TryGetValue(582, out _phrase582)) { _phrase582 = " you have a maximum {Count} waypoints."; } _phrase582 = _phrase582.Replace("{Count}", Max_Waypoints.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase582 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } else { if (ReservedSlots.IsEnabled && ReservedSlots.Dict.ContainsKey(_cInfo.playerId)) { DateTime _dt; ReservedSlots.Dict.TryGetValue(_cInfo.playerId, out _dt); if (DateTime.Now < _dt) { if (Donator_Max_Waypoints > 0) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; string _wposition = x + "," + y + "," + z; _waypoint = SQL.EscapeString(_waypoint); _sql = string.Format("INSERT INTO Waypoints (steamid, wayPointName, position) VALUES ('{0}', '{1}', '{2}')", _cInfo.playerId, _waypoint, _wposition); SQL.FastQuery(_sql, "Waypoints"); string _message = " saved waypoint name as {Name} to {X} {Y} {Z}."; _message = _message.Replace("{Name}", _waypoint); _message = _message.Replace("{X}", x.ToString()); _message = _message.Replace("{Y}", y.ToString()); _message = _message.Replace("{Z}", z.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { string _phrase581; if (!Phrases.Dict.TryGetValue(581, out _phrase581)) { _phrase581 = " you have a maximum {Count} waypoints."; } _phrase581 = _phrase581.Replace("{Count}", Donator_Max_Waypoints.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase581 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { string _phrase582; if (!Phrases.Dict.TryGetValue(582, out _phrase582)) { _phrase582 = " you have a maximum {Count} waypoints."; } _phrase582 = _phrase582.Replace("{Count}", Max_Waypoints.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase582 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { if (Max_Waypoints > 0) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; string _wposition = x + "," + y + "," + z; _waypoint = SQL.EscapeString(_waypoint); _sql = string.Format("INSERT INTO Waypoints (steamid, wayPointName, position) VALUES ('{0}', '{1}', '{2}')", _cInfo.playerId, _waypoint, _wposition); SQL.FastQuery(_sql, "Waypoints"); string _message = " saved waypoint name as {Name} to {X} {Y} {Z}."; _message = _message.Replace("{Name}", _waypoint); _message = _message.Replace("{X}", x.ToString()); _message = _message.Replace("{Y}", y.ToString()); _message = _message.Replace("{Z}", z.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { string _phrase582; if (!Phrases.Dict.TryGetValue(582, out _phrase582)) { _phrase582 = " you have a maximum {Count} waypoints."; } _phrase582 = _phrase582.Replace("{Count}", Max_Waypoints.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase582 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } _result.Dispose(); }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_params.Count < 1 || _params.Count > 2) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1 or 2, found {0}", _params.Count)); return; } if (_params[0].ToLower().Equals("off")) { Animals.IsEnabled = false; SdtdConsole.Instance.Output(string.Format("Animals has been set to off")); return; } else if (_params[0].ToLower().Equals("on")) { Animals.IsEnabled = true; SdtdConsole.Instance.Output(string.Format("Animals has been set to on")); return; } else if (_params[0].ToLower().Equals("reset")) { ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); if (_cInfo != null) { string _sql = string.Format("SELECT lastAnimals FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count != 0) { DateTime _lastAnimals; DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _lastAnimals); if (_lastAnimals.ToString() != "10/29/2000 7:30:00 AM") { _sql = string.Format("UPDATE Players SET lastAnimals = '10/29/2000 7:30:00 AM' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql); SdtdConsole.Instance.Output("Animal tracking delay reset."); } } else { SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a animal tracking delay to reset.", _params[1])); } _result.Dispose(); } else { if (_params[1].Length != 17) { SdtdConsole.Instance.Output(string.Format("Can not reset Id: Invalid Id {0}.", _params[1])); return; } string _id = SQL.EscapeString(_params[1]); string _sql = string.Format("SELECT lastAnimals FROM Players WHERE steamid = '{0}'", _id); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count != 0) { DateTime _lastAnimals; DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _lastAnimals); if (_lastAnimals.ToString() != "10/29/2000 7:30:00 AM") { _sql = string.Format("UPDATE Players SET lastAnimals = '10/29/2000 7:30:00 AM' WHERE steamid = '{0}'", _id); SQL.FastQuery(_sql); SdtdConsole.Instance.Output("Animal tracking delay reset."); } else { SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a animal tracking delay to reset.", _params[1])); } } else { SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a animal tracking delay to reset.", _params[1])); } _result.Dispose(); } } else { SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0])); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in AnimalTrackingConsole.Run: {0}.", e)); } }
public static void EndGame(ClientInfo _cInfo, EntityPlayer _player) { DateTime _time; Players.Session.TryGetValue(_cInfo.playerId, out _time); TimeSpan varTime = DateTime.Now - _time; double fractionalMinutes = varTime.TotalMinutes; int _timepassed = (int)fractionalMinutes; int _deaths = XUiM_Player.GetDeaths(_player); string _sql = string.Format("SELECT sessionTime FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result = SQL.TQuery(_sql); int _oldSession; int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _oldSession); _result.Dispose(); int _newSession = _oldSession + _timepassed; _sql = string.Format("SELECT last_gimme FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result1 = SQL.TQuery(_sql); if (_result1.Rows.Count != 0) { string _name = SQL.EscapeString(_cInfo.playerName); _sql = string.Format("UPDATE Players SET " + "playername = 'Unknown', " + "last_gimme = '10/29/2000 7:30:00 AM', " + "lastkillme = '10/29/2000 7:30:00 AM', " + "playerSpentCoins = 0, " + "hardcoreSessionTime = {0}, " + "hardcoreKills = {1}, " + "hardcoreZKills = {2}, " + "hardcoreScore = {3}, " + "hardcoreDeaths = {4}, " + "hardcoreName = '{5}', " + "sessionTime = 0, " + "bikeId = 0, " + "lastBike = '10/29/2000 7:30:00 AM', " + "jailName = 'Unknown', " + "jailDate = '10/29/2000 7:30:00 AM', " + "muteName = 'Unknown', " + "muteDate = '10/29/2000 7:30:00 AM', " + "lobbyReturn = 'Unknown', " + "newTeleSpawn = 'Unknown', " + "homeposition = 'Unknown', " + "homeposition2 = 'Unknown', " + "lastsethome = '10/29/2000 7:30:00 AM', " + "lastwhisper = 'Unknown', " + "lastStuck = '10/29/2000 7:30:00 AM', " + "lastLobby = '10/29/2000 7:30:00 AM', " + "lastLog = '10/29/2000 7:30:00 AM', " + "lastDied = '10/29/2000 7:30:00 AM', " + "lastFriendTele = '10/29/2000 7:30:00 AM', " + "respawnTime = '10/29/2000 7:30:00 AM', " + "lastTravel = '10/29/2000 7:30:00 AM', " + "lastAnimals = '10/29/2000 7:30:00 AM', " + "lastVoteReward = '10/29/2000 7:30:00 AM', " + "firstClaim = 'false', " + "ismuted = 'false', " + "isjailed = 'false', " + "startingItems = 'false', " + "clanname = 'Unknown', " + "invitedtoclan = 'Unknown', " + "isclanowner = 'false', " + "isclanofficer = 'false', " + "customCommand1 = '10/29/2000 7:30:00 AM', " + "customCommand2 = '10/29/2000 7:30:00 AM', " + "customCommand3 = '10/29/2000 7:30:00 AM', " + "customCommand4 = '10/29/2000 7:30:00 AM', " + "customCommand5 = '10/29/2000 7:30:00 AM', " + "customCommand6 = '10/29/2000 7:30:00 AM', " + "customCommand7 = '10/29/2000 7:30:00 AM', " + "customCommand8 = '10/29/2000 7:30:00 AM', " + "customCommand9 = '10/29/2000 7:30:00 AM', " + "customCommand10 = '10/29/2000 7:30:00 AM' " + "WHERE steamid = '{6}'", _newSession, _player.KilledPlayers, _player.KilledZombies, _player.Score, _deaths, _name, _cInfo.playerId); SQL.FastQuery(_sql); _sql = string.Format("SELECT steamid FROM Auction WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result2 = SQL.TQuery(_sql); if (_result2.Rows.Count > 0) { _sql = string.Format("DELETE FROM Auction WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql); } _result2.Dispose(); } _result1.Dispose(); if (ClanManager.ClanMember.Contains(_cInfo.playerId)) { ClanManager.ClanMember.Remove(_cInfo.playerId); } string _session = string.Format("0:00", _newSession % 60); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Hardcore Game Over: Zombie Kills {1}, Player Kills {2}, Deaths {3}, Score {4}, Playtime {5}\"", _cInfo.playerId, _player.KilledZombies, _player.KilledPlayers, _deaths, _player.Score, _newSession), (ClientInfo)null); Player p = PersistentContainer.Instance.Players[_cInfo.playerId, false]; if (p != null) { string _filepath = string.Format("{0}/Player/{1}.map", GameUtils.GetSaveGameDir(), _cInfo.playerId); string _filepath1 = string.Format("{0}/Player/{1}.ttp", GameUtils.GetSaveGameDir(), _cInfo.playerId); if (File.Exists(_filepath)) { File.Delete(_filepath); } if (File.Exists(_filepath1)) { File.Delete(_filepath1); } } string _phrase951; if (!Phrases.Dict.TryGetValue(951, out _phrase951)) { _phrase951 = "Hardcore Game Over: Player {PlayerName}, Zombie Kills {ZombieKills}, Player Kills {PlayerKills}, Deaths {Deaths}, Score {Score}, Playtime {Playtime}"; } _phrase951 = _phrase951.Replace("{PlayerName}", _cInfo.playerName); _phrase951 = _phrase951.Replace("{ZombieKills}", _player.KilledZombies.ToString()); _phrase951 = _phrase951.Replace("{PlayerKills}", _player.KilledPlayers.ToString()); _phrase951 = _phrase951.Replace("{Deaths}", _deaths.ToString()); _phrase951 = _phrase951.Replace("{Score}", _player.Score.ToString()); _phrase951 = _phrase951.Replace("{Playtime}", _session); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase951 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); }
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 VehicleDelay(ClientInfo _cInfo, string _playerName, int _vehicle) { string _sql = string.Format("SELECT steamid FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count == 0) { string _steamid = SQL.EscapeString(_cInfo.playerId); _sql = string.Format("INSERT INTO Vehicles (steamid) VALUES ('{0}')", _steamid); SQL.FastQuery(_sql, "VehicleTeleport"); } _result.Dispose(); Entity _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; Entity _attachedEntity = _player.AttachedToEntity; if (_attachedEntity == null) { bool _donator = false; if (Delay_Between_Uses < 1) { if (Wallet.IsEnabled && Command_Cost >= 1) { CommandCost(_cInfo, _player, _vehicle); } else { Exec2(_cInfo, _player, _vehicle); } } else { if (_vehicle == 1) { _sql = string.Format("SELECT lastBike FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId); } if (_vehicle == 2) { _sql = string.Format("SELECT lastMiniBike FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId); } if (_vehicle == 3) { _sql = string.Format("SELECT lastMotorBike FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId); } if (_vehicle == 4) { _sql = string.Format("SELECT lastJeep FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId); } if (_vehicle == 5) { _sql = string.Format("SELECT lastGyro FROM Vehicles WHERE steamid = '{0}'", _cInfo.playerId); } _result = SQL.TQuery(_sql); DateTime _lastVehicle; DateTime.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _lastVehicle); _result.Dispose(); TimeSpan varTime = DateTime.Now - _lastVehicle; double fractionalMinutes = varTime.TotalMinutes; int _timepassed = (int)fractionalMinutes; if (ReservedSlots.IsEnabled && ReservedSlots.Reduced_Delay) { if (ReservedSlots.Dict.ContainsKey(_cInfo.playerId)) { DateTime _dt; ReservedSlots.Dict.TryGetValue(_cInfo.playerId, out _dt); if (DateTime.Now < _dt) { _donator = true; int _newDelay = Delay_Between_Uses / 2; if (_timepassed >= _newDelay) { if (Wallet.IsEnabled && Command_Cost >= 1) { CommandCost(_cInfo, _player, _vehicle); } else { Exec2(_cInfo, _player, _vehicle); } } else { int _timeleft = _newDelay - _timepassed; string _phrase786; if (!Phrases.Dict.TryGetValue(786, out _phrase786)) { _phrase786 = " you can only use vehicle teleport once every {DelayBetweenUses} minutes. Time remaining: {TimeRemaining} minutes."; } _phrase786 = _phrase786.Replace("{DelayBetweenUses}", _newDelay.ToString()); _phrase786 = _phrase786.Replace("{TimeRemaining}", _timeleft.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase786 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } } if (!_donator) { if (_timepassed >= Delay_Between_Uses) { if (Wallet.IsEnabled && Command_Cost >= 1) { CommandCost(_cInfo, _player, _vehicle); } else { Exec2(_cInfo, _player, _vehicle); } } else { int _timeleft = Delay_Between_Uses - _timepassed; string _phrase786; if (!Phrases.Dict.TryGetValue(786, out _phrase786)) { _phrase786 = " you can only use vehicle teleport once every {DelayBetweenUses} minutes. Time remaining: {TimeRemaining} minutes."; } _phrase786 = _phrase786.Replace("{DelayBetweenUses}", Delay_Between_Uses.ToString()); _phrase786 = _phrase786.Replace("{TimeRemaining}", _timeleft.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase786 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } } else { Exec1(_cInfo, _player, _vehicle); } }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_params[0].ToLower().Equals("add")) { if (_params.Count != 2) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}.", _params.Count)); return; } ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); if (_cInfo != null) { string _sql = string.Format("SELECT countryban FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result = SQL.TQuery(_sql); bool _countrybanImmune = false; if (_result.Rows.Count > 0) { bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _countrybanImmune); } if (_countrybanImmune) { SdtdConsole.Instance.Output(string.Format("Can not add Id. {0} is already in the Country Ban Immunity list.", _params[1])); } else { if (_result.Rows.Count > 0) { _sql = string.Format("UPDATE Players SET countryban = 'true' WHERE steamid = '{0}'", _cInfo.playerId); } else { _sql = string.Format("INSERT INTO Players (steamid, countryban) VALUES ('{0}', 'true')", _cInfo.playerId); } SQL.FastQuery(_sql); SdtdConsole.Instance.Output(string.Format("Added Id {0} to the Country Ban Immunity list.", _params[1])); } _result.Dispose(); } else { if (_params[1].Length != 17) { SdtdConsole.Instance.Output(string.Format("You can only use a player id or their name if online. Can not add Id: Invalid Id {0}", _params[1])); return; } else { string _id = SQL.EscapeString(_params[1]); string _sql = string.Format("SELECT countryban FROM Players WHERE steamid = '{0}'", _id); DataTable _result = SQL.TQuery(_sql); bool _countrybanImmune = false; if (_result.Rows.Count > 0) { bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _countrybanImmune); } if (_countrybanImmune) { SdtdConsole.Instance.Output(string.Format("Can not add Id. {0} is already in the Country Ban Immunity list.", _params[1])); } else { if (_result.Rows.Count > 0) { _sql = string.Format("UPDATE Players SET countryban = 'true' WHERE steamid = '{0}'", _id); } else { _sql = string.Format("INSERT INTO Players (steamid, countryban) VALUES ('{0}', 'true')", _id); } SQL.FastQuery(_sql); SdtdConsole.Instance.Output(string.Format("Added Id {0} to the Country Ban Immunity list.", _params[1])); } _result.Dispose(); } } } else if (_params[0].ToLower().Equals("remove")) { if (_params.Count != 2) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 2, found {0}", _params.Count)); return; } ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); if (_cInfo != null) { string _sql = string.Format("SELECT countryban FROM Players WHERE steamid = '{0}' AND countryban = 'true'", _cInfo.playerId); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count > 0) { _sql = string.Format("UPDATE Players SET countryban = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql); SdtdConsole.Instance.Output(string.Format("Removed Id {0} from Country Ban Immunity list.", _params[1])); } else { SdtdConsole.Instance.Output(string.Format("Id {0} was not found.", _params[1])); } _result.Dispose(); } else { if (_params[1].Length != 17) { SdtdConsole.Instance.Output(string.Format("You can only use a player id or their name if online. Can not remove Id: Invalid Id {0}", _params[1])); } else { string _id = SQL.EscapeString(_params[1]); string _sql = string.Format("SELECT countryban FROM Players WHERE steamid = '{0}' AND countryban = 'true'", _id); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count > 0) { _sql = string.Format("UPDATE Players SET countryban = 'false' WHERE steamid = '{0}'", _id); SQL.FastQuery(_sql); SdtdConsole.Instance.Output(string.Format("Removed Id {0} from the Country Ban Immunity list.", _params[1])); } else { SdtdConsole.Instance.Output(string.Format("Id {0} was not found.", _params[1])); } _result.Dispose(); } } } else if (_params[0].ToLower().Equals("list")) { if (_params.Count != 1) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1, found {0}.", _params.Count)); return; } string _sql = "SELECT countryban FROM Players WHERE countryban = 'true'"; DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count < 1) { SdtdConsole.Instance.Output("There are no Ids on the Country Ban Immunity list."); } else { foreach (DataRow row in _result.Rows) { SdtdConsole.Instance.Output(string.Format("{0}", row[0])); } SdtdConsole.Instance.Output(string.Format("Total: {0}", _result.Rows.Count.ToString())); } _result.Dispose(); } else { SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0])); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in CountryBanImmunityCommandConsole.Run: {0}.", e)); } }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_params.Count < 1 || _params.Count > 2) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1 or 2, found {0}", _params.Count)); return; } if (_params[0].ToLower().Equals("off")) { FirstClaimBlock.IsEnabled = false; LoadConfig.WriteXml(); SdtdConsole.Instance.Output(string.Format("First claim block has been set to off")); return; } else if (_params[0].ToLower().Equals("on")) { FirstClaimBlock.IsEnabled = true; LoadConfig.WriteXml(); SdtdConsole.Instance.Output(string.Format("First claim block has been set to on")); return; } else if (_params[0].ToLower().Equals("reset")) { ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[1]); if (_cInfo != null) { string _sql = string.Format("SELECT firstClaim FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result = SQL.TQuery(_sql); bool _firstClaim; bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _firstClaim); _result.Dispose(); if (_firstClaim) { _sql = string.Format("UPDATE Players SET firstClaim = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "FirstClaimBlockConsole"); SdtdConsole.Instance.Output("Players first claim block reset."); } else { SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a first claim block to reset.", _params[1])); } } else if (_params[1].Length == 17) { string _id = SQL.EscapeString(_params[1]); string _sql = string.Format("SELECT firstClaim FROM Players WHERE steamid = '{0}'", _id); DataTable _result = SQL.TQuery(_sql); bool _firstClaim; bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _firstClaim); _result.Dispose(); if (_firstClaim) { _sql = string.Format("UPDATE Players SET firstClaim = 'false' WHERE steamid = '{0}'", _id); SQL.FastQuery(_sql, "FirstClaimBlockConsole"); SdtdConsole.Instance.Output("Players first claim block reset."); } else { SdtdConsole.Instance.Output(string.Format("Player with id {0} does not have a first claim block to reset.", _params[1])); } } else { SdtdConsole.Instance.Output(string.Format("Can not reset Id: Invalid Id {0}.", _params[1])); } } else { SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0])); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in FirstClaimBlockConsole.Run: {0}.", e)); } }
public void PlayerSpawnedInWorld(ClientInfo _cInfo, RespawnType _respawnReason, Vector3i _pos) { if (_cInfo != null) { string _name = SQL.EscapeString(_cInfo.playerName); if (Motd.IsEnabled & Motd.Show_On_Respawn) { Motd.Send(_cInfo); } if (Bloodmoon.Show_On_Login && Bloodmoon.Show_On_Respawn) { Bloodmoon.GetBloodmoon(_cInfo, false); } if (_respawnReason == RespawnType.EnterMultiplayer) { if (NewPlayer.IsEnabled) { NewPlayer.Exec(_cInfo); } if (NewSpawnTele.IsEnabled) { NewSpawnTele.TeleNewSpawn(_cInfo); } if (StartingItems.IsEnabled) { if (!NewSpawnTele.IsEnabled) { StartingItems.StartingItemCheck(_cInfo); } else if (NewSpawnTele.IsEnabled && NewSpawnTele.New_Spawn_Tele_Position != "0,0,0") { StartingItems.Que.Add(_cInfo.playerId); } else if (NewSpawnTele.IsEnabled && NewSpawnTele.New_Spawn_Tele_Position == "0,0,0") { StartingItems.StartingItemCheck(_cInfo); } } string _sql = "SELECT pollOpen FROM Polls WHERE pollOpen = 'true'"; DataTable _result1 = SQL.TQuery(_sql); if (_result1.Rows.Count > 0 && !PollConsole.PolledYes.Contains(_cInfo.playerId) && !PollConsole.PolledNo.Contains(_cInfo.playerId)) { PollConsole.Message(_cInfo); } _result1.Dispose(); if (Hardcore.IsEnabled) { Hardcore.Announce(_cInfo); } _sql = string.Format("UPDATE Players SET playername = '{0}', wallet = 0, playerSpentCoins = 0, sessionTime = 0, zkills = 0, kills = 0, deaths = 0 WHERE steamid = '{1}'", _name, _cInfo.playerId); SQL.FastQuery(_sql); } if (_respawnReason == RespawnType.JoinMultiplayer) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; int _zCount = XUiM_Player.GetZombieKills(_player); int _deathCount = XUiM_Player.GetDeaths(_player); int _killCount = XUiM_Player.GetPlayerKills(_player); string _sql = "SELECT pollOpen FROM Polls WHERE pollOpen = 'true'"; DataTable _result = SQL.TQuery(_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)) { if (Hardcore.IsEnabled) { Hardcore.Check(_cInfo); } } else { _sql = string.Format("SELECT eventRespawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result1 = SQL.TQuery(_sql); bool _eventRespawn; 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.TQuery(_sql); bool _return1 = false, _return2 = false; 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); } _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql); Event.EventReturn(_cInfo); } else if (_return2) { Event.EventSpawn(_cInfo); } } } } else { if (Hardcore.IsEnabled) { Hardcore.Check(_cInfo); } } _sql = string.Format("UPDATE Players SET playername = '{0}', zkills = {1}, kills = {2}, deaths = {3} WHERE steamid = '{4}'", _name, _zCount, _killCount, _deathCount, _cInfo.playerId); SQL.FastQuery(_sql); if (Mogul.IsEnabled) { if (Wallet.IsEnabled) { int currentCoins = Wallet.GetcurrentCoins(_cInfo); _sql = string.Format("UPDATE Players SET wallet = {0} WHERE steamid = '{1}'", currentCoins, _cInfo.playerId); SQL.FastQuery(_sql); } } } if (_respawnReason == RespawnType.Died) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (Event.Open) { if (!Event.PlayersTeam.ContainsKey(_cInfo.playerId)) { if (Wallet.Lose_On_Death) { Wallet.ClearWallet(_cInfo); } if (Hardcore.IsEnabled) { Hardcore.Check(_cInfo); } string _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result1 = SQL.TQuery(_sql); bool _return1 = false, _return2 = false; 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); } _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql); Event.EventReturn(_cInfo); } } else { string _sql = string.Format("SELECT eventRespawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result = SQL.TQuery(_sql); bool _eventRespawn; bool.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _eventRespawn); _result.Dispose(); if (_eventRespawn) { Event.Died(_cInfo); } else { _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result1 = SQL.TQuery(_sql); bool _return1 = false, _return2 = false; 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); } _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql); Event.EventReturn(_cInfo); } else if (_return2) { Event.EventSpawn(_cInfo); } } } } else { if (Wallet.Lose_On_Death) { Wallet.ClearWallet(_cInfo); } if (Hardcore.IsEnabled) { Hardcore.Check(_cInfo); } string _sql = string.Format("SELECT return, eventSpawn FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result1 = SQL.TQuery(_sql); bool _return1 = false, _return2 = false; 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); } _sql = string.Format("UPDATE Players SET return = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql); Event.EventReturn(_cInfo); } } string _sql2 = string.Format("UPDATE Players SET deaths = {0} WHERE steamid = '{1}'", XUiM_Player.GetDeaths(_player), _cInfo.playerId); SQL.FastQuery(_sql2); if (Zones.IsEnabled && Players.Victim.ContainsKey(_cInfo.entityId)) { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + ", type /return to teleport back to your death position. There is a time limit.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); _sql2 = string.Format("UPDATE Players SET respawnTime = '{0}' WHERE steamid = '{1}'", DateTime.Now, _cInfo.playerId); SQL.FastQuery(_sql2); if (Players.Forgive.ContainsKey(_cInfo.entityId)) { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + ", type /forgive to release your killer from jail.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } if (Mogul.IsEnabled) { if (Wallet.IsEnabled) { int currentCoins = Wallet.GetcurrentCoins(_cInfo); _sql2 = string.Format("UPDATE Players SET wallet = {0} WHERE steamid = '{1}'", currentCoins, _cInfo.playerId); SQL.FastQuery(_sql2); } } } if (_respawnReason == RespawnType.Teleport) { if (StartingItems.IsEnabled && StartingItems.Que.Contains(_cInfo.playerId)) { StartingItems.StartingItemCheck(_cInfo); StartingItems.Que.Remove(_cInfo.playerId); } if (Players.NoFlight.Contains(_cInfo.entityId)) { Players.NoFlight.Remove(_cInfo.entityId); } if (HatchElevator.IsEnabled) { HatchElevator.LastPositionY.Remove(_cInfo.entityId); } } if (Players.Dead.Contains(_cInfo.entityId)) { Players.Dead.Remove(_cInfo.entityId); } } }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_params.Count < 1 || _params.Count > 2) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1 or 2, found {0}", _params.Count)); return; } if (_params[0].ToLower().Equals("off")) { Wallet.IsEnabled = false; LoadConfig.WriteXml(); SdtdConsole.Instance.Output(string.Format("Wallet has been set to off")); return; } else if (_params[0].ToLower().Equals("on")) { Wallet.IsEnabled = true; LoadConfig.WriteXml(); SdtdConsole.Instance.Output(string.Format("Wallet has been set to on")); return; } else if (_params.Count == 2) { if (_params[1].Length < 1 || _params[1].Length > 5) { SdtdConsole.Instance.Output(string.Format("Can not adjust wallet. Value {0} is invalid", _params[1])); return; } int _adjustCoins; if (!int.TryParse(_params[1], out _adjustCoins)) { SdtdConsole.Instance.Output(string.Format("Can not adjust wallet. Value {0} is invalid", _params[1])); return; } else { string _steamid = SQL.EscapeString(_params[0]); string _sql = string.Format("SELECT playerSpentCoins FROM Players WHERE steamid = '{0}'", _steamid); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count != 0) { Wallet.AddCoinsToWallet(_steamid, _adjustCoins); if (_adjustCoins >= 0) { SdtdConsole.Instance.Output(string.Format("Added {0} {1} to player id {2} wallet", _params[1], Wallet.Coin_Name, _steamid)); } else { SdtdConsole.Instance.Output(string.Format("Subtracted {0} {1} from player id {2} wallet", _params[1], Wallet.Coin_Name, _steamid)); } } else { SdtdConsole.Instance.Output(string.Format("Player id not found: {0}", _steamid)); } _result.Dispose(); } } else if (_params.Count == 1) { string _steamid = SQL.EscapeString(_params[0]); string _sql = string.Format("SELECT playerSpentCoins, zkills, kills, deaths FROM Players WHERE steamid = '{0}'", _steamid); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count != 0) { int currentCoins; World world = GameManager.Instance.World; int _playerSpentCoins; int _zkills; int _kills; int _deaths; int.TryParse(_result.Rows[0].ItemArray.GetValue(0).ToString(), out _playerSpentCoins); int.TryParse(_result.Rows[0].ItemArray.GetValue(1).ToString(), out _zkills); int.TryParse(_result.Rows[0].ItemArray.GetValue(2).ToString(), out _kills); int.TryParse(_result.Rows[0].ItemArray.GetValue(3).ToString(), out _deaths); int gameMode = world.GetGameMode(); if (gameMode == 7) { currentCoins = (_zkills * Wallet.Zombie_Kills) + (_kills * Wallet.Player_Kills) - (_deaths * Wallet.Deaths) + _playerSpentCoins; } else { currentCoins = (_zkills * Wallet.Zombie_Kills) - (_deaths * Wallet.Deaths) + _playerSpentCoins; } SdtdConsole.Instance.Output(string.Format("Wallet for id {0}: {1} {2}", _params[0], currentCoins, Wallet.Coin_Name)); return; } else { SdtdConsole.Instance.Output(string.Format("Player id not found: {0}", _steamid)); } _result.Dispose(); } else { SdtdConsole.Instance.Output(string.Format("Invalid argument {0}.", _params[0])); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in WalletConsole.Run: {0}.", e)); } }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_params.Count != 1) { SdtdConsole.Instance.Output(string.Format("Wrong number of arguments, expected 1, found {0}", _params.Count)); return; } ClientInfo _cInfo = ConsoleHelper.ParseParamIdOrName(_params[0]); if (_cInfo != null) { string _filepath = string.Format("{0}/Player/{1}.map", GameUtils.GetSaveGameDir(), _cInfo.playerId); string _filepath1 = string.Format("{0}/Player/{1}.ttp", GameUtils.GetSaveGameDir(), _cInfo.playerId); string _sql = string.Format("SELECT steamid FROM Players WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count != 0) { string _phrase400; if (!Phrases.Dict.TryGetValue(400, out _phrase400)) { _phrase400 = "Reseting players profile."; } SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.entityId, _phrase400), _cInfo); if (!File.Exists(_filepath)) { SdtdConsole.Instance.Output(string.Format("Could not find file {0}.map", _params[0])); } else { File.Delete(_filepath); } if (!File.Exists(_filepath1)) { SdtdConsole.Instance.Output(string.Format("Could not find file {0}.ttp", _params[0])); } else { File.Delete(_filepath1); } _sql = string.Format("UPDATE Players SET playername = 'Unknown', last_gimme = '10/29/2000 7:30:00 AM', lastkillme = '10/29/2000 7:30:00 AM', playerSpentCoins = 0, sessionTime = 0, bikeId = 0, lastBike = '10/29/2000 7:30:00 AM', jailName = 'Unknown', jailDate = '10/29/2000 7:30:00 AM', muteName = 'Unknown', muteDate = '10/29/2000 7:30:00 AM', lobbyReturn = 'Unknown', newTeleSpawn = 'Unknown', homeposition = 'Unknown', homeposition2 = 'Unknown', lastsethome = '10/29/2000 7:30:00 AM', lastwhisper = 'Unknown', lastStuck = '10/29/2000 7:30:00 AM', lastLobby = '10/29/2000 7:30:00 AM', lastLog = '10/29/2000 7:30:00 AM', lastBackpack = '10/29/2000 7:30:00 AM', lastFriendTele = '10/29/2000 7:30:00 AM', respawnTime = '10/29/2000 7:30:00 AM', lastTravel = '10/29/2000 7:30:00 AM', lastAnimals = '10/29/2000 7:30:00 AM', lastVoteReward = '10/29/2000 7:30:00 AM', firstClaim = 'false', ismuted = 'false', isjailed = 'false', startingItems = 'false', clanname = 'Unknown', invitedtoclan = 'Unknown', isclanowner = 'false', isclanofficer = 'false', customCommand1 = '10/29/2000 7:30:00 AM', customCommand2 = '10/29/2000 7:30:00 AM', customCommand3 = '10/29/2000 7:30:00 AM', customCommand4 = '10/29/2000 7:30:00 AM', customCommand5 = '10/29/2000 7:30:00 AM', customCommand6 = '10/29/2000 7:30:00 AM', customCommand7 = '10/29/2000 7:30:00 AM', customCommand8 = '10/29/2000 7:30:00 AM', customCommand9 = '10/29/2000 7:30:00 AM', customCommand10 = '10/29/2000 7:30:00 AM' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "ResetPlayerConsole"); _sql = string.Format("SELECT * FROM Auction WHERE steamid = '{0}'", _cInfo.playerId); DataTable _result1 = SQL.TQuery(_sql); if (_result1.Rows.Count != 0) { _sql = string.Format("DELETE FROM Auction WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "ResetPlayerConsole"); } _result1.Dispose(); } _result.Dispose(); string _phrase401; if (!Phrases.Dict.TryGetValue(401, out _phrase401)) { _phrase401 = "You have reset the profile for Player {SteamId}."; } _phrase401 = _phrase401.Replace("{SteamId}", _params[0]); SdtdConsole.Instance.Output(string.Format("{0}", _phrase401)); } else if (_params[0].Length == 17) { string _steamid = SQL.EscapeString(_params[0]); string _filepath = string.Format("{0}/Player/{1}.map", GameUtils.GetSaveGameDir(), _steamid); string _filepath1 = string.Format("{0}/Player/{1}.ttp", GameUtils.GetSaveGameDir(), _steamid); string _sql = string.Format("SELECT last_gimme FROM Players WHERE steamid = '{0}'", _steamid); DataTable _result = SQL.TQuery(_sql); if (_result.Rows.Count != 0) { if (!File.Exists(_filepath)) { SdtdConsole.Instance.Output(string.Format("Could not find file {0}.map", _params[0])); } else { File.Delete(_filepath); } if (!File.Exists(_filepath1)) { SdtdConsole.Instance.Output(string.Format("Could not find file {0}.ttp", _params[0])); } else { File.Delete(_filepath1); } _sql = string.Format("UPDATE Players SET playername = 'Unknown', last_gimme = '10/29/2000 7:30:00 AM', lastkillme = '10/29/2000 7:30:00 AM', playerSpentCoins = 0, sessionTime = 0, bikeId = 0, lastBike = '10/29/2000 7:30:00 AM', jailName = 'Unknown', jailDate = '10/29/2000 7:30:00 AM', muteName = 'Unknown', muteDate = '10/29/2000 7:30:00 AM', lobbyReturn = 'Unknown', newTeleSpawn = 'Unknown', homeposition = 'Unknown', homeposition2 = 'Unknown', lastsethome = '10/29/2000 7:30:00 AM', lastwhisper = 'Unknown', lastStuck = '10/29/2000 7:30:00 AM', lastLobby = '10/29/2000 7:30:00 AM', lastLog = '10/29/2000 7:30:00 AM', lastDied = '10/29/2000 7:30:00 AM', lastFriendTele = '10/29/2000 7:30:00 AM', respawnTime = '10/29/2000 7:30:00 AM', lastTravel = '10/29/2000 7:30:00 AM', lastAnimals = '10/29/2000 7:30:00 AM', lastVoteReward = '10/29/2000 7:30:00 AM', firstClaim = 'false', ismuted = 'false', isjailed = 'false', startingItems = 'false', clanname = 'Unknown', invitedtoclan = 'Unknown', isclanowner = 'false', isclanofficer = 'false', customCommand1 = '10/29/2000 7:30:00 AM', customCommand2 = '10/29/2000 7:30:00 AM', customCommand3 = '10/29/2000 7:30:00 AM', customCommand4 = '10/29/2000 7:30:00 AM', customCommand5 = '10/29/2000 7:30:00 AM', customCommand6 = '10/29/2000 7:30:00 AM', customCommand7 = '10/29/2000 7:30:00 AM', customCommand8 = '10/29/2000 7:30:00 AM', customCommand9 = '10/29/2000 7:30:00 AM', customCommand10 = '10/29/2000 7:30:00 AM' WHERE steamid = '{0}'", _steamid); SQL.FastQuery(_sql, "ResetPlayerConsole"); _sql = string.Format("SELECT * FROM Auction WHERE steamid = '{0}'", _steamid); DataTable _result1 = SQL.TQuery(_sql); if (_result1.Rows.Count != 0) { _sql = string.Format("DELETE FROM Auction WHERE steamid = '{0}'", _steamid); SQL.FastQuery(_sql, "ResetPlayerConsole"); } _result1.Dispose(); } _result.Dispose(); string _phrase401; if (!Phrases.Dict.TryGetValue(401, out _phrase401)) { _phrase401 = "You have reset the profile for Player {SteamId}."; } _phrase401 = _phrase401.Replace("{SteamId}", _params[0]); SdtdConsole.Instance.Output(string.Format("{0}", _phrase401)); } else { SdtdConsole.Instance.Output(string.Format("Player id {0} is not a valid integer", _params[0])); return; } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ResetPlayerConsole.Run: {0}.", e)); } }
private static void PutPlayerInJail(ClientInfo _cInfo, ClientInfo _PlayertoJail) { string[] _cords = { }; if (Jail_Position.Contains(",")) { if (Jail_Position.Contains(" ")) { Jail_Position.Replace(" ", ""); } _cords = Jail_Position.Split(','); } else { _cords = Jail_Position.Split(' '); } int x, y, z; int.TryParse(_cords[0], out x); int.TryParse(_cords[1], out y); int.TryParse(_cords[2], out z); _PlayertoJail.SendPackage(new NetPackageTeleportPlayer(new Vector3(x, y, z), null, false)); Jailed.Add(_PlayertoJail.playerId); string _name = SQL.EscapeString(_PlayertoJail.playerName); if (_name.Contains("!") || _name.Contains("@") || _name.Contains("#") || _name.Contains("$") || _name.Contains("%") || _name.Contains("^") || _name.Contains("&") || _name.Contains("*") || _name.Contains("'") || _name.Contains(";")) { _name = _name.Replace("!", ""); _name = _name.Replace("@", ""); _name = _name.Replace("#", ""); _name = _name.Replace("$", ""); _name = _name.Replace("%", ""); _name = _name.Replace("^", ""); _name = _name.Replace("&", ""); _name = _name.Replace("*", ""); _name = _name.Replace("'", ""); _name = _name.Replace(";", ""); } string _sql = string.Format("UPDATE Players SET jailTime = 60, jailName = '{0}', jailDate = '{1}' WHERE steamid = '{2}'", _name, DateTime.Now, _PlayertoJail.playerId); SQL.FastQuery(_sql, "Jail"); string _phrase500; if (!Phrases.Dict.TryGetValue(500, out _phrase500)) { _phrase500 = " you have been sent to jail."; } ChatHook.ChatMessage(_PlayertoJail, LoadConfig.Chat_Response_Color + _PlayertoJail.playerName + LoadConfig.Chat_Response_Color + _phrase500 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); if (Jail_Shock) { string _phrase507; if (!Phrases.Dict.TryGetValue(507, out _phrase507)) { _phrase507 = " the jail is electrified. Do not try to leave it."; } ChatHook.ChatMessage(_PlayertoJail, LoadConfig.Chat_Response_Color + _PlayertoJail.playerName + LoadConfig.Chat_Response_Color + _phrase507 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } string _phrase505; if (!Phrases.Dict.TryGetValue(505, out _phrase505)) { _phrase505 = " you have put {PlayerName} in jail."; } _phrase505 = _phrase505.Replace("{PlayerName}", _PlayertoJail.playerName); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase505 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); }