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 Set(ClientInfo _cInfo) { string[] command = { Command_set }; if (!GameManager.Instance.adminTools.CommandAllowedFor(command, _cInfo)) { Phrases.Dict.TryGetValue("Market7", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } else { 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; string mposition = x + "," + y + "," + z; Market_Position = mposition; Config.WriteXml(); Phrases.Dict.TryGetValue("Market6", out string phrase); phrase = phrase.Replace("{MarketPosition}", Market_Position); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } }
public static void SetHome2(ClientInfo _cInfo, string _playerName, bool _announce) { 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; 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)); } }
public static void SetJail(ClientInfo _cInfo) { string[] _command1 = { Command26 }; if (!GameManager.Instance.adminTools.CommandAllowedFor(_command1, _cInfo.playerId)) { string _phrase107; if (!Phrases.Dict.TryGetValue(107, out _phrase107)) { _phrase107 = " you do not have permissions to use this command."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase107 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { 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; Jail_Position = _sposition; string _phrase502; if (!Phrases.Dict.TryGetValue(502, out _phrase502)) { _phrase502 = " you have set the jail position as {JailPosition}."; } _phrase502 = _phrase502.Replace("{JailPosition}", Jail_Position); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase502 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); LoadConfig.WriteXml(); } }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_params.Count != 3 && _params.Count != 4) { SdtdConsole.Instance.Output("Wrong number of arguments, expected 3 or 4, found " + _params.Count + "."); return; } ClientInfo ci = ConsoleHelper.ParseParamIdOrName(_params [0]); if (ci == null) { SdtdConsole.Instance.Output("Playername or entity id not found."); return; } ItemValue iv = ItemList.Instance.GetItemValue(_params [1]); if (iv == null) { SdtdConsole.Instance.Output("Item not found."); return; } int n = int.MinValue; if (!int.TryParse(_params [2], out n) || n <= 0) { SdtdConsole.Instance.Output("Amount is not an integer or not greater than zero."); return; } if (_params.Count == 4) { if (!iv.HasQuality) { SdtdConsole.Instance.Output("Item " + _params [1] + " does not support quality."); return; } int quality = int.MinValue; if (!int.TryParse(_params [3], out quality) || quality <= 0) { SdtdConsole.Instance.Output("Quality is not an integer or not greater than zero."); return; } iv.Quality = quality; } EntityPlayer p = GameManager.Instance.World.Players.dict [ci.entityId]; ItemStack invField = new ItemStack(iv, n); GameManager.Instance.ItemDropServer(invField, p.GetPosition(), Vector3.zero, -1, 50); SdtdConsole.Instance.Output("Dropped item"); } catch (Exception e) { Log.Out("Error in Give.Run: " + e); } }
private static void SavePoint(ClientInfo _cInfo, string _waypoint, int _waypointTotal) { if (PersistentContainer.Instance.Players[_cInfo.playerId].Waypoints != null && PersistentContainer.Instance.Players[_cInfo.playerId].Waypoints.Count > 0) { if (PersistentContainer.Instance.Players[_cInfo.playerId].Waypoints.Count < _waypointTotal) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { Vector3 _position = _player.GetPosition(); int _x = (int)_position.x; int _y = (int)_position.y; int _z = (int)_position.z; string _wposition = _x + "," + _y + "," + _z; Dictionary <string, string> _waypoints = PersistentContainer.Instance.Players[_cInfo.playerId].Waypoints; if (!_waypoints.ContainsKey(_waypoint)) { _waypoints.Add(_waypoint, _wposition); PersistentContainer.Instance.Players[_cInfo.playerId].Waypoints = _waypoints; PersistentContainer.Instance.Save(); string _message = string.Format("Saved waypoint name as {0} to position {1}.", _waypoint, _wposition); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "You have a waypoint with this name already. Choose another name." + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } else { string _phrase579; if (!Phrases.Dict.TryGetValue(579, out _phrase579)) { _phrase579 = "You have a maximum {Count} waypoints."; } _phrase579 = _phrase579.Replace("{Count}", _waypointTotal.ToString()); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase579 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { Dictionary <string, string> _waypoints = new Dictionary <string, string>(); Vector3 _position = _player.GetPosition(); int _x = (int)_position.x; int _y = (int)_position.y; int _z = (int)_position.z; string _wposition = _x + "," + _y + "," + _z; _waypoints.Add(_waypoint, _wposition); PersistentContainer.Instance.Players[_cInfo.playerId].Waypoints = _waypoints; PersistentContainer.Instance.Save(); string _message = string.Format("Saved waypoint name as {0} to position {1}.", _waypoint, _wposition); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } }
private static void SavePoint(ClientInfo _cInfo, string _waypoint, int _waypointTotal) { if (PersistentContainer.Instance.Players[_cInfo.playerId].Waypoints != null && PersistentContainer.Instance.Players[_cInfo.playerId].Waypoints.Count > 0) { if (PersistentContainer.Instance.Players[_cInfo.playerId].Waypoints.Count < _waypointTotal) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { Vector3 _position = _player.GetPosition(); int _x = (int)_position.x; int _y = (int)_position.y; int _z = (int)_position.z; string _wposition = _x + "," + _y + "," + _z; Dictionary <string, string> _waypoints = PersistentContainer.Instance.Players[_cInfo.playerId].Waypoints; if (!_waypoints.ContainsKey(_waypoint)) { _waypoints.Add(_waypoint, _wposition); PersistentContainer.Instance.Players[_cInfo.playerId].Waypoints = _waypoints; Phrases.Dict.TryGetValue(278, out string _phrase278); _phrase278 = _phrase278.Replace("{Name}", _waypoint); _phrase278 = _phrase278.Replace("{Position}", _wposition); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase278 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } else { Phrases.Dict.TryGetValue(285, out string _phrase285); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase285 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } else { Phrases.Dict.TryGetValue(275, out string _phrase275); _phrase275 = _phrase275.Replace("{Value}", _waypointTotal.ToString()); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase275 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { Dictionary <string, string> _waypoints = new Dictionary <string, string>(); Vector3 _position = _player.GetPosition(); int _x = (int)_position.x; int _y = (int)_position.y; int _z = (int)_position.z; string _wposition = _x + "," + _y + "," + _z; _waypoints.Add(_waypoint, _wposition); PersistentContainer.Instance.Players[_cInfo.playerId].Waypoints = _waypoints; Phrases.Dict.TryGetValue(278, out string _phrase278); _phrase278 = _phrase278.Replace("{Name}", _waypoint); _phrase278 = _phrase278.Replace("{Position}", _wposition); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase278 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } }
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); } } }
private void _ResetTooFar(EntityPlayer player) { Vector3i ppos = Vectors.ToInt(player.GetPosition()); int pdist = Math.Abs(ppos.x - Searcher.x) + Math.Abs(ppos.z - Searcher.y); // Iter.EverySeconds(ref _printDistLast, 10, (_x) => Printer.Print(_x), "Search pdist=" + pdist.ToString()); if (pdist > radius) { Printer.Log(85, "Searcher.Reset !", ppos, Searcher.x, Searcher.y); Searcher.Reset(ppos.x, ppos.z, ppos.y); } }
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)); } } }
private static void Checks(ClientInfo _cInfo, string _waypoint) { World world = GameManager.Instance.World; EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.playerId); if (_player != null) { if (Vehicle) { Entity _attachedEntity = _player.AttachedToEntity; if (_attachedEntity != null) { string _phrase587; if (!Phrases.Dict.TryGetValue(587, out _phrase587)) { _phrase587 = " you can not teleport to a waypoint with a vehicle."; ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase587 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } return; } } if (PvP_Check) { if (Teleportation.PCheck(_cInfo, _player)) { return; } } if (Zombie_Check) { if (Teleportation.ZCheck(_cInfo, _player)) { return; } } } 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); if (PersistentOperations.ClaimedByNone(_cInfo.playerId, _vec3i)) { CommandCost(_cInfo, _waypoint); } 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 + LoadConfig.Chat_Response_Color + _phrase576 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { Printer.Print("SingleChunked Effect1", place.position, place.ipos, opt.OptionItem.item); Vector3i where = Vectors.ToInt(player.GetPosition()); int y0 = Geo3D.Surface(where).y; Vector3i nw4 = ZChunk.TL4(place.ipos); Bounds b4 = ZChunk.Bounds4(nw4, y0); Zombiome.Routines.Start(Regen(player, b4, y0), name + "-SingleChunked"); }
private static void Kill(ClientInfo _cInfo) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (Player_Check) { List <ClientInfo> ClientInfoList = PersistentOperations.ClientList(); for (int i = 0; i < ClientInfoList.Count; i++) { ClientInfo _cInfo2 = ClientInfoList[i]; if (_cInfo2 != null) { EntityPlayer _player2 = GameManager.Instance.World.Players.dict[_cInfo2.entityId]; if (_player2 != null) { Vector3 _pos2 = _player2.GetPosition(); if (((int)_player.position.x - (int)_pos2.x) * ((int)_player.position.x - (int)_pos2.x) + ((int)_player.position.z - (int)_pos2.z) * ((int)_player.position.z - (int)_pos2.z) <= 25 * 25) { if (!_player.IsFriendsWith(_player2)) { Phrases.Dict.TryGetValue(32, out string _phrase32); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase32 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return; } } } } } } if (Zombie_Check) { List <Entity> Entities = GameManager.Instance.World.Entities.list; for (int i = 0; i < Entities.Count; i++) { Entity _entity = Entities[i]; if (_entity != null) { EntityType _type = _entity.entityType; if (_type == EntityType.Zombie) { Vector3 _pos2 = _entity.GetPosition(); if (((int)_player.position.x - (int)_pos2.x) * ((int)_player.position.x - (int)_pos2.x) + ((int)_player.position.z - (int)_pos2.z) * ((int)_player.position.z - (int)_pos2.z) <= 10 * 10) { Phrases.Dict.TryGetValue(33, out string _phrase33); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase33 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return; } } } } } SdtdConsole.Instance.ExecuteSync(string.Format("kill {0}", _cInfo.playerId), (ClientInfo)null); PersistentContainer.Instance.Players[_cInfo.playerId].LastKillMe = DateTime.Now; PersistentContainer.DataChange = true; }
private static void Entityspawn(ClientInfo _cInfo) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player.IsSpawned()) { Vector3 pos = _player.GetPosition(); float x = pos.x; float y = pos.y; float z = pos.z; int _x, _y, _z; posFound = true; posFound = GameManager.Instance.World.FindRandomSpawnPointNearPosition(new Vector3((float)x, (float)y, (float)z), 15, out _x, out _y, out _z, new Vector3((float)5, (float)5, (float)5), true); if (!posFound) { posFound = GameManager.Instance.World.FindRandomSpawnPointNearPosition(new Vector3((float)x, (float)y, (float)z), 15, out _x, out _y, out _z, new Vector3((float)5 + 5, (float)5 + 10, (float)5 + 5), true); } if (posFound) { int counter = 1; Dictionary <int, EntityClass> .KeyCollection entityTypesCollection = EntityClass.list.Dict.Keys; foreach (int i in entityTypesCollection) { EntityClass eClass = EntityClass.list[i]; if (!eClass.bAllowUserInstantiate) { continue; } if (Entity_Id == counter) { Entity entity = EntityFactory.CreateEntity(i, new Vector3((float)_x, (float)_y, (float)_z)); GameManager.Instance.World.SpawnEntityInWorld(entity); Log.Out(string.Format("[SERVERTOOLS] Spawned an entity reward {0} at {1} x, {2} y, {3} z for {4}", eClass.entityClassName, _x, _y, _z, _cInfo.playerName)); string _message = " spawned a {EntityName} near you."; _message = _message.Replace("{EntityName}", eClass.entityClassName); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } counter++; } if (counter == entityTypesCollection.Count + 1) { Log.Out(string.Format("[SERVERTOOLS] Failed to spawn entity Id {0} as a reward. Check your entity spawn list in console.", Entity_Id)); } } else { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + ", no spawn point was found near you. Please move locations and try again.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + ", can not give you a vote reward unless spawned. Please type " + ChatHook.Command_Private + Command46 + " again.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
PlayerZone UpdatePlayer(PlayerZone ply, EntityPlayer ent) { var pos = ent.GetPosition(); ply.mins = pos - (VisibleBox * 0.5f); ply.maxs = pos + (VisibleBox * 0.5f); ply.minsSpawnBlock = pos - (SpawnBlockBox * 0.5f); ply.maxsSpawnBlock = pos + (SpawnBlockBox * 0.5f); ply.center = pos; return(ply); }
public static void Exec(ClientInfo _cInfo, string _playerName) { if (SetLobby.Lobby_Position != "0,0,0") { int x, y, z; if (Return) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); x = (int)_position.x; y = (int)_position.y; z = (int)_position.z; string _pposition = x + "," + y + "," + z; LobbyPlayers.Add(_cInfo.entityId); PersistentContainer.Instance.Players[_cInfo.playerId, true].LobbyReturn = _pposition; PersistentContainer.Instance.Save(); string _phrase552; if (!Phrases.Dict.TryGetValue(552, out _phrase552)) { _phrase552 = "{PlayerName} you can go back by typing /return when you are ready to leave the lobby."; } _phrase552 = _phrase552.Replace("{PlayerName}", _playerName); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase552), Config.Server_Response_Name, false, "ServerTools", false)); } string[] _cords = SetLobby.Lobby_Position.Split(','); int.TryParse(_cords[0], out x); int.TryParse(_cords[1], out y); int.TryParse(_cords[2], out z); Players.NoFlight.Add(_cInfo.entityId); _cInfo.SendPackage(new NetPackageTeleportPlayer(new Vector3(x, y, z), false)); string _phrase553; if (!Phrases.Dict.TryGetValue(553, out _phrase553)) { _phrase553 = "{PlayerName} you have been sent to the lobby."; } _phrase553 = _phrase553.Replace("{PlayerName}", _playerName); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase553), Config.Server_Response_Name, false, "ServerTools", false)); int _oldCoins = PersistentContainer.Instance.Players[_cInfo.playerId, false].PlayerSpentCoins; PersistentContainer.Instance.Players[_cInfo.playerId, true].PlayerSpentCoins = _oldCoins - Command_Cost; PersistentContainer.Instance.Players[_cInfo.playerId, true].LastLobby = DateTime.Now; PersistentContainer.Instance.Save(); } else { string _phrase554; if (!Phrases.Dict.TryGetValue(554, out _phrase554)) { _phrase554 = "{PlayerName} the lobby position is not set."; } _phrase554 = _phrase554.Replace("{PlayerName}", _playerName); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", Config.Chat_Response_Color, _phrase554), Config.Server_Response_Name, false, "ServerTools", false)); } }
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; } if (_params[0].ToLower().Equals("off")) { Lobby.IsEnabled = false; LoadConfig.WriteXml(); SdtdConsole.Instance.Output(string.Format("Lobby has been set to off")); return; } else if (_params[0].ToLower().Equals("on")) { Lobby.IsEnabled = true; LoadConfig.WriteXml(); SdtdConsole.Instance.Output(string.Format("Lobby has been set to on")); return; } else if (_params[0] == ("set")) { ClientInfo _cInfo = _senderInfo.RemoteClientInfo; 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 _lposition = x + "," + y + "," + z; Lobby.Lobby_Position = _lposition; string _phrase551; if (!Phrases.Dict.TryGetValue(551, out _phrase551)) { _phrase551 = "{PlayerName} you have set the lobby position as {LobbyPosition}"; } _phrase551 = _phrase551.Replace("{PlayerName}", _cInfo.playerName); _phrase551 = _phrase551.Replace("{LobbyPosition}", _lposition); SdtdConsole.Instance.Output(string.Format("{0}", _phrase551)); LoadConfig.WriteXml(); } else { SdtdConsole.Instance.Output(string.Format("Invalid argument {0}", _params[0])); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in CommandJailConsole.Execute: {0}", e.Message)); } }
public string Next(EntityPlayer player, Vector3 position) { // Printer.Print("Zone Next", player, position, effect); Vector3 ppos = player.GetPosition(); float dist = (float)Math.Sqrt(Math.Pow(ppos.x - this.x, 2f) + Math.Pow(ppos.z - this.z, 2f)); dist = Math.Max(dist, radius) - radius; float posIntensity = 1f / (1f + 4 * dist / Zone.ZoneSize); // in [1, 1/5], 1/2 at d/D = 1/4 // in [1, 1/10], 1/2 at d/D = 1/9 return(effect.Next(player, position, posIntensity)); }
private static void _GiveItem(ClientInfo _cInfo, bool _announce) { string _randomItem = list.RandomObject(); ItemValue _itemValue = new ItemValue(); if (GameItems.Dict.ContainsKey(_randomItem)) { _itemValue = GameItems.Dict[_randomItem].Clone(); } else { _randomItem = _randomItem.ToLower(); foreach (KeyValuePair <string, ItemValue> _key in GameItems.Dict) { if (_key.Key.ToLower().Equals(_randomItem)) { _itemValue = _key.Value.Clone(); } } } EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_itemValue.HasQuality) { int _quality = random.Next(1, 600); _itemValue.Quality = _quality; } int[] _counts; if (dict.TryGetValue(_randomItem, out _counts)) { int _count = random.Next(_counts[0], _counts[1]); ItemStack _itemDrop = new ItemStack(_itemValue, _count); GameManager.Instance.ItemDropServer(_itemDrop, _player.GetPosition(), Vector3.zero, -1, 60); string _phrase7; if (!Phrases.Dict.TryGetValue(7, out _phrase7)) { _phrase7 = "{PlayerName} has received {ItemCount} {ItemName}."; } _phrase7 = _phrase7.Replace("{PlayerName}", _cInfo.playerName); _phrase7 = _phrase7.Replace("{ItemCount}", _count.ToString()); _phrase7 = _phrase7.Replace("{ItemName}", _randomItem); if (_announce || AlwaysShowResponse) { GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("{0}{1}[-]", CustomCommands.ChatColor, _phrase7), "Server", false, "", false); } else { _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{0}{1}[-]", CustomCommands.ChatColor, _phrase7), "Server", false, "", false)); } PersistentContainer.Instance.Players[_cInfo.playerId, true].LastGimme = DateTime.Now; PersistentContainer.Instance.Save(); } }
public override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { Printer.Log(46, "SingleChunked Effect1", place.position, place.ipos, opt.OptionItem.item); Vector3i where = Vectors.ToInt(player.GetPosition()); int y0 = Geo3D.Surface(where).y; Vector3i nw4 = ZChunk.TL4(place.ipos); Zombiome.Routines.Start(Regen(player, nw4, y0), name + "-SingleChunked0"); Zombiome.Routines.Start(Regen(player, nw4 + new Vector3i(1, 0, 0), y0), name + "-SingleChunked1"); Zombiome.Routines.Start(Regen(player, nw4 + new Vector3i(0, 0, 1), y0), name + "-SingleChunked2"); Zombiome.Routines.Start(Regen(player, nw4 + new Vector3i(1, 0, 1), y0), name + "-SingleChunked3"); }
private static void Entityspawn(ClientInfo _cInfo) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player.IsSpawned()) { Vector3 pos = _player.GetPosition(); float x = pos.x; float y = pos.y; float z = pos.z; int _x, _y, _z; posFound = true; posFound = GameManager.Instance.World.FindRandomSpawnPointNearPosition(new Vector3((float)x, (float)y, (float)z), 15, out _x, out _y, out _z, new Vector3((float)5, (float)5, (float)5), true); if (!posFound) { posFound = GameManager.Instance.World.FindRandomSpawnPointNearPosition(new Vector3((float)x, (float)y, (float)z), 15, out _x, out _y, out _z, new Vector3((float)5 + 5, (float)5 + 10, (float)5 + 5), true); } if (posFound) { int counter = 1; Dictionary <int, EntityClass> .KeyCollection entityTypesCollection = EntityClass.list.Dict.Keys; foreach (int i in entityTypesCollection) { EntityClass eClass = EntityClass.list[i]; if (!eClass.bAllowUserInstantiate) { continue; } if (Entity_Id == counter) { Entity entity = EntityFactory.CreateEntity(i, new Vector3((float)_x, (float)_y, (float)_z)); GameManager.Instance.World.SpawnEntityInWorld(entity); Log.Out(string.Format("[SERVERTOOLS] Spawned an entity reward {0} at {1} x, {2} y, {3} z for {4}", eClass.entityClassName, _x, _y, _z, _cInfo.playerName)); Phrases.Dict.TryGetValue(309, out string _phrase309); _phrase309 = _phrase309.Replace("{EntityName}", eClass.entityClassName); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase309 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } counter++; } if (counter == entityTypesCollection.Count + 1) { Log.Out(string.Format("[SERVERTOOLS] Failed to spawn entity Id {0} as a reward. Check your entity spawn list in console.", Entity_Id)); } } else { Phrases.Dict.TryGetValue(310, out string _phrase310); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase310 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } }
private static void Checks(ClientInfo _cInfo, string _waypoint, bool _friends) { EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.playerId); if (_player != null) { if (Vehicle) { Entity _attachedEntity = _player.AttachedToEntity; if (_attachedEntity != null) { Phrases.Dict.TryGetValue(281, out string _phrase281); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase281 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return; } } if (PvP_Check) { if (Teleportation.PCheck(_cInfo, _player)) { return; } } if (Zombie_Check) { if (Teleportation.ZCheck(_cInfo, _player)) { return; } } 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); // BPPR: allow player to teleport regardless of where they are //if (PersistentOperations.ClaimedByNone(_cInfo.playerId, _vec3i)) //{ CommandCost(_cInfo, _waypoint, _position, _friends); //} //else //{ // Phrases.Dict.TryGetValue(272, out string _phrase272); // ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase272 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); //} } }
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 override void Effect1(EntityPlayer player, Emplacement place, OptionEffect opt) { DecoSearch.Search(player, 20, 3); int nsteps = Math.Min(3, DecoSearch.Count); for (int k=0; k<nsteps; k++) { BlockPos deco = DecoSearch.Dequeue(); if (deco == null) continue; Vector3i ppos = Vectors.ToInt(player.GetPosition()); if (Math.Abs(ppos.x - deco.Pos.x) + Math.Abs(ppos.z - deco.Pos.z) > DecoSearch.radius){ Printer.Log(85, "MovingDeco: too far !", deco, ppos); continue; } string item = Deco2Proj(deco.Value.Block); if (item == "") continue; Zombiome.Routines.Start(Fly(deco, item), "FlyDeco"); } }
public override IEnumerator Regen(EntityPlayer player, Vector3i zchunk, int iniguess) { Bounds bounds = ZChunk.Bounds4(zchunk, iniguess); List <Entity> existing = GameManager.Instance.World.GetEntitiesInBounds( EntityGhost.Concretes[this.concreteIdx], bounds, new List <Entity>() ); yield return(Iterating.Repeater.Frame); // listent may be costly Vector3i min = Vectors.ToInt(bounds.min); Vector3i max = Vectors.ToInt(bounds.max); int current = existing.Count; int gen = ZChunk.Size(this.gen); // gen = 1; // DEBUG int regen = ZChunk.Size(this.regen); int iniy = (int)Math.Floor(player.GetPosition().y); Zombiome.Routines.Start(Routines.IfNotRunning( LockRenew, EffectExisting(player, existing) ), "Ghost-Existing"); int nnew = Math.Min(limit_new, gen - current); Entity[] Tracker = new Entity[] { null }; if (current < regen) { Printer.Log(45, "Ghost regen", regen, current, gen, "=>", gen - current); for (int k = 0; k < nnew; k++) { Vector3i pos = new Vector3i(rand.RandomRange(min.x, max.x), 0, rand.RandomRange(min.z, max.z)); pos = Geo3D.Surface(pos, iniy); if (GameManager.Instance.World.GetTerrainHeight(pos.x, pos.z) > 2) { Printer.Log(40, "Ghost", pos, opt.OptionEntity.entity, opt.OptionEntity.buff); Emplacement place = Emplacement.At(Vectors.ToFloat(pos) + 2f * Vectors.Float.UnitY, Vectors.Float.UnitY); GhostData gdata = (ghost_type == "") ? this.GhostData : GhostData.Ghosts[ghost_type]; yield return(EntityGhost.Create(gdata, place, opt.OptionEntity.entity)); } yield return(Repeater.Yield); } } }
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 override IEnumerator _Next(EntityPlayer player) { /* Over should keep some memory (position), and regenerate toward player */ long start_time = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(); Emplacement placeBase = new Emplacement(player, opt); placeBase.direction = Vectors.Float.Randomize(this.rand, 1f); // useless for peak Printer.Log(46, "MultiEffect._Next() placeBase", player, placeBase.position, placeBase.direction); foreach (int p in Cycler.Over()) { if (Cycler.dt >= 0 && DateTimeOffset.UtcNow.ToUnixTimeMilliseconds() - start_time > (long)(Cycler.dt * 1000)) { yield break; } Printer.Log(41, "_Next iterating Over"); Vector3 maybeFollowing = (this.isFollowing) ? player.GetPosition() : placeBase.position; int q = -1; foreach (Emplacement place in Iter.On(Placer.Get(maybeFollowing))) { q = q + 1; if (q >= Repeater.n) { break; } if (place.valid) { Printer.Log(40, "MultiEffect._Next iterating Clones", place); // last before null (firestorm) // float state = ((float) q) / Repeater.copies; OptionEffect rdm = Randomize(); Printer.Log(40, "_Next Randomized", p, q, opt); Printer.Log(40, "_Next Place", p, q, place); this.Effect1(player, place, rdm); } else { Printer.Log(40, "Invalid place:", q, place, place.valid_msg); } yield return(Repeater.Yield); } yield return(Cycler.Yield); } }
public static void SetHome(ClientInfo _cInfo) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; Vector3 _position = _player.GetPosition(); string x = _position.x.ToString(); string y = _position.y.ToString(); string z = _position.z.ToString(); string _sposition = x + "," + y + "," + z; PersistentContainer.Instance.Players[_cInfo.playerId, true].HomePosition = _sposition; PersistentContainer.Instance.Save(); string _phrase10; if (!Phrases.Dict.TryGetValue(10, out _phrase10)) { _phrase10 = "{PlayerName} your home has been saved."; } _phrase10 = _phrase10.Replace("{PlayerName}", _cInfo.playerName); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("{1}{0}[-]", _phrase10, CustomCommands.ChatColor), "Server", false, "", false)); }
/* ******************** Item ******************** */ public static void spawnItem(EntityPlayer player, string item) { //EntityPlayerLocal player = GameManager.Instance.World.GetPrimaryPlayer(); // if(entityAlive is EntityPlayerLocal) // base.ItemController in ItemActionEntryResharpenSDX : BaseItemActionEntry // using System;using System.Globalization;using System.Xml;using UnityEngine; // item = "meleeToolClawHammer"; ItemStack itemStack = new ItemStack(ItemClass.GetItem(item, false), 1); // this.CreateItemCount //player.world.gameManager.ItemDropServer(itemStack, player.GetPosition(), Vector3.zero, -1, 60f, false); //invData.gameManager.ItemDropServer(new ItemStack(holdingEntity.inventory.holdingItemItemValue, 1), vector, Vector3.zero, // lookVector * _actionData.m_ThrowStrength, holdingEntity.entityId, 60f, true, -1); /* ItemDropServer( * ItemStack _itemStack, * Vector3 _dropPos, Vector3 _randomPosAdd, Vector3 _initialMotion, * int _entityId = -1, * float _lifetime = 60f * bool _bDropPosIsRelativeToHead = false, int _clientInstanceId = 0); */ player.world.gameManager.ItemDropServer( itemStack, player.GetPosition() + new Vector3(1.0f, 0.2f, 0.0f), Vector3.zero, new Vector3(1, -1, 0), player.entityId, // -1 plante (pour gagner XP ?) 1f, false, 0); //if (!LocalPlayerUI.GetUIForPlayer(player).xui.PlayerInventory.AddItem(itemStack, true)) // Argument 1: cannot convert from 'EntityPlayer' to 'EntityPlayerLocal' //{ // player.world.gameManager.ItemDropServer(itemStack, player.GetPosition(), Vector3.zero, -1, 60f, false); //} }
public static void SetHome1(ClientInfo _cInfo) { if (!Event.Teams.ContainsKey(_cInfo.playerId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_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 _vec3i = new Vector3i(x, y, z); if (PersistentOperations.ClaimedByAllyOrSelf(_cInfo.playerId, _vec3i)) { string _sposition = x + "," + y + "," + z; PersistentContainer.Instance.Players[_cInfo.playerId].HomePosition1 = _sposition; PersistentContainer.Instance.Save(); string _phrase10; if (!Phrases.Dict.TryGetValue(10, out _phrase10)) { _phrase10 = "Your home has been saved."; } ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase10 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { string _phrase817; if (!Phrases.Dict.TryGetValue(817, out _phrase817)) { _phrase817 = "You are not inside your own or an ally's claimed space. You can not save this as your home."; } ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase817 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } else { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "You can not use home commands while signed up for or inside an event.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }