public FriendList FriendsOf(ulong steamid) { FriendsCommand command2 = (FriendsCommand)ChatCommand.GetCommand("friends"); FriendList list = (FriendList)command2.GetFriendsLists()[steamid]; return(list); }
public FriendList FriendsOf(string steamid) { FriendsCommand command2 = (FriendsCommand)ChatCommand.GetCommand("friends"); FriendList list = (FriendList)command2.GetFriendsLists()[Convert.ToUInt64(steamid)]; return(list); }
static void OnPlayerHurt(HurtEvent he) { if (he.AttackerIsPlayer && he.Attacker != null) { Fougerite.Player player = (Fougerite.Player)he.Attacker; User user = Data.Globals.usersOnline.Find(x => x.Name == player.Name); string lang = LanguageComponent.LanguageComponent.GetPlayerLangOrDefault(player); if (!UserIsLogged(player)) { char ch = '☢'; player.Notice(ch.ToString(), LanguageComponent.LanguageComponent.getMessage("notice_not_logged", lang), 4f); he.DamageAmount = 0; return; } if (he.VictimIsPlayer && he.Victim != null && he.Victim != he.Attacker) { Fougerite.Player victim = (Fougerite.Player)he.Victim; User victimPlayer = Data.Globals.usersOnline.Find(x => x.Name == victim.Name); if (!UserIsLogged(victim)) { char ch = '☢'; player.Notice(ch.ToString(), $"Este usuario no esta logueado, no puedes hacerle daño", 4f); he.DamageAmount = 0; return; } if (user.ClanID == victimPlayer.ClanID && user.ClanID != -1) { char ch = '☢'; player.Notice(ch.ToString(), $"Este usuario es de tu Clan, no puedes hacerle daño", 4f); he.DamageAmount = 0; return; } FriendsCommand command = (FriendsCommand)ChatCommand.GetCommand("amigos"); FriendList list = (FriendList)command.GetFriendsLists()[player.UID]; if (list == null) { list = new FriendList(); } if (list.isFriendWith(victim.UID)) { char ch = '☢'; player.Notice(ch.ToString(), $"No puedes hacer daño a tus amigos", 4f); he.DamageAmount = 0; return; } } } if (he.AttackerIsNPC && he.Attacker != null && he.VictimIsPlayer && he.Victim != null) { Fougerite.Player player = (Fougerite.Player)he.Victim; User user = Data.Globals.usersOnline.Find(x => x.Name == player.Name); if (!UserIsLogged(player)) { he.DamageAmount = 0; return; } } }
public static bool IsFriend(HurtEvent e) // ref { //Server.GetServer().Broadcast("1"); GodModeCommand command = (GodModeCommand)ChatCommand.GetCommand("god"); //Server.GetServer().Broadcast("2"); //Server.GetServer().Broadcast("2 " + command.IsOn(e.victim.userID)); Fougerite.Player victim = Fougerite.Server.Cache[e.DamageEvent.victim.userID]; if (victim != null) { if (command.IsOn(victim.UID)) { //Server.GetServer().Broadcast("3"); return(true); } //Server.GetServer().Broadcast("4"); Fougerite.Player attacker = Fougerite.Server.Cache[e.DamageEvent.attacker.userID]; if (attacker != null) { FriendsCommand command2 = (FriendsCommand)ChatCommand.GetCommand("friends"); bool b = Core.config.GetBoolSetting("Settings", "friendly_fire"); //Server.GetServer().Broadcast("5 " + b); try { //Server.GetServer().Broadcast("6"); FriendList list = (FriendList)command2.GetFriendsLists()[attacker.UID]; //Server.GetServer().Broadcast("7 " + list); if (list == null || b || (DataStore.GetInstance().ContainsKey("HGIG", attacker.SteamID) && DataStore.GetInstance().ContainsKey("HGIG", victim.SteamID))) { //Server.GetServer().Broadcast("8"); return(false); } //Server.GetServer().Broadcast("9"); return(list.isFriendWith(victim.UID)); } catch { //Server.GetServer().Broadcast("end"); return(command.IsOn(victim.UID)); } } } return(false); }
public static void Init() { InitializeCommands(); ShareCommand command = ChatCommand.GetCommand("share") as ShareCommand; FriendsCommand command2 = ChatCommand.GetCommand("friends") as FriendsCommand; if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp"))) { command.SetSharedDoors(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp"))); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp"))) { command2.SetFriendsLists(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp"))); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("admins.xml"))) { Administrator.AdminList = Helper.ObjectFromXML <System.Collections.Generic.List <Administrator> >(RustPPModule.GetAbsoluteFilePath("admins.xml")); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("cache.rpp"))) { userCache = Helper.ObjectFromFile <Dictionary <ulong, string> >(RustPPModule.GetAbsoluteFilePath("cache.rpp")); } else { userCache = new Dictionary <ulong, string>(); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("whitelist.xml"))) { whiteList = new PList(Helper.ObjectFromXML <System.Collections.Generic.List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("whitelist.xml"))); } else { whiteList = new PList(); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("bans.xml"))) { blackList = new PList(Helper.ObjectFromXML <System.Collections.Generic.List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("bans.xml"))); } else { blackList = new PList(); } }
public static bool IsFriend(HurtEvent e) // ref { GodModeCommand command = (GodModeCommand)ChatCommand.GetCommand("god"); Fougerite.Player victim = e.Victim as Fougerite.Player; if (victim != null) { if (command.IsOn(victim.UID)) { FallDamage dmg = victim.FallDamage; if (dmg != null) { dmg.ClearInjury(); } return(true); } Fougerite.Player attacker = e.Attacker as Fougerite.Player; if (attacker != null) { FriendsCommand command2 = (FriendsCommand)ChatCommand.GetCommand("amigos"); if (command2.ContainsException(attacker.UID) && command2.ContainsException(victim.UID)) { return(false); } bool b = Core.config.GetBoolSetting("Settings", "friendly_fire"); try { FriendList list = (FriendList)command2.GetFriendsLists()[attacker.UID]; if (list == null || b) { return(false); } return(list.isFriendWith(victim.UID)); } catch { return(false); } } } return(false); }
public static bool IsFriend(DamageEvent e) // ref { GodModeCommand command = (GodModeCommand)ChatCommand.GetCommand("god"); try { FriendsCommand command2 = (FriendsCommand)ChatCommand.GetCommand("friends"); FriendList list = (FriendList)command2.GetFriendsLists()[e.attacker.userID]; if (Core.config.GetSetting("Settings", "friendly_fire").ToLower() == "true") { return(command.IsOn(e.victim.userID)); } if (list == null) { return(command.IsOn(e.victim.userID)); } return(list.isFriendWith(e.victim.userID) || command.IsOn(e.victim.userID)); } catch { return(command.IsOn(e.victim.userID)); } }
public static void CreateSaves() { try { ShareCommand command = (ShareCommand)ChatCommand.GetCommand("share"); FriendsCommand command2 = (FriendsCommand)ChatCommand.GetCommand("friends"); if (command.GetSharedDoors().Count != 0) { ObjectToFile <Hashtable>(command.GetSharedDoors(), RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")); } if (command2.GetFriendsLists().Count != 0) { ObjectToFile <Hashtable>(command2.GetFriendsLists(), RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")); } if (Administrator.AdminList.Count != 0) { ObjectToXML <List <Administrator> >(Administrator.AdminList, RustPPModule.GetAbsoluteFilePath("admins.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("admins.xml"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("admins.xml")); } if (Core.userCache.Count != 0) { ObjectToFile <Dictionary <ulong, string> >(Core.userCache, RustPPModule.GetAbsoluteFilePath("cache.rpp")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("cache.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("cache.rpp")); } if (Core.whiteList.Count != 0) { ObjectToXML <List <PList.Player> >(Core.whiteList.PlayerList, RustPPModule.GetAbsoluteFilePath("whitelist.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("whitelist.xml"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("whitelist.xml")); } if (Core.blackList.Count != 0) { ObjectToXML <List <PList.Player> >(Core.blackList.PlayerList, RustPPModule.GetAbsoluteFilePath("bans.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("bans.xml"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("bans.xml")); } } catch (Exception ex) { Fougerite.Logger.LogException(ex); throw; } }
public static void CreateSaves() { Logger.Log("Guardando clanes"); RustPP.Data.Globals.GuardarClanes(); Logger.Log("Guardando cuentas"); RustPP.Data.Globals.GuardarCuentas(); ShareCommand command = (ShareCommand)ChatCommand.GetCommand("share"); FriendsCommand command2 = (FriendsCommand)ChatCommand.GetCommand("amigos"); if (command.GetSharedDoors().Count != 0) { Logger.Log("Guardando puertas"); ObjectToFile <Hashtable>(command.GetSharedDoors(), RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")); SerializableDictionary <ulong, List <ulong> > doorsSave = new SerializableDictionary <ulong, List <ulong> >(); foreach (DictionaryEntry entry in command.GetSharedDoors()) { ulong key = (ulong)entry.Key; ArrayList value = (ArrayList)entry.Value; List <ulong> list = new List <ulong>(value.OfType <ulong>()); doorsSave.Add(key, list); } ObjectToXML <SerializableDictionary <ulong, List <ulong> > >(doorsSave, RustPPModule.GetAbsoluteFilePath("doorsSave.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")); } if (command2.GetFriendsLists().Count != 0) { Logger.Log("Saving friends lists."); ObjectToFile <Hashtable>(command2.GetFriendsLists(), RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp")); } if (Administrator.AdminList.Count != 0) { Logger.Log("Saving administrator list."); ObjectToXML <List <Administrator> >(Administrator.AdminList, RustPPModule.GetAbsoluteFilePath("admins.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("admins.xml"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("admins.xml")); } if (Core.userCache.Count != 0) { Logger.Log("Saving user cache."); ObjectToXML <SerializableDictionary <ulong, string> >(new SerializableDictionary <ulong, string>(Core.userCache), RustPPModule.GetAbsoluteFilePath("userCache.xml")); ObjectToFile <Dictionary <ulong, string> >(Core.userCache, RustPPModule.GetAbsoluteFilePath("cache.rpp")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("cache.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("cache.rpp")); } if (Core.structureCache.Count != 0) { Logger.Log("Saving structure cache."); ObjectToXML <SerializableDictionary <int, string> >(new SerializableDictionary <int, string>(Core.structureCache), RustPPModule.GetAbsoluteFilePath("structureCache.xml")); ObjectToFile <Dictionary <int, string> >(Core.structureCache, RustPPModule.GetAbsoluteFilePath("structureCache.rpp")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("structureCache.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("structureCache.rpp")); } if (Core.userLang.Count != 0) { Logger.Log("Guardando preferencias de lenguaje."); ObjectToXML <SerializableDictionary <ulong, string> >(new SerializableDictionary <ulong, string>(Core.userLang), RustPPModule.GetAbsoluteFilePath("userLang.xml")); ObjectToFile <Dictionary <ulong, string> >(Core.userLang, RustPPModule.GetAbsoluteFilePath("userLang.rpp")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("userLang.rpp"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("userLang.rpp")); } if (Core.whiteList.Count != 0) { Logger.Log("Saving whitelist."); ObjectToXML <List <PList.Player> >(Core.whiteList.PlayerList, RustPPModule.GetAbsoluteFilePath("whitelist.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("whitelist.xml"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("whitelist.xml")); } if (Core.muteList.Count != 0) { Logger.Log("Saving mutelist."); ObjectToXML <List <PList.Player> >(Core.muteList.PlayerList, RustPPModule.GetAbsoluteFilePath("mutelist.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("mutelist.xml"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("mutelist.xml")); } if (Core.blackList.Count != 0) { Logger.Log("Saving blacklist."); ObjectToXML <List <PList.Player> >(Core.blackList.PlayerList, RustPPModule.GetAbsoluteFilePath("bans.xml")); } else if (File.Exists(RustPPModule.GetAbsoluteFilePath("bans.xml"))) { File.Delete(RustPPModule.GetAbsoluteFilePath("bans.xml")); } }
public static void Init() { InitializeCommands(); ShareCommand command = ChatCommand.GetCommand("share") as ShareCommand; FriendsCommand command2 = ChatCommand.GetCommand("friends") as FriendsCommand; bool success = false; if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.xml"))) { SerializableDictionary <ulong, List <ulong> > doorsDict; doorsDict = Helper.ObjectFromXML <SerializableDictionary <ulong, List <ulong> > >(RustPPModule.GetAbsoluteFilePath("doorsSave.xml")); Hashtable doorsSave = new Hashtable(); foreach (KeyValuePair <ulong, List <ulong> > kvp in doorsDict) { ArrayList arr = new ArrayList(kvp.Value); doorsSave.Add(kvp.Key, arr); } command.SetSharedDoors(doorsSave); success = true; } if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")) && !success) { command.SetSharedDoors(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp"))); } if (!File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.xml"))) { SerializableDictionary <ulong, List <ulong> > doorsSave = new SerializableDictionary <ulong, List <ulong> >(); foreach (DictionaryEntry entry in command.GetSharedDoors()) { ulong key = (ulong)entry.Key; ArrayList value = (ArrayList)entry.Value; List <ulong> list = new List <ulong>(value.OfType <ulong>()); doorsSave.Add(key, list); } Helper.ObjectToXML <SerializableDictionary <ulong, List <ulong> > >(doorsSave, RustPPModule.GetAbsoluteFilePath("doorsSave.xml")); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp"))) { command2.SetFriendsLists(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp"))); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("admins.xml"))) { Administrator.AdminList = Helper.ObjectFromXML <List <Administrator> >(RustPPModule.GetAbsoluteFilePath("admins.xml")); } success = false; if (File.Exists(RustPPModule.GetAbsoluteFilePath("userCache.xml"))) { FileInfo fi = new FileInfo(RustPPModule.GetAbsoluteFilePath("userCache.xml")); float mega = (fi.Length / 1024f) / 1024f; if (mega > 0.70) { Logger.LogWarning("Rust++ Cache.xml and Cache.rpp are getting big. Deletion is suggested."); } SerializableDictionary <ulong, string> userDict = Helper.ObjectFromXML <SerializableDictionary <ulong, string> >(RustPPModule.GetAbsoluteFilePath("userCache.xml")); userCache = new Dictionary <ulong, string>(userDict); success = true; } if (File.Exists(RustPPModule.GetAbsoluteFilePath("cache.rpp")) && !success) { userCache = Helper.ObjectFromFile <Dictionary <ulong, string> >(RustPPModule.GetAbsoluteFilePath("cache.rpp")); if (!File.Exists(RustPPModule.GetAbsoluteFilePath("userCache.xml"))) { Helper.ObjectToXML <SerializableDictionary <ulong, string> >(new SerializableDictionary <ulong, string>(userCache), RustPPModule.GetAbsoluteFilePath("userCache.xml")); } } else if (!success) { userCache = new Dictionary <ulong, string>(); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("whitelist.xml"))) { whiteList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("whitelist.xml"))); } else { whiteList = new PList(); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("mutelist.xml"))) { muteList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("mutelist.xml"))); } else { muteList = new PList(); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("bans.xml"))) { blackList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("bans.xml"))); } else { blackList = new PList(); } }
public static void Init() { InitializeCommands(); ShareCommand command = ChatCommand.GetCommand("share") as ShareCommand; FriendsCommand command2 = ChatCommand.GetCommand("friends") as FriendsCommand; bool success = false; if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.xml"))) { SerializableDictionary <ulong, List <ulong> > doorsDict; doorsDict = Helper.ObjectFromXML <SerializableDictionary <ulong, List <ulong> > >(RustPPModule.GetAbsoluteFilePath("doorsSave.xml")); Hashtable doorsSave = new Hashtable(); foreach (KeyValuePair <ulong, List <ulong> > kvp in doorsDict) { ArrayList arr = new ArrayList(kvp.Value); doorsSave.Add(kvp.Key, arr); } command.SetSharedDoors(doorsSave); success = true; } if (File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp")) && !success) { command.SetSharedDoors(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("doorsSave.rpp"))); } if (!File.Exists(RustPPModule.GetAbsoluteFilePath("doorsSave.xml"))) { SerializableDictionary <ulong, List <ulong> > doorsSave = new SerializableDictionary <ulong, List <ulong> >(); foreach (DictionaryEntry entry in command.GetSharedDoors()) { ulong key = (ulong)entry.Key; ArrayList value = (ArrayList)entry.Value; List <ulong> list = new List <ulong>(value.OfType <ulong>()); doorsSave.Add(key, list); } Helper.ObjectToXML <SerializableDictionary <ulong, List <ulong> > >(doorsSave, RustPPModule.GetAbsoluteFilePath("doorsSave.xml")); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp"))) { command2.SetFriendsLists(Helper.ObjectFromFile <Hashtable>(RustPPModule.GetAbsoluteFilePath("friendsSave.rpp"))); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("admins.xml"))) { Administrator.AdminList = Helper.ObjectFromXML <List <Administrator> >(RustPPModule.GetAbsoluteFilePath("admins.xml")); } success = false; bool clearer = false; if (File.Exists(RustPPModule.GetAbsoluteFilePath("userCache.xml"))) { FileInfo fi = new FileInfo(RustPPModule.GetAbsoluteFilePath("userCache.xml")); float mega = (fi.Length / 1024f) / 1024f; if (mega > 0.65) { try { //string n = Path.Combine(RustPPModule.ConfigsFolder, "userCache-OLD-" + DateTime.Now.ToShortDateString() + ".xml"); System.IO.File.Move(RustPPModule.GetAbsoluteFilePath("userCache.xml"), Path.Combine(RustPPModule.ConfigsFolder, "userCache-OLD-" + DateTime.Now.ToShortDateString() + ".xml")); clearer = true; } catch (Exception ex) { Logger.LogError("Rust++ failed to copy the usercache file."); } } else { SerializableDictionary <ulong, string> userDict = Helper.ObjectFromXML <SerializableDictionary <ulong, string> >(RustPPModule.GetAbsoluteFilePath("userCache.xml")); userCache = new Dictionary <ulong, string>(userDict); success = true; } } if (File.Exists(RustPPModule.GetAbsoluteFilePath("cache.rpp")) && !success) { if (clearer) { File.WriteAllText(RustPPModule.GetAbsoluteFilePath("cache.rpp"), string.Empty); } userCache = Helper.ObjectFromFile <Dictionary <ulong, string> >(RustPPModule.GetAbsoluteFilePath("cache.rpp")); if (!File.Exists(RustPPModule.GetAbsoluteFilePath("userCache.xml"))) { Helper.ObjectToXML <SerializableDictionary <ulong, string> >(new SerializableDictionary <ulong, string>(userCache), RustPPModule.GetAbsoluteFilePath("userCache.xml")); } } else if (!success) { userCache = new Dictionary <ulong, string>(); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("whitelist.xml"))) { whiteList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("whitelist.xml"))); } else { whiteList = new PList(); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("mutelist.xml"))) { muteList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("mutelist.xml"))); } else { muteList = new PList(); } if (File.Exists(RustPPModule.GetAbsoluteFilePath("bans.xml"))) { blackList = new PList(Helper.ObjectFromXML <List <PList.Player> >(RustPPModule.GetAbsoluteFilePath("bans.xml"))); } else { blackList = new PList(); } }