public static void Exec() { try { if (!BloodmoonStarted) { if (PersistentOperations.BloodMoonSky()) { BloodmoonStarted = true; List <ClientInfo> _cInfoList = PersistentOperations.ClientList(); if (_cInfoList != null) { for (int i = 0; i < _cInfoList.Count; i++) { ClientInfo _cInfo = _cInfoList[i]; if (_cInfo != null) { if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.playerId); if (_player != null && _player.IsSpawned() && _player.IsAlive() && _player.Died > 0 && _player.Progression.GetLevel() >= 10 && random.Next(0, 100) < Chance) { WarriorList.Add(_cInfo.playerId); KilledZombies.Add(_cInfo.playerId, 0); Phrases.Dict.TryGetValue(691, out string _phrase691); _phrase691 = _phrase691.Replace("{Count}", Zombie_Kills.ToString()); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase691 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } } } } } else if (!PersistentOperations.BloodMoonSky()) { BloodmoonStarted = false; RewardWarriors(); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in BloodmoonWarrior.Exec: {0}", e.Message)); } }
public static void SendAdmins(ClientInfo _sender, string _message) { List <ClientInfo> clientList = PersistentOperations.ClientList(); if (clientList != null) { for (int i = 0; i < clientList.Count; i++) { ClientInfo cInfo = clientList[i]; if (cInfo != null && (GameManager.Instance.adminTools.GetUserPermissionLevel(cInfo.PlatformId) <= ChatHook.Mod_Level || GameManager.Instance.adminTools.GetUserPermissionLevel(cInfo.CrossplatformId) <= ChatHook.Mod_Level) && _sender.CrossplatformId.CombinedString != cInfo.CrossplatformId.CombinedString) { ChatHook.ChatMessage(cInfo, Config.Chat_Response_Color + _message + "[-]", _sender.entityId, _sender.playerName, EChatType.Whisper, null); } } } }
public static void KickPlayer(ClientInfo _cInfo) { try { SingletonMonoBehaviour <SdtdConsole> .Instance.ExecuteSync(string.Format("kick {0} \"Auto kicked at end of hardcore session\"", _cInfo.CrossplatformId.CombinedString), null); EntityPlayer entityPlayer = (EntityPlayer)GameManager.Instance.World.GetEntity(_cInfo.entityId); PersistentOperations.SavePersistentPlayerDataXML(); PersistentOperations.RemoveAllClaims(_cInfo.CrossplatformId.CombinedString); PersistentOperations.RemovePersistentPlayerData(_cInfo.CrossplatformId.CombinedString); PersistentOperations.RemoveAllACL(_cInfo.CrossplatformId.CombinedString); Hardcore.ResetHardcoreProfile(_cInfo); } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Hardcore.KickPlayer: {0}", e.Message)); } }
public static void FriendInvite(ClientInfo _cInfo, Vector3 _position, string _destination) { try { int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; List <ClientInfo> _cInfoList = PersistentOperations.ClientList(); for (int i = 0; i < _cInfoList.Count; i++) { ClientInfo _cInfo2 = _cInfoList[i]; EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId]; if (_player2 != null) { if (_player.IsFriendsWith(_player2)) { if ((x - (int)_player2.position.x) * (x - (int)_player2.position.x) + (z - (int)_player2.position.z) * (z - (int)_player2.position.z) <= 10 * 10) { Phrases.Dict.TryGetValue(744, out string _phrase744); _phrase744 = _phrase744.Replace("{PlayerName}", _cInfo.playerName); _phrase744 = _phrase744.Replace("{CommandPrivate}", ChatHook.Command_Private); _phrase744 = _phrase744.Replace("{Command5}", Command5); ChatHook.ChatMessage(_cInfo2, Config.Chat_Response_Color + _phrase744 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); Phrases.Dict.TryGetValue(745, out string _phrase745); _phrase745 = _phrase745.Replace("{PlayerName}", _cInfo2.playerName); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase745 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); if (Invite.ContainsKey(_cInfo2.entityId)) { Invite.Remove(_cInfo2.entityId); FriendPosition.Remove(_cInfo2.entityId); } Invite.Add(_cInfo2.entityId, DateTime.Now); FriendPosition.Add(_cInfo2.entityId, _destination); } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Homes.FriendInvite: {0}", e.Message)); } }
public static void BedBug(string _persistentPlayerId) { try { EntityPlayer _player = PersistentOperations.GetEntityPlayer(_persistentPlayerId); if (_player != null) { EntityBedrollPositionList _bedrollList = _player.SpawnPoints; if (_bedrollList != null) { Vector3i _bedrollPosition = _bedrollList.GetPos(); List <EntityPlayer> _playerList = PersistentOperations.PlayerList(); if (_bedrollPosition != null && _playerList != null) { for (int i = 0; i < _playerList.Count; i++) { EntityPlayer _player2 = _playerList[i]; if (_player2 != null && _player2 != _player && _player2.SpawnPoints != null && _player2.SpawnPoints.GetPos().Equals(_bedrollPosition)) { PersistentPlayerData _ppd = PersistentOperations.GetPersistentPlayerDataFromSteamId(_persistentPlayerId); if (_ppd != null && !_player2.SpawnPoints.GetPos().Equals(_ppd.BedrollPos)) { _player2.SpawnPoints.Set(_ppd.BedrollPos); continue; } _player2.SpawnPoints.Clear(); GameManager.Instance.World.ObjectOnMapRemove(EnumMapObjectType.SleepingBag, _player2.entityId); ConnectionManager.Instance.SendPackage(NetPackageManager.GetPackage <NetPackageEntityMapMarkerRemove>().Setup(EnumMapObjectType.SleepingBag, _player2.entityId), false, -1, -1, -1, -1); ClientInfo _cInfo2 = PersistentOperations.GetClientInfoFromEntityId(_player2.entityId); if (_cInfo2 != null) { ChatHook.ChatMessage(_cInfo2, LoadConfig.Chat_Response_Color + "Detected bug with your bed. Check your bed and replace if needed[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in PersistentOperations.BedBug: {0}", e.Message)); } }
private static bool PlayerLogin(ClientInfo _cInfo, string _message, StringBuilder _stringBuild)//Initiating player login { try { if (_cInfo != null && _cInfo.CrossplatformId != null) { if (Shutdown.NoEntry) { Phrases.Dict.TryGetValue("Shutdown4", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); SingletonMonoBehaviour <SdtdConsole> .Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.CrossplatformId.CombinedString, phrase), null); } if (NewPlayer.Block_During_Bloodmoon && PersistentOperations.IsBloodmoon() && ConnectionManager.Instance.ClientCount() > 1) { Phrases.Dict.TryGetValue("NewPlayer1", out string phrase); PlayerDataFile pdf = PersistentOperations.GetPlayerDataFileFromUId(_cInfo.CrossplatformId); if (pdf != null) { if (pdf.totalTimePlayed < 5) { SingletonMonoBehaviour <SdtdConsole> .Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.CrossplatformId.CombinedString, phrase), null); } } else { SingletonMonoBehaviour <SdtdConsole> .Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.CrossplatformId.CombinedString, phrase), null); } } if (!string.IsNullOrEmpty(_cInfo.ip)) { Log.Out(string.Format("[SERVERTOOLS] Player connected with ID '{0}' '{1}' and IP '{2}' named '{3}'", _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.ip, _cInfo.playerName)); } else { Log.Out(string.Format("[SERVERTOOLS] Player connected with ID '{0}' '{1}' named '{2}'", _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName)); } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerLogin: {0}", e.Message)); } return(true); }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_params.Count != 1) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 1, found '{0}'", _params.Count)); return; } ClientInfo cInfo = PersistentOperations.GetClientInfoFromNameOrId(_params[0]); if (cInfo != null) { EntityPlayer player = PersistentOperations.GetEntityPlayer(cInfo.entityId); if (player != null) { if (GameEventManager.GameEventSequences.ContainsKey("action_dukes")) { GameEventManager.Current.HandleAction("action_dukes", null, player, false, ""); cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageGameEventResponse>().Setup("action_dukes", cInfo.playerName, "", "", NetPackageGameEventResponse.ResponseTypes.Approved)); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Removed all items tagged dukes from inventory and backpack of player id '{0}' '{1}' named '{2}'", cInfo.PlatformId.CombinedString, cInfo.CrossplatformId.CombinedString, cInfo.playerName)); return; } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Unable to locate action_dukes in the game events list")); return; } } } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Unable to locate player '{0}' online", _params[0])); return; } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in RemoveItemDukesConsole.Execute: {0}", e.Message)); } }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { SdtdConsole.Instance.Output("Minibike List:"); List <Entity> Entities = GameManager.Instance.World.Entities.list; for (int i = 0; i < Entities.Count; i++) { Entity _entity = Entities[i]; string _name = EntityClass.list[_entity.entityClass].entityClassName; if (_name == "minibike") { Vector3 _pos = _entity.position; int x = (int)_pos.x; int y = (int)_pos.y; int z = (int)_pos.z; Entity _attachedPlayer = _entity.AttachedMainEntity; if (_attachedPlayer != null) { List <ClientInfo> _cInfoList = PersistentOperations.ClientList(); for (int j = 0; j < _cInfoList.Count; j++) { ClientInfo _cInfo = _cInfoList[j]; if (_cInfo != null) { if (_attachedPlayer.entityId == _cInfo.entityId) { SdtdConsole.Instance.Output(string.Format("#{0}: Id {1}, Located at x {2} y {3} z {4}, Player {5} is riding this bike.", i, _entity.entityId, x, y, z, _cInfo.playerName)); } } } } else { SdtdConsole.Instance.Output(string.Format("#{0}: Id {1}, Located at x {2} y {3} z {4}", i, _entity.entityId, x, y, z)); } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in BikeListConsole.Execute: {0}", e)); } }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_params.Count < 1 || _params.Count > 2) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 1 or 2, found '{0}'", _params.Count)); return; } if (!int.TryParse(_params[1], out int _time)) { _time = 15; } ClientInfo cInfo = PersistentOperations.GetClientInfoFromNameOrId(_params[0]); if (cInfo != null) { if (GameManager.Instance.adminTools.GetUserPermissionLevel(cInfo.PlatformId) > Admin_Level && GameManager.Instance.adminTools.GetUserPermissionLevel(cInfo.CrossplatformId) > Admin_Level) { if (_time > 60) { SingletonMonoBehaviour <SdtdConsole> .Instance.ExecuteSync(string.Format("ban add {0} {1} minutes \"You have been temporarily banned for {2} minutes\"", cInfo.CrossplatformId.CombinedString, _time, _time), cInfo); } else { SingletonMonoBehaviour <SdtdConsole> .Instance.ExecuteSync(string.Format("ban add {0} {1} minutes \"You have been temporarily banned for {2} minutes\"", cInfo.CrossplatformId.CombinedString, _params[1], _params[1]), cInfo); } } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Can not ban Id '{0}'. The Id belongs to an Admin", _params[1])); } } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] No Id '{0}' found online", _params[0])); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in TempBanConsole.Run: {0}", e.Message)); } }
public static void CheckLocation(ClientInfo _cInfo, string _amount, int _exec) { try { if (Inside_Claim) { if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { Vector3 _position = _player.GetPosition(); Vector3i _vec3i = new Vector3i((int)_position.x, (int)_position.y, (int)_position.z); if (!PersistentOperations.ClaimedByAllyOrSelf(_cInfo.playerId, _vec3i)) { Phrases.Dict.TryGetValue(642, out string _phrase642); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase642 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return; } } } } if (_exec == 1) { ChestToBankDeposit(_cInfo, _amount); } else if (_exec == 2) { BankToPlayerWithdraw(_cInfo, _amount); } else if (_exec == 3) { WalletToBankDeposit(_cInfo, _amount); } else if (_exec == 4) { BankToWalletWithdraw(_cInfo, _amount); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Bank.CheckLocation: {0}", e.Message)); } }
public static void PlayerExit(string _id) { try { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_id); if (_cInfo != null) { if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { if (ExitPos.TryGetValue(_cInfo.playerId, out Vector3 _pos)) { ExitPos.Remove(_cInfo.playerId); if (_player.position != _pos) { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "You moved and need to restart your countdown." + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); return; } } } } PlayerDataFile _playerDataFile = PersistentOperations.GetPlayerDataFileFromSteamId(_cInfo.playerId); if (_playerDataFile != null) { PersistentOperations.SavePlayerDataFile(_cInfo.playerId, _playerDataFile); } if (Exit.Contains(_cInfo.playerId)) { Exit.Remove(_cInfo.playerId); } if (ExitPos.ContainsKey(_cInfo.playerId)) { ExitPos.Remove(_cInfo.playerId); } Disconnect(_cInfo); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in BattleLogger.PlayerExit: {0}", e.Message)); } }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_params.Count != 2) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 2, found '{0}'", _params.Count)); return; } ClientInfo cInfo = ConsoleHelper.ParseParamIdOrName(_params[0]); if (cInfo != null) { EntityPlayer player = PersistentOperations.GetEntityPlayer(cInfo.entityId); if (player != null) { if (GameEventManager.GameEventSequences.ContainsKey(_params[1])) { GameEventManager.Current.HandleAction(_params[1], null, player, false, ""); cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageGameEventResponse>().Setup(_params[1], cInfo.playerName, "", "", NetPackageGameEventResponse.ResponseTypes.Approved)); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Ran game event named '{0}' on player '{1}'", _params[1], cInfo.CrossplatformId.CombinedString)); return; } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Unable to locate '{0}' in the game events list", _params[1])); return; } } } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Unable to locate player '{0}' online", _params[0])); return; } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in RunGameEventConsole.Execute: {0}", e.Message)); } }
public static void Exec(ClientInfo _cInfo, EntityPlayer _player) { if (GameManager.Instance.World.Players.dict.Count > 1) { foreach (KeyValuePair <int, EntityPlayer> player in GameManager.Instance.World.Players.dict) { if (_player.entityId != player.Value.entityId) { if (_player.partyInvites != null && _player.partyInvites.Contains(player.Value)) { return; } PersistentPlayerData ppd2 = PersistentOperations.GetPersistentPlayerDataFromEntityId(player.Key); if (ppd2 != null) { if (PersistentContainer.Instance.Players[ppd2.UserIdentifier.CombinedString].AutoPartyInvite != null && PersistentContainer.Instance.Players[ppd2.UserIdentifier.CombinedString].AutoPartyInvite.Count > 0) { List <string[]> autoInvites = PersistentContainer.Instance.Players[ppd2.UserIdentifier.CombinedString].AutoPartyInvite; for (int i = 0; i < autoInvites.Count; i++) { if (autoInvites[i][0] == _cInfo.entityId.ToString()) { PersistentPlayerData ppd1 = PersistentOperations.GetPersistentPlayerDataFromEntityId(_player.entityId); if (ppd1 != null && ppd1.ACL.Contains(ppd2.UserIdentifier) && ppd2.ACL.Contains(ppd1.UserIdentifier)) { EntityPlayer player2 = player.Value; if ((player2.IsInParty() && player2.IsPartyLead() == player2 && player2.Party != null && player2.Party.MemberList.Count < Constants.cMaxPartySize) || !player2.IsInParty()) { _player.AddPartyInvite(player.Key); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackagePartyActions>().Setup(NetPackagePartyActions.PartyActions.SendInvite, player.Key, _player.entityId, null)); Phrases.Dict.TryGetValue("AutoPartyInvite7", out string phrase); phrase = phrase.Replace("{PlayerName}", player2.EntityName); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } } } } } } } }
public static void RewardWarriors() { try { List <string> _warriors = WarriorList; for (int i = 0; i < _warriors.Count; i++) { string _warrior = _warriors[i]; EntityPlayer _player = PersistentOperations.GetEntityPlayer(_warrior); if (_player != null && _player.IsAlive()) { if (KilledZombies.TryGetValue(_warrior, out int _killedZ)) { if (_killedZ >= Zombie_Kills) { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_warrior); if (_cInfo != null) { RandomItem(_cInfo); if (Reduce_Death_Count) { int _deathCount = _player.Died - 1; _player.Died = _deathCount; _player.bPlayerStatsChanged = true; _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackagePlayerStats>().Setup(_player)); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "You have survived and been rewarded by hades himself. Your death count was reduced by one" + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "You have survived and been rewarded by hades himself." + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in BloodmoonWarrior.RewardWarriors: {0}", e.Message)); } WarriorList.Clear(); KilledZombies.Clear(); }
public static void Clear() { for (int i = 0; i < Jailed.Count; i++) { string id = Jailed[i]; if (Jailed.Contains(id)) { int jailTime = PersistentContainer.Instance.Players[id].JailTime; DateTime jailDate = PersistentContainer.Instance.Players[id].JailDate; if (jailTime > 0) { TimeSpan varTime = DateTime.Now - jailDate; double fractionalMinutes = varTime.TotalMinutes; int timepassed = (int)fractionalMinutes; if (timepassed >= jailTime) { ClientInfo cInfo = PersistentOperations.GetClientInfoFromNameOrId(id); if (cInfo != null) { EntityPlayer player = GameManager.Instance.World.Players.dict[cInfo.entityId]; if (player.IsSpawned()) { Jailed.Remove(id); PersistentContainer.Instance.Players[cInfo.CrossplatformId.CombinedString].JailTime = 0; PersistentContainer.DataChange = true; Vector3[] _pos = GameManager.Instance.World.GetRandomSpawnPointPositions(1); cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_pos[0].x, _pos[0].y + 1, _pos[0].z), null, false)); Phrases.Dict.TryGetValue("Jail2", out string phrase); ChatHook.ChatMessage(cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { Jailed.Remove(id); PersistentContainer.Instance.Players[cInfo.CrossplatformId.CombinedString].JailTime = 0; PersistentContainer.Instance.Players[cInfo.CrossplatformId.CombinedString].JailRelease = true; PersistentContainer.DataChange = true; } } } } } }
public static void PrepareShutdown() { if (PersistentOperations.IsBloodmoon() && !Interrupt_Bloodmoon) { EventSchedule.Add("Shutdown", DateTime.Now.AddMinutes(10)); if (Event.Open && !Event.OperatorWarned) { ClientInfo cInfo = PersistentOperations.GetClientInfoFromNameOrId(Event.Operator); if (cInfo != null) { Event.OperatorWarned = true; ChatHook.ChatMessage(cInfo, Config.Chat_Response_Color + "A scheduled shutdown is set to begin but is on hold until the bloodmoon ends" + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } return; } EventSchedule.Remove("Shutdown"); StartShutdown(Countdown); }
public static void Add(int xMin, int zMin, int xMax, int zMax) { List <Chunk> _chunkList = new List <Chunk>(); for (int i = xMin; i <= xMax; i++) { for (int j = 1; i <= 200; j++) { for (int k = zMin; k <= zMax; k++) { if (GameManager.Instance.World.IsChunkAreaLoaded(i, j, k)) { Chunk _chunk = (Chunk)GameManager.Instance.World.GetChunkFromWorldPos(i, j, k); if (!_chunkList.Contains(_chunk)) { _chunkList.Add(_chunk); } Bounds bounds = _chunk.GetAABB(); _chunk.SetTraderArea(i - ((int)bounds.min.x), k - ((int)bounds.min.z), true); } else { SdtdConsole.Instance.Output(string.Format("{0}x,{1}z has not been loaded. Protection was skipped for this area", i, k)); continue; } } } } for (int i = 0; i <= _chunkList.Count; i++) { Chunk _chunk = _chunkList[i]; List <ClientInfo> _clientList = PersistentOperations.ClientsWithin200Blocks(_chunk.GetWorldPos().x, _chunk.GetWorldPos().z); if (_clientList != null) { for (int j = 0; j < _clientList.Count; j++) { ClientInfo _cInfo = _clientList[j]; //_cInfo.SendPackage(NetPackageManager.GetPackage<NetPackageChunkRemove>().Setup(_chunk.Key)); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageChunk>().Setup(_chunk, true)); } } } }
public static void SendAdmins(ClientInfo _sender, string _message) { if (GameManager.Instance.adminTools.CommandAllowedFor(new string[] { _message }, _sender.playerId) || GameManager.Instance.adminTools.GetAdminToolsClientInfo(_sender.playerId).PermissionLevel <= ChatHook.Mod_Level) { List <ClientInfo> _cInfoList = PersistentOperations.ClientList(); for (int i = 0; i < _cInfoList.Count; i++) { ClientInfo _cInfo = _cInfoList[i]; if (_cInfo != null) { if (GameManager.Instance.adminTools.GetAdminToolsClientInfo(_cInfo.playerId).PermissionLevel <= ChatHook.Mod_Level) { _message = _message.Replace("@" + Command118 + " ", ""); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", _sender.entityId, _sender.playerName, EChatType.Whisper, null); } } } } }
public static void Detected(ClientInfo _cInfo, EntityPlayer _player) { if (Flags.ContainsKey(_cInfo.entityId)) { Flags.TryGetValue(_cInfo.entityId, out int flags); flags++; if (flags == Flag_Limit) { List <EntityPlayer> playerList = PersistentOperations.PlayerList(); for (int j = 0; j < playerList.Count; j++) { if (playerList[j].entityId != _player.entityId && (int)playerList[j].position.x == (int)_player.position.x && (int)playerList[j].position.z == (int)_player.position.z) { Flags.Remove(_cInfo.entityId); return; } } Flags.Remove(_cInfo.entityId); Phrases.Dict.TryGetValue("Flying2", out string phrase); SingletonMonoBehaviour <SdtdConsole> .Instance.ExecuteSync(string.Format("ban add {0} 5 years \"{1}\"", _cInfo.CrossplatformId.CombinedString, phrase), null); using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8)) { sw.WriteLine(string.Format("Detected Id '{0}' '{1}' named '{2}' flying @ '{3}'", _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName, _player.position)); sw.WriteLine(); sw.Flush(); sw.Close(); } Log.Warning("[SERVERTOOLS] Detected Id '{0}' '{1}' named '{2}' flying @ '{3}'. They have been banned", _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName, _player.position); Phrases.Dict.TryGetValue("Flying1", out phrase); phrase = phrase.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } else { Flags[_cInfo.entityId] = flags; } } else { Flags.Add(_cInfo.entityId, 1); } }
public static bool Bloodmoon() { try { if (PersistentOperations.BloodMoonSky() || PersistentOperations.BloodMoonDuskSky()) { return(true); } else { return(false); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Shutdown.Bloodmoon: {0}", e.Message)); } return(false); }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_params.Count != 2) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 2, found '{0}'", _params.Count)); return; } if (!int.TryParse(_params[1], out int value)) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Invalid value '{0}'", _params[1])); return; } ClientInfo cInfo = PersistentOperations.GetClientInfoFromNameOrId(_params[0]); if (cInfo != null) { EntityPlayer player = PersistentOperations.GetEntityPlayer(cInfo.entityId); if (player != null) { player.KilledPlayers = value; player.bPlayerStatsChanged = true; cInfo.SendPackage(NetPackageManager.GetPackage <NetPackagePlayerStats>().Setup(player)); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Player kills for Id '{0}' '{1}' named '{2}' has been set to '{3}'", cInfo.PlatformId.CombinedString, cInfo.CrossplatformId.CombinedString, cInfo.playerName, value)); return; } } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Player '{0}' not found", _params[0])); return; } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in SetPlayerKillsConsole.Execute: {0}", e.Message)); } }
public static void Exec() { try { if (!BloodmoonStarted) { if (PersistentOperations.BloodMoonSky()) { BloodmoonStarted = true; List <ClientInfo> _cInfoList = PersistentOperations.ClientList(); if (_cInfoList != null) { for (int i = 0; i < _cInfoList.Count; i++) { ClientInfo _cInfo = _cInfoList[i]; if (_cInfo != null && !string.IsNullOrEmpty(_cInfo.playerId) && _cInfo.entityId > 0) { EntityAlive _player = (EntityAlive)PersistentOperations.GetEntity(_cInfo.entityId); if (_player != null && _player.IsSpawned() && _player.IsAlive() && _player.Died > 0 && _player.Progression.GetLevel() >= 10 && random.Next(0, 11) < 6) { WarriorList.Add(_cInfo.entityId); KilledZombies.Add(_cInfo.entityId, 0); string _response = "Hades has called upon you. Survive this night and kill {ZombieCount} zombies to be rewarded by the king of the underworld."; _response = _response.Replace("{ZombieCount}", Zombie_Kills.ToString()); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _response + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } } } } else if (!PersistentOperations.BloodMoonSky()) { BloodmoonStarted = false; RewardWarriors(); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in BloodmoonWarrior.Exec: {0}.", e.Message)); } }
public static bool BattleLog(ClientInfo _cInfo) { try { EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.playerId); if (_player != null) { List <EntityPlayer> _players = PersistentOperations.PlayerList(); if (_players != null) { for (int i = 0; i < _players.Count; i++) { EntityPlayer _player2 = _players[i]; if (_player2 != null && _player2 != _player) { EntityPlayer _damageTarget = (EntityPlayer)_player.GetDamagedTarget(); EntityPlayer _attackTarget = (EntityPlayer)_player.GetAttackTarget(); EntityPlayer _damageTarget2 = (EntityPlayer)_player2.GetDamagedTarget(); EntityPlayer _attackTarget2 = (EntityPlayer)_player2.GetAttackTarget(); if ((_damageTarget != null && _damageTarget == _player2 && !_damageTarget.IsFriendsWith(_player2)) || (_attackTarget != null && _attackTarget == _player2 && !_attackTarget.IsFriendsWith(_player2)) || (_damageTarget2 != null && _damageTarget2 == _player && !_damageTarget2.IsFriendsWith(_player)) || (_attackTarget2 != null && _attackTarget2 == _player && !_damageTarget2.IsFriendsWith(_player))) { float _distance = _player2.GetDistanceSq(_player); if (_distance <= 80f) { Timers.BattleLogTool(_cInfo.playerId); } } } } } } BattleLogger.Players.Remove(_cInfo.playerId); } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.BattleLog: {0}.", e.Message)); } return(true); }
public static void Exec() { try { if (!BloodmoonStarted) { if (PersistentOperations.IsBloodmoon()) { BloodmoonStarted = true; List <ClientInfo> clientList = PersistentOperations.ClientList(); if (clientList != null) { for (int i = 0; i < clientList.Count; i++) { ClientInfo cInfo = clientList[i]; if (cInfo != null) { EntityPlayer player = PersistentOperations.GetEntityPlayer(cInfo.entityId); if (player != null && player.IsSpawned() && player.IsAlive() && player.Died > 0 && player.Progression.GetLevel() >= 10 && Random.Next(0, 100) < Chance) { WarriorList.Add(cInfo.entityId); KilledZombies.Add(cInfo.entityId, 0); Phrases.Dict.TryGetValue("BloodmoonWarrior1", out string phrase); phrase = phrase.Replace("{Count}", Zombie_Kills.ToString()); ChatHook.ChatMessage(cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } } } } else if (!PersistentOperations.IsBloodmoon()) { BloodmoonStarted = false; RewardWarriors(); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in BloodmoonWarrior.Exec: {0}", e.Message)); } }
public static void ConsoleBountyList() { List <ClientInfo> clientList = PersistentOperations.ClientList(); if (clientList != null) { for (int i = 0; i < clientList.Count; i++) { ClientInfo cInfo = clientList[i]; if (cInfo != null) { int currentbounty = PersistentContainer.Instance.Players[cInfo.CrossplatformId.CombinedString].Bounty; if (currentbounty > 0) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("Entity Id: '{0}' named '{1}'. Bounty total '{2}'", cInfo.entityId, cInfo.playerName, currentbounty)); } } } } }
public static void List(ClientInfo _cInfo) { Admins.Clear(); Mods.Clear(); List <ClientInfo> ClientInfoList = PersistentOperations.ClientList(); for (int i = 0; i < ClientInfoList.Count; i++) { ClientInfo _cInfoAdmins = ClientInfoList[i]; if (GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) <= Admin_Level) { Admins.Add(_cInfoAdmins.playerName); } if (GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) > Admin_Level && GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) <= Mod_Level) { Mods.Add(_cInfoAdmins.playerName); } } Response(_cInfo); }
private static bool PlayerLogin(ClientInfo _cInfo, string _message, StringBuilder _stringBuild)//Initiating player login { try { Log.Out("[SERVERTOOLS] Player connected"); if (StopServer.NoEntry) { SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Server is shutting down. Rejoin when it restarts\"", _cInfo.playerId), null); } if (NewPlayer.Block_During_Bloodmoon && PersistentOperations.BloodMoonSky()) { SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Currently in bloodmoon. Please join when it finishes\"", _cInfo.playerId), null); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerLogin: {0}", e.Message)); } return(true); }
public static void Vote(ClientInfo _cInfo, string _player) { if (!VoteOpen) { if (ConnectionManager.Instance.ClientCount() >= Players_Online) { if (int.TryParse(_player, out int entityId)) { ClientInfo cInfo2 = PersistentOperations.GetClientInfoFromEntityId(entityId); if (cInfo2 != null) { if (Mute.Mutes.Contains(cInfo2.CrossplatformId.CombinedString)) { Phrases.Dict.TryGetValue("MuteVote5", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return; } playerMute = cInfo2; VoteOpen = true; Phrases.Dict.TryGetValue("MuteVote1", out string phrase1); phrase1 = phrase1.Replace("{PlayerName}", cInfo2.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + phrase1 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); Phrases.Dict.TryGetValue("MuteVote2", out phrase1); phrase1 = phrase1.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1); phrase1 = phrase1.Replace("{Command_yes}", RestartVote.Command_yes); ChatHook.ChatMessage(null, Config.Chat_Response_Color + phrase1 + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } else { Phrases.Dict.TryGetValue("MuteVote6", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } else { Phrases.Dict.TryGetValue("MuteVote7", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } }
public static void Exec(ClientInfo _cInfo, string _message) { _message = _message.Replace(Command82 + " ", ""); if (_message.Length > Length) { Phrases.Dict.TryGetValue(524, out string _phrase524); _phrase524 = _phrase524.Replace("{Length}", Length.ToString()); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase524 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return; } Vector3 _pos = GameManager.Instance.World.Players.dict[_cInfo.entityId].position; List <ClientInfo> ClientInfoList = PersistentOperations.ClientList(); if (ClientInfoList != null && ClientInfoList.Count > 0) { for (int i = 0; i < ClientInfoList.Count; i++) { ClientInfo _cInfoAdmins = ClientInfoList[i]; if (GameManager.Instance.adminTools.GetUserPermissionLevel(_cInfo) <= Admin_Level) { Phrases.Dict.TryGetValue(522, out string _phrase522); _phrase522 = _phrase522.Replace("{Position}", _pos.ToString()); _phrase522 = _phrase522.Replace("{PlayerName}", _cInfo.playerName); _phrase522 = _phrase522.Replace("{Message}", _message); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase522 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } using (StreamWriter sw = new StreamWriter(_filepath, false, Encoding.UTF8)) { sw.WriteLine(string.Format("{0}: Location: {1} {2} {3}. Player {4} {5} reports: {6}.", DateTime.Now, (int)_pos.x, (int)_pos.y, (int)_pos.z, _cInfo.playerName, _cInfo.playerId, _message)); sw.WriteLine(); sw.Flush(); sw.Close(); } PersistentContainer.Instance.Players[_cInfo.playerId].LastLog = DateTime.Now; PersistentContainer.DataChange = true; Phrases.Dict.TryGetValue(525, out string _phrase525); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase525 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); Log.Out(string.Format("[SERVERTOOLS] Report sent by player {0} {1} and saved to the report logs", _cInfo.playerName, _cInfo.playerId)); }
private static bool PlayerLogin(ClientInfo _cInfo, string _message, StringBuilder _stringBuild)//Initiating player login { try { if (_cInfo != null && !string.IsNullOrEmpty(_cInfo.playerId)) { if (!string.IsNullOrEmpty(_cInfo.ip)) { Log.Out(string.Format("[SERVERTOOLS] Player {0} connected from IP: {1}", _cInfo.playerId, _cInfo.ip)); } else { Log.Out(string.Format("[SERVERTOOLS] Player {0} connected", _cInfo.playerId)); } if (StopServer.NoEntry) { SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Server is shutting down. Rejoin when it restarts\"", _cInfo.playerId), null); } if (NewPlayer.Block_During_Bloodmoon && PersistentOperations.BloodMoonSky()) { PlayerDataFile _pdf = PersistentOperations.GetPlayerDataFileFromSteamId(_cInfo.playerId); if (_pdf != null) { if (_pdf.totalTimePlayed < 5) { SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Currently in bloodmoon. Please join when it finishes\"", _cInfo.playerId), null); } } else { SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Currently in bloodmoon. Please join when it finishes\"", _cInfo.playerId), null); } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerLogin: {0}", e.Message)); } return(true); }