private static void SetBuff(ClientInfo _cInfo) { try { if (Dict.Count > 0) { List <string> Keys = new List <string>(Dict.Keys); string randomKey = Keys[Random.Next(Dict.Count)]; string message = Dict[randomKey]; SingletonMonoBehaviour <SdtdConsole> .Instance.ExecuteSync(string.Format("buffplayer {0} {1}", _cInfo.CrossplatformId.CombinedString, randomKey), null); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + message + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); if (Wallet.IsEnabled && Command_Cost >= 1) { Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, Command_Cost); } PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastPrayer = DateTime.Now; PersistentContainer.DataChange = true; } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Prayer.SetBuff: {0}", e.Message)); } }
public static void BuyLife(ClientInfo _cInfo) { try { EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId); if (player != null) { if (Max_Extra_Lives > 0) { if (PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].HardcoreEnabled) { string[] stats = PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].HardcoreStats; int.TryParse(stats[2], out int extraLives); if (extraLives < Max_Extra_Lives) { if (Life_Price < 0) { Life_Price = 0; } int cost = Life_Price * extraLives++; if (Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString) >= cost) { Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, cost); stats[2] = (extraLives + 1).ToString(); PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].HardcoreStats = stats; PersistentContainer.DataChange = true; Phrases.Dict.TryGetValue("Hardcore7", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } else { Phrases.Dict.TryGetValue("Hardcore8", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue("Hardcore9", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue("Hardcore10", out string _phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue("Hardcore9", out string _phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Hardcore.BuyLife: {0}", e.Message)); } }
public static void NewLotto(ClientInfo _cInfo, string _message) { if (!ShuttingDown) { if (OpenLotto) { int winnings = LottoValue * LottoEntries.Count; Phrases.Dict.TryGetValue("Lottery2", out string phrase); phrase = phrase.Replace("{Value1}", winnings.ToString()); phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name); phrase = phrase.Replace("{Value2}", LottoValue.ToString()); phrase = phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1); phrase = phrase.Replace("{Command_lottery_enter}", Command_lottery_enter); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } else { if (int.TryParse(_message, out int _lottoValue)) { if (_lottoValue > 0) { if (Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString) >= _lottoValue) { OpenLotto = true; LottoValue = _lottoValue; LottoEntries.Add(_cInfo); Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, LottoValue); Phrases.Dict.TryGetValue("Lottery4", out string phrase); phrase = phrase.Replace("{Value}", _lottoValue.ToString()); phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); Phrases.Dict.TryGetValue("Lottery5", out phrase); phrase = phrase.Replace("{Value}", LottoValue.ToString()); phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name); phrase = phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1); phrase = phrase.Replace("{Command_lottery_enter}", Command_lottery_enter); ChatHook.ChatMessage(null, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } else { Phrases.Dict.TryGetValue("Lottery6", out string phrase); phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue("Lottery3", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue("Lottery3", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } }
private static void Exec(ClientInfo _cInfo, string _waypoint, Vector3 _position, bool _friends, int _cost) { try { if (PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Waypoints != null && PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Waypoints.ContainsKey(_waypoint)) { Dictionary <string, string> waypoints = PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Waypoints; waypoints.TryGetValue(_waypoint, out string 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); if (_friends) { FriendInvite(_cInfo, _position, waypointPos); } _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastWaypoint = DateTime.Now; PersistentContainer.DataChange = true; if (Wallet.IsEnabled && _cost >= 1) { Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, _cost); } } else if (Dict.ContainsKey(_waypoint)) { Dict.TryGetValue(_waypoint, out string[] waypointData); string[] cords = waypointData[0].Split(','); int.TryParse(cords[0], out int x); int.TryParse(cords[1], out int y); int.TryParse(cords[2], out int z); if (_friends) { FriendInvite(_cInfo, _position, waypointData[0]); } _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(x, y, z), null, false)); PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastWaypoint = DateTime.Now; PersistentContainer.DataChange = true; if (Wallet.IsEnabled && _cost >= 1) { Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, _cost); } } else { Phrases.Dict.TryGetValue("Waypoints4", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Waypoints.Exec: {0}", e.Message)); } }
public static void ShopPurchase(ClientInfo _cInfo, string _itemName, string _secondaryName, int _count, int _quality, int _price) { try { World world = GameManager.Instance.World; ItemValue itemValue = new ItemValue(ItemClass.GetItem(_itemName).type); if (itemValue.HasQuality) { itemValue.Quality = 1; if (_quality > 0) { itemValue.Quality = _quality; } } 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.Despawned); Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, _price); Log.Out(string.Format("Sold '{0}' to '{1}' '{2}' named '{3}' through the shop", itemValue.ItemClass.Name, _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName)); Phrases.Dict.TryGetValue("Shop16", out string _phrase); _phrase = _phrase.Replace("{Count}", _count.ToString()); if (_secondaryName != "") { _phrase = _phrase.Replace("{Item}", _secondaryName); } else { _phrase = _phrase.Replace("{Item}", itemValue.ItemClass.GetLocalizedItemName() ?? itemValue.ItemClass.GetItemName()); } ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Shop.ShopPurchase: {0}", e.Message)); } }
public static void EnterLotto(ClientInfo _cInfo) { if (OpenLotto) { if (Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString) >= LottoValue) { if (!LottoEntries.Contains(_cInfo)) { LottoEntries.Add(_cInfo); Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, LottoValue); Phrases.Dict.TryGetValue("Lottery7", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); if (LottoEntries.Count == 8) { StartLotto(); } } else { Phrases.Dict.TryGetValue("Lottery8", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue("Lottery6", out string phrase); phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue("Lottery1", out string phrase); phrase = phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1); phrase = phrase.Replace("{Command_lottery}", Command_lottery); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } }
public static void TeleFriend(ClientInfo _cInfo, int _invitingFriend) { ClientInfo cInfo2 = PersistentOperations.GetClientInfoFromEntityId(_invitingFriend); if (cInfo2 != null) { EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId); if (player != null) { if (Wallet.IsEnabled && Command_Cost >= 1) { if (Wallet.GetCurrency(cInfo2.CrossplatformId.CombinedString) >= Command_Cost) { Wallet.RemoveCurrency(cInfo2.CrossplatformId.CombinedString, Command_Cost); } else { Phrases.Dict.TryGetValue("FriendTeleport10", out string phrase); phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name); ChatHook.ChatMessage(cInfo2, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return; } } Phrases.Dict.TryGetValue("FriendTeleport7", out string phrase1); ChatHook.ChatMessage(cInfo2, Config.Chat_Response_Color + phrase1 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); cInfo2.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3((int)player.position.x, (int)player.position.y, (int)player.position.z), null, false)); PersistentContainer.Instance.Players[cInfo2.CrossplatformId.CombinedString].LastFriendTele = DateTime.Now; PersistentContainer.DataChange = true; } } else { Phrases.Dict.TryGetValue("FriendTeleport11", out string _phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } }
public override void Execute(List <string> _params, CommandSenderInfo _senderInfo) { try { if (_params.Count < 1 || _params.Count > 2) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wrong number of arguments, expected 1 or 2, found '{0}'", _params.Count)); return; } if (_params[0].ToLower().Equals("off")) { if (Wallet.IsEnabled) { Wallet.IsEnabled = false; Config.WriteXml(); Config.LoadXml(); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wallet has been set to off")); return; } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wallet is already off")); return; } } else if (_params[0].ToLower().Equals("on")) { if (!Wallet.IsEnabled) { Wallet.IsEnabled = true; Config.WriteXml(); Config.LoadXml(); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wallet has been set to on")); return; } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Wallet is already on")); return; } } else if (_params[0].ToLower().Equals("all")) { bool negative = false; if (_params[1].Contains("-")) { _params[1].Replace("-", ""); negative = true; } if (!int.TryParse(_params[1], out int adjustCoins)) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Can not adjust wallet. Value '{0}' is invalid", _params[1])); } else { List <ClientInfo> clientList = PersistentOperations.ClientList(); if (clientList != null) { for (int i = 0; i < clientList.Count; i++) { ClientInfo cInfo = clientList[i]; if (cInfo != null) { if (negative) { if (Wallet.GetCurrency(cInfo.CrossplatformId.CombinedString) >= adjustCoins) { Wallet.RemoveCurrency(cInfo.CrossplatformId.CombinedString, adjustCoins); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Removed '{0}' '{1}' from Id '{2}' named '{3}'", _params[1], Wallet.Currency_Name, cInfo.CrossplatformId.CombinedString, cInfo.playerName)); } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Unable to remove '{0}' '{1}'. Target '{2}' named '{3}' does not have enough", _params[1], Wallet.Currency_Name, cInfo.CrossplatformId.CombinedString, cInfo.playerName)); } return; } else { Wallet.AddCurrency(cInfo.CrossplatformId.CombinedString, adjustCoins); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Added '{0}' '{1}' to id '{2}' named '{3}'", _params[1], Wallet.Currency_Name, cInfo.CrossplatformId.CombinedString, cInfo.playerName)); return; } } } } } } else if (_params.Count == 2) { if (_params[1].Length < 1 || _params[1].Length > 6) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Can not adjust wallet. Value '{0}' is invalid", _params[1])); return; } bool negative = false; if (_params[1].Contains("-")) { _params[1].Replace("-", ""); negative = true; } if (!int.TryParse(_params[1], out int adjustCoins)) { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Can not adjust wallet. Value '{0}' is invalid", _params[1])); return; } if (_params[0].Contains("_")) { PersistentPlayer p = PersistentContainer.Instance.Players[_params[0]]; if (p != null) { if (negative) { Wallet.RemoveCurrency(_params[0], adjustCoins); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Removed '{0}' '{1}' from Id '{2}'", _params[1], Wallet.Currency_Name, _params[0])); } else { Wallet.AddCurrency(_params[0], adjustCoins); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Added '{0}' '{1}' to wallet '{2}'", _params[1], Wallet.Currency_Name, _params[0])); } } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Id not found '{0}'", _params[0])); } } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Invalid Id '{0}'", _params[0])); } } else if (_params.Count == 1) { if (_params[0].Contains("_")) { ClientInfo cInfo = PersistentOperations.GetClientInfoFromNameOrId(_params[0]); if (cInfo != null) { int currentWallet = Wallet.GetCurrency(cInfo.CrossplatformId.CombinedString); SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Id '{0}' named '{1}' has '{2}' '{3}'", _params[0], cInfo.playerName, currentWallet, Wallet.Currency_Name)); } } } else { SingletonMonoBehaviour <SdtdConsole> .Instance.Output(string.Format("[SERVERTOOLS] Invalid argument '{0}'", _params[0])); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in WalletConsole.Execute: {0}", e.Message)); } }
private static void Init10(string _playerId, int _amount) { Wallet.RemoveCurrency(_playerId, _amount); }
public static void Bet(ClientInfo _cInfo) { try { if (Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString) < Command_Cost) { Phrases.Dict.TryGetValue("Gamble3", out string phrase); phrase = phrase.Replace("{Value}", Command_Cost.ToString()); phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return; } else { DateTime lastgamble = new DateTime(); if (PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastGamble != null) { lastgamble = PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastGamble; } TimeSpan varTime = DateTime.Now - lastgamble; double fractionalMinutes = varTime.TotalMinutes; int timepassed = (int)fractionalMinutes; int delay = Delay_Between_Uses; if (ReservedSlots.IsEnabled && ReservedSlots.Reduced_Delay && ReservedSlots.Dict.ContainsKey(_cInfo.PlatformId.CombinedString) || ReservedSlots.Dict.ContainsKey(_cInfo.CrossplatformId.CombinedString)) { if (ReservedSlots.Dict.TryGetValue(_cInfo.PlatformId.ReadablePlatformUserIdentifier, out DateTime dt)) { if (DateTime.Now < dt) { delay = Delay_Between_Uses / 2; } } else if (ReservedSlots.Dict.TryGetValue(_cInfo.CrossplatformId.ReadablePlatformUserIdentifier, out dt)) { if (DateTime.Now < dt) { delay = Delay_Between_Uses / 2; } } } if (timepassed >= delay) { int[] pot; if (Dict.ContainsKey(_cInfo.CrossplatformId.CombinedString)) { Dict.TryGetValue(_cInfo.CrossplatformId.CombinedString, out pot); } else { pot = new int[] { 1, 0 }; } Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, Command_Cost); int gamble = Random.Next(pot[0] + 1); if (gamble == 1) { int winnings = Command_Cost * 2; if (pot[1] > 0) { winnings = pot[1] * 2; } if (!Dict.ContainsKey(_cInfo.CrossplatformId.CombinedString)) { Dict.Add(_cInfo.CrossplatformId.CombinedString, new int[] { pot[0] + 1, winnings }); } else { Dict[_cInfo.CrossplatformId.CombinedString] = new int[] { pot[0] + 1, winnings }; } Phrases.Dict.TryGetValue("Gamble5", out string phrase); phrase = phrase.Replace("{Number}", pot[0].ToString()); phrase = phrase.Replace("{Value}", winnings.ToString()); phrase = phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1); phrase = phrase.Replace("{Command_gamble_payout}", Command_gamble_payout); phrase = phrase.Replace("{Command_gamble_bet}", Command_gamble_bet); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } else { if (Dict.ContainsKey(_cInfo.CrossplatformId.CombinedString)) { Dict.Remove(_cInfo.CrossplatformId.CombinedString); } PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastGamble = DateTime.Now; PersistentContainer.DataChange = true; Phrases.Dict.TryGetValue("Gamble6", out string phrase); phrase = phrase.Replace("{Number}", pot[0].ToString()); phrase = phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1); phrase = phrase.Replace("{Command_gamble_bet}", Command_gamble_bet); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { int remaining = delay - timepassed; Phrases.Dict.TryGetValue("Gamble7", out string phrase); phrase = phrase.Replace("{DelayBetweenUses}", delay.ToString()); phrase = phrase.Replace("{TimeRemaining}", remaining.ToString()); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Gamble.Bet: {0}", e.Message)); } }
public static void TeleVehicle(ClientInfo _cInfo, Entity _player, int _vehicleId) { Entity entity = PersistentOperations.GetEntity(_vehicleId); if (entity != null && entity is EntityVehicle) { if (entity.AttachedToEntity != null) { Phrases.Dict.TryGetValue("VehicleRecall10", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return; } EntityVehicle vehicle = (EntityVehicle)entity; if (entity.GetDistance(_player) <= Distance) { if (Wallet.IsEnabled && Command_Cost >= 1) { Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, Command_Cost); } int delay = Delay_Between_Uses; vehicle.SetPosition(new Vector3(_player.position.x + 1, _player.position.y, _player.position.z + 1)); if (ReservedSlots.IsEnabled && ReservedSlots.Reduced_Delay) { if (ReservedSlots.Dict.ContainsKey(_cInfo.PlatformId.CombinedString) || ReservedSlots.Dict.ContainsKey(_cInfo.CrossplatformId.CombinedString)) { if (ReservedSlots.Dict.TryGetValue(_cInfo.PlatformId.CombinedString, out DateTime dt)) { if (DateTime.Now < dt) { delay = Delay_Between_Uses / 2; } } } else if (ReservedSlots.Dict.TryGetValue(_cInfo.CrossplatformId.CombinedString, out DateTime dt)) { if (DateTime.Now < dt) { delay = Delay_Between_Uses / 2; } } } PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Vehicles[_vehicleId] = new string[] { vehicle.EntityClass.entityClassName, DateTime.Now.AddMinutes(delay).ToString() }; Phrases.Dict.TryGetValue("VehicleRecall11", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); PersistentContainer.DataChange = true; } else { Phrases.Dict.TryGetValue("VehicleRecall12", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { List <EntityVehicle> vehicleList = vehiclesActive(VehicleManager.Instance); if (vehicleList != null && vehicleList.Count > 0) { for (int i = 0; i < vehicleList.Count; i++) { if (vehicleList[i].entityId == _vehicleId) { if (vehicleList[i].GetDistance(_player) <= Distance) { if (Wallet.IsEnabled && Command_Cost >= 1) { Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, Command_Cost); } int delay = Delay_Between_Uses; vehicleList[i].SetPosition(new Vector3(_player.position.x + 1, _player.position.y, _player.position.z + 1)); if (ReservedSlots.IsEnabled && ReservedSlots.Reduced_Delay) { if (ReservedSlots.Dict.ContainsKey(_cInfo.PlatformId.CombinedString) || ReservedSlots.Dict.ContainsKey(_cInfo.CrossplatformId.CombinedString)) { if (ReservedSlots.Dict.TryGetValue(_cInfo.PlatformId.CombinedString, out DateTime dt)) { if (DateTime.Now < dt) { delay = Delay_Between_Uses / 2; } } } else if (ReservedSlots.Dict.TryGetValue(_cInfo.CrossplatformId.CombinedString, out DateTime dt)) { if (DateTime.Now < dt) { delay = Delay_Between_Uses / 2; } } } PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Vehicles[_vehicleId] = new string[] { vehicleList[i].EntityClass.entityClassName, DateTime.Now.AddMinutes(delay).ToString() }; Phrases.Dict.TryGetValue("VehicleRecall11", out string phrase2); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase2 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); PersistentContainer.DataChange = true; } else { Phrases.Dict.TryGetValue("VehicleRecall12", out string phrase2); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase2 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } return; } } } List <EntityCreationData> vehicleListData = vehiclesUnloaded(VehicleManager.Instance); if (vehicleListData != null && vehicleListData.Count > 0) { for (int i = 0; i < vehicleListData.Count; i++) { if (vehicleListData[i].id == _vehicleId) { if (Vector3.Distance(vehicleListData[i].pos, _player.position) <= Distance) { if (Wallet.IsEnabled && Command_Cost >= 1) { Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, Command_Cost); } int delay = Delay_Between_Uses; vehicleListData[i].pos = new Vector3(_player.position.x + 1, _player.position.y, _player.position.z + 1); EntityVehicle vehicle = EntityFactory.CreateEntity(vehicleListData[i]) as EntityVehicle; vehiclesActive(VehicleManager.Instance).Add(vehicle); GameManager.Instance.World.SpawnEntityInWorld(vehicle); vehiclesUnloaded(VehicleManager.Instance).RemoveAt(i); if (ReservedSlots.IsEnabled && ReservedSlots.Reduced_Delay) { if (ReservedSlots.Dict.ContainsKey(_cInfo.PlatformId.CombinedString) || ReservedSlots.Dict.ContainsKey(_cInfo.CrossplatformId.CombinedString)) { if (ReservedSlots.Dict.TryGetValue(_cInfo.PlatformId.CombinedString, out DateTime dt)) { if (DateTime.Now < dt) { delay = Delay_Between_Uses / 2; } } } else if (ReservedSlots.Dict.TryGetValue(_cInfo.CrossplatformId.CombinedString, out DateTime dt)) { if (DateTime.Now < dt) { delay = Delay_Between_Uses / 2; } } } PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].Vehicles[_vehicleId] = new string[] { vehicle.EntityClass.entityClassName, DateTime.Now.AddMinutes(delay).ToString() }; Phrases.Dict.TryGetValue("VehicleRecall11", out string phrase3); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase3 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); PersistentContainer.DataChange = true; } else { Phrases.Dict.TryGetValue("VehicleRecall12", out string phrase3); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase3 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } return; } } } Phrases.Dict.TryGetValue("VehicleRecall14", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } }
public static void GiveAnimals(ClientInfo _cInfo) { try { if (Animal_Ids.Length > 0) { string[] animalList = { }; List <string> animalId = new List <string>(); if (Animal_Ids.Contains(",")) { string[] animals = Animal_Ids.Split(','); for (int i = 0; i < animals.Length; i++) { animalId.Add(animals[i]); } } else { animalId.Add(Animal_Ids); } int minRad = 0; int maxRad = 0; if (Maximum_Spawn_Radius < Minimum_Spawn_Radius) { minRad = 40; maxRad = 60; } else { minRad = Minimum_Spawn_Radius; maxRad = Maximum_Spawn_Radius; } int r = new System.Random().Next(1, animalId.Count + 1); int.TryParse(animalId[r], out int randomId); int nextRadius = new System.Random().Next(minRad, maxRad + 1); Dictionary <int, EntityClass> .KeyCollection entityTypesCollection = EntityClass.list.Dict.Keys; int counter = 1; foreach (int i in entityTypesCollection) { EntityClass eClass = EntityClass.list[i]; if (!eClass.bAllowUserInstantiate) { continue; } if (randomId == counter) { EntityPlayer entityPlayer = PersistentOperations.GetEntityPlayer(_cInfo.entityId); if (entityPlayer != null) { if (SpawnAnimal(_cInfo, entityPlayer, nextRadius, randomId)) { if (Wallet.IsEnabled && Command_Cost >= 1) { Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, Command_Cost); } PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastAnimal = DateTime.Now; PersistentContainer.DataChange = true; break; } } } counter++; } } else { Phrases.Dict.TryGetValue("AnimalTracking4", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Animals.GiveAnimals: {0}", e.Message)); } }
private static void LobbyTele(ClientInfo _cInfo) { if (Lobby_Position != "0,0,0" && Lobby_Position != "0 0 0" && Lobby_Position != "") { EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId); if (player != null) { if (!LobbyPlayers.Contains(_cInfo.entityId)) { if (Player_Check) { if (Teleportation.PCheck(_cInfo, player)) { return; } } if (Zombie_Check) { if (Teleportation.ZCheck(_cInfo, player)) { return; } } if (!Teleportation.Teleporting.Contains(_cInfo.entityId)) { Teleportation.Teleporting.Add(_cInfo.entityId); } int x, y, z; if (Return) { 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.CrossplatformId.CombinedString].LobbyReturnPos = pposition; PersistentContainer.DataChange = true; Phrases.Dict.TryGetValue("Lobby3", out string phrase); phrase = phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1); phrase = phrase.Replace("{Command_lobbyback}", Command_lobbyback); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } string[] cords = Lobby_Position.Split(',').ToArray(); if (int.TryParse(cords[0], out int i)) { if (int.TryParse(cords[1], out int j)) { if (int.TryParse(cords[2], out int k)) { _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(i, j, k), null, false)); if (Wallet.IsEnabled && Command_Cost >= 1) { Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, Command_Cost); } PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastLobby = DateTime.Now; PersistentContainer.DataChange = true; } } } } else { Phrases.Dict.TryGetValue("Lobby10", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } else { Phrases.Dict.TryGetValue("Lobby5", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } }
public static void NewBounty(ClientInfo _cInfo, string _message) { try { if (_message.Contains(" ")) { string[] idAndBounty = _message.Split(' ').ToArray(); if (int.TryParse(idAndBounty[0], out int id)) { if (int.TryParse(idAndBounty[1], out int bounty)) { ClientInfo cInfo2 = ConnectionManager.Instance.Clients.ForEntityId(id); if (cInfo2 != null) { if (bounty < Minimum_Bounty) { bounty = Minimum_Bounty; } int currentCoins = Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString); if (currentCoins >= bounty) { Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, bounty); int _currentbounty = PersistentContainer.Instance.Players[cInfo2.CrossplatformId.CombinedString].Bounty; PersistentContainer.Instance.Players[cInfo2.CrossplatformId.CombinedString].Bounty = _currentbounty + bounty; PersistentContainer.DataChange = true; using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8)) { sw.WriteLine(string.Format("{0}: '{1}' named '{2}' added '{3}' bounty to '{4}' '{5}' named '{6}'", DateTime.Now, _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName, bounty, cInfo2.PlatformId.CombinedString, cInfo2.CrossplatformId.CombinedString, cInfo2.playerName)); sw.WriteLine(); sw.Flush(); sw.Close(); } Phrases.Dict.TryGetValue("Bounties5", out string phrase); phrase = phrase.Replace("{Value}", bounty.ToString()); phrase = phrase.Replace("{PlayerName}", cInfo2.playerName); ChatHook.ChatMessage(null, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Global, null); } else { Phrases.Dict.TryGetValue("Bounties4", out string phrase); phrase = phrase.Replace("{Value}", bounty.ToString()); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } else { Phrases.Dict.TryGetValue("Bounties6", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } else { if (int.TryParse(_message, out int _id)) { ClientInfo cInfo2 = ConnectionManager.Instance.Clients.ForEntityId(_id); if (cInfo2 != null) { int currentCoins = Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString); if (currentCoins >= Minimum_Bounty) { Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, Minimum_Bounty); int _currentbounty = PersistentContainer.Instance.Players[cInfo2.CrossplatformId.CombinedString].Bounty; PersistentContainer.Instance.Players[cInfo2.CrossplatformId.CombinedString].Bounty = _currentbounty + Minimum_Bounty; PersistentContainer.DataChange = true; using (StreamWriter sw = new StreamWriter(filepath, true, Encoding.UTF8)) { sw.WriteLine(string.Format("{0}: '{1}' '{2}' named '{3}' added '{4}' bounty to '{5}' '{6}' named '{7}'", DateTime.Now, _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName, Minimum_Bounty, cInfo2.PlatformId.CombinedString, cInfo2.CrossplatformId.CombinedString, cInfo2.playerName)); sw.WriteLine(); sw.Flush(); sw.Close(); } Phrases.Dict.TryGetValue("Bounties5", out string phrase); phrase = phrase.Replace("{Value}", Minimum_Bounty.ToString()); phrase = phrase.Replace("{PlayerName}", cInfo2.playerName); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } else { Phrases.Dict.TryGetValue("Bounties4", out string phrase); phrase = phrase.Replace("{Value}", Minimum_Bounty.ToString()); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Bounties.NewBounty: {0}", e.Message)); } }
public static void BagToBank(ClientInfo _cInfo, string _amount) { try { EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId); if (player != null) { if (int.TryParse(_amount, out int value)) { if (Wallet.GetCurrency(_cInfo.CrossplatformId.CombinedString) >= value) { Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, value); if (Deposit_Fee_Percent > 0) { float fee = value * ((float)Deposit_Fee_Percent / 100); int adjustedDeposit = value - (int)fee; AddCoinsToBank(_cInfo.CrossplatformId.CombinedString, adjustedDeposit); using (StreamWriter sw = new StreamWriter(Filepath, true, Encoding.UTF8)) { sw.WriteLine(string.Format("{0}: '{1}' '{2}' added '{3}' to their bank", DateTime.Now, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName, adjustedDeposit)); sw.WriteLine(); sw.Flush(); sw.Close(); } Phrases.Dict.TryGetValue("Bank3", out string phrase); phrase = phrase.Replace("{Value}", adjustedDeposit.ToString()); phrase = phrase.Replace("{Name}", Wallet.Currency_Name); phrase = phrase.Replace("{Percent}", Deposit_Fee_Percent.ToString()); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } else { AddCoinsToBank(_cInfo.CrossplatformId.CombinedString, value); using (StreamWriter sw = new StreamWriter(Filepath, true, Encoding.UTF8)) { sw.WriteLine(string.Format("{0}: '{1}' '{2}' added '{3}' to their bank", DateTime.Now, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName, value)); sw.WriteLine(); sw.Flush(); sw.Close(); } Phrases.Dict.TryGetValue("Bank4", out string phrase); phrase = phrase.Replace("{Value}", value.ToString()); phrase = phrase.Replace("{Name}", Wallet.Currency_Name); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue("Bank5", out string phrase); phrase = phrase.Replace("{Name}", Wallet.Currency_Name); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue("Bank6", out string _phrase); _phrase = _phrase.Replace("{Command_Prefix1}", ChatHook.Chat_Command_Prefix1); _phrase = _phrase.Replace("{Command_deposit}", Command_deposit); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Bank.ChestToBankDeposit: {0}", e.Message)); } }
public static void BuyAuction(ClientInfo _cInfo, int _purchase, int _price) { if (AuctionItems.TryGetValue(_purchase, out string id)) { if (PersistentContainer.Instance.Players[id].Auction != null && PersistentContainer.Instance.Players[id].Auction.Count > 0) { PersistentContainer.Instance.Players[id].Auction.TryGetValue(_purchase, out ItemDataSerializable itemData); ItemValue itemValue = new ItemValue(ItemClass.GetItem(itemData.name, false).type); if (itemValue != null) { if (itemValue.ItemClass.HasQuality) { itemValue.Quality = 1; if (itemData.quality > 0) { itemValue.Quality = itemData.quality; } } itemValue.UseTimes = itemData.useTimes; itemValue.Seed = itemData.seed; if (itemData.modSlots > 0) { itemValue.Modifications = new ItemValue[itemData.modSlots]; } if (itemData.cosmeticSlots > 0) { itemValue.CosmeticMods = new ItemValue[itemData.cosmeticSlots]; } World world = GameManager.Instance.World; EntityItem entityItem = (EntityItem)EntityFactory.CreateEntity(new EntityCreationData { entityClass = EntityClass.FromString("item"), id = EntityFactory.nextEntityID++, itemStack = new ItemStack(itemValue, itemData.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.Despawned); AuctionItems.Remove(_purchase); PersistentContainer.Instance.Players[id].Auction.Remove(_purchase); PersistentContainer.Instance.AuctionPrices.Remove(_purchase); PersistentContainer.DataChange = true; Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, _price); float fee = _price * ((float)Tax / 100); int adjustedPrice = _price - (int)fee; Wallet.AddCurrency(id, adjustedPrice); string playerName = PersistentOperations.GetPlayerDataFileFromId(id).ecd.entityName; using (StreamWriter sw = new StreamWriter(Filepath, true, Encoding.UTF8)) { sw.WriteLine(string.Format("{0}: '{1}' '{2}' named '{3}' has purchased auction entry '{3}', profits went to id '{4}' named '{5}'", DateTime.Now, _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName, _purchase, id, playerName)); sw.WriteLine(); sw.Flush(); sw.Close(); } Phrases.Dict.TryGetValue("Auction9", out string phrase); phrase = phrase.Replace("{Count}", itemData.count.ToString()); phrase = phrase.Replace("{ItemName}", itemValue.ItemClass.GetLocalizedItemName() ?? itemValue.ItemClass.GetItemName()); phrase = phrase.Replace("{Value}", _price.ToString()); phrase = phrase.Replace("{CoinName}", Wallet.Currency_Name); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); ClientInfo cInfo2 = PersistentOperations.GetClientInfoFromNameOrId(id); if (cInfo2 != null) { Phrases.Dict.TryGetValue("Auction10", out string phrase1); ChatHook.ChatMessage(cInfo2, Config.Chat_Response_Color + phrase1 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } } }
private static void TeleportPlayer(ClientInfo _cInfo) { if (DeathTime.ContainsKey(_cInfo.entityId)) { if (DeathTime.TryGetValue(_cInfo.entityId, out DateTime _time)) { TimeSpan varTime = DateTime.Now - _time; double fractionalMinutes = varTime.TotalMinutes; int timepassed = (int)fractionalMinutes; if (ReservedSlots.IsEnabled && ReservedSlots.Reduced_Delay) { if (ReservedSlots.Dict.ContainsKey(_cInfo.PlatformId.CombinedString) || ReservedSlots.Dict.ContainsKey(_cInfo.CrossplatformId.CombinedString)) { if (ReservedSlots.Dict.TryGetValue(_cInfo.PlatformId.CombinedString, out DateTime dt)) { if (DateTime.Now < dt) { int newTime = timepassed / 2; timepassed = newTime; } } else if (ReservedSlots.Dict.TryGetValue(_cInfo.CrossplatformId.CombinedString, out dt)) { if (DateTime.Now < dt) { int newTime = timepassed / 2; timepassed = newTime; } } } } if (timepassed < Time) { if (LastDeathPos.TryGetValue(_cInfo.entityId, out string _value)) { string[] cords = _value.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)); DeathTime.Remove(_cInfo.entityId); LastDeathPos.Remove(_cInfo.entityId); if (Wallet.IsEnabled && Command_Cost >= 1) { Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, Command_Cost); } PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastDied = DateTime.Now; } } else { Phrases.Dict.TryGetValue("Died2", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } else { Phrases.Dict.TryGetValue("Died4", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } }
public static void Tele(ClientInfo _cInfo) { try { EntityPlayer player = PersistentOperations.GetEntityPlayer(_cInfo.entityId); if (player != null) { if (Dict.Count > 0) { int x = (int)player.position.x; int y = (int)player.position.y; int z = (int)player.position.z; foreach (KeyValuePair <string, string[]> travel in Dict) { string[] c1 = travel.Value[0].Split(','); int.TryParse(c1[0], out int x1); int.TryParse(c1[1], out int y1); int.TryParse(c1[2], out int z1); string[] c2 = travel.Value[1].Split(','); int.TryParse(c2[0], out int x2); int.TryParse(c2[1], out int y2); int.TryParse(c2[2], out int z2); if (x >= x1 && x <= x2 && y >= y1 && y <= y2 && z >= z1 && z <= z2) { if (Player_Check) { if (Teleportation.PCheck(_cInfo, player)) { return; } } if (Zombie_Check) { if (Teleportation.ZCheck(_cInfo, player)) { return; } } string[] destination = travel.Value[2].Split(','); int.TryParse(destination[0], out int destinationX); int.TryParse(destination[1], out int destinationY); int.TryParse(destination[2], out int destinationZ); _cInfo.SendPackage(NetPackageManager.GetPackage <NetPackageTeleportPlayer>().Setup(new Vector3(destinationX, destinationY, destinationZ), null, false)); if (Wallet.IsEnabled && Command_Cost >= 1) { Wallet.RemoveCurrency(_cInfo.CrossplatformId.CombinedString, Command_Cost); } PersistentContainer.Instance.Players[_cInfo.CrossplatformId.CombinedString].LastTravel = DateTime.Now; PersistentContainer.DataChange = true; Phrases.Dict.TryGetValue("Travel1", out string phrase); phrase = phrase.Replace("{Destination}", travel.Value[2]); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return; } } Phrases.Dict.TryGetValue("Travel2", out string phrase1); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase1 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); return; } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in Travel.Tele: {0}", e.Message)); } }