/// <summary> /// Gets the Last editor for a given Signage /// </summary> /// <param name="sign"></param> /// <param name="caller"></param> /// <returns></returns> private string getPlayerDataForSign(Signage sign, string caller) { if (sign != null) { string playerData = ""; foreach (SignCheckerData data in FindSignById(sign.ToString())) { playerData = data.ToString(); } if (!string.IsNullOrEmpty(playerData)) { return(playerData); } } return(string.Format(GetLangValue("NoOne", caller))); }
/// <summary> /// Server hook wich gets called on every edit of an Signage /// </summary> /// <param name="sign"></param> /// <param name="player"></param> /// <param name="text"></param> void OnSignUpdated(Signage sign, BasePlayer player, string text) { //Quick check if the Called sign is already in the Datafile if (!isAlreadyInStorageData(sign)) { //If not, it gets added storedData.signCheckerDatas.Add(new SignCheckerData(player, sign)); } else { //If it is, we get it from the list, and Edit it to the new "Last editor"-Data foreach (SignCheckerData data in FindSignById(sign.ToString())) { data.userId = player.UserIDString; data.name = player.UserIDString; } } Interface.Oxide.DataFileSystem.WriteObject(this.Name, storedData); }
public SignCheckerData(BasePlayer player, Signage sign) { signId = sign.ToString(); userId = player.UserIDString; name = player.displayName; }
bool isAlreadyInStorageData(Signage sign) => storedData.signCheckerDatas.Any(item => item.signId.Equals(sign.ToString()));