public override void Initialize() { try { RestrictedCommands = new List <string>(); Hooks.OnCommand += Command; Hooks.OnPlayerSpawned += Spawned; Hooks.OnPlayerHurt += PlayerHurt; Hooks.OnEntityDeployedWithPlacer += Deploy; Hooks.OnEntityHurt += EntityHurt; Resendinmates(); CheckConfig(); if (ini.ContainsSetting("JailRadius", "radius")) { int rad = Convert.ToInt32(ini.GetSetting("JailRadius", "radius")); if (radius.ContainsKey("radius")) { radius.Remove("radius"); radius.Add("radius", rad); } else { radius.Add("radius", rad); } } } catch (Exception ex) { Logger.Log("Error happend at Initialize " + ex); } }
void Command(Player pl, string cmd, string[] args) { if (cmd == "stp" && pl.Admin) { if (args.Length < 1) { pl.MessageFrom(Name, "Try /stp ID"); string[] en = locs.EnumSection("Locs"); // Loops trough the ini folder and sends all id into a list foreach (var n in en) { pl.MessageFrom(Name, n); } } else { if (locs.ContainsSetting("Locs", args[0])) { string j = locs.GetSetting("Locs", args[0]); Vector3 loc = Util.GetUtil().ConvertStringToVector3(j); // makes vector3 of the location which is saved into string pl.TeleportTo(loc); pl.InventoryNotice(loc.ToString()); } } } }
private void ReloadConfig() { if (!File.Exists(Path.Combine(ModuleFolder, "Settings.ini"))) { File.Create(Path.Combine(ModuleFolder, "Settings.ini")).Dispose(); Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini")); Settings.AddSetting("PoisonArrow", "PossibilityOfPoisoning(0-100)", "50"); Settings.AddSetting("PoisonArrow", "AmountOfVenne(0-10)", "3"); Settings.AddSetting("PoisonArrow", "AvoidBypass", "true"); Settings.AddSetting("PoisonArrow", "TimeToAvoidBypass", "2"); Settings.Save(); Logger.Log(Name + " Plugin: New Settings File Created!"); ReloadConfig(); } else { Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini")); if (Settings.ContainsSetting("PoisonArrow", "PossibilityOfPoisoning(0-100)") && Settings.ContainsSetting("PoisonArrow", "AmountOfVenne(0-10)") && Settings.ContainsSetting("PoisonArrow", "AvoidBypass") && Settings.ContainsSetting("PoisonArrow", "TimeToAvoidBypass")) { try { PossibilityOfPoisoning = int.Parse(Settings.GetSetting("PoisonArrow", "PossibilityOfPoisoning(0-100)")); AmountOfVenne = int.Parse(Settings.GetSetting("PoisonArrow", "AmountOfVenne(0-10)")); AvoidBypass = Settings.GetBoolSetting("PoisonArrow", "AvoidBypass"); TimeToAvoidBypass = int.Parse(Settings.GetSetting("PoisonArrow", "TimeToAvoidBypass")); Logger.Log(Name + " Plugin: Settings file Loaded!"); } catch (Exception ex) { Logger.Log(Name + " Plugin: Detected a problem in the configuration"); Logger.Log("ERROR -->" + ex.Message); File.Delete(Path.Combine(ModuleFolder, "Settings.ini")); Logger.Log(Name + " Plugin: Deleted the old configuration file"); ReloadConfig(); } } else { Logger.LogError(Name + " Plugin: Detected a problem in the configuration (lost key)"); File.Delete(Path.Combine(ModuleFolder, "Settings.ini")); Logger.LogError(Name + " Plugin: Deleted the old configuration file"); ReloadConfig(); } return; } }
public void OnPlayerConnected(User pl) { PlayerDatabase.AddSetting(pl.SteamID, "ID", pl.SteamID); PlayerDatabase.AddSetting(pl.SteamID, "IP", pl.IP); PlayerDatabase.AddSetting(pl.SteamID, "Name", pl.Name); PlayerDatabase.AddSetting(pl.SteamID, "FID", pl.ToString()); if(EnableJoinMessages) { if (!PlayerDatabase.ContainsSetting(pl.SteamID, "Joined")) { PlayerDatabase.AddSetting(pl.SteamID, "Joined", "yes"); PlayerDatabase.Save(); if (EnableFirstjoinMessages) { Logger.Log("[Fougerite-Essentials] " + pl.Name + " has joined the server for the first time"); string message = FirstJoinMessage.Replace("{player}", pl.Name); Broadcast(message); } } if (EnableCountryMessages) { FindCountry(pl); } else { string msg = JoinMessage.Replace("{player}", pl.Name); Broadcast(msg); } PlayerDatabase.Save(); } }
public void Connected(User pl) { var id = pl.SteamID; if (pl == null) { Logger.LogWarning(name + " a player was null"); return; } if (!list.ContainsSetting(id, "GameID")) { Logger.Log(name + " " + pl.Name + " - " + id + " has been added to the PlayerDatabase"); } list.AddSetting(id, "Name", pl.Name); list.AddSetting(id, "GameID", id); list.AddSetting(id, "IP", pl.IP); list.AddSetting(id, "LastJoined", DateTime.Now.ToString()); list.AddSetting(id, "Online", "yes"); if (player.netUser.admin) { list.AddSetting(id, "IsAdmin", "true"); } else { list.AddSetting(id, "IsAdmin", "false"); } list.Save(); }
private void ReloadConfig() { if (!File.Exists(Path.Combine(ModuleFolder, "Settings.ini"))) { File.Create(Path.Combine(ModuleFolder, "Settings.ini")).Dispose(); Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini")); Settings.AddSetting("Settings", "MinsToSave", "10"); Settings.AddSetting("Settings", "SaveInBackground", "false"); Settings.AddSetting("Settings", "ShowObjectCount", "true"); Settings.Save(); Logger.Log(Name + " Plugin: New Settings File Created!"); ReloadConfig(); } else { Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini")); if (Settings.ContainsSetting("Settings", "MinsToSave") && Settings.ContainsSetting("Settings", "SaveInBackground") && Settings.ContainsSetting("Settings", "ShowObjectCount")) { try { MinsToSave = int.Parse(Settings.GetSetting("Settings", "MinsToSave")); SaveInBackground = Settings.GetBoolSetting("Settings", "SaveInBackground"); ShowObjectCount = Settings.GetBoolSetting("Settings", "ShowObjectCount"); Logger.Log(Name + " Plugin: Settings file Loaded!"); } catch (Exception ex) { Logger.Log(Name + " Plugin: Detected a problem in the configuration"); Logger.Log("ERROR -->" + ex.Message); File.Delete(Path.Combine(ModuleFolder, "Settings.ini")); Logger.Log(Name + " Plugin: Deleted the old configuration file"); ReloadConfig(); } } else { Logger.LogError(Name + " Plugin: Detected a problem in the configuration (lost key)"); File.Delete(Path.Combine(ModuleFolder, "Settings.ini")); Logger.LogError(Name + " Plugin: Deleted the old configuration file"); ReloadConfig(); } return; } return; }
public void Resendinmates() { foreach (var pl in server.Players) { if (list.ContainsSetting("inmates", pl.SteamID)) { if (ini.ContainsSetting("jailloc", "location")) { string j = ini.GetSetting("jailloc", "location"); Vector3 loc = util.ConvertStringToVector3(j); pl.TeleportTo(loc); pl.MessageFrom(Name, "You have been teleported to jail"); Notify("All inmates are resended to jail"); } } } }
//this function is from Salva "AntiBugOnSpawn" public string GetClanName(string TargetID) { string clanname = "XXXXXXXXXXXXX"; if (ClansIni.ContainsSetting("ClanOwners", TargetID)) { clanname = ClansIni.GetSetting("ClanOwners", TargetID); } else { if (ClansIni.ContainsSetting("ClanMembers", TargetID)) { clanname = ClansIni.GetSetting("ClanMembers", TargetID); } } return(clanname); }
private void ReloadConfig() { if (!File.Exists(Path.Combine(ModuleFolder, "Settings.ini"))) { File.Create(Path.Combine(ModuleFolder, "Settings.ini")).Dispose(); Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini")); Settings.AddSetting("ServerName", "Color", "[color #FFFFFF]"); Settings.AddSetting("ServerName", "Name", "Edit this whit the name you want"); Logger.Log(Name + " Plugin: New Settings File Created!"); Settings.Save(); ReloadConfig(); } else { Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini")); if (Settings.ContainsSetting("ServerName", "Color") && Settings.ContainsSetting("ServerName", "Name")) { Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini")); try { SvColor = Settings.GetSetting("ServerName", "Color"); SvName = Settings.GetSetting("ServerName", "Name"); Logger.Log(Name + " Plugin: Settings file Loaded!"); } catch (Exception ex) { Logger.LogError(Name + " Plugin: Detected a problem in the configuration"); Logger.Log("ERROR -->" + ex.Message); File.Delete(Path.Combine(ModuleFolder, "Settings.ini")); Logger.LogError(Name + " Plugin: Deleted the old configuration file"); ReloadConfig(); } } else { Logger.LogError(Name + " Plugin: Detected a problem in the configuration (lost key)"); File.Delete(Path.Combine(ModuleFolder, "Settings.ini")); Logger.LogError(Name + " Plugin: Deleted the old configuration file"); ReloadConfig(); } return; } }
public bool IsBannedIP(string ip) { IniParser ini = GlobalBanList; if (ini.ContainsSetting("Ips", ip)) { return(true); } return(false); }
bool Hasflag(Fougerite.Player pl, string flag) { var id = pl.SteamID; if (flags.ContainsSetting(id, flag)) { return(true); } return(false); }
public bool UnbanByID(string id) { IniParser ini = GlobalBanList; if (ini.ContainsSetting("Ids", id)) { ini.DeleteSetting("Ids", id); ini.Save(); return(true); } return(false); }
public bool OnWhiteList(string playerid, string playerip) { foreach (var steamid in WhiteList.Sections) { if (WhiteList.ContainsSetting(steamid, playerip)) { return(true); } if (steamid == playerid) { return(true); } } return(false); }
private void ReloadConfig() { if (!File.Exists(Path.Combine(ModuleFolder, "Settings.ini"))) { File.Create(Path.Combine(ModuleFolder, "Settings.ini")).Dispose(); Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini")); Settings.AddSetting("Timer", "MinutesToRefillShop", "60"); Logger.Log(Name + ": New Settings File Created!"); Settings.Save(); ReloadConfig(); } else { Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini")); if (Settings.ContainsSetting("Timer", "MinutesToRefillShop")) { try { MinutesToRefillShop = int.Parse(Settings.GetSetting("Timer", "MinutesToRefillShop")); Logger.Log(Name + ": Settings file Loaded!"); } catch (Exception ex) { Logger.LogError(Name + ": Detected a problem in the configuration"); Logger.Log("ERROR -->" + ex.Message); File.Delete(Path.Combine(ModuleFolder, "Settings.ini")); Logger.LogError(Name + ": Deleted the old configuration file"); ReloadConfig(); } } else { Logger.LogError(Name + ": Detected a problem in the configuration (lost key)"); File.Delete(Path.Combine(ModuleFolder, "Settings.ini")); Logger.LogError(Name + ": Deleted the old configuration file"); ReloadConfig(); } return; } }
public void Command(User player, string cmd, string[] args) { if (cmd == "restartkit") { if (args.Length == 0) { player.MessageFrom(Name, aqua + "Usage /restartkit help"); return; } if (args[0] == "help") { player.MessageFrom(Name, aqua + "Usage /restartkit kits = See all avaible kits"); player.MessageFrom(Name, aqua + "Usage /restartkit receive kitname - Receive this kit (Only works when the admin gave you acces to it)"); player.MessageFrom(Name, aqua + "usage /restartkit info kitname - see the kit items of a specific kit"); if (player.Admin) { player.MessageFrom(Name, "/restartkit_adduser player kitname - give the player acces to a kit"); } } else if (args[0] == "info") { if (File.Exists(Path.Combine(defaultpath, args[1] + ".txt"))) { foreach (string xx in File.ReadAllLines(defaultpath + "\\" + args[1] + ".txt")) { string[] split = xx.Split(':'); string one = split[0]; string two = split[1]; if (one == "Message") { player.MessageFrom(Name, two); } else { player.MessageFrom(Name, $"{aqua}{two}x{one}"); } } } } else if (args[0] == "kits") { player.MessageFrom(Name, aqua + "Avaible kits. Usage /restartkit receive kitname"); foreach (string file in Directory.GetFiles(defaultpath)) { string name = file.Split('\\').Last(); player.MessageFrom(Name, $"{aqua} {name.Replace(".txt", string.Empty)}"); } } else if (args[0] == "receive") { //util.Log("1"); if (!users.ContainsSetting(args[1], player.SteamID)) { player.MessageFrom(Name, aqua + MessageBuyChat1); player.MessageFrom(Name, aqua + MessageBuyChat2); return; } //util.Log("2"); if (AlreadyUsedKit(player, args)) { player.MessageFrom(Name, aqua + MessageAlready); player.MessageFrom(Name, aqua + MessageAlready1); return; } if (File.Exists(Path.Combine(defaultpath, args[1] + ".txt"))) { if (player.Inventory.FreeSlots == 0) { player.MessageFrom(Name, aqua + InventoryFull); return; } // util.Log("2"); foreach (string xx in File.ReadAllLines(defaultpath + "\\" + args[1] + ".txt")) { string[] split = xx.Split(':'); string one = split[0]; // util.Log("3"); string two = split[1]; if (one != "Message") { player.Inventory.AddItem(one, Convert.ToInt32(two)); } } player.MessageFrom(Name, aqua + MessageThanks); StreamWriter writer = File.AppendText(path + player.SteamID + ".txt"); writer.WriteLine(args[1]); writer.Close(); } } } else if (cmd == "restartkit_adduser") { if (player.Admin) { if (args.Length == 2) { User target = Server.GetServer().FindPlayer(args[0]); users.AddSetting(args[1], target.SteamID, args[1]); users.Save(); player.MessageFrom(Name, $"{aqua} You gave {args[1]} kit acces to {target.Name}"); } } } }
void Command(Player pl, string cmd, string[] args) { if (cmd == "flag") { if (pl.Admin || API.HasFlag(pl, "canflag")) { pl.Notice("⚑", "FlagsAPI brought by ice cold", 20f); pl.MessageFrom(Name, "FlagsAPI 1.1 by ice cold"); pl.MessageFrom(Name, "/flag_add Player flagname - gives the player the flagname"); pl.MessageFrom(Name, "/flag_invoke Player flagname - removes the flag in player"); pl.MessageFrom(Name, "/flag_register Flagname - register a new flag"); } else { pl.MessageFrom(Name, "You dont have the > canflag < flag"); } } else if (cmd == "flag_add") { if (pl.Admin || API.HasFlag(pl, "canflag")) { if (args.Length != 2) { pl.Notice("⚑", "Syntax /flag_add PlayerName FlagName"); return; } if (list.ContainsSetting("Flags", args[1])) { var user = Fougerite.Server.GetServer().FindPlayer(args[0]); if (user == null) { pl.Notice("⚑", "Failed to find user"); return; } ini.AddSetting(user.SteamID, args[1], args[1]); ini.Save(); pl.Notice("⚑", "You have given " + user.Name + " flag (" + args[1] + ")", 20f); user.Notice("⚑", "You have received flag (" + args[1] + ")", 20f); } else { pl.MessageFrom(Name, "You must register this flag first by doing /flag_register " + args[1]); } } } else if (cmd == "flag_invoke") { if (pl.Admin || API.HasFlag(pl, "canflag")) { if (args.Length != 2) { pl.Notice("⚑", "Syntax /flag_invoke PlayerName FlagName"); return; } var user = Fougerite.Server.GetServer().FindPlayer(args[0]); if (user == null) { pl.Notice("⚑", "Failed to find user"); return; } if (ini.ContainsSetting(user.SteamID, args[1])) { ini.DeleteSetting(user.SteamID, args[1]); ini.Save(); pl.Notice("⚑", user.Name + " has no longer the flag " + args[1]); } else { pl.Notice("⚑", user.Name + " doesn't have this flag"); } } } else if (cmd == "flags_reload") { if (pl.Admin || API.HasFlag(pl, "canflag")) { ini = new IniParser(Path.Combine(ModuleFolder, "PlayerFlagdb.ini")); list = new IniParser(Path.Combine(ModuleFolder, "Flags.list")); pl.Notice("Flags database reloaded"); } } else if (cmd == "flag_register") { if (pl.Admin || API.HasFlag(pl, "canflag")) { API.RegisterFlag(args[0]); pl.MessageFrom(Name, "The flag (" + args[0] + ") was succestfully registered"); } } }
public void ReloadConfig() { Loom.QueueOnMainThread(() => { if (!File.Exists(Path.Combine(ModuleFolder, "Settings.ini"))) { File.Create(Path.Combine(ModuleFolder, "Settings.ini")).Dispose(); Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini")); Settings.AddSetting("Timer", "IntervalBetweenMessages_seconds", "60"); Settings.AddSetting("ChatMessages", "ShowInChat", "true"); Settings.AddSetting("PopupMessages", "ShowInPopup", "true"); Settings.AddSetting("PopupMessages", "PopupIcon", "X"); Settings.AddSetting("PopupMessages", "DurationPopup_secs", "10"); Settings.Save(); Logger.LogError(Name + "... New Settings File Created!"); ReloadConfig(); return; } else { Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini")); if (Settings.ContainsSetting("Timer", "IntervalBetweenMessages_seconds") && Settings.ContainsSetting("ChatMessages", "ShowInChat") && Settings.ContainsSetting("PopupMessages", "ShowInPopup") && Settings.ContainsSetting("PopupMessages", "PopupIcon") && Settings.ContainsSetting("PopupMessages", "DurationPopup_secs")) { try { IntervalSeconds = int.Parse(Settings.GetSetting("Timer", "IntervalBetweenMessages_seconds")); chat = Settings.GetBoolSetting("ChatMessages", "ShowInChat"); popup = Settings.GetBoolSetting("PopupMessages", "ShowInPopup"); popupicon = Settings.GetSetting("PopupMessages", "PopupIcon"); popupduration = int.Parse(Settings.GetSetting("PopupMessages", "DurationPopup_secs")); } catch (Exception ex) { Logger.LogError(Name + "... Detected a problem in the configuration"); Logger.LogError("ERROR -->" + ex.Message); File.Delete(Path.Combine(ModuleFolder, "Settings.ini")); Logger.LogError(Name + "... Deleted the old configuration file"); ReloadConfig(); return; } } else { Logger.LogError(Name + "... Detected a problem in the configuration (lost key)"); File.Delete(Path.Combine(ModuleFolder, "Settings.ini")); Logger.LogError(Name + "... Deleted the old configuration file"); ReloadConfig(); return; } } if (!File.Exists(rutatxt)) { File.Create(rutatxt).Dispose(); StreamWriter WF = File.AppendText(rutatxt); WF.WriteLine("[color red] Hello... this is message 1"); WF.WriteLine("[color blue] Hello... this is message 2"); WF.WriteLine("[color green] Hello... this is message 3"); WF.WriteLine("[color orange] Hello... this is message 4"); WF.WriteLine("[color yellow] Hello... this is message 5"); WF.WriteLine("Add more lines if you want ;)"); WF.Close(); Logger.LogError(Name + "... File not found (RandomMessages.txt) ,creating new one"); ReloadConfig(); return; } else { if (File.ReadAllText(rutatxt).Length == 0) { Logger.LogError(Name + "... The File (RandomMessages.txt) dont contain any line or is empty..."); Logger.LogError(Name + "... You need to add at least one line so that the plugin works correctly"); msgs.Clear(); msgs.Add("The File (RandomMessages.txt) dont contain any line or is empty..."); } else { msgs.Clear(); try { foreach (string str in File.ReadAllLines(rutatxt)) { //if (str == string.Empty) if (str.Length == 0) { continue; } msgs.Add(str); } } catch (Exception ex) { Logger.LogError(Name + "... The File (RandomMessages.txt) could not be read for any reason"); } } } //Logger.Log(File.ReadAllText(rutatxt).Length.ToString());//comprobar si el archivo txt esta vacio return; }); }
private void ReloadConfig() { if (!File.Exists(Path.Combine(ModuleFolder, "Settings.ini"))) { File.Create(Path.Combine(ModuleFolder, "Settings.ini")).Dispose(); Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini")); Settings.AddSetting("Timer", "EnableAnnounce", "true"); Settings.AddSetting("Timer", "AnnounceTimeMins", "5"); Settings.AddSetting("Timer", "AnnounceMessage", "Commands: /web /discord /facebook /instagram /vk"); Settings.AddSetting("Links", "Web", "http://fougerite.com/"); Settings.AddSetting("Links", "Discord", "https://discord.gg/aw6N4pm"); Settings.AddSetting("Links", "Facebook", "http://fougerite.com/"); Settings.AddSetting("Links", "Instagram", "http://fougerite.com/"); Settings.AddSetting("Links", "VKontakte", "http://fougerite.com/"); Settings.AddSetting("ClientSide", "ClientMessage", "A new web browser has been opened"); Settings.AddSetting("ClientSide", "MessageDuration", "15"); Settings.Save(); Logger.Log(Name + " Plugin: New Settings File Created!"); ReloadConfig(); } else { Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini")); if (Settings.ContainsSetting("Timer", "EnableAnnounce") && Settings.ContainsSetting("Timer", "AnnounceTimeMins") && Settings.ContainsSetting("Timer", "AnnounceMessage") && Settings.ContainsSetting("Links", "Web") && Settings.ContainsSetting("Links", "Discord") && Settings.ContainsSetting("Links", "Facebook") && Settings.ContainsSetting("Links", "Instagram") && Settings.ContainsSetting("Links", "VKontakte") && Settings.ContainsSetting("ClientSide", "ClientMessage") && Settings.ContainsSetting("ClientSide", "MessageDuration")) { try { EnableAnnounce = Settings.GetBoolSetting("Timer", "EnableAnnounce"); AnnounceTimeMins = int.Parse(Settings.GetSetting("Timer", "AnnounceTimeMins")); AnnounceMessage = Settings.GetSetting("Timer", "AnnounceMessage"); Web = Settings.GetSetting("Links", "Web"); Discord = Settings.GetSetting("Links", "Discord"); Facebook = Settings.GetSetting("Links", "Facebook"); Instagram = Settings.GetSetting("Links", "Instagram"); VKontakte = Settings.GetSetting("Links", "VKontakte"); ClientMessage = Settings.GetSetting("ClientSide", "ClientMessage"); MessageDuration = int.Parse(Settings.GetSetting("ClientSide", "MessageDuration")); Logger.Log(Name + " Plugin: Settings file Loaded!"); if (EnableAnnounce) { Timer1(30 * 1000, null).Start(); } } catch (Exception ex) { Logger.Log(Name + " Plugin: Detected a problem in the configuration"); Logger.Log("ERROR -->" + ex.Message); File.Delete(Path.Combine(ModuleFolder, "Settings.ini")); Logger.Log(Name + " Plugin: Deleted the old configuration file"); ReloadConfig(); } } else { Logger.LogError(Name + " Plugin: Detected a problem in the configuration (lost key)"); File.Delete(Path.Combine(ModuleFolder, "Settings.ini")); Logger.LogError(Name + " Plugin: Deleted the old configuration file"); ReloadConfig(); } return; } }
public void Command(Player pl, string cmd, string[] args) { if (cmd == "tploc") { if (pl.Admin || Hasflag(pl, FLAG_USE)) { if (args.Length == 0) { pl.MessageFrom(Name, "Try out /tploc name"); string[] en = ini.EnumSection("Locations"); { foreach (var locs in en) { pl.MessageFrom(Name, locs); } } } else { if (ini.ContainsSetting("Locations", args[0])) { string j = ini.GetSetting("Locations", args[0]); Vector3 loc = Util.GetUtil().ConvertStringToVector3(j); // makes a Vector3 of string pl.TeleportTo(loc); pl.InventoryNotice(args[0]); } else { pl.MessageFrom(Name, "There is no location called " + args[0]); } } } } else if (cmd == "tplocadd") { if (pl.Admin || Hasflag(pl, FLAG_USE)) { if (args.Length == 0) { pl.MessageFrom(Name, "Syntax /tplocadd name"); return; } if (ini.ContainsSetting("Locations", args[0])) { pl.MessageFrom(Name, "There is already a location called " + args[0]); } else { ini.AddSetting("Locations", args[0], pl.Location.ToString()); pl.MessageFrom(Name, "New location called " + args[0] + " added at " + pl.Location); ini.Save(); } } } else if (cmd == "tplocremove") { if (pl.Admin || Hasflag(pl, FLAG_USE)) { if (args.Length == 0) { pl.MessageFrom(Name, "Syntax /tplocremove name"); return; } if (ini.ContainsSetting("Locations", args[0])) { ini.DeleteSetting("Locations", args[0]); ini.Save(); pl.MessageFrom(Name, "The location " + args[0] + " has been deleted"); } } } }
public void Command(User pl, string cmd, string[] args) { if(cmd == "esshelp") { pl.Message("Fougerite-Essentials " + Version + " by ice cold"); pl.Message("/help - see all commands"); pl.Message("/rules - see all the rules"); pl.Message("/info - See info about this plugin"); pl.Message("/friendhelp - See all information about the friends system"); pl.Message("/sharehelp - See all help about the share system"); if(EnableHome) { pl.Message("/home - See all help about the home system"); } if(EnableRemove) { pl.Message("/remove - Enables/disables remover tool"); } if(Enabletpr) { pl.Message("/tpr name - sends teleport request to that user"); pl.Message("/tpa - Accepts an teleport reqequest"); } if(EnableWarps) { pl.Message("/warphelp - See all the help for the warping system"); } if(pl.Admin || pl.Moderator) { pl.Message("/prod - Shows the owner of the object you are looking at"); pl.Message("/country player - Shows from which country a player comes"); pl.Message("/download url filename - downloads that object and put it in the the Downloaded folder EXAMPLE: (/download http://myitem.com myitem.zip)"); pl.Message("/addnewspawn - adds a new spawns to the overwrite spawn list"); } } else if(cmd == "country") { if(pl.Admin || pl.Moderator) { if(args.Length != 1) { pl.Message("Usage /country player"); return; } User target = Server.GetServer().FindPlayer(args[0]); if(target == null) { pl.Message("Couldn't find the target user"); return; } string country = PlayerDatabase.GetSetting(target.SteamID, "Country"); pl.Message("[color #ffb90f]" + target.Name + " is located from [color #c1ffc1]" + country); } } else if(cmd == "download") { if(pl.Admin) { if(args.Length != 2) { pl.Message("Usage /download url filename - EXAMPLE: (/download http://myitem.com myitem.zip)"); return; } using (WebClient web = new WebClient()) { web.DownloadFileAsync(new Uri(args[0]), Util.GetRootFolder() + "\\Save\\Fougerite-Essentials\\Downloaded\\" + args[1]); pl.Message("[color #00ced1]Downloading " + args[1] + " to downloaded folder"); } } } else if(cmd == "addnewspawn") { if(pl.Admin) { if(EnableNewSpawns) { string[] c = SpawnsOverwrite.EnumSection("SpawnLocations"); string co = (Convert.ToInt32(c[c.Length - 1]) + 1).ToString(); SpawnsOverwrite.AddSetting("SpawnLocations", co, pl.Location.ToString()); SpawnsOverwrite.Save(); } } } else if(cmd == "warphelp") { pl.Message("Fougerite-Essentials WarpSystem by ice cold"); pl.Message("/warp name - Warps you to that location"); pl.Message("/warps - See all the current warps"); if(pl.Admin) { pl.Message("/warp_set Name"); pl.Message("/warp_remove Name"); } } else if(cmd == "warp") { if(args.Length != 1) { pl.Message("Usage /warp name"); return; } if(Warps.ContainsSetting("Warps", args[0])) { if (pl.Admin) { Vector3 loc = Util.GetUtil().ConvertStringToVector3(Warps.GetSetting("Warps", args[0])); pl.TeleportTo(loc); pl.Message("[color#00bfff]Warped to " + args[0]); } else { if(!warpcd.Contains(pl.UID)) { var dict = new Dictionary<string, object>(); dict["pl"] = pl; warpcd.Add(pl.UID); Warpcooldown(WarpCooldown * 1000, dict).Start(); Warpdelaytimer(WarpDelay * 1000, dict).Start(); string message = WarpDelayMessage.Replace("{warpname}", args[0]); } else { pl.Message(WarpCooldownMessage); } } } } else if(cmd == "warps") { pl.Message("WarpsList"); string[] l = Warps.EnumSection("Warps"); foreach(var num in l) { pl.Message(num); } } else if(cmd == "warp_set") { if(pl.Admin) { if(args.Length != 1) { pl.Message("Usage /warp_set Name"); return; } if(Warps.ContainsSetting("Warps", args[0])) { pl.Message("There is already a warp with the name " + args[0]); return; } Warps.AddSetting("Warps", args[0], pl.Location.ToString()); Warps.Save(); pl.Message("Warp saved"); } } else if(cmd == "warp_remove") { if(pl.Admin) { if(args.Length != 1) { pl.Message("Usage /warp_remove Name"); return; } if(!Warps.ContainsSetting("Warps", args[0])) { pl.Message("There is no warp with the name " + args[0]); return; } Warps.DeleteSetting("Warps", args[0]); Warps.Save(); pl.Message("The warp " + args[0] + " has been succesfully removed"); } } else if(cmd == "help") { if(EnableHelp) { foreach (var h in HelpList.EnumSection("Help")) { string d = HelpList.GetSetting("Help", h); pl.MessageFrom("Help", d); } } } else if(cmd == "rules") { if(EnableRules) { foreach (var r in RulesList.EnumSection("Rules")) { string d = RulesList.GetSetting("Help", r); pl.MessageFrom("Help", d); } } } else if(cmd == "info") { pl.MessageFrom(Name, "[color #87cefa][Fougerite-Essentials " + Version + " plugin brought by ice cold"); pl.MessageFrom(Name, "[color #20b2aa]Wanna support ice cold? https://www.patreon.com/uberrust"); pl.MessageFrom(Name, "[color #8470ff]You can download this plugin at "); } else if(cmd == "friendhelp") { pl.Message("[Fougerite-Essentials] Friends system brought by ice cold"); pl.Message("/addfriend Name - ads player to your friends list"); pl.Message("/unfriend Name - Unfriend someone"); pl.Message("/friends - See all your friends"); } else if(cmd == "sharehelp") { pl.Message("[Fougerite-Essentials] Share system brought by ice cold"); pl.Message("/share Name - Door/structure share the player"); pl.Message("/unshare Name - unshare someone"); pl.Message("/sharelist - See all the people you have shared"); } else if(cmd == "addfriend") { if(EnableFriendsSystem) { if (args.Length != 1) { pl.Message("Usage /addfriend Name"); return; } User target = Server.GetServer().FindPlayer(args[0]); if (target == null) { pl.Message("Couldn't find the target user"); return; } if (friends.ContainsSetting(pl.SteamID, target.SteamID)) { string message = AlreadyFriendedMessage.Replace("{friend}", target.Name); pl.Message(message); return; } string me = AddFriendMessage.Replace("{friend}", target.Name); pl.Message(me); friends.AddSetting(pl.SteamID, target.SteamID, target.Name); friends.Save(); } } else if(cmd == "unfriend") { if(EnableShareSystem) { if (args.Length != 1) { pl.Message("Usage /unfriend Name"); return; } User target = Server.GetServer().FindPlayer(args[0]); if(target == null) { pl.Message("Couldn't find the target user"); return; } if(!friends.ContainsSetting(pl.SteamID, target.SteamID)) { pl.Message(target.Name + " Isnt in your friends list"); return; } friends.DeleteSetting(pl.SteamID, target.SteamID); friends.Save(); string message = UnfriendMessage.Replace("{target}", target.Name); pl.Message(message); friends.DeleteSetting(pl.SteamID, target.SteamID); friends.Save(); } } else if(cmd == "friends") { if(EnableFriendsSystem) { pl.Message("===FriendsList==="); foreach (var id in friends.EnumSection(pl.SteamID)) { string m = friends.GetSetting(pl.SteamID, id); pl.Message("_ " + m); } } } else if(cmd == "share") { if(EnableShareSystem) { if(args.Length != 1) { pl.Message("Usage /share Name"); return; } User target = Server.GetServer().FindPlayer(args[0]); if (target == null) { pl.Message("Couldn't find the target user"); return; } if(share.ContainsSetting(pl.SteamID, target.SteamID)) { string message = AlreadySharedMessage.Replace("{player}", target.Name); pl.Message(message); return; } share.AddSetting(pl.SteamID, target.SteamID, target.Name); share.Save(); string me = SharedMessage.Replace("{player}", target.Name); pl.Message(me); } } else if(cmd == "unshare") { if(EnableShareSystem) { if(args.Length != 1) { pl.Message("Usage /unshare Name"); return; } User target = Server.GetServer().FindPlayer(args[0]); if(target == null) { pl.Message("Couldn't find the target user"); return; } if(!share.ContainsSetting(pl.SteamID, target.SteamID)) { pl.Message("You are not sharing with " + target.Name); return; } share.DeleteSetting(pl.SteamID, target.SteamID); share.Save(); string message = UnSharedMessage.Replace("{player}", target.Name); pl.Message(message); } } else if(cmd == "sharelist") { if(EnableShareSystem) { pl.Message("===ShareList==="); foreach(var id in share.EnumSection(pl.SteamID)) { string m = share.GetSetting(pl.SteamID, id); pl.Message("- " + m); } } } else if(cmd == "prod") { if(pl.Admin || pl.Moderator) { cachedCharacter = pl.PlayerClient.rootControllable.idMain.GetComponent<Character>(); if (!MeshBatchPhysics.Raycast(cachedCharacter.eyesRay, out cachedRaycast, out cachedBoolean, out cachedhitInstance)) { pl.Message("He Hello thats the sky bro"); return; } if(cachedhitInstance != null) { cachedCollider = cachedhitInstance.physicalColliderReferenceOnly; if (cachedCollider == null) { pl.Message("Sorry but i cannot prod that"); return; } cachedStructure = cachedCollider.GetComponent<StructureComponent>(); if (cachedStructure != null && cachedStructure._master != null) { cachedMaster = cachedStructure._master; var name = PlayerDatabase.GetSetting(cachedMaster.ownerID.ToString(), "Name"); pl.Message(string.Format("{object} - {ID} - {name}", cachedStructure.gameObject.name, cachedMaster.ownerID.ToString(), name == null ? "Unknown" : name.ToString())); } } else { cachedDeployable = cachedRaycast.collider.GetComponent<DeployableObject>(); if(cachedDeployable != null) { var name = PlayerDatabase.GetSetting(cachedMaster.ownerID.ToString(), "Name"); pl.Message(string.Format("{object} - {ID} - {name}", cachedDeployable.gameObject.name, cachedDeployable.ownerID.ToString(), name == null ? cachedDeployable.ownerName.ToString() : name.ToString())); } } pl.Message("Failed to prod " + cachedRaycast.collider.gameObject.name); } } else if(cmd == "home") { if(EnableHome) { if(args.Length != 1) { pl.Message("[Fougerite-Essentials] Home system brought by ice cold"); if(!SleepingHome) { pl.Message("/home Name - teleports you the home"); pl.Message("/sethome Name - Enabled sethome mode (hit a foundation or ceiling to save your home)"); pl.Message("/delhome Name - Deletes that home"); pl.Message("/homes - Shows the list of homes"); } else { pl.Message("/homeon - Enables home mode (place a Sleepingbag or Bed to save that as your current home)"); pl.Message("/gohome - Teleports you to your sleepingBag or Bed"); } } else { if(!SleepingHome) { if(!homecd.Contains(pl.UID)) { if (StructureHome.ContainsSetting(pl.SteamID, args[0])) { var homeloc = StructureHome.GetSetting(pl.SteamID, args[0]); var dict = new Dictionary<string, object>(); dict["pl"] = pl; dict["homeloc"] = homeloc; HomeTimer(HomeDelay * 1000, dict).Start(); string message = HomeDelayMessage.Replace("{home}", args[0]).Replace("{delay}", HomeDelay.ToString()); pl.Message(message); HomeCooldown(HomeCooldown * 1000, dict).Start(); homecd.Add(pl.UID); } else { string message = NoHomeMessage.Replace("{home}", args[0]); pl.Message(message); } } else { string message = HomeCooldownMessage.Replace("{cooldown}", HomeCooldown.ToString()); pl.Message(message); } } } } } else if(cmd == "sethome") { if(EnableHome) { if(!homemode.Contains(pl.UID)) { if (args.Length != 1) { pl.Message("Usage /sethome Name"); return; } string[] l = StructureHome.EnumSection(pl.SteamID); if ((Convert.ToBoolean(l.Length == MaxHomes))) { pl.Message(MaxHomesMessage); } else { homemode.Add(pl.UID); pl.Message("Sethome mode activated hit a foundation/ceiling to set your home"); homenum.Add(pl.UID, args[0]); } } else { pl.Message("Please do /homestop first"); } } } else if(cmd == "") }
private void ReloadConfig() { weapons.Clear(); if (!File.Exists(Path.Combine(ModuleFolder, "Settings.ini"))) { File.Create(Path.Combine(ModuleFolder, "Settings.ini")).Dispose(); Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini")); Settings.AddSetting("WeaponsCanShowDamage", "Rock", "true"); Settings.AddSetting("WeaponsCanShowDamage", "Stone Hatchet", "true"); Settings.AddSetting("WeaponsCanShowDamage", "Hatchet", "true"); Settings.AddSetting("WeaponsCanShowDamage", "Pick Axe", "true"); Settings.AddSetting("WeaponsCanShowDamage", "Hunting Bow", "true"); Settings.AddSetting("WeaponsCanShowDamage", "Uber Hunting Bow", "true"); Settings.AddSetting("WeaponsCanShowDamage", "Revolver", "true"); Settings.AddSetting("WeaponsCanShowDamage", "HandCannon", "false"); Settings.AddSetting("WeaponsCanShowDamage", "Pipe Shotgun", "false"); Settings.AddSetting("WeaponsCanShowDamage", "9mm Pistol", "true"); Settings.AddSetting("WeaponsCanShowDamage", "P250", "true"); Settings.AddSetting("WeaponsCanShowDamage", "MP5A4", "false"); Settings.AddSetting("WeaponsCanShowDamage", "Shotgun", "false"); Settings.AddSetting("WeaponsCanShowDamage", "M4", "false"); Settings.AddSetting("WeaponsCanShowDamage", "Bolt Action Rifle", "true"); Settings.AddSetting("WeaponsCanShowDamage", "F1 Grenade", "false"); Settings.AddSetting("WeaponsCanShowDamage", "Explosive Charge", "true"); Logger.Log(Name + " Plugin: New Settings File Created!"); Settings.Save(); ReloadConfig(); } else { Settings = new IniParser(Path.Combine(ModuleFolder, "Settings.ini")); if (Settings.ContainsSetting("WeaponsCanShowDamage", "Rock") && Settings.ContainsSetting("WeaponsCanShowDamage", "Stone Hatchet") && Settings.ContainsSetting("WeaponsCanShowDamage", "Hatchet") && Settings.ContainsSetting("WeaponsCanShowDamage", "Pick Axe") && Settings.ContainsSetting("WeaponsCanShowDamage", "Hunting Bow") && Settings.ContainsSetting("WeaponsCanShowDamage", "Uber Hunting Bow") && Settings.ContainsSetting("WeaponsCanShowDamage", "Revolver") && Settings.ContainsSetting("WeaponsCanShowDamage", "HandCannon") && Settings.ContainsSetting("WeaponsCanShowDamage", "Pipe Shotgun") && Settings.ContainsSetting("WeaponsCanShowDamage", "9mm Pistol") && Settings.ContainsSetting("WeaponsCanShowDamage", "P250") && Settings.ContainsSetting("WeaponsCanShowDamage", "MP5A4") && Settings.ContainsSetting("WeaponsCanShowDamage", "Shotgun") && Settings.ContainsSetting("WeaponsCanShowDamage", "M4") && Settings.ContainsSetting("WeaponsCanShowDamage", "Bolt Action Rifle") && Settings.ContainsSetting("WeaponsCanShowDamage", "F1 Grenade") && Settings.ContainsSetting("WeaponsCanShowDamage", "Explosive Charge")) { try { if (Settings.GetBoolSetting("WeaponsCanShowDamage", "Rock")) { weapons.Add("Rock"); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "Stone Hatchet")) { weapons.Add("Stone Hatchet"); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "Hatchet")) { weapons.Add("Hatchet"); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "Pick Axe")) { weapons.Add("Pick Axe"); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "Hunting Bow")) { weapons.Add("Hunting Bow"); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "Uber Hunting Bow")) { weapons.Add("Uber Hunting Bow"); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "Revolver")) { weapons.Add("Revolver"); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "HandCannon")) { weapons.Add("HandCannon"); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "Pipe Shotgun")) { weapons.Add("Pipe Shotgun"); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "9mm Pistol")) { weapons.Add(""); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "P250")) { weapons.Add("P250"); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "MP5A4")) { weapons.Add("MP5A4"); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "Shotgun")) { weapons.Add("Shotgun"); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "M4")) { weapons.Add("M4"); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "Bolt Action Rifle")) { weapons.Add("Bolt Action Rifle"); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "F1 Grenade")) { weapons.Add("F1 Grenade"); } if (Settings.GetBoolSetting("WeaponsCanShowDamage", "Explosive Charge")) { weapons.Add("Explosive Charge"); } Logger.Log(Name + " Plugin: Settings File Loaded!"); } catch (Exception ex) { Logger.LogError(Name + " Plugin: Detected a problem in the configuration"); Logger.Log("ERROR -->" + ex.Message); File.Delete(Path.Combine(ModuleFolder, "Settings.ini")); Logger.LogError(Name + " Plugin: Deleted the old configuration file"); ReloadConfig(); } } else { Logger.LogError(Name + " Plugin: Detected a problem in the configuration (lost key)"); File.Delete(Path.Combine(ModuleFolder, "Settings.ini")); Logger.LogError(Name + " Plugin: Deleted the old configuration file"); ReloadConfig(); } return; } }