public static void RemoveAllACL(string _playerId) { PersistentPlayerData _persistentPlayerData = GetPersistentPlayerData(_playerId); if (_persistentPlayerData != null) { PersistentPlayerList _persistentPlayerList = PersistentOperations.GetPersistentPlayerList(); foreach (KeyValuePair <string, PersistentPlayerData> _persistentPlayerData2 in _persistentPlayerList.Players) { if (_persistentPlayerData2.Key != _persistentPlayerData.PlayerId) { if (_persistentPlayerData2.Value.ACL != null && _persistentPlayerData2.Value.ACL.Contains(_persistentPlayerData.PlayerId)) { _persistentPlayerData2.Value.RemovePlayerFromACL(_persistentPlayerData.PlayerId); _persistentPlayerData2.Value.Dispatch(_persistentPlayerData, EnumPersistentPlayerDataReason.ACL_Removed); } if (_persistentPlayerData.ACL != null && _persistentPlayerData.ACL.Contains(_persistentPlayerData2.Value.PlayerId)) { _persistentPlayerData.RemovePlayerFromACL(_persistentPlayerData2.Key); _persistentPlayerData.Dispatch(_persistentPlayerData2.Value, EnumPersistentPlayerDataReason.ACL_Removed); } } } SavePersistentPlayerDataXML(); } }
public static void CheckLP(ClientInfo _cInfo) { EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId); if (player != null) { Vector3 position = player.GetPosition(); int x = (int)position.x; int y = (int)position.y; int z = (int)position.z; Vector3i vector = new Vector3i(x, y, z); PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList(); PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(player.entityId); EnumLandClaimOwner _owner = GameManager.Instance.World.GetLandClaimOwner(vector, _persistentPlayerData); if (_owner == EnumLandClaimOwner.Self || _owner == EnumLandClaimOwner.Ally || _owner == EnumLandClaimOwner.None) { if (CheckStuck(position.x, position.y, position.z)) { TeleToSurface(_cInfo, player); } else { Phrases.Dict.TryGetValue("Stuck4", out string _phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue("Stuck2", out string _phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } }
public static void CheckLP(ClientInfo _cInfo) { World world = GameManager.Instance.World; EntityPlayer _player = world.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; Vector3i _vec3i = new Vector3i(x, y, z); PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList(); PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_player.entityId); EnumLandClaimOwner _owner = world.GetLandClaimOwner(_vec3i, _persistentPlayerData); if (_owner == EnumLandClaimOwner.Self || _owner == EnumLandClaimOwner.Ally || _owner == EnumLandClaimOwner.None) { if (CheckStuck(_position.x, _position.y, _position.z)) { TeleToSurface(_cInfo, _player); } else { Phrases.Dict.TryGetValue(554, out string _phrase554); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase554 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue(552, out string _phrase552); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase552 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } }
public static PersistentPlayerData GetPPD(string playerName) { PersistentPlayerList playerList = GameManager.Instance.GetPersistentPlayerList(); PersistentPlayerData ppd = playerList.GetPlayerData(playerName); return(ppd); }
private static void FClaimCheck(ClientInfo _cInfo, string _waypoint) { World world = GameManager.Instance.World; EntityPlayer _player = world.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; Vector3i _vec3i = new Vector3i(x, y, z); PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList(); PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_player.entityId); EnumLandClaimOwner _owner = world.GetLandClaimOwner(_vec3i, _persistentPlayerData); if (_owner == EnumLandClaimOwner.None) { FCommandCost(_cInfo, _waypoint, _player); } else { string _phrase576; if (!Phrases.Dict.TryGetValue(576, out _phrase576)) { _phrase576 = " you can only use a waypoint that is outside of a claimed space."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase576 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
public static void SaveClaimCheck(ClientInfo _cInfo, string _waypoint) { if (!Event.PlayersTeam.ContainsKey(_cInfo.playerId)) { World world = GameManager.Instance.World; EntityPlayer _player = world.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; Vector3i _vec3i = new Vector3i(x, y, z); PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList(); PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_player.entityId); EnumLandClaimOwner _owner = world.GetLandClaimOwner(_vec3i, _persistentPlayerData); if (_owner == EnumLandClaimOwner.None) { SetPoint(_cInfo, _waypoint); } else { string _phrase586; if (!Phrases.Dict.TryGetValue(586, out _phrase586)) { _phrase586 = " you can only save a waypoint that is outside of a claimed space."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase586 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you can not use waypoint commands while signed up for or in an event.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
private void removeById(string _id) { try { PersistentPlayerList ppl = GameManager.Instance.GetPersistentPlayerList(); if (_id.Length < 1 || !ppl.Players.ContainsKey(_id)) { SdtdConsole.Instance.Output("Not a valid Steam ID or user has never logged on. Use \"listlandprotection\" to get a list of keystones."); return; } if (ppl.Players [_id].LPBlocks == null || ppl.Players [_id].LPBlocks.Count == 0) { SdtdConsole.Instance.Output("Player does not own any keystones. Use \"listlandprotection\" to get a list of keystones."); return; } List <BlockChangeInfo> changes = new List <BlockChangeInfo> (); foreach (Vector3i pos in ppl.Players[_id].LPBlocks) { BlockChangeInfo bci = new BlockChangeInfo(pos, 0, true); changes.Add(bci); } GameManager.Instance.SetBlocksRPC(changes); SdtdConsole.Instance.Output("Tried to remove #" + changes.Count + " land protection blocks for player \"" + _id + "\". Note " + "that only blocks in chunks that are currently loaded (close to any player) could be removed. " + "Please check for remaining blocks by running:"); SdtdConsole.Instance.Output(" listlandprotection " + _id); } catch (Exception e) { Log.Out("Error in RemoveLandProtection.removeById: " + e); } }
public static void RemoveAllClaims(string _playerId) { PersistentPlayerData _persistentPlayerData = PersistentOperations.GetPersistentPlayerData(_playerId); if (_persistentPlayerData != null) { List <Vector3i> landProtectionBlocks = _persistentPlayerData.LPBlocks; if (landProtectionBlocks != null) { PersistentPlayerList _persistentPlayerList = GetPersistentPlayerList(); for (int i = 0; i < landProtectionBlocks.Count; i++) { Vector3i _position = landProtectionBlocks[i]; World world = GameManager.Instance.World; BlockValue _blockValue = world.GetBlock(_position); Block _block = _blockValue.Block; if (_block != null && _block is BlockLandClaim) { world.SetBlockRPC(0, _position, BlockValue.Air); ConnectionManager.Instance.SendPackage(NetPackageManager.GetPackage <NetPackageEntityMapMarkerRemove>().Setup(EnumMapObjectType.LandClaim, _position.ToVector3()), false, -1, -1, -1, -1); world.ObjectOnMapRemove(EnumMapObjectType.LandClaim, _position.ToVector3()); LandClaimBoundsHelper.RemoveBoundsHelper(_position.ToVector3()); } GameManager.Instance.persistentPlayers.m_lpBlockMap.Remove(_position); _persistentPlayerData.LPBlocks.Remove(_position); } SavePersistentPlayerDataXML(); } } }
public static void RemoveAllACL(string _playerId) { PersistentPlayerData persistentPlayerData = GetPersistentPlayerDataFromId(_playerId); if (persistentPlayerData != null) { PersistentPlayerList persistentPlayerList = GetPersistentPlayerList(); foreach (KeyValuePair <PlatformUserIdentifierAbs, PersistentPlayerData> persistentPlayerData2 in persistentPlayerList.Players) { if (persistentPlayerData2.Key != persistentPlayerData.UserIdentifier) { if (persistentPlayerData2.Value.ACL != null && persistentPlayerData2.Value.ACL.Contains(persistentPlayerData.UserIdentifier)) { persistentPlayerData2.Value.RemovePlayerFromACL(persistentPlayerData.UserIdentifier); persistentPlayerData2.Value.Dispatch(persistentPlayerData, EnumPersistentPlayerDataReason.ACL_Removed); } if (persistentPlayerData.ACL != null && persistentPlayerData.ACL.Contains(persistentPlayerData2.Value.UserIdentifier)) { persistentPlayerData.RemovePlayerFromACL(persistentPlayerData2.Key); persistentPlayerData.Dispatch(persistentPlayerData2.Value, EnumPersistentPlayerDataReason.ACL_Removed); } } } SavePersistentPlayerDataXML(); } }
private void removeByPosition(List <string> _coords) { try { int x = int.MinValue; int.TryParse(_coords [0], out x); int y = int.MinValue; int.TryParse(_coords [1], out y); int z = int.MinValue; int.TryParse(_coords [2], out z); if (x == int.MinValue || y == int.MinValue || z == int.MinValue) { SdtdConsole.Instance.Output("At least one of the given coordinates is not a valid integer"); return; } Vector3i vectorKfpValue = new Vector3i(x, y, z); Vector3i vectorKfpMin = new Vector3i(x - 3, y - 3, z - 3); Vector3i vectorKfpMax = new Vector3i(x + 3, y + 3, z + 3); PersistentPlayerList PlayersLst = GameManager.Instance.GetPersistentPlayerList(); Boolean KFound = false; Dictionary <Vector3i, PersistentPlayerData> positionToLPBlockOwner = PlayersLst.m_lpBlockMap; foreach (KeyValuePair <Vector3i, PersistentPlayerData> current in positionToLPBlockOwner) { if ((int)current.Key.x >= (int)vectorKfpMin.x && (int)current.Key.x <= (int)vectorKfpMax.x) { SdtdConsole.Instance.Output("Coordinates X found: " + (int)current.Key.x); if ((int)current.Key.y >= (int)vectorKfpMin.y && (int)current.Key.y <= (int)vectorKfpMax.y) { SdtdConsole.Instance.Output("Coordinates Y found: " + (int)current.Key.y); if ((int)current.Key.z >= (int)vectorKfpMin.z && (int)current.Key.z <= (int)vectorKfpMax.z) { SdtdConsole.Instance.Output("Coordinates Z found: " + (int)current.Key.z); Vector3i vectorKfpEnd = new Vector3i((int)current.Key.x, (int)current.Key.y, (int)current.Key.z); BlockChangeInfo bci = new BlockChangeInfo(vectorKfpEnd, 0, true); List <BlockChangeInfo> changes = new List <BlockChangeInfo> (); changes.Add(bci); GameManager.Instance.SetBlocksRPC(changes); SdtdConsole.Instance.Output("Land protection block at (" + vectorKfpEnd.ToString() + ") removed"); KFound = true; return; } } } } if (!KFound) { SdtdConsole.Instance.Output("Aucune keystone trouvee a cet emplacement (" + vectorKfpValue.ToString() + ")."); } } catch (Exception e) { Log.Out("Error in RemoveLandProtection.removeByPosition: " + e); } }
public static void CheckLocation(ClientInfo _cInfo, string _amount, int _exec) { if (Inside_Claim) { World world = GameManager.Instance.World; EntityPlayer _player = world.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; Vector3i _vec3i = new Vector3i(x, y, z); PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList(); PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_player.entityId); EnumLandClaimOwner _owner = world.GetLandClaimOwner(_vec3i, _persistentPlayerData); if (_owner == EnumLandClaimOwner.Self || _owner == EnumLandClaimOwner.Ally) { if (_exec == 1) { Deposit(_cInfo, _amount); } if (_exec == 2) { Withdraw(_cInfo, _amount); } if (_exec == 3) { WalletDeposit(_cInfo, _amount); } if (_exec == 4) { WalletWithdraw(_cInfo, _amount); } } else { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " you can not use this command here.Stand in your own or a friend's claimed space.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { if (_exec == 1) { Deposit(_cInfo, _amount); } if (_exec == 2) { Withdraw(_cInfo, _amount); } if (_exec == 3) { WalletDeposit(_cInfo, _amount); } if (_exec == 4) { WalletWithdraw(_cInfo, _amount); } } }
public static void SetHome2(ClientInfo _cInfo, string _playerName, bool _announce) { bool Found = false; 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; int _claimSize = GameStats.GetInt(EnumGameStats.LandClaimSize) / 2; PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList(); PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerData(_cInfo.playerId); List <Vector3i> _blocks = _persistentPlayerData.LPBlocks; for (int i = 0; i < _blocks.Count; i++) { Vector3i _vec3i = _blocks[i]; if ((_vec3i.x - x) * (_vec3i.x - x) + (_vec3i.z - z) * (_vec3i.z - z) <= _claimSize * _claimSize) { Found = true; string _sposition = x + "," + y + "," + z; PersistentContainer.Instance.Players[_cInfo.playerId, true].HomePosition2 = _sposition; PersistentContainer.Instance.Save(); string _phrase607; if (!Phrases.Dict.TryGetValue(607, out _phrase607)) { _phrase607 = "{PlayerName} your home2 has been saved."; } _phrase607 = _phrase607.Replace("{PlayerName}", _cInfo.playerName); if (_announce) { GameManager.Instance.GameMessageServer((ClientInfo)null, EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase607), Config.Server_Response_Name, false, "ServerTools", true); } else { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase607), Config.Server_Response_Name, false, "ServerTools", false)); } } } if (!Found) { string _phrase817; if (!Phrases.Dict.TryGetValue(817, out _phrase817)) { _phrase817 = "{PlayerName} you are not inside your own claimed space. You can not save this as your home."; } _phrase817 = _phrase817.Replace("{PlayerName}", _cInfo.playerName); if (_announce) { GameManager.Instance.GameMessageServer((ClientInfo)null, EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase817), Config.Server_Response_Name, false, "ServerTools", true); } else { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase817), Config.Server_Response_Name, false, "ServerTools", false)); } } }
public static PersistentPlayerList GetPersistentPlayerList() { PersistentPlayerList _persistentPlayerList = GameManager.Instance.persistentPlayers; if (_persistentPlayerList != null) { return(_persistentPlayerList); } return(null); }
public static void RemovePersistentPlayerData(string _playerId) { PersistentPlayerList _persistentPlayerList = GetPersistentPlayerList(); if (_persistentPlayerList != null) { if (_persistentPlayerList.Players.ContainsKey(_playerId)) { _persistentPlayerList.Players.Remove(_playerId); SavePersistentPlayerDataXML(); } } }
public static PersistentPlayerData GetPersistentPlayerData(string _playerId) { PersistentPlayerList _persistentPlayerList = GameManager.Instance.persistentPlayers; if (_persistentPlayerList != null) { PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerData(_playerId); if (_persistentPlayerData != null) { return(_persistentPlayerData); } } return(null); }
public static EnumLandClaimOwner ClaimedByWho(PlatformUserIdentifierAbs _uId, Vector3i _position) { PersistentPlayerList persistentPlayerList = GetPersistentPlayerList(); if (persistentPlayerList != null) { PersistentPlayerData persistentPlayerData = persistentPlayerList.GetPlayerData(_uId); if (persistentPlayerData != null) { return(GameManager.Instance.World.GetLandClaimOwner(_position, persistentPlayerData)); } } return(EnumLandClaimOwner.None); }
public static PersistentPlayerData GetPersistentPlayerDataFromEntityId(int _entityId) { PersistentPlayerList _persistentPlayerList = GameManager.Instance.persistentPlayers; if (_persistentPlayerList != null) { PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_entityId); if (_persistentPlayerData != null) { return(_persistentPlayerData); } } return(null); }
public static PersistentPlayerData GetPersistentPlayerDataFromUId(PlatformUserIdentifierAbs _uId) { PersistentPlayerList persistentPlayerList = GetPersistentPlayerList(); if (persistentPlayerList != null) { PersistentPlayerData ppd = persistentPlayerList.GetPlayerData(_uId); if (ppd != null) { return(ppd); } } return(null); }
private static bool Claimed(ClientInfo _cInfo, Vector3i _position) { PersistentPlayerList _persistentPlayerList = PersistentOperations.GetPersistentPlayerList(); if (_persistentPlayerList != null) { PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_cInfo.entityId); EnumLandClaimOwner _owner = GameManager.Instance.World.GetLandClaimOwner(_position, _persistentPlayerData); if (_owner == EnumLandClaimOwner.None) { return(false); } } return(true); }
public static void RemovePersistentPlayerData(string _id) { PersistentPlayerList persistentPlayerList = GetPersistentPlayerList(); if (persistentPlayerList != null) { PlatformUserIdentifierAbs uId = GetPlatformUserFromNameOrId(_id); if (uId != null) { if (persistentPlayerList.Players.ContainsKey(uId)) { persistentPlayerList.Players.Remove(uId); SavePersistentPlayerDataXML(); } } } }
public static void Exec1(ClientInfo _cInfo, EntityPlayer _player) { if (Inside_Claim) { World world = GameManager.Instance.World; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; Vector3i _vec3i = new Vector3i(x, y, z); PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList(); PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_player.entityId); EnumLandClaimOwner _owner = world.GetLandClaimOwner(_vec3i, _persistentPlayerData); if (_owner == EnumLandClaimOwner.Self || _owner == EnumLandClaimOwner.Ally) { string _phrase781; if (!Phrases.Dict.TryGetValue(781, out _phrase781)) { _phrase781 = "saved your current bike for retrieval."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase781 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); string _sql = string.Format("UPDATE Players SET bikeId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId); SQL.FastQuery(_sql); } else { string _phrase780; if (!Phrases.Dict.TryGetValue(780, out _phrase780)) { _phrase780 = "you have not claimed this space or a friend. You can only save your bike inside a claimed space."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase780 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { string _phrase781; if (!Phrases.Dict.TryGetValue(781, out _phrase781)) { _phrase781 = "saved your current bike for retrieval."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase781 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); string _sql = string.Format("UPDATE Players SET bikeId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId); SQL.FastQuery(_sql); } }
public static PersistentPlayerData GetPersistentPlayerDataFromId(string _id) { PlatformUserIdentifierAbs uId = GetPlatformUserFromNameOrId(_id); if (uId != null) { PersistentPlayerList persistentPlayerList = GetPersistentPlayerList(); if (persistentPlayerList != null) { PersistentPlayerData ppd = persistentPlayerList.GetPlayerData(uId); if (ppd != null) { return(ppd); } } } return(null); }
public static void CheckLP(ClientInfo _cInfo) { World world = GameManager.Instance.World; EntityPlayer _player = world.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; Vector3i _vec3i = new Vector3i(x, y, z); PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList(); PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_player.entityId); EnumLandClaimOwner _owner = world.GetLandClaimOwner(_vec3i, _persistentPlayerData); if (_owner == EnumLandClaimOwner.Self || _owner == EnumLandClaimOwner.Ally) { if (CheckStuck(_player)) { Exec(_cInfo, _player); } else { string _phrase923; if (!Phrases.Dict.TryGetValue(923, out _phrase923)) { _phrase923 = "you do not seem to be stuck."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase923 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { string _phrase921; if (!Phrases.Dict.TryGetValue(921, out _phrase921)) { _phrase921 = "you are outside of your claimed space or a friends. Command is unavailable."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _phrase921 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
public static void CheckLocation(ClientInfo _cInfo, string _amount, int _exec) { bool Found = false; EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; int _claimSize = GameStats.GetInt(EnumGameStats.LandClaimSize) / 2; PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList(); PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerData(_cInfo.playerId); List <Vector3i> _blocks = _persistentPlayerData.LPBlocks; for (int i = 0; i < _blocks.Count; i++) { Vector3i _vec3i = _blocks[i]; if ((_vec3i.x - _player.position.x) * (_vec3i.x - _player.position.x) + (_vec3i.z - _player.position.z) * (_vec3i.z - _player.position.z) <= _claimSize * _claimSize) { Found = true; if (_exec == 1) { Deposit(_cInfo, _amount); } if (_exec == 2) { Withdraw(_cInfo, _amount); } if (_exec == 3) { WalletDeposit(_cInfo, _amount); } if (_exec == 4) { WalletWithdraw(_cInfo, _amount); } } } if (!Found) { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}You can not use this command here. Stand in your own claimed space.[-]", Config.Chat_Response_Color), Config.Server_Response_Name, false, "ServerTools", false)); } }
public static bool ClaimedByNone(Vector3i _position) { Chunk chunk = (Chunk)GameManager.Instance.World.GetChunkFromWorldPos(_position); if (chunk != null) { PersistentPlayerList persistentPlayerList = GetPersistentPlayerList(); if (persistentPlayerList != null) { int claimSize = GameStats.GetInt(EnumGameStats.LandClaimSize); Dictionary <Vector3i, PersistentPlayerData> claims = persistentPlayerList.m_lpBlockMap; foreach (var claim in claims) { float distance = (claim.Key.ToVector3() - _position.ToVector3()).magnitude; if (distance <= claimSize / 2 && GameManager.Instance.World.IsLandProtectionValidForPlayer(claim.Value)) { return(false); } } } } return(true); }
public static void CheckLP(ClientInfo _cInfo) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList(); PersistentPlayerData _landOwner = _persistentPlayerList.GetLandProtectionBlockOwner(new Vector3i((int)_player.position.x, (int)_player.position.y, (int)_player.position.z)); PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerData(_cInfo.playerId); if (_landOwner != null) { if (_landOwner != _persistentPlayerData) { EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_landOwner.EntityId]; if (_player2 != null) { if (_player.IsFriendsWith(_player2)) { if (CheckStuck(_player)) { Exec(_cInfo, _player); } else { string _phrase923; if (!Phrases.Dict.TryGetValue(923, out _phrase923)) { _phrase923 = "{PlayerName} you do not seem to be stuck."; } _phrase923 = _phrase923.Replace("{PlayerName}", _cInfo.playerName); { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase923), Config.Server_Response_Name, false, "ServerTools", false)); } } } else { string _phrase921; if (!Phrases.Dict.TryGetValue(921, out _phrase921)) { _phrase921 = "{PlayerName} you can not use this command here."; } _phrase921 = _phrase921.Replace("{PlayerName}", _cInfo.playerName); { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase921), Config.Server_Response_Name, false, "ServerTools", false)); } } } else { string _phrase921; if (!Phrases.Dict.TryGetValue(921, out _phrase921)) { _phrase921 = "{PlayerName} you can not use this command here."; } _phrase921 = _phrase921.Replace("{PlayerName}", _cInfo.playerName); { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase921), Config.Server_Response_Name, false, "ServerTools", false)); } } } else { if (CheckStuck(_player)) { Exec(_cInfo, _player); } else { string _phrase923; if (!Phrases.Dict.TryGetValue(923, out _phrase923)) { _phrase923 = "{PlayerName} you do not seem to be stuck."; } _phrase923 = _phrase923.Replace("{PlayerName}", _cInfo.playerName); { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase923), Config.Server_Response_Name, false, "ServerTools", false)); } } } } else { if (CheckStuck(_player)) { Exec(_cInfo, _player); } else { string _phrase923; if (!Phrases.Dict.TryGetValue(923, out _phrase923)) { _phrase923 = "{PlayerName} you do not seem to be stuck."; } _phrase923 = _phrase923.Replace("{PlayerName}", _cInfo.playerName); { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase923), Config.Server_Response_Name, false, "ServerTools", false)); } } } }
public static void Exec1(ClientInfo _cInfo, Entity _player, int _vehicle) { if (Inside_Claim) { World world = GameManager.Instance.World; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; Vector3i _vec3i = new Vector3i(x, y, z); PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList(); PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_player.entityId); EnumLandClaimOwner _owner = world.GetLandClaimOwner(_vec3i, _persistentPlayerData); if (_owner == EnumLandClaimOwner.Self || _owner == EnumLandClaimOwner.Ally) { string _vehicleName = ""; string _messageName = ""; if (_vehicle == 1) { _vehicleName = "vehicleBicycle"; _messageName = "bike"; } if (_vehicle == 2) { _vehicleName = "vehicleMinibike"; _messageName = "minibike"; } if (_vehicle == 3) { _vehicleName = "vehicleMotorcycle"; _messageName = "motorbike"; } if (_vehicle == 4) { _vehicleName = "vehicle4x4Truck"; _messageName = "jeep"; } if (_vehicle == 5) { _vehicleName = "vehicleGyrocopter"; _messageName = "gyro"; } if (_player.AttachedToEntity.EntityClass.entityClassName.ToString() == _vehicleName) { string _phrase781; if (!Phrases.Dict.TryGetValue(781, out _phrase781)) { _phrase781 = " saved your current vehicle for retrieval."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase781 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); string _sql = ""; if (_vehicle == 1) { _sql = string.Format("UPDATE Vehicles SET bikeId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId); } if (_vehicle == 2) { _sql = string.Format("UPDATE Vehicles SET miniBikeId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId); } if (_vehicle == 3) { _sql = string.Format("UPDATE Vehicles SET motorBikeId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId); } if (_vehicle == 4) { _sql = string.Format("UPDATE Vehicles SET jeepId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId); } if (_vehicle == 5) { _sql = string.Format("UPDATE Vehicles SET gyroId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId); } SQL.FastQuery(_sql, "VehicleTeleport"); } else { string _phrase787; if (!Phrases.Dict.TryGetValue(787, out _phrase787)) { _phrase787 = " you are on the wrong vehicle to save it with this command. You are using a {Vehicle}."; } _phrase787 = _phrase787.Replace("{Vehicle}", _messageName); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase787 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { string _phrase780; if (!Phrases.Dict.TryGetValue(780, out _phrase780)) { _phrase780 = " you have not claimed this space or a friend. You can only save your vehicle inside a claimed space."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase780 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { string _vehicleName = ""; string _messageName = ""; if (_vehicle == 1) { _vehicleName = "vehicleBicycle"; _messageName = "bike"; } if (_vehicle == 2) { _vehicleName = "vehicleMinibike"; _messageName = "minibike"; } if (_vehicle == 3) { _vehicleName = "vehicleMotorcycle"; _messageName = "motorbike"; } if (_vehicle == 4) { _vehicleName = "vehicle4x4Truck"; _messageName = "jeep"; } if (_vehicle == 5) { _vehicleName = "vehicleGyrocopter"; _messageName = "gyro"; } if (_player.AttachedToEntity.name == _vehicleName) { string _phrase781; if (!Phrases.Dict.TryGetValue(781, out _phrase781)) { _phrase781 = " saved your current vehicle for retrieval."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase781 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); string _sql = ""; if (_vehicle == 1) { _sql = string.Format("UPDATE Vehicles SET bikeId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId); } if (_vehicle == 2) { _sql = string.Format("UPDATE Vehicles SET miniBikeId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId); } if (_vehicle == 3) { _sql = string.Format("UPDATE Vehicles SET motorBikeId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId); } if (_vehicle == 4) { _sql = string.Format("UPDATE Vehicles SET jeepId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId); } if (_vehicle == 5) { _sql = string.Format("UPDATE Vehicles SET gyroId = {0} WHERE steamid = '{1}'", _player.AttachedToEntity.entityId, _cInfo.playerId); } SQL.FastQuery(_sql, "VehicleTeleport"); } else { string _phrase787; if (!Phrases.Dict.TryGetValue(787, out _phrase787)) { _phrase787 = " you are on the wrong vehicle to save it with this command. You are using a {Vehicle}."; } _phrase787 = _phrase787.Replace("{Vehicle}", _messageName); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase787 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } }
public static void SaveVehicle(ClientInfo _cInfo, Entity _player, int _vehicle, int _vehicleId) { if (Inside_Claim) { World world = GameManager.Instance.World; Vector3 _position = _player.GetPosition(); int x = (int)_position.x; int y = (int)_position.y; int z = (int)_position.z; Vector3i _vec3i = new Vector3i(x, y, z); PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList(); PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerDataFromEntityID(_player.entityId); EnumLandClaimOwner _owner = world.GetLandClaimOwner(_vec3i, _persistentPlayerData); if (!(_owner == EnumLandClaimOwner.Self || _owner == EnumLandClaimOwner.Ally)) { string _phrase780; if (!Phrases.Dict.TryGetValue(780, out _phrase780)) { _phrase780 = "You have not claimed this space or a friend. You can only save your vehicle inside a claimed space."; } ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase780 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); return; } } string _entityName = "", _vehicleName = ""; if (_vehicle == 1) { _entityName = "vehicleBicycle"; _vehicleName = "bike"; } else if (_vehicle == 2) { _entityName = "vehicleMinibike"; _vehicleName = "minibike"; } else if (_vehicle == 3) { _entityName = "vehicleMotorcycle"; _vehicleName = "motorbike"; } else if (_vehicle == 4) { _entityName = "vehicle4x4Truck"; _vehicleName = "jeep"; } else if (_vehicle == 5) { _entityName = "vehicleGyrocopter"; _vehicleName = "gyro"; } if (_player.AttachedToEntity.EntityClass.entityClassName.ToString() == _entityName) { if (_vehicle == 1) { PersistentContainer.Instance.Players[_cInfo.playerId].BikeId = _vehicleId; } else if (_vehicle == 2) { PersistentContainer.Instance.Players[_cInfo.playerId].MiniBikeId = _vehicleId; } else if (_vehicle == 3) { PersistentContainer.Instance.Players[_cInfo.playerId].MotorBikeId = _vehicleId; } else if (_vehicle == 4) { PersistentContainer.Instance.Players[_cInfo.playerId].JeepId = _vehicleId; } else if (_vehicle == 5) { PersistentContainer.Instance.Players[_cInfo.playerId].GyroId = _vehicleId; } PersistentContainer.Instance.Save(); string _phrase781; if (!Phrases.Dict.TryGetValue(781, out _phrase781)) { _phrase781 = "Saved your current {Vehicle} for retrieval."; _phrase781 = _phrase781.Replace("{Vehicle}", _vehicleName); } ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase781 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { string _phrase787; if (!Phrases.Dict.TryGetValue(787, out _phrase787)) { _phrase787 = "You are on the wrong vehicle to save it with this command. You are using a {Vehicle}."; } _phrase787 = _phrase787.Replace("{Vehicle}", _vehicleName); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase787 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
public static void CheckLP(ClientInfo _cInfo) { bool Found = false; EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; int _claimSize = GameStats.GetInt(EnumGameStats.LandClaimSize) / 2; PersistentPlayerList _persistentPlayerList = GameManager.Instance.GetPersistentPlayerList(); PersistentPlayerData _persistentPlayerData = _persistentPlayerList.GetPlayerData(_cInfo.playerId); List <Vector3i> _blocks = _persistentPlayerData.LPBlocks; for (int i = 0; i < _blocks.Count; i++) { if (!Found) { Vector3i _vec3i = _blocks[i]; if ((_vec3i.x - _player.position.x) * (_vec3i.x - _player.position.x) + (_vec3i.z - _player.position.z) * (_vec3i.z - _player.position.z) <= _claimSize * _claimSize) { Found = true; if (CheckStuck(_player)) { Exec(_cInfo, _player); } else { string _phrase923; if (!Phrases.Dict.TryGetValue(923, out _phrase923)) { _phrase923 = "{PlayerName} you do not seem to be stuck."; } _phrase923 = _phrase923.Replace("{PlayerName}", _cInfo.playerName); { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase923), Config.Server_Response_Name, false, "ServerTools", false)); } } } } } if (!Found) { List <ClientInfo> _cInfoList = ConnectionManager.Instance.GetClients(); for (int i = 0; i < _cInfoList.Count; i++) { ClientInfo _cInfo2 = _cInfoList[i]; if (_cInfo2 != null && _cInfo != _cInfo2) { EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId]; if (_player2 != null && _player.IsFriendsWith(_player2)) { int _claimSize2 = GameStats.GetInt(EnumGameStats.LandClaimSize) / 2; PersistentPlayerData _persistentPlayerData2 = GameManager.Instance.GetPersistentPlayerList().GetPlayerData(_cInfo2.playerId); List <Vector3i> _blocks2 = _persistentPlayerData.LPBlocks; for (int j = 0; j < _blocks2.Count; j++) { if (!Found) { Vector3i _vec3i = _blocks2[j]; if ((_vec3i.x - _player.position.x) * (_vec3i.x - _player.position.x) + (_vec3i.z - _player.position.z) * (_vec3i.z - _player.position.z) <= _claimSize2 * _claimSize2) { Found = true; if (CheckStuck(_player)) { Exec(_cInfo, _player); } else { string _phrase923; if (!Phrases.Dict.TryGetValue(923, out _phrase923)) { _phrase923 = "{PlayerName} you do not seem to be stuck."; } _phrase923 = _phrase923.Replace("{PlayerName}", _cInfo.playerName); { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase923), Config.Server_Response_Name, false, "ServerTools", false)); } } } } } } } } } if (!Found) { string _phrase921; if (!Phrases.Dict.TryGetValue(921, out _phrase921)) { _phrase921 = "{PlayerName} you are outside of your claimed space or a friends. Command is unavailable."; } _phrase921 = _phrase921.Replace("{PlayerName}", _cInfo.playerName); { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase921), Config.Server_Response_Name, false, "ServerTools", false)); } } }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_senderInfo.RemoteClientInfo != null) { if (_params.Count >= 1 && _params [0].ToLower().Equals("nearby")) { _params.Add(_senderInfo.RemoteClientInfo.playerId); } } World w = GameManager.Instance.World; PersistentPlayerList ppl = GameManager.Instance.GetPersistentPlayerList(); bool summaryOnly = false; string steamIdFilter = string.Empty; Vector3i closeTo = default(Vector3i); bool onlyCloseToPlayer = false; int closeToDistance = 32; if (_params.Count == 1) { long tempLong; if (_params [0].ToLower().Equals("summary")) { summaryOnly = true; } else if (_params [0].Length == 17 && long.TryParse(_params [0], out tempLong)) { steamIdFilter = _params [0]; } else { ClientInfo ci = ConsoleHelper.ParseParamIdOrName(_params [0]); if (ci != null) { steamIdFilter = ci.playerId; } else { SdtdConsole.Instance.Output("Player name or entity id \"" + _params [0] + "\" not found."); return; } } } else if (_params.Count >= 2) { if (_params [0].ToLower().Equals("nearby")) { try { if (_params.Count == 3) { if (!int.TryParse(_params[1], out closeToDistance)) { SdtdConsole.Instance.Output("Given radius is not an integer!"); } } ClientInfo ci = ConsoleHelper.ParseParamSteamIdOnline(_params [_params.Count - 1]); EntityPlayer ep = w.Players.dict [ci.entityId]; closeTo = new Vector3i(ep.GetPosition()); onlyCloseToPlayer = true; } catch (Exception e) { SdtdConsole.Instance.Output("Error getting current player's position"); Log.Out("Error in ListLandProtection.Run: " + e); } } else { SdtdConsole.Instance.Output("Illegal parameter list"); return; } } Boolean Bol = false; Dictionary <Vector3i, PersistentPlayerData> d = ppl.m_lpBlockMap; if (d != null) { Dictionary <PersistentPlayerData, List <Vector3i> > owners = new Dictionary <PersistentPlayerData, List <Vector3i> > (); foreach (KeyValuePair <Vector3i, PersistentPlayerData> kvp in d) { if (!onlyCloseToPlayer || (Math.Abs(kvp.Key.x - closeTo.x) <= closeToDistance && Math.Abs(kvp.Key.z - closeTo.z) <= closeToDistance)) { if (!owners.ContainsKey(kvp.Value)) { owners.Add(kvp.Value, new List <Vector3i> ()); } owners [kvp.Value].Add(kvp.Key); } } foreach (KeyValuePair <PersistentPlayerData, List <Vector3i> > kvp in owners) { if (steamIdFilter.Length == 0 || kvp.Key.PlayerId.Equals(steamIdFilter)) { PersistentData.Player p = PersistentData.PersistentContainer.Instance.Players [kvp.Key.PlayerId, false]; string name = string.Empty; if (p != null) { name = p.Name; } name += " (" + kvp.Key.PlayerId + ")"; Bol = true; SdtdConsole.Instance.Output(String.Format( "Player \"{0}\" owns {3} keystones (protected: {1}, current hardness multiplier: {2})", name, w.IsLandProtectionValidForPlayer(kvp.Key), w.GetLandProtectionHardnessModifierForPlayer(kvp.Key), kvp.Value.Count) ); if (!summaryOnly) { foreach (Vector3i v in kvp.Value) { SdtdConsole.Instance.Output(" (" + v.ToString() + ")"); } } } } } if (Bol == false) { SdtdConsole.Instance.Output("Player not found..."); } if (steamIdFilter.Length == 0) { SdtdConsole.Instance.Output("Total of " + d.Count + " keystones in the game"); } } catch (Exception e) { Log.Out("Error in ListLandProtection.Run: " + e); } }