public static void DonatorRad(ClientInfo _cInfo, EntityPlayer _player) { if ((0 - _player.position.x) * (0 - _player.position.x) + (0 - _player.position.z) * (0 - _player.position.z) >= Reserved * Reserved) { int _vec3x, _vec3z; if (_player.position.x >= 0) { _vec3x = (int)_player.position.x - 6; } else { _vec3x = (int)_player.position.x + 6; } if (_player.position.z >= 0) { _vec3z = (int)_player.position.z - 6; } else { _vec3z = (int)_player.position.z + 6; } _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_vec3x, -1, _vec3z), null, false)); string _phrase790; if (!Phrases.Dict.TryGetValue(790, out _phrase790)) { _phrase790 = " you have reached the world border."; } _phrase790 = _phrase790.Replace("{PlayerName}", _cInfo.playerName); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase790 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Global, null); } }
public static void SendBack(ClientInfo _cInfo) { if (MarketPlayers.Contains(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { string _lastPos = PersistentContainer.Instance.Players[_cInfo.playerId].MarketReturnPos; if (_lastPos != "") { int x, y, z; string[] _returnCoords = _lastPos.Split(','); int.TryParse(_returnCoords[0], out x); int.TryParse(_returnCoords[1], out y); int.TryParse(_returnCoords[2], out z); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); MarketPlayers.Remove(_cInfo.entityId); PersistentContainer.Instance.Players[_cInfo.playerId].MarketReturnPos = ""; PersistentContainer.Instance.Save(); } else { Phrases.Dict.TryGetValue(255, out string _phrase255); _phrase255 = _phrase255.Replace("{CommandPrivate}", ChatHook.Command_Private); _phrase255 = _phrase255.Replace("{Command51}", Command51); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase255 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } else { Phrases.Dict.TryGetValue(253, out string _phrase253); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase253 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
public static void FriendWaypoint(ClientInfo _cInfo) { DateTime _dt; Invite.TryGetValue(_cInfo.entityId, out _dt); { TimeSpan varTime = DateTime.Now - _dt; double fractionalMinutes = varTime.TotalMinutes; int _timepassed = (int)fractionalMinutes; if (_timepassed <= 2) { string _pos; FriendPosition.TryGetValue(_cInfo.entityId, out _pos); { int x, y, z; string[] _cords = _pos.Split(','); int.TryParse(_cords[0], out x); int.TryParse(_cords[1], out y); int.TryParse(_cords[2], out z); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); Invite.Remove(_cInfo.entityId); FriendPosition.Remove(_cInfo.entityId); } } else { Invite.Remove(_cInfo.entityId); FriendPosition.Remove(_cInfo.entityId); Phrases.Dict.TryGetValue(288, out string _phrase288); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase288 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } }
public static void SendBack(ClientInfo _cInfo) { if (LobbyPlayers.Contains(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { string _lastPos = PersistentContainer.Instance.Players[_cInfo.playerId].LobbyReturnPos; if (_lastPos != "") { int x, y, z; string[] _returnCoords = _lastPos.Split(','); int.TryParse(_returnCoords[0], out x); int.TryParse(_returnCoords[1], out y); int.TryParse(_returnCoords[2], out z); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); LobbyPlayers.Remove(_cInfo.entityId); PersistentContainer.Instance.Players[_cInfo.playerId].LobbyReturnPos = ""; } else { LobbyPlayers.Remove(_cInfo.entityId); Phrases.Dict.TryGetValue(246, out string _phrase246); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase246 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } else { Phrases.Dict.TryGetValue(246, out string _phrase246); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase246 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } }
public static void PlayerLoginRPC_Prefix(string _playerId, out bool __state) { __state = false; try { if (_playerId != null && _playerId.Length == 17) { int __maxPlayers = GamePrefs.GetInt(EnumGamePrefs.ServerMaxPlayerCount); if (ReservedSlots.IsEnabled && ConnectionManager.Instance.ClientCount() > __maxPlayers) { if (ReservedSlots.FullServer(_playerId)) { GamePrefs.Set(EnumGamePrefs.ServerMaxPlayerCount, __maxPlayers + 1); __state = true; return; } } if (NewPlayer.IsEnabled && NewPlayer.Block_During_Bloodmoon && SkyManager.BloodMoon()) { PersistentPlayerData _ppd = PersistentOperations.GetPersistentPlayerDataFromSteamId(_playerId); if (_ppd == null) { ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(_playerId); if (_cInfo != null) { _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackagePlayerDenied>().Setup(new GameUtils.KickPlayerData(GameUtils.EKickReason.ManualKick, 0, default, "[ServerTools] - New players are kicked during the bloodmoon. Please return after the bloodmoon is over")));
/*internal static bool RemovePlayerFromTeam(Team.Member player) * { * foreach (string id in Teams.Keys) * { * RemovePlayerFromTeam(player, id); * } * return true; * }*/ internal static void RemovePlayerAfterDisconnect(string pId, string teamId) { if (Teams[teamId] == null) { return; } int entityId = 0; Team.Member toRemove = null; foreach (Team.Member member in Teams[teamId].members) { if (member.pId == pId) { entityId = member.entityId; toRemove = member; break; } } if (toRemove == null) { return; } Teams[teamId].RemoveMember(toRemove); foreach (Team.Member member in Teams[teamId].members) { member.ClientInfo().SendPackage(NetPackageManager.GetPackage <NetPackagePartyData>().Setup(member.EntityPlayer().Party, entityId, NetPackagePartyData.PartyActions.Disconnected, member.EntityPlayer().Party.MemberList.Count == 0)); } }
public static void StatusCheck() { if (Jailed.Count > 0) { for (int i = 0; i < Jailed.Count; i++) { ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForPlayerId(Jailed[i]); if (_cInfo != null) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player.Spawned) { int _x, _y, _z; string[] _cords = Jail_Position.Split(','); int.TryParse(_cords[0], out _x); int.TryParse(_cords[1], out _y); int.TryParse(_cords[2], out _z); Vector3 _vector3 = _player.position; if ((_x - _vector3.x) * (_x - _vector3.x) + (_z - _vector3.z) * (_z - _vector3.z) >= Jail_Size * Jail_Size || _vector3.y > _y + Jail_Size || _vector3.y < _y + Jail_Size) { _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_x, _y, _z), null, false)); if (Jail_Shock) { _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageConsoleCmdClient>().Setup("buff buffShocked", true)); Phrases.Dict.TryGetValue(198, out string _phrase198); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase198 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } } } } }
public static void TeleFriend(ClientInfo _cInfo, int _friendToTele) { ClientInfo _cInfo2 = ConnectionManager.Instance.Clients.ForEntityId(_friendToTele); if (_cInfo2 != null) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { _cInfo2.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3((int)_player.position.x, (int)_player.position.y, (int)_player.position.z), null, false)); if (Wallet.IsEnabled && Command_Cost >= 1) { Wallet.SubtractCoinsFromWallet(_cInfo2.playerId, Command_Cost); } PersistentContainer.Instance.Players[_cInfo2.playerId].LastFriendTele = DateTime.Now; PersistentContainer.Instance.Save(); Phrases.Dict.TryGetValue(367, out string _phrase367); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase367 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue(371, out string _phrase371); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase371 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
public static void SendBack(ClientInfo _cInfo) { if (MarketPlayers.Contains(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { string _lastPos = PersistentContainer.Instance.Players[_cInfo.playerId].MarketReturnPos; if (_lastPos != "") { int x, y, z; string[] _returnCoords = _lastPos.Split(','); int.TryParse(_returnCoords[0], out x); int.TryParse(_returnCoords[1], out y); int.TryParse(_returnCoords[2], out z); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); MarketPlayers.Remove(_cInfo.entityId); PersistentContainer.Instance.Players[_cInfo.playerId].MarketReturnPos = ""; PersistentContainer.Instance.Save(); string _phrase555; if (!Phrases.Dict.TryGetValue(555, out _phrase555)) { _phrase555 = " sent you back to your saved location."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase555 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } } else { ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + " you have no saved return point.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
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 or more, found {0}", _params.Count)); return; } ClientInfo cInfo = PersistentOperations.GetClientInfoFromNameOrId(_params[0]); if (cInfo != null) { _params.RemoveAt(0); string command = string.Join(" ", _params); cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageConsoleCmdClient>().Setup(string.Format("{0}", command), true)); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Ran console command '{0}' on id '{1}' '{2}' named {3}", command, cInfo.PlatformId.CombinedString, cInfo.CrossplatformId.CombinedString, cInfo.playerName)); } else { Log.Out(string.Format("[SERVERTOOLS] Unable to locate '{0}' online", _params[0])); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in ClientConsoleCommandConsole.Execute: {0}", e.Message)); } }
public static void SendBack(ClientInfo _cInfo) { if (LobbyPlayers.Contains(_cInfo.entityId)) { EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId); if (player != null) { string lastPos = PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LobbyReturnPos; if (lastPos != "") { string[] returnCoords = lastPos.Split(','); int.TryParse(returnCoords[0], out int x); int.TryParse(returnCoords[1], out int y); int.TryParse(returnCoords[2], out int z); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); LobbyPlayers.Remove(_cInfo.entityId); PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LobbyReturnPos = ""; PersistentContainer.DataChange = true; } else { LobbyPlayers.Remove(_cInfo.entityId); Phrases.Dict.TryGetValue("Lobby6", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } else { Phrases.Dict.TryGetValue("Lobby6", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } }
public static void Time(ClientInfo _cInfo, int _timePassed, int _timeAllowed) { if (_timePassed <= _timeAllowed) { string _deathPos; if (Victim.TryGetValue(_cInfo.entityId, out _deathPos)) { int x, y, z; string[] _cords = _deathPos.Split(','); int.TryParse(_cords[0], out x); int.TryParse(_cords[1], out y); int.TryParse(_cords[2], out z); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); Victim.Remove(_cInfo.entityId); } } else { string _phrase811; if (!Phrases.Dict.TryGetValue(606, out _phrase811)) { _phrase811 = "You can only use {CommandPrivate}{Command50} for {Time} minutes after being killed in a pve zone. Time has expired."; } _phrase811 = _phrase811.Replace("{PlayerName}", _cInfo.playerName); _phrase811 = _phrase811.Replace("{CommandPrivate}", ChatHook.Command_Private); _phrase811 = _phrase811.Replace("{Command50}", Zones.Command50); _phrase811 = _phrase811.Replace("{Time}", _timeAllowed.ToString()); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase811 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); Victim.Remove(_cInfo.entityId); } }
private static void RandomItem(ClientInfo _cInfo) { try { string _randomItem = list.RandomObject(); ItemValue _itemValue = new ItemValue(ItemClass.GetItem(_randomItem, false).type, false); int[] _itemData; if (Dict.TryGetValue(_randomItem, out _itemData)) { int _count = 0; if (_itemData[0] > _itemData[1]) { _count = random.Next(_itemData[1], _itemData[0] + 1); } else { _count = random.Next(_itemData[0], _itemData[1] + 1); } if (_itemValue.HasQuality && _itemData[2] > 0 && _itemData[3] >= _itemData[2]) { _itemValue.Quality = random.Next(_itemData[2], _itemData[3] + 1); } var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData { entityClass = EntityClass.FromString("item"), id = EntityFactory.nextEntityID++, itemStack = new ItemStack(_itemValue, _count), pos = GameManager.Instance.World.Players.dict[_cInfo.entityId].position, rot = new Vector3(20f, 0f, 20f), lifetime = 60f, belongsPlayerId = _cInfo.entityId }); GameManager.Instance.World.SpawnEntityInWorld(entityItem); _cInfo.SendPackage(NetPackageManager.GetPackage<NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId)); GameManager.Instance.World.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Despawned); if (Wallet.IsEnabled && Command_Cost >= 1) { Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost); } PersistentContainer.Instance.Players[_cInfo.playerId].LastGimme = DateTime.Now; PersistentContainer.Instance.Save(); Phrases.Dict.TryGetValue(22, out string _phrase22); _phrase22 = _phrase22.Replace("{ItemCount}", _count.ToString()); Dict1.TryGetValue(_randomItem, out string _name); if (_name != "") { _phrase22 = _phrase22.Replace("{ItemName}", _name); } else { _phrase22 = _phrase22.Replace("{ItemName}", _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.Name); } ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase22 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Gimme.RandomItem: {0}", e.Message)); } }
public static void Exec() { if (ConnectionManager.Instance.ClientCount() > 0) { List <ClientInfo> ClientInfoList = ConnectionManager.Instance.Clients.List.ToList(); for (int i = 0; i < ClientInfoList.Count; i++) { ClientInfo _cInfo = ClientInfoList[i]; EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; int x = (int)_player.position.x; int y = (int)_player.position.y; int z = (int)_player.position.z; if (WaterCheck(_cInfo, _player, x, y, z)) { if (Flag.Contains(_cInfo.entityId)) { _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, -1, z), null, false)); Flag.Remove(_cInfo.entityId); } else { Flag.Add(_cInfo.entityId); } } else { if (Flag.Contains(_cInfo.entityId)) { Flag.Remove(_cInfo.entityId); } } } } }
public static void DonatorRad(ClientInfo _cInfo, EntityPlayer _player) { if ((0 - _player.position.x) * (0 - _player.position.x) + (0 - _player.position.z) * (0 - _player.position.z) >= Reserved * Reserved) { int vec3x, vec3z; if (_player.position.x >= 0) { vec3x = (int)_player.position.x - 6; } else { vec3x = (int)_player.position.x + 6; } if (_player.position.z >= 0) { vec3z = (int)_player.position.z - 6; } else { vec3z = (int)_player.position.z + 6; } _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(vec3x, -1, vec3z), null, false)); Phrases.Dict.TryGetValue("WorldRadius1", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } }
public static void RewardWarriors() { List <int> _warriors = WarriorList; for (int i = 0; i < _warriors.Count; i++) { int _warrior = _warriors[i]; EntityAlive _player = GameManager.Instance.World.Players.dict[_warrior]; if (_player != null && _player.IsAlive()) { int _killedZ; KilledZombies.TryGetValue(_warrior, out _killedZ); if (_killedZ >= Zombie_Kills && _player.Died > 0) { ClientInfo _cInfo = ConnectionManager.Instance.Clients.ForEntityId(_warrior); if (_cInfo != null) { int _deathCount = _player.Died - 1; _player.Died = _deathCount; _player.bPlayerStatsChanged = true; _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackagePlayerStats>().Setup(_player)); WarriorList.Remove(_warrior); KilledZombies.Remove(_warrior); 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); } } } if (WarriorList.Contains(_warrior)) { WarriorList.Remove(_warrior); KilledZombies.Remove(_warrior); } } }
public static void Spawn(ClientInfo _cInfo) { if (Teams.TryGetValue(_cInfo.playerId, out int _team)) { if (EventCommandsConsole.Setup.TryGetValue(Operator, out List <string> _setup)) { string _spawnPosition = _setup[_team + 4]; string[] _cords = _spawnPosition.Split(','); int.TryParse(_cords[0], out int _x); int.TryParse(_cords[1], out int _y); int.TryParse(_cords[2], out int _z); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_x, _y, _z), null, false)); PersistentContainer.Instance.Players[_cInfo.playerId].EventSpawn = false; PersistentContainer.Instance.Save(); Phrases.Dict.TryGetValue(785, out string _phrase785); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase785 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { PersistentContainer.Instance.Players[_cInfo.playerId].EventSpawn = false; PersistentContainer.Instance.Save(); Phrases.Dict.TryGetValue(786, out string _phrase786); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase786 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
//private static void PutPlayerInJail(ClientInfo _cInfo, ClientInfo _PlayertoJail) //{ // string[] cords = Jail_Position.Split(','); // int.TryParse(cords[0], out int x); // int.TryParse(cords[1], out int y); // int.TryParse(cords[2], out int z); // _PlayertoJail.SendPackage(NetPackageManager.GetPackage<NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); // Jailed.Add(_PlayertoJail.CrossplatformId.CombinedString); // PersistentContainer.Instance.Players[_PlayertoJail.CrossplatformId.CombinedString].JailTime = 60; // PersistentContainer.Instance.Players[_PlayertoJail.CrossplatformId.CombinedString].JailName= _PlayertoJail.playerName; // PersistentContainer.Instance.Players[_PlayertoJail.CrossplatformId.CombinedString].JailDate = DateTime.Now; // PersistentContainer.DataChange = true; // Phrases.Dict.TryGetValue("Jail1", out string phrase); // ChatHook.ChatMessage(_PlayertoJail, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); // if (Jail_Shock) // { // Phrases.Dict.TryGetValue("Jail8", out phrase); // ChatHook.ChatMessage(_PlayertoJail, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); // } // Phrases.Dict.TryGetValue("Jail6", out phrase); // phrase = phrase.Replace("{PlayerName}", _PlayertoJail.playerName); // ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); //} public static void StatusCheck() { if (Jailed.Count > 0) { for (int i = 0; i < Jailed.Count; i++) { ClientInfo cInfo = PersistentOperations.GetClientInfoFromNameOrId(Jailed[i]); if (cInfo != null) { EntityPlayer player = PersistentOperations.GetEntityPlayer(cInfo.entityId); if (player.Spawned && player.IsAlive()) { string[] cords = Jail_Position.Split(','); int.TryParse(cords[0], out int x); int.TryParse(cords[1], out int y); int.TryParse(cords[2], out int z); Vector3 vector = player.position; if ((x - vector.x) * (x - vector.x) + (z - vector.z) * (z - vector.z) >= Jail_Size * Jail_Size) { cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); if (Jail_Shock) { cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageConsoleCmdClient>().Setup("buff buffShocked", true)); Phrases.Dict.TryGetValue("Jail9", out string phrase); ChatHook.ChatMessage(cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } } } } }
public static void TeleFriend(ClientInfo _cInfo, int _friendToTele) { ClientInfo _cInfo2 = ConnectionManager.Instance.Clients.ForEntityId(_friendToTele); if (_cInfo2 != null) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { _cInfo2.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3((int)_player.position.x, (int)_player.position.y, (int)_player.position.z), null, false)); if (Wallet.IsEnabled && Command_Cost >= 1) { Wallet.SubtractCoinsFromWallet(_cInfo2.playerId, Command_Cost); } PersistentContainer.Instance.Players[_cInfo2.playerId].LastFriendTele = DateTime.Now; PersistentContainer.Instance.Save(); string _phrase631; if (!Phrases.Dict.TryGetValue(631, out _phrase631)) { _phrase631 = "Your request was accepted. Teleported you to your friend."; } ChatHook.ChatMessage(_cInfo2, LoadConfig.Chat_Response_Color + _phrase631 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "Unable to complete request. Friend was not found online" + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
public static void NormalRad(ClientInfo _cInfo, EntityPlayer _player) { if ((0 - _player.position.x) * (0 - _player.position.x) + (0 - _player.position.z) * (0 - _player.position.z) >= Normal_Player * Normal_Player) { int _vec3x, _vec3z; if (_player.position.x >= 0) { _vec3x = (int)_player.position.x - 6; } else { _vec3x = (int)_player.position.x + 6; } if (_player.position.z >= 0) { _vec3z = (int)_player.position.z - 6; } else { _vec3z = (int)_player.position.z + 6; } _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_vec3x, -1, _vec3z), null, false)); Phrases.Dict.TryGetValue(1021, out string _phrase1021); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase1021 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } }
private static void PutPlayerInJail(ClientInfo _cInfo, ClientInfo _PlayertoJail) { string[] _cords = Jail_Position.Split(','); int _x, _y, _z; int.TryParse(_cords[0], out _x); int.TryParse(_cords[1], out _y); int.TryParse(_cords[2], out _z); _PlayertoJail.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_x, _y, _z), null, false)); Jailed.Add(_PlayertoJail.playerId); PersistentContainer.Instance.Players[_PlayertoJail.playerId].JailTime = 60; PersistentContainer.Instance.Players[_PlayertoJail.playerId].JailName = _PlayertoJail.playerName; PersistentContainer.Instance.Players[_PlayertoJail.playerId].JailDate = DateTime.Now; PersistentContainer.Instance.Save(); Phrases.Dict.TryGetValue(190, out string _phrase190); ChatHook.ChatMessage(_PlayertoJail, LoadConfig.Chat_Response_Color + _phrase190 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); if (Jail_Shock) { Phrases.Dict.TryGetValue(197, out string _phrase197); ChatHook.ChatMessage(_PlayertoJail, LoadConfig.Chat_Response_Color + _phrase197 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } Phrases.Dict.TryGetValue(195, out string _phrase195); _phrase195 = _phrase195.Replace("{PlayerName}", _PlayertoJail.playerName); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase195 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); }
private static void FHome2(ClientInfo _cInfo, string _pos) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { FriendInvite(_cInfo, _player.position, _pos); int x, y, z; string[] _cords = _pos.Split(','); int.TryParse(_cords[0], out x); int.TryParse(_cords[1], out y); int.TryParse(_cords[2], out z); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); if (Wallet.IsEnabled && Command_Cost >= 1) { Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost); } if (Home2_Delay) { PersistentContainer.Instance.Players[_cInfo.playerId].LastHome1 = DateTime.Now; } else { PersistentContainer.Instance.Players[_cInfo.playerId].LastHome2 = DateTime.Now; } PersistentContainer.Instance.Save(); string _phrase818; if (!Phrases.Dict.TryGetValue(818, out _phrase818)) { _phrase818 = " you are traveling home."; } ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _phrase818 + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
public static void ReturnBlock(ClientInfo _cInfo, string _blockName, int _quantity) { EntityPlayer _player = PersistentOperations.GetEntityPlayer(_cInfo.playerId); if (_player != null && _player.IsSpawned() && !_player.IsDead()) { World _world = GameManager.Instance.World; ItemValue _itemValue = ItemClass.GetItem(_blockName, false); if (_itemValue != null) { var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData { entityClass = EntityClass.FromString("item"), id = EntityFactory.nextEntityID++, itemStack = new ItemStack(_itemValue, _quantity), pos = _world.Players.dict[_cInfo.entityId].position, rot = new Vector3(20f, 0f, 20f), lifetime = 60f, belongsPlayerId = _cInfo.entityId }); _world.SpawnEntityInWorld(entityItem); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId)); _world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Despawned); Phrases.Dict.TryGetValue(901, out string _phrase901); _phrase901 = _phrase901.Replace("{Value}", _quantity.ToString()); _phrase901 = _phrase901.Replace("{ItemName}", _itemValue.ItemClass.GetLocalizedItemName() ?? _itemValue.ItemClass.Name); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase901 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } }
public static void FriendHome(ClientInfo _cInfo) { DateTime _dt; Invite.TryGetValue(_cInfo.entityId, out _dt); { TimeSpan varTime = DateTime.Now - _dt; double fractionalMinutes = varTime.TotalMinutes; int _timepassed = (int)fractionalMinutes; if (_timepassed <= 2) { string _pos; FriendPosition.TryGetValue(_cInfo.entityId, out _pos); { int x, y, z; string[] _cords = _pos.Split(','); int.TryParse(_cords[0], out x); int.TryParse(_cords[1], out y); int.TryParse(_cords[2], out z); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); Invite.Remove(_cInfo.entityId); FriendPosition.Remove(_cInfo.entityId); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " sending you to your friend's home.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { Invite.Remove(_cInfo.entityId); FriendPosition.Remove(_cInfo.entityId); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + " you have run out of time to accept your friend's home invitation.[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } }
public static void TeleNewSpawn(ClientInfo _cInfo, EntityPlayer _player) { if (!PersistentContainer.Instance.Players[_cInfo.playerId].NewSpawn) { if (Return) { Vector3 Vec3 = _player.position; string _position = (int)_player.position.x + "," + (int)_player.position.y + "," + (int)_player.position.z; PersistentContainer.Instance.Players[_cInfo.playerId].NewSpawnPosition = _position; } string[] _cords = New_Spawn_Tele_Position.Split(','); int x, y, z; int.TryParse(_cords[0], out x); int.TryParse(_cords[1], out y); int.TryParse(_cords[2], out z); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); PersistentContainer.Instance.Players[_cInfo.playerId].NewSpawn = true; PersistentContainer.Instance.Save(); Phrases.Dict.TryGetValue(212, out string _phrase212); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase212 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); if (Return) { Phrases.Dict.TryGetValue(213, out string _phrase213); _phrase213 = _phrase213.Replace("{CommandPrivate}", ChatHook.Command_Private); _phrase213 = _phrase213.Replace("{Command86}", Command86); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase213 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } }
public static void EventSpawn(ClientInfo _cInfo) { if (Open) { int _team; if (PlayersTeam.TryGetValue(_cInfo.playerId, out _team)) { string _sql = string.Format("SELECT eventid FROM Events WHERE eventActive = 'true'"); DataTable _result1 = SQL.TypeQuery(_sql); int _eventid; int.TryParse(_result1.Rows[0].ItemArray.GetValue(0).ToString(), out _eventid); _result1.Dispose(); _sql = string.Format("SELECT eventSpawn FROM EventSpawns WHERE eventid = {0} AND eventTeam = {1}", _eventid, _team); DataTable _result2 = SQL.TypeQuery(_sql); string _pos = _result2.Rows[0].ItemArray.GetValue(0).ToString(); _result2.Dispose(); int _x, _y, _z; string[] _cords = _pos.Split(','); int.TryParse(_cords[0], out _x); int.TryParse(_cords[1], out _y); int.TryParse(_cords[2], out _z); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_x, _y, _z), null, false)); _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "Event"); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", you have been sent to your event spawn point.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { string _sql = string.Format("UPDATE Players SET eventSpawn = 'false' WHERE steamid = '{0}'", _cInfo.playerId); SQL.FastQuery(_sql, "Event"); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + ", the event ended while you were offline or not spawned.[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
private static void Exec(ClientInfo _cInfo, string _waypoint, Vector3 _position, bool _friends) { if (PersistentContainer.Instance.Players[_cInfo.playerId].Waypoints != null && PersistentContainer.Instance.Players[_cInfo.playerId].Waypoints.ContainsKey(_waypoint)) { Dictionary <string, string> _waypoints = PersistentContainer.Instance.Players[_cInfo.playerId].Waypoints; _waypoints.TryGetValue(_waypoint, out string _waypointPos); if (_friends) { FriendInvite(_cInfo, _position, _waypointPos); } string[] _cords = _waypointPos.Split(','); int.TryParse(_cords[0], out int _x); int.TryParse(_cords[1], out int _y); int.TryParse(_cords[2], out int _z); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(_x, _y, _z), null, false)); PersistentContainer.Instance.Players[_cInfo.playerId].LastWaypoint = DateTime.Now; PersistentContainer.Instance.Save(); if (Wallet.IsEnabled && Command_Cost >= 1) { Wallet.SubtractCoinsFromWallet(_cInfo.playerId, Command_Cost); } } else { Phrases.Dict.TryGetValue(274, out string _phrase274); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase274 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }
public static void TeleToSurface(ClientInfo _cInfo, EntityPlayer _player) { _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3((int)_player.position.x, -1, (int)_player.position.z), null, false)); PersistentContainer.Instance.Players[_cInfo.playerId].LastStuck = DateTime.Now; Phrases.Dict.TryGetValue(553, out string _phrase553); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase553 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); }
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 ShopPurchase(ClientInfo _cInfo, string _itemName, int _count, int _quality, int _price, int currentCoins) { World world = GameManager.Instance.World; ItemValue itemValue = new ItemValue(ItemClass.GetItem(_itemName).type, _quality, _quality, false, null, 1); int _maxAllowed = itemValue.ItemClass.Stacknumber.Value; if (_count <= _maxAllowed) { var entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData { entityClass = EntityClass.FromString("item"), id = EntityFactory.nextEntityID++, itemStack = new ItemStack(itemValue, _count), pos = world.Players.dict[_cInfo.entityId].position, rot = new Vector3(20f, 0f, 20f), lifetime = 60f, belongsPlayerId = _cInfo.entityId }); world.SpawnEntityInWorld(entityItem); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageEntityCollect>().Setup(entityItem.entityId, _cInfo.entityId)); world.RemoveEntity(entityItem.entityId, EnumRemoveEntityReason.Killed); Wallet.SubtractCoinsFromWallet(_cInfo.playerId, _price); Log.Out(string.Format("Sold {0} to {1}.", itemValue.ItemClass.GetLocalizedItemName() ?? itemValue.ItemClass.Name, _cInfo.playerName)); string _message = "{Count} {Item} was purchased through the shop. If your bag is full, check the ground."; _message = _message.Replace("{Count}", _count.ToString()); _message = _message.Replace("{Item}", itemValue.ItemClass.GetLocalizedItemName() ?? itemValue.ItemClass.Name); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _message + "[-]", _cInfo.entityId, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { string _message = " you can only withdraw a full stack at a time. The maximum stack size is {Max}."; _message = _message.Replace("{Max}", _maxAllowed.ToString()); ChatHook.ChatMessage(_cInfo, ChatHook.Player_Name_Color + _cInfo.playerName + LoadConfig.Chat_Response_Color + _message + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } }