public static void List(ClientInfo _cInfo) { if (PrivateMutes.Count > 0) { foreach (var mute in PrivateMutes) { if (mute.Value.Contains(_cInfo.entityId)) { PlayerDataFile pdf = PersistentOperations.GetPlayerDataFileFromEntityId(mute.Key); if (pdf != null) { Phrases.Dict.TryGetValue("Mute9", out string phrase); phrase = phrase.Replace("{PlayerName}", pdf.ecd.entityName); phrase = phrase.Replace("{EntityId}", mute.Key.ToString()); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } else { Phrases.Dict.TryGetValue("Mute7", out string phrase); phrase = phrase.Replace("{EntityId}", mute.Key.ToString()); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } } }
public static void List(ClientInfo _cInfo) { if (PrivateMutes != null && PrivateMutes.Count > 0 && PrivateMutes.ContainsKey(_cInfo.entityId)) { List <int> _mutedPlayers; PrivateMutes.TryGetValue(_cInfo.entityId, out _mutedPlayers); if (_mutedPlayers != null && _mutedPlayers.Count > 0) { for (int i = 0; i < _mutedPlayers.Count; i++) { int _entityId = _mutedPlayers[i]; PlayerDataFile _pdf = PersistentOperations.GetPlayerDataFileFromEntityId(_entityId); if (_pdf != null) { Phrases.Dict.TryGetValue(759, out string _phrase759); _phrase759 = _phrase759.Replace("{PlayerName}", _pdf.ecd.entityName); _phrase759 = _phrase759.Replace("{EntityId}", _entityId.ToString()); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase759 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } } else { Phrases.Dict.TryGetValue(757, out string _phrase757); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase757 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } }
/// <summary> /// Default constructor. /// </summary> /// <param name="playerDataFile">PlayerDataFile to use</param> public ScorePanel(PlayerDataFile playerDataFile) { this.playerDataFile = playerDataFile; scoreBox = new NumericTextBox <int>(playerDataFile.score, 0 /*GetMinScore()*/, int.MaxValue, 60); LabeledControl labeledScoreBox = new LabeledControl("Score", scoreBox, 190); Controls.Add(labeledScoreBox); LabeledControl LabeledPlayerKillsBox = new LabeledControl("Player kills", new NumericTextBox <int>(playerDataFile.playerKills, 0, int.MaxValue, 60), 190); Controls.Add(LabeledPlayerKillsBox); LabeledControl labeledZombieKillsBox = new LabeledControl("Zombie kills", new NumericTextBox <int>(playerDataFile.zombieKills, 0, int.MaxValue, 60), 190); Controls.Add(labeledZombieKillsBox); LabeledControl labeledDeathsBox = new LabeledControl("Deaths", new NumericTextBox <int>(playerDataFile.deaths, 0, int.MaxValue, 60), 190); Controls.Add(labeledDeathsBox); Size = new Size(196, 140); /*playerDataFile.playerKills.AddListener(this); * playerDataFile.zombieKills.AddListener(this); * playerDataFile.deaths.AddListener(this);*/ }
public void NotifyPlayerDataSavedHandlers(ClientInfo _cInfo, PlayerDataFile _playerDataFile) { if (OnPlayerDataSaved != null) { OnPlayerDataSaved(_cInfo, _playerDataFile); } }
public static void Remove(ClientInfo _cInfo, string _player) { _player = _player.Replace(Command14 + " ", ""); if (!string.IsNullOrEmpty(_player)) { int _id; if (int.TryParse(_player, out _id)) { if (PrivateMutes != null && PrivateMutes.Count > 0 && PrivateMutes.ContainsKey(_cInfo.entityId)) { List <int> _mutedPlayers; PrivateMutes.TryGetValue(_cInfo.entityId, out _mutedPlayers); if (_mutedPlayers.Contains(_id)) { _mutedPlayers.Remove(_id); if (_mutedPlayers.Count > 0) { PrivateMutes[_cInfo.entityId] = _mutedPlayers; } else { PrivateMutes.Remove(_cInfo.entityId); } PersistentContainer.Instance.ClientMuteList = PrivateMutes; PersistentContainer.Instance.Save(); PlayerDataFile _pdf = PersistentOperations.GetPlayerDataFileFromEntityId(_id); if (_pdf != null) { Phrases.Dict.TryGetValue(754, out string _phrase754); _phrase754 = _phrase754.Replace("{PlayerName}", _pdf.ecd.entityName); _phrase754 = _phrase754.Replace("{EntityId}", _id.ToString()); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase754 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { Phrases.Dict.TryGetValue(755, out string _phrase755); _phrase755 = _phrase755.Replace("{EntityId}", _id.ToString()); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase755 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue(756, out string _phrase756); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase756 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue(757, out string _phrase757); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase757 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { Phrases.Dict.TryGetValue(758, out string _phrase758); _phrase758 = _phrase758.Replace("{EntityId}", _id.ToString()); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase758 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } }
public static void List(ClientInfo _cInfo) { if (PrivateMutes.Count > 0) { foreach (var _mute in PrivateMutes) { if (_mute.Value.Contains(_cInfo.entityId)) { PlayerDataFile _pdf = PersistentOperations.GetPlayerDataFileFromEntityId(_mute.Key); if (_pdf != null) { Phrases.Dict.TryGetValue(759, out string _phrase759); _phrase759 = _phrase759.Replace("{PlayerName}", _pdf.ecd.entityName); _phrase759 = _phrase759.Replace("{EntityId}", _mute.Key.ToString()); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase759 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } else { Phrases.Dict.TryGetValue(757, out string _phrase757); _phrase757 = _phrase757.Replace("{EntityId}", _mute.Key.ToString()); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + _phrase757 + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); } } } } }
public TabInventory(PlayerDataFile playerDataFile) { this.playerDataFile = playerDataFile; Text = "Inventory"; panel = new TableLayoutPanel(); panel.Dock = DockStyle.Fill; panel.AutoSize = true; panel.RowCount = 5; panel.ColumnCount = 8; for (int i = 0; i < 4; i++) { for (int j = 0; j < 8; j++) { ItemStack itemStack = playerDataFile.bag[i * 8 + j]; BinderItem itemBinder = new BinderItem(itemStack); SlotInventory slot = new SlotInventory(itemBinder, DataItem.getNameList()); panel.Controls.Add(slot, j, i); } } for (int i = 0; i < 8; i++) { ItemStack itemStack = playerDataFile.inventory[i]; BinderItem itemBinder = new BinderItem(itemStack); SlotInventory slot = new SlotInventory(itemBinder, DataItem.getNameList()); panel.Controls.Add(slot, i, 4); } Controls.Add(panel); }
private static bool PlayerLogin(ClientInfo _cInfo, string _message, StringBuilder _stringBuild)//Initiating player login { try { Log.Out("[SERVERTOOLS] Player connected"); if (StopServer.NoEntry) { SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Server is shutting down. Rejoin when it restarts\"", _cInfo.playerId), null); } if (NewPlayer.Block_During_Bloodmoon && PersistentOperations.BloodMoonSky()) { PlayerDataFile _pdf = PersistentOperations.GetPlayerDataFileFromSteamId(_cInfo.playerId); if (_pdf != null) { if (_pdf.totalTimePlayed < 5) { SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Currently in bloodmoon. Please join when it finishes\"", _cInfo.playerId), null); } } else { SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Currently in bloodmoon. Please join when it finishes\"", _cInfo.playerId), null); } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerLogin: {0}", e.Message)); } return(true); }
public static int GetCurrency(string _id) { int value = 0; ClientInfo cInfo = PersistentOperations.GetClientInfoFromNameOrId(_id); if (cInfo != null) { ItemStack[] stacks = cInfo.latestPlayerData.bag; for (int i = 0; i < stacks.Length; i++) { if (!stacks[i].IsEmpty() && stacks[i].itemValue.ItemClass.Name == PersistentOperations.Currency_Item) { value += stacks[i].count; } } } else { PlayerDataFile pdf = PersistentOperations.GetPlayerDataFileFromId(_id); if (pdf != null) { ItemStack[] stacks = pdf.bag; for (int i = 0; i < stacks.Length; i++) { if (!stacks[i].IsEmpty() && stacks[i].itemValue.ItemClass.Name == PersistentOperations.Currency_Item) { value += stacks[i].count; } } } } return(value); }
/// <summary> /// Saves a specific tab to specified location. /// </summary> /// <param name="tab">Tab to save</param> /// <param name="path">Path of the location to save the tab to</param> public void Save(PlayerTab tab, string path) { mainWindow.focusDummy.Focus(); bottomStatusBar.SetText("Saving..."); try { BackupFile(path); if (!path.EndsWith(".ttp")) { path += ".ttp"; } PlayerDataFile playerDataFile = tab.playerDataFile.Clone(); PostProcess(playerDataFile); playerDataFile.Write(path); tab.path = path; tab.fileName = path.Substring(path.LastIndexOf('\\') + 1); MessageBox.Show(string.Format("File {0} saved!", path.Substring(path.LastIndexOf('\\') + 1)), "Success!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (Exception e) { ErrorHandler.HandleError(string.Format("Failed to save file {0}. {1}", path.Substring(path.LastIndexOf('\\') + 1), e.Message), e, true, tab.path); } bottomStatusBar.Reset(); }
private static void SavePlayerData(ClientInfo _cInfo, PlayerDataFile _playerDataFile) { try { if (_cInfo != null && _playerDataFile != null) { if (HighPingKicker.IsEnabled) { HighPingKicker.Exec(_cInfo); } if (InventoryCheck.IsEnabled || InventoryCheck.Announce_Invalid_Stack) { InventoryCheck.CheckInv(_cInfo, _playerDataFile); } if (DupeLog.IsEnabled) { DupeLog.Exec(_cInfo, _playerDataFile); } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.SavePlayerData: {0}.", e.Message)); } }
public static IEnumerable <POI> FromTtpFile(string ttpFilename) { // Format eines Waypoints // Int32 X, Int32 Y, Int32 Z X=W/E, Y=0, Z=S/N // String icon (1 Byte Längenprefix, kein Nullterminator) // String name (1 Byte Längenprefix, kein Nullterminator) // Boolean tracked (belegt ein Byte) List <POI> pois = new List <POI>(); if (String.IsNullOrEmpty(ttpFilename) || !File.Exists(ttpFilename)) { return(pois); } try { var playerfile = new PlayerDataFile(ttpFilename); //dropped backpack if (playerfile.droppedBackpackPosition.x.Get() != 0 && playerfile.droppedBackpackPosition.z.Get() != 0) { var poi1 = new POI(playerfile.droppedBackpackPosition.z.Get(), playerfile.droppedBackpackPosition.x.Get(), "dropped_backpack", ""); pois.Add(poi1); } // spawn point -> bedroll if (playerfile.spawnPoints != null && playerfile.spawnPoints.Count > 0) { int index = (playerfile.selectedSpawnPointKey.Get() > 0) ? (int)playerfile.selectedSpawnPointKey.Get() : 0; var spawnpoint = playerfile.spawnPoints.ElementAt(index); if (spawnpoint.x.Get() != 0 && spawnpoint.z.Get() != 0) { var poi2 = new POI(spawnpoint.z.Get(), spawnpoint.x.Get(), "spawnposition", ""); pois.Add(poi2); } } // quick map marker if (playerfile.markerPosition.x.Get() != 0 && playerfile.markerPosition.z.Get() != 0) { var poi3 = new POI(playerfile.markerPosition.z.Get(), playerfile.markerPosition.x.Get(), "quickmarker", ""); pois.Add(poi3); } // waypoints var waypoints = playerfile.waypoints.waypointList; foreach (var waypoint in waypoints) { var poi = new POI(waypoint.pos.z.Get(), waypoint.pos.x.Get(), waypoint.icon.Get(), waypoint.name.Get()); pois.Add(poi); } } catch (Exception ex) { ; } // erstmal alle Fehler ignorieren und Map trotzdem rendern, bis ich ein besseres Verfahren zur Fehlermeldung habe (Logging) return(pois); }
public static void GM_SavePlayerData(ClientInfo _cInfo, PlayerDataFile _playerDataFile) { try { PersistentContainer.Instance.Players[_cInfo.playerId, true].Update (_playerDataFile); } catch (Exception e) { Log.Out ("Error in GM_SavePlayerData: " + e); } }
public void Update(PlayerDataFile pdf) { lock (this) { //Log.Out ("Updating player inventory - player id: " + pdf.id); ProcessInv (bag, pdf.bag, pdf.id); ProcessInv (belt, pdf.inventory, pdf.id); ProcessEqu (pdf.equipment, pdf.id); } }
public static void SavePlayerDataFile(string _playerId, PlayerDataFile _playerDataFile) { _playerDataFile.Save(GameUtils.GetPlayerDataDir(), _playerId.Trim()); ClientInfo _cInfo = GetClientInfoFromSteamId(_playerId); if (_cInfo != null) { ModEvents.SavePlayerData.Invoke(_cInfo, _playerDataFile); } }
public static void SavePlayerDataFile(string _id, PlayerDataFile _playerDataFile) { _playerDataFile.Save(GameIO.GetPlayerDataDir(), _id.Trim()); ClientInfo cInfo = GetClientInfoFromNameOrId(_id); if (cInfo != null) { ModEvents.SavePlayerData.Invoke(cInfo, _playerDataFile); } }
public override void SavePlayerData(ClientInfo _cInfo, PlayerDataFile _playerDataFile) { if (HighPingKicker.IsEnabled) { HighPingKicker.CheckPing(_cInfo); } if (InventoryCheck.IsEnabled) { InventoryCheck.CheckInv(_cInfo, _playerDataFile); } }
/// <summary> /// Opens a file. /// </summary> /// <param name="fileName">File to open</param> /// <param name="playerDataFile">Holds all the ttp info of a file</param> /// <param name="selectedIndex">Tab index to be selected after opening</param> private void OpenFile(string fileName, PlayerDataFile playerDataFile, int selectedIndex) { ItemStack[] inventory = playerDataFile.inventory; ItemStack[] bag = playerDataFile.bag; List <string> devItems = new List <string>(); for (int i = 0; i < bag.Length; i++) { ItemData devItem = ItemData.GetDevItemById(bag[i].itemValue.type.Get()); if (devItem != null) { devItems.Add(string.Format("{0} at position: row {1}, column {2}\n", devItem.name, (i / 8) + 1, (i % 8) + 1)); } } for (int i = 0; i < inventory.Length; i++) { ItemData devItem = ItemData.GetDevItemById(inventory[i].itemValue.type.Get()); if (devItem != null) { devItems.Add(string.Format("{0} at position: row 5, column {1}\n", devItem.name, i + 1)); } } if (devItems.Count == 0) { try { PlayerTab tab = new PlayerTab(playerDataFile, fileName, selectedIndex); playerTabControl.AddTab(tab); } catch (Exception e) { ErrorHandler.HandleError(string.Format("Failed to open file {0}. {1}", fileName, e.Message), e, true, fileName); } } else { // Split the full path into an array where the last element will be the short filename string[] fullPathFileNameArray = fileName.Split('\\'); // Capture the short filename from the last element of the array string shortFileName = fullPathFileNameArray[fullPathFileNameArray.Length - 1]; string text = string.Format("Player file {0} has the following developer items in their inventory:\n\n", shortFileName); for (int i = 0; i < devItems.Count; i++) { text += devItems[i] + "\n"; } text += "\nPlease remove these items before continuing."; MessageBox.Show(text, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }
public static PlayerDataFile GetPlayerDataFileFromUId(PlatformUserIdentifierAbs _uId) { PlayerDataFile playerDatafile = new PlayerDataFile(); playerDatafile.Load(GameIO.GetPlayerDataDir(), _uId.CombinedString.Trim()); if (playerDatafile != null) { return(playerDatafile); } return(null); }
public static void SavePlayerData(ClientInfo _cInfo, PlayerDataFile _playerDataFile) { try { PersistentContainer.Instance.Players[_cInfo.playerId, true].Update(_playerDataFile); } catch (Exception e) { Log.Out("" + Config.ModPrefix + " Error in DataManager." + MethodBase.GetCurrentMethod().Name + ": " + e); } }
public static void SavePlayerData(ClientInfo cInfo, PlayerDataFile playerDataFile) { try { PersistentContainer.Instance.Players[cInfo.playerId, true]?.Update(playerDataFile); } catch (Exception e) { Log.Out($"{Config.ModPrefix} Error in DataManager.{MethodBase.GetCurrentMethod().Name}: {e}"); } }
public static PlayerDataFile GetPlayerDataFile(string _playerId) { PlayerDataFile _playerDatafile = new PlayerDataFile(); _playerDatafile.Load(GameUtils.GetPlayerDataDir(), _playerId.Trim()); if (_playerDatafile != null) { return(_playerDatafile); } return(null); }
public static PlayerDataFile GetPlayerDataFileFromId(string _id) { if (ConsoleHelper.ParseParamPartialNameOrId(_id, out PlatformUserIdentifierAbs platformUserIdentifierAbs, out ClientInfo clientInfo, true) == 1 && platformUserIdentifierAbs != null) { PlayerDataFile playerDatafile = GetPlayerDataFileFromUId(platformUserIdentifierAbs); if (playerDatafile != null) { return(playerDatafile); } } return(null); }
/// <summary> /// Creates an empty skill. /// </summary> /// <param name="id">Id of the skill</param> /// <param name="playerDataFile">PlayerDataFile to use</param> /// <returns></returns> public static Skill GetEmptySkill(int id, PlayerDataFile playerDataFile) { Skill skill = new Skill() { skillVersion = new Value <int>(2), id = new Value <int>(id), isLocked = new Value <bool>(false), parent = playerDataFile.skills, level = new Value <int>(0) }; SkillData skillData = SkillData.GetSkillDataById(id); skill.expToNextLevel = new Value <int>(skillData.expToLevel); if (skillData.requirements.Count > 0) { foreach (Requirement requirement in skillData.requirements) { if (requirement.perkLevel == 1) { String skillName = requirement.requiredSkillName; int requiredSkillLevel = 0; if (skillName.Equals("Player Level")) { requiredSkillLevel = playerDataFile.level.Get(); } else { int skillId = requirement.requiredSkillId; Skill requiredSkill; if (skill.parent.skillDictionary.TryGetValue(skillId, out requiredSkill)) { requiredSkillLevel = requiredSkill.level.Get(); } } if (requirement.requiredSkillLevel > requiredSkillLevel) { skill.isLocked.Set(true); return(skill); } } } } return(skill); }
public static void Remove(ClientInfo _cInfo, string _player) { _player = _player.Replace(Command14 + " ", ""); if (!string.IsNullOrEmpty(_player)) { int _id; if (int.TryParse(_player, out _id)) { if (PrivateMutes != null && PrivateMutes.Count > 0 && PrivateMutes.ContainsKey(_cInfo.entityId)) { List <int> _mutedPlayers; PrivateMutes.TryGetValue(_cInfo.entityId, out _mutedPlayers); if (_mutedPlayers.Contains(_id)) { _mutedPlayers.Remove(_id); if (_mutedPlayers.Count > 0) { PrivateMutes[_cInfo.entityId] = _mutedPlayers; } else { PrivateMutes.Remove(_cInfo.entityId); } PersistentContainer.Instance.ClientMuteList = PrivateMutes; PersistentContainer.Instance.Save(); PlayerDataFile _pdf = PersistentOperations.GetPlayerDataFileFromEntityId(_id); if (_pdf != null) { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + string.Format("You have removed player named {0} with id {1} from your mute list", _pdf.ecd.entityName, _id) + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); return; } ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + string.Format("You have removed a player with id {0} from your mute list", _id) + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } else { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "This player is not on your mute list" + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + "You have no muted players" + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } else { ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + string.Format("You must input a invalid id: {0}", _player) + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); } } }
public TabPlayer(PlayerDataFile playerDataFile, string path) : base() { populateStrings(path); this.playerDataFile = playerDataFile; Text = playerDataFile.ecd.entityName.get() + " (" + fileName + ") "; tabs = new TabControl(); tabs.Dock = DockStyle.Fill; tabs.Controls.Add(new TabInventory(playerDataFile)); tabs.Controls.Add(new TabSkills(playerDataFile)); Controls.Add(tabs); }
public static PlayerDataFile GetPlayerDataFileFromEntityId(int _entityId) { PersistentPlayerData persistentPlayerData = GetPersistentPlayerDataFromEntityId(_entityId); if (persistentPlayerData != null) { PlayerDataFile playerDatafile = new PlayerDataFile(); playerDatafile.Load(GameIO.GetPlayerDataDir(), persistentPlayerData.UserIdentifier.CombinedString.Trim()); if (playerDatafile != null) { return(playerDatafile); } } return(null); }
public override void SavePlayerData(ClientInfo _cInfo, PlayerDataFile _playerDataFile) { if (HighPingKicker.IsEnabled) { HighPingKicker.CheckPing(_cInfo); } if (InventoryCheck.IsEnabled || InventoryCheck.AnounceInvalidStack) { InventoryCheck.CheckInv(_cInfo, _playerDataFile); } if (Watchlist.IsEnabled) { Watchlist.CheckWatchlist(_cInfo); } }
public static PlayerDataFile GetPlayerDataFileFromEntityId(int _entityId) { PersistentPlayerData _persistentPlayerData = GetPersistentPlayerDataFromEntityId(_entityId); if (_persistentPlayerData != null) { PlayerDataFile _playerDatafile = new PlayerDataFile(); _playerDatafile.Load(GameUtils.GetPlayerDataDir(), _persistentPlayerData.PlayerId.Trim()); if (_playerDatafile != null) { return(_playerDatafile); } } return(null); }
public static void PlayerExit(string _id) { try { ClientInfo _cInfo = PersistentOperations.GetClientInfoFromSteamId(_id); if (_cInfo != null) { if (GameManager.Instance.World.Players.dict.ContainsKey(_cInfo.entityId)) { EntityPlayer _player = GameManager.Instance.World.Players.dict[_cInfo.entityId]; if (_player != null) { if (ExitPos.TryGetValue(_cInfo.playerId, out Vector3 _pos)) { ExitPos.Remove(_cInfo.playerId); if (_player.position != _pos) { Phrases.Dict.TryGetValue(671, out string _phrase671); ChatHook.ChatMessage(_cInfo, LoadConfig.Chat_Response_Color + _phrase671 + "[-]", -1, LoadConfig.Server_Response_Name, EChatType.Whisper, null); return; } } } } PlayerDataFile _playerDataFile = PersistentOperations.GetPlayerDataFileFromSteamId(_cInfo.playerId); if (_playerDataFile != null) { PersistentOperations.SavePlayerDataFile(_cInfo.playerId, _playerDataFile); } if (Exit.Contains(_cInfo.playerId)) { Exit.Remove(_cInfo.playerId); } if (ExitPos.ContainsKey(_cInfo.playerId)) { ExitPos.Remove(_cInfo.playerId); } Disconnect(_cInfo); } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in BattleLogger.PlayerExit: {0}", e.Message)); } }
public void SavePlayerData(ClientInfo _cInfo, PlayerDataFile _playerDataFile) { if (_cInfo != null) { if (HighPingKicker.IsEnabled) { HighPingKicker.CheckPing(_cInfo); } if (InventoryCheck.IsEnabled || InventoryCheck.Anounce_Invalid_Stack) { InventoryCheck.CheckInv(_cInfo, _playerDataFile); } if (DupeLog.IsEnabled) { DupeLog.Exec(_cInfo, _playerDataFile); } } }
private static bool PlayerLogin(ClientInfo _cInfo, string _message, StringBuilder _stringBuild)//Initiating player login { try { if (_cInfo != null && _cInfo.CrossplatformId != null) { if (Shutdown.NoEntry) { Phrases.Dict.TryGetValue("Shutdown4", out string phrase); ChatHook.ChatMessage(_cInfo, Config.Chat_Response_Color + phrase + "[-]", -1, Config.Server_Response_Name, EChatType.Whisper, null); SingletonMonoBehaviour <SdtdConsole> .Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.CrossplatformId.CombinedString, phrase), null); } if (NewPlayer.Block_During_Bloodmoon && PersistentOperations.IsBloodmoon() && ConnectionManager.Instance.ClientCount() > 1) { Phrases.Dict.TryGetValue("NewPlayer1", out string phrase); PlayerDataFile pdf = PersistentOperations.GetPlayerDataFileFromUId(_cInfo.CrossplatformId); if (pdf != null) { if (pdf.totalTimePlayed < 5) { SingletonMonoBehaviour <SdtdConsole> .Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.CrossplatformId.CombinedString, phrase), null); } } else { SingletonMonoBehaviour <SdtdConsole> .Instance.ExecuteSync(string.Format("kick {0} \"{1}\"", _cInfo.CrossplatformId.CombinedString, phrase), null); } } if (!string.IsNullOrEmpty(_cInfo.ip)) { Log.Out(string.Format("[SERVERTOOLS] Player connected with ID '{0}' '{1}' and IP '{2}' named '{3}'", _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.ip, _cInfo.playerName)); } else { Log.Out(string.Format("[SERVERTOOLS] Player connected with ID '{0}' '{1}' named '{2}'", _cInfo.PlatformId.CombinedString, _cInfo.CrossplatformId.CombinedString, _cInfo.playerName)); } } } catch (Exception e) { Log.Out(string.Format("[SERVERTOOLS] Error in API.PlayerLogin: {0}", e.Message)); } return(true); }
public void Update(PlayerDataFile _pdf) { PlayerData.bLoaded = _pdf.bLoaded; PlayerData.ecd = _pdf.ecd; PlayerData.inventory = _pdf.inventory; PlayerData.bag = _pdf.bag; PlayerData.equipment = _pdf.equipment; PlayerData.favoriteEquipment = _pdf.favoriteEquipment; PlayerData.selectedInventorySlot = _pdf.selectedInventorySlot; PlayerData.food = _pdf.food; PlayerData.drink = _pdf.drink; PlayerData.spawnPoints = _pdf.spawnPoints; PlayerData.selectedSpawnPointKey = _pdf.selectedSpawnPointKey; PlayerData.alreadyCraftedList = _pdf.alreadyCraftedList; PlayerData.unlockedRecipeList = _pdf.unlockedRecipeList; PlayerData.favoriteRecipeList = _pdf.favoriteRecipeList; PlayerData.lastSpawnPosition = _pdf.lastSpawnPosition; PlayerData.droppedBackpackPosition = _pdf.droppedBackpackPosition; PlayerData.playerKills = _pdf.playerKills; PlayerData.zombieKills = _pdf.zombieKills; PlayerData.deaths = _pdf.deaths; PlayerData.score = _pdf.score; PlayerData.id = _pdf.id; PlayerData.markerPosition = _pdf.markerPosition; PlayerData.experience = _pdf.experience; PlayerData.level = _pdf.level; PlayerData.skillPoints = _pdf.skillPoints; PlayerData.bCrouchedLocked = _pdf.bCrouchedLocked; PlayerData.craftingData = _pdf.craftingData; PlayerData.deathUpdateTime = _pdf.deathUpdateTime; PlayerData.bDead = _pdf.bDead; PlayerData.distanceWalked = _pdf.distanceWalked; PlayerData.totalItemsCrafted = _pdf.totalItemsCrafted; PlayerData.longestLife = _pdf.longestLife; PlayerData.currentLife = _pdf.currentLife; PlayerData.waypoints = _pdf.waypoints; PlayerData.questJournal = _pdf.questJournal; //PlayerData.IsModdedSave = _pdf.IsModdedSave; PlayerData.playerJournal = _pdf.playerJournal; PlayerData.rentedVMPosition = _pdf.rentedVMPosition; PlayerData.rentalEndTime = _pdf.rentalEndTime; PlayerData.trackedFriendEntityIds = _pdf.trackedFriendEntityIds; //PlayerData.skills = _pdf.skills; }
/// <summary> /// Default constructor. /// </summary> /// <param name="playerDataFile">PlayerDataFile to be used</param> public StatsPanel(PlayerDataFile playerDataFile) { Size = new Size(204, 262); Margin = new Padding(0); EntityStats stats = playerDataFile.ecd.stats; StatSlot health = new StatSlot(stats.health, "Health", 0f, stats.wellness); Controls.Add(health, 0, 0); StatSlot stamina = new StatSlot(stats.stamina, "Stamina", 0f, stats.wellness); Controls.Add(stamina, 0, 1); StatSlot wellness = new StatSlot(stats.wellness, "Wellness", 70f, null); Controls.Add(wellness, 0, 2); LiveStatSlot food = new LiveStatSlot(playerDataFile.food, "Food", 72); Controls.Add(food, 0, 3); LiveStatSlot water = new LiveStatSlot(playerDataFile.drink, "Water", 72); Controls.Add(water, 0, 4); StatSlot coreTemp = new StatSlot(stats.coreTemp, "Core Temp", 0f, null); Controls.Add(coreTemp, 0, 5); StatSlot speedModifier = new StatSlot(stats.speedModifier, "Speed Modifier", 0f, null); Controls.Add(speedModifier, 0, 6); StatSlot sickness = new StatSlot(stats.sickness, "Sickness (no effect)", 0f, null); Controls.Add(sickness, 0, 7); StatSlot gassiness = new StatSlot(stats.gassiness, "Gassiness (no effect)", 0f, null); Controls.Add(gassiness, 0, 8); }
private void openClick(object sender, System.EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = "7 Days to Die save file(*.ttp)|*.ttp|All Files(*.*)|*.*"; openFile.Multiselect = true; openFile.CheckFileExists = true; openFile.FileOk += (sender1, e1) => { statusBar.setText("Opening..."); foreach (string fileName in openFile.FileNames) { PlayerDataFile playerDataFile = new PlayerDataFile(fileName); ItemStack[] inventory = playerDataFile.inventory; ItemStack[] bag = playerDataFile.bag; bool hasDevItem = false; for (int i = 0; i < inventory.Length; i++) { if (DataItem.getDevItemById(inventory[i].itemValue.type.get()) != null) { hasDevItem = true; MessageBox.Show("You have a dev item in inventory slot row " + i / 4 + ", column " + i % 4 + ". Please remove it from inventory before using this program."); break; } } if (!hasDevItem) { for (int i = 0; i < bag.Length; i++) { if (DataItem.getDevItemById(bag[i].itemValue.type.get()) != null) { hasDevItem = true; MessageBox.Show("You have a dev item in toolbelt slot" + i + ". Please remove it from inventory before using this program."); break; } } if (!hasDevItem) { try { tabs.addTab(new TabPlayer(playerDataFile, fileName)); } catch (Exception e2) { Log.writeError(e2); MessageBox.Show("Failed to open file " + fileName + ". " + e2.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } } statusBar.reset(); }; openFile.ShowDialog(); }
private void openClick(object sender, System.EventArgs e) { OpenFileDialog openFile = new OpenFileDialog(); openFile.Filter = "7 Days to Die save file(*.ttp)|*.ttp|All Files(*.*)|*.*"; openFile.Multiselect = true; openFile.CheckFileExists = true; openFile.FileOk += (sender1, e1) => { statusBar.setText("Opening..."); foreach (string fileName in openFile.FileNames) { PlayerDataFile playerDataFile = new PlayerDataFile(fileName); ItemStack[] inventory = playerDataFile.inventory; ItemStack[] bag = playerDataFile.bag; List<string> devItems = new List<string>(); for (int i = 0; i < bag.Length; i++) { DataItem devItem = DataItem.getDevItemById(bag[i].itemValue.type.get()); if (devItem != null) { devItems.Add(devItem.name + " at position: row " + ((i / 8) + 1) + ", column " + ((i % 8) + 1) + "\n"); } } for (int i = 0; i < inventory.Length; i++) { DataItem devItem = DataItem.getDevItemById(inventory[i].itemValue.type.get()); if (devItem != null) { devItems.Add(devItem.name + " at position: row 5, column " + (i + 1) + "\n"); } } if (devItems.Count == 0) { try { tabs.addTab(new TabPlayer(playerDataFile, fileName)); } catch (Exception e2) { Log.writeError(e2); MessageBox.Show("Failed to open file " + fileName + ". " + e2.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { string text = "You have following developer items in your inventory:\n"; for (int i = 0; i < devItems.Count; i++) { text += devItems[i]; } text += "Please remove these items before continuing."; MessageBox.Show(text, "Warning", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } statusBar.reset(); }; openFile.ShowDialog(); }
public TabSkills(PlayerDataFile playerDataFile) : base() { this.playerDataFile = playerDataFile; Text = "Skills"; skillList = new SkillCollection(playerDataFile.skills.skillDictionary, playerDataFile.level, playerListeners); panel = new TableLayoutPanel(); panel.Dock = DockStyle.Fill; TableLayoutPanel general = new TableLayoutPanel(); general.Dock = DockStyle.Fill; TextBoxPlayerLevel playerLevelBox = new TextBoxPlayerLevel(playerDataFile.level, 1, DataSkill.maxPlayerLevel, playerListeners); LabeledBox labeledPlayerLevelBox = new LabeledBox("Player level", playerLevelBox); general.Controls.Add(labeledPlayerLevelBox); TextBoxInt skillPointsBox = new TextBoxInt(playerDataFile.skillPoints, 0, 10000); LabeledBox labeledSkillPointsBox = new LabeledBox("Skill points", skillPointsBox); general.Controls.Add(labeledSkillPointsBox); panel.Controls.Add(general); TableLayoutPanel skillsPanel = new TableLayoutPanel(); skillsPanel.Dock = DockStyle.Fill; skillsPanel.AutoScroll = true; List<SlotSkill> skillSlotList = new List<SlotSkill>(); foreach (BinderSkill binderSkill in skillList.skillList) { SlotSkill skillSlot = new SlotSkill(binderSkill); skillSlotList.Add(skillSlot); } int count = skillSlotList.Count; int perColumn = count / 7; int extraColumns = count % 7; int done = 0; for (int i = 0; i < 7; i++) { int thisColumn = perColumn; if (extraColumns > 0) { thisColumn++; extraColumns--; } for (int j = 0; j < thisColumn; j++) { skillsPanel.Controls.Add(skillSlotList[done], i, j); done++; } } panel.Controls.Add(skillsPanel, 0, 1); Controls.Add(panel); }
public static void CheckInv(ClientInfo _cInfo, PlayerDataFile _playerDataFile) { if (_cInfo != null && !GameManager.Instance.adminTools.IsAdmin(_cInfo.playerId)) { for (int i = 0; i < _playerDataFile.inventory.Length; i++) { ItemStack _intemStack = new ItemStack(); ItemValue _itemValue = new ItemValue(); _intemStack = _playerDataFile.inventory[i]; _itemValue = _intemStack.itemValue; int _count = _playerDataFile.inventory[i].count; if (_count > 0 && _itemValue != null && !_itemValue.Equals(ItemValue.None) && _cInfo != null) { int _maxAllowed = ItemClass.list[_itemValue.type].Stacknumber.Value; string _name = ItemClass.list[_itemValue.type].GetItemName(); if (AnounceInvalidStack && _count > _maxAllowed) { string _phrase3; if (!Phrases.Dict.TryGetValue(3, out _phrase3)) { _phrase3 = "{PlayerName} you have a invalid item stack: {ItemName} {ItemCount}. Max per stack: {MaxPerStack}."; } _phrase3 = _phrase3.Replace("{PlayerName}", _cInfo.playerName); _phrase3 = _phrase3.Replace("{ItemName}", _name); _phrase3 = _phrase3.Replace("{ItemCount}", _count.ToString()); _phrase3 = _phrase3.Replace("{MaxPerStack}", _maxAllowed.ToString()); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("[FF8000]{0}[-]", _phrase3), "Server", false, "", false)); ChatLog.Log(_phrase3, "Server"); } if (IsEnabled && dict.ContainsKey(_name)) { if (BanPlayer) { string _phrase4; if (!Phrases.Dict.TryGetValue(4, out _phrase4)) { _phrase4 = "Cheat Detected: Auto banned {PlayerName} for having a invalid item: {ItemName}."; } _phrase4 = _phrase4.Replace("{PlayerName}", _cInfo.playerName); _phrase4 = _phrase4.Replace("{ItemName}", _name); GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("[FF8000]{0}[-]", _phrase4), "Server", false, "", false); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 10 years \"Invalid Item {1}\"", _cInfo.entityId, _name), _cInfo); } else { string _phrase5; if (!Phrases.Dict.TryGetValue(5, out _phrase5)) { _phrase5 = "Cheat Detected: Auto kicked {PlayerName} for having a invalid item: {ItemName}."; } _phrase5 = _phrase5.Replace("{PlayerName}", _cInfo.playerName); _phrase5 = _phrase5.Replace("{ItemName}", _name); GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("[FF8000]{0}[-]", _phrase5), "Server", false, "", false); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Invalid Item: {1}\"", _cInfo.entityId, _name), _cInfo); } break; } } } for (int i = 0; i < _playerDataFile.bag.Length; i++) { ItemStack _intemStack = new ItemStack(); ItemValue _itemValue = new ItemValue(); _intemStack = _playerDataFile.bag[i]; _itemValue = _intemStack.itemValue; int _count = _playerDataFile.bag[i].count; if (_count > 0 && _itemValue != null && !_itemValue.Equals(ItemValue.None) && _cInfo != null) { int _maxAllowed = ItemClass.list[_itemValue.type].Stacknumber.Value; string _name = ItemClass.list[_itemValue.type].GetItemName(); if (AnounceInvalidStack && _count > _maxAllowed) { string _phrase3; if (!Phrases.Dict.TryGetValue(3, out _phrase3)) { _phrase3 = "{PlayerName} you have a invalid item stack: {ItemName} {ItemCount}. Max per stack: {MaxPerStack}."; } _phrase3 = _phrase3.Replace("{PlayerName}", _cInfo.playerName); _phrase3 = _phrase3.Replace("{ItemName}", _name); _phrase3 = _phrase3.Replace("{ItemCount}", _count.ToString()); _phrase3 = _phrase3.Replace("{MaxPerStack}", _maxAllowed.ToString()); _cInfo.SendPackage(new NetPackageGameMessage(EnumGameMessages.Chat, string.Format("[FF8000]{0}[-]", _phrase3), "Server", false, "", false)); ChatLog.Log(_phrase3, "Server"); } if (IsEnabled && dict.ContainsKey(_name)) { if (BanPlayer) { string _phrase4; if (!Phrases.Dict.TryGetValue(4, out _phrase4)) { _phrase4 = "Cheat Detected: Auto banned {PlayerName} for having a invalid item: {ItemName}."; } _phrase4 = _phrase4.Replace("{PlayerName}", _cInfo.playerName); _phrase4 = _phrase4.Replace("{ItemName}", _name); GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("[FF8000]{0}[-]", _phrase4), "Server", false, "", false); SdtdConsole.Instance.ExecuteSync(string.Format("ban add {0} 10 years \"Invalid Item {1}\"", _cInfo.entityId, _name), _cInfo); } else { string _phrase5; if (!Phrases.Dict.TryGetValue(5, out _phrase5)) { _phrase5 = "Cheat Detected: Auto kicked {PlayerName} for having a invalid item: {ItemName}."; } _phrase5 = _phrase5.Replace("{PlayerName}", _cInfo.playerName); _phrase5 = _phrase5.Replace("{ItemName}", _name); GameManager.Instance.GameMessageServer(_cInfo, EnumGameMessages.Chat, string.Format("[FF8000]{0}[-]", _phrase5), "Server", false, "", false); SdtdConsole.Instance.ExecuteSync(string.Format("kick {0} \"Invalid Item: {1}\"", _cInfo.entityId, _name), _cInfo); } break; } } } } }
public override void SavePlayerData(ClientInfo _cInfo, PlayerDataFile _playerDataFile) { PingChecker.CheckPing(_cInfo); }
public TabGeneral(PlayerDataFile playerDataFile) { this.playerDataFile = playerDataFile; Text = "General"; panel = new TableLayoutPanel(); panel.Dock = DockStyle.Fill; panel.CellBorderStyle = TableLayoutPanelCellBorderStyle.Single; panel.AutoScroll = true; panel.AutoSize = true; TextBoxInt score = new TextBoxInt(playerDataFile.score, 0, int.MaxValue); LabeledBox scoreBox = new LabeledBox("Score", score); panel.Controls.Add(scoreBox); TextBoxInt playerKills = new TextBoxInt(playerDataFile.playerKills, 0, int.MaxValue); LabeledBox playerK = new LabeledBox("Player kills", playerKills); panel.Controls.Add(playerK); TextBoxInt zombieKills = new TextBoxInt(playerDataFile.zombieKills, 0, int.MaxValue); LabeledBox zombieK = new LabeledBox("Zombie kills", zombieKills); panel.Controls.Add(zombieK); TextBoxInt deaths = new TextBoxInt(playerDataFile.deaths, 0, int.MaxValue); LabeledBox deathsBox = new LabeledBox("Deaths", deaths); panel.Controls.Add(deathsBox); TextBoxFloat positionX = new TextBoxFloat(playerDataFile.ecd.pos.x, float.MinValue, float.MaxValue); LabeledBox posX = new LabeledBox("Position x", positionX); panel.Controls.Add(posX); TextBoxFloat positionY = new TextBoxFloat(playerDataFile.ecd.pos.y, float.MinValue, float.MaxValue); LabeledBox posY = new LabeledBox("Position y", positionY); panel.Controls.Add(posY); TextBoxFloat positionZ = new TextBoxFloat(playerDataFile.ecd.pos.z, float.MinValue, float.MaxValue); LabeledBox posZ = new LabeledBox("Position z", positionZ); panel.Controls.Add(posZ); TextBoxFloat rotationX = new TextBoxFloat(playerDataFile.ecd.rot.x, float.MinValue, float.MaxValue); LabeledBox rotX = new LabeledBox("Rotation x", rotationX); panel.Controls.Add(rotX); TextBoxFloat rotationY = new TextBoxFloat(playerDataFile.ecd.rot.y, float.MinValue, float.MaxValue); LabeledBox rotY = new LabeledBox("Rotation y", rotationY); panel.Controls.Add(rotY); TextBoxFloat rotationZ = new TextBoxFloat(playerDataFile.ecd.rot.z, float.MinValue, float.MaxValue); LabeledBox rotZ = new LabeledBox("Rotation z", rotationZ); panel.Controls.Add(rotZ); TextBoxInt homeX = new TextBoxInt(playerDataFile.ecd.homePosition.x, int.MinValue, int.MaxValue); LabeledBox hX = new LabeledBox("Home x", homeX); panel.Controls.Add(hX); TextBoxInt homeY = new TextBoxInt(playerDataFile.ecd.homePosition.y, int.MinValue, int.MaxValue); LabeledBox hY = new LabeledBox("Home y", homeY); panel.Controls.Add(hY); TextBoxInt homeZ = new TextBoxInt(playerDataFile.ecd.homePosition.z, int.MinValue, int.MaxValue); LabeledBox hZ = new LabeledBox("Home z", homeZ); panel.Controls.Add(hZ); TextBoxInt backpackX = new TextBoxInt(playerDataFile.droppedBackpackPosition.x, int.MinValue, int.MaxValue); LabeledBox bX = new LabeledBox("Backpack position x", backpackX); panel.Controls.Add(bX); TextBoxInt backpackY = new TextBoxInt(playerDataFile.droppedBackpackPosition.y, int.MinValue, int.MaxValue); LabeledBox bY = new LabeledBox("Backpack position y", backpackY); panel.Controls.Add(bY); TextBoxInt backpackZ = new TextBoxInt(playerDataFile.droppedBackpackPosition.z, int.MinValue, int.MaxValue); LabeledBox bZ = new LabeledBox("Backpack position z", backpackZ); panel.Controls.Add(bZ); Controls.Add(panel); }
public override void SavePlayerData(ClientInfo _cInfo, PlayerDataFile _playerDataFile) { PlayerDataStuff.GM_SavePlayerData (_cInfo, _playerDataFile); }