public void OnCommand(Fougerite.Player player, string cmd, string[] args) { switch (cmd) { case "flushdeathmsg": { if (player.Admin || PermissionSystem.GetPermissionSystem().PlayerHasPermission(player, "deathmsg.flushdeathmsg")) { DataStore.GetInstance().Flush("DeathMSGAVG"); DataStore.GetInstance().Flush("DeathMSGAVG2"); player.MessageFrom(DeathMSGName, "Flushed!"); } break; } case "deathmsgrd": { if (player.Admin || PermissionSystem.GetPermissionSystem().PlayerHasPermission(player, "deathmsg.deathmsgrd")) { LoadConfig(); player.MessageFrom(DeathMSGName, "Reloaded!"); } break; } } }
private void OnCommand(Fougerite.Player player, string cmd, string[] args) { switch (cmd) { case "record": { if (player.Admin || PermissionSystem.GetPermissionSystem().PlayerHasPermission(player, "recorder.record")) { if (args.Length == 0) { player.MessageFrom("Recorder", "Usage: /record name"); return; } object state = DataStore.GetInstance().Get("Recorder", player.UID); if (state != null) { player.MessageFrom("Recorder", "Already Recording!"); return; } string name = string.Join("_", args).ToLower(); DataStore.GetInstance().Flush("RecordedData" + player.UID); DataStore.GetInstance().Add("Recorder", player.UID, 1); DataStore.GetInstance().Add("Recorder_Name", player.UID, name); player.MessageFrom("Recorder", "Recording " + name + ".ini (/rstop to finish!)"); } break; } case "rspawn": if (player.Admin || PermissionSystem.GetPermissionSystem().PlayerHasPermission(player, "recorder.rspawn")) { if (args.Length != 2) { player.MessageFrom("Recorder", "Usage: /rspawn name.ini distance"); return; } float distance = 0f; bool success = float.TryParse(args[1], out distance); if (!success) { player.MessageFrom("Recorder", "Usage: /rspawn name.ini distance"); return; } if (!File.Exists(Path.Combine(ModuleFolder, "Buildings\\" + args[0]))) { player.MessageFrom("Recorder", "Building not found!"); return; } IniParser file = new IniParser(Path.Combine(ModuleFolder, "Buildings\\" + args[0])); DataStore.GetInstance().Flush("SpawnedData" + player.UID); DataStore.GetInstance().Remove("RecorderSMs", player.UID); Vector3 playerFront = Util.GetUtil().Infront(player, distance); float groundposition = World.GetWorld().GetGround(playerFront.x, playerFront.z); //playerFront.y = World.GetGround(playerFront.x, playerFront.z); List <string> sections = file.Sections.Where(x => x != "Init").ToList(); StructureMaster master = null; int failures = 0; for (int i = 0; i < sections.Count; i++) { Vector3 entPos = Util.GetUtil().CreateVector(float.Parse(file.GetSetting("Part" + i, "PosX")), float.Parse(file.GetSetting("Part" + i, "PosY")), float.Parse(file.GetSetting("Part" + i, "PosZ"))); Vector3 spawnPos = Util.GetUtil().CreateVector(entPos.x + playerFront.x, entPos.y + groundposition, entPos.z + playerFront.z); Quaternion spawnRot = Util.GetUtil().CreateQuat(float.Parse(file.GetSetting("Part" + i, "RotX")), float.Parse(file.GetSetting("Part" + i, "RotY")), float.Parse(file.GetSetting("Part" + i, "RotZ")), float.Parse(file.GetSetting("Part" + i, "RotW"))); if (master == null) { master = World.GetWorld() .CreateSM(player, spawnPos.x, spawnPos.y, spawnPos.z, spawnRot); } Entity go = null; try { go = World.GetWorld().SpawnEntity(file.GetSetting("Part" + i, "Prefab"), spawnPos, spawnRot); } catch { failures++; // Ignore. continue; } try { if (go.IsLootableObject()) { LootableObject lootableObject = (LootableObject)go.Object; go.ChangeOwner(player); DataStore.GetInstance().Add("SpawnedData" + player.UID, "Part" + i, lootableObject.gameObject); } else if (go.IsDeployableObject()) { go.ChangeOwner(player); DeployableObject deployableObject = (DeployableObject)go.Object; DataStore.GetInstance().Add("SpawnedData" + player.UID, "Part" + i, deployableObject.gameObject); } else if (go.IsBasicDoor()) { BasicDoor door = (BasicDoor)go.Object; go.ChangeOwner(player); DataStore.GetInstance().Add("SpawnedData" + player.UID, "Part", door.gameObject); } else if (go.IsStructure()) { StructureComponent structureComponent = (StructureComponent)go.Object; master.AddStructureComponent(structureComponent); DataStore.GetInstance().Add("SpawnedData" + player.UID, "Part" + i, structureComponent.gameObject); } } catch (Exception ex) { Logger.LogError("[Recorder] Error: " + ex); Logger.LogError("At prefab: " + file.GetSetting("Part" + i, "Prefab")); } } player.MessageFrom("Recorder", args[0] + " was spawned !"); if (failures > 0) { player.MessageFrom("Recorder", failures + " amount of failures happened. This file might have wrong values!"); } } break; case "rlist": if (player.Admin || PermissionSystem.GetPermissionSystem().PlayerHasPermission(player, "recorder.rlist")) { string[] files = Directory.GetFiles(Path.Combine(ModuleFolder, "Buildings\\"), "*.ini"); for (int i = 0; i < files.Length; i++) { files[i] = Path.GetFileName(files[i]); } player.MessageFrom("Recorder", "=== Files ==="); player.MessageFrom("Recorder", string.Join(", ", files)); } break; case "rcancel": if (player.Admin || PermissionSystem.GetPermissionSystem().PlayerHasPermission(player, "recorder.rcancel")) { int cpt = DataStore.GetInstance().Count("SpawnedData" + player.UID); for (int i = 0; i < cpt; i++) { GameObject ent = DataStore.GetInstance().Get("SpawnedData" + player.UID, "Part" + i) as GameObject; if (ent != null) { Util.GetUtil().DestroyObject(ent); } DataStore.GetInstance().Remove("Recorder", player.UID); DataStore.GetInstance().Flush("RecordedData" + player.UID); DataStore.GetInstance().Flush("SpawnedData" + player.UID); DataStore.GetInstance().Remove("RecorderInit", player.UID); DataStore.GetInstance().Remove("RecorderSMs", player.UID); } DataStore.GetInstance().Flush("SpawnedData" + player.UID); player.Message("Cancelled recording"); } break; case "rstop": if (player.Admin || PermissionSystem.GetPermissionSystem().PlayerHasPermission(player, "recorder.rstop")) { string name = (string)DataStore.GetInstance().Get("Recorder_Name", player.UID); if (File.Exists(Path.Combine(ModuleFolder, "Buildings\\" + name))) { var rnd = new Random(); int rnd2 = rnd.Next(0, 500000); player.Message(name + ".ini already exists ! renaming.."); name = name + rnd2; } name = name + ".ini"; Vector3 loc = (Vector3)DataStore.GetInstance().Get("RecorderInit", player.UID); float groundposition = World.GetWorld().GetGround(loc.x, loc.z); //loc.y = World.GetGround(loc.x, loc.z) int cpt = DataStore.GetInstance().Count("RecordedData" + player.UID); if (cpt == 0) { DataStore.GetInstance().Flush("RecordedData" + player.UID); return; } if (!File.Exists(Path.Combine(ModuleFolder, "Buildings\\" + name))) { File.Create(Path.Combine(ModuleFolder, "Buildings\\" + name)).Dispose(); } IniParser rfile = new IniParser(Path.Combine(ModuleFolder, "Buildings\\" + name)); for (int i = 0; i < cpt; i++) { Entity ent = (Entity)DataStore.GetInstance().Get("RecordedData" + player.UID, "Part" + i); Vector3 entPos = new Vector3((ent.X - loc.x), (ent.Y - groundposition), (ent.Z - loc.z)); Quaternion spawnRot = ent.Rotation; rfile.AddSetting("Part" + i, "Prefab", Prefabs[ent.Name]); rfile.AddSetting("Part" + i, "PosX", entPos.x.ToString(CultureInfo.CurrentCulture)); rfile.AddSetting("Part" + i, "PosY", entPos.y.ToString(CultureInfo.CurrentCulture)); rfile.AddSetting("Part" + i, "PosZ", entPos.z.ToString(CultureInfo.CurrentCulture)); rfile.AddSetting("Part" + i, "RotX", spawnRot.x.ToString(CultureInfo.CurrentCulture)); rfile.AddSetting("Part" + i, "RotY", spawnRot.y.ToString(CultureInfo.CurrentCulture)); rfile.AddSetting("Part" + i, "RotZ", spawnRot.z.ToString(CultureInfo.CurrentCulture)); rfile.AddSetting("Part" + i, "RotW", spawnRot.w.ToString(CultureInfo.CurrentCulture)); } DataStore.GetInstance().Remove("Recorder", player.UID); DataStore.GetInstance().Flush("RecordedData" + player.UID); DataStore.GetInstance().Flush("SpawnedData" + player.UID); DataStore.GetInstance().Remove("RecorderInit", player.UID); DataStore.GetInstance().Remove("RecorderSMs", player.UID); DataStore.GetInstance().Flush("SpawnedData" + player.UID); rfile.Save(); player.MessageFrom("Recorder", name + " was saved !"); } break; } }
public void OnCommand(Fougerite.Player player, string cmd, string[] args) { if (cmd == "legitraid") { player.MessageFrom("LegitRaid", green + "LegitRaid " + yellow + " V" + Version + " [COLOR#FFFFFF] By " + Author); if (player.Admin || PermissionSystem.GetPermissionSystem().PlayerHasPermission(player, "legitraid.reload")) { Settings = new IniParser(PathC); RaidTime = int.Parse(Settings.GetSetting("Settings", "RaidTime")); MaxRaidTime = int.Parse(Settings.GetSetting("Settings", "MaxRaidTime")); AllowAllModerators = Settings.GetBoolSetting("Settings", "AllowAllModerators"); CanOpenChestIfThereIsNoStructureClose = Settings.GetBoolSetting("Settings", "CanOpenChestIfThereIsNoStructureClose"); AutoWhiteListFriends = Settings.GetBoolSetting("Settings", "AutoWhiteListFriends"); var Collect = Settings.GetSetting("Settings", "WhiteListedIDs"); var splits = Collect.Split(','); WhiteListedIDs.Clear(); foreach (var x in splits) { WhiteListedIDs.Add(x); } var Collect2 = Settings.GetSetting("Settings", "DataStoreTables"); var splits2 = Collect2.Split(','); foreach (var x in splits2) { DSNames.Add(x); } player.MessageFrom("LegitRaid", "Reloaded!"); } } else if (cmd == "flushlegita") { if (player.Admin || PermissionSystem.GetPermissionSystem().PlayerHasPermission(player, "legitraid.flushlegita")) { DataStore.GetInstance().Flush("LegitRaidED"); player.MessageFrom("LegitRaid", "Flushed!"); } } else if (cmd == "friendraid") { if (!RustPP || AutoWhiteListFriends) { player.MessageFrom("LegitRaid", "Friends are AutoWhitelisted on this Server."); return; } bool contains = DataStore.GetInstance().ContainsKey("LegitRaid", player.UID); if (!contains) { DataStore.GetInstance().Add("LegitRaid", player.UID, true); player.MessageFrom("LegitRaid", "Your friends can now open your chests."); } else { DataStore.GetInstance().Remove("LegitRaid", player.UID); player.MessageFrom("LegitRaid", "Your friends can not open your chests."); } } else if (cmd == "raida") { if (player.Admin || (player.Moderator && AllowAllModerators) || (player.Moderator && WhiteListedIDs.Contains(player.SteamID)) || PermissionSystem.GetPermissionSystem().PlayerHasPermission(player, "legitraid.raida")) { bool contains = DataStore.GetInstance().ContainsKey("LegitRaidA", player.UID); if (!contains) { DataStore.GetInstance().Add("LegitRaidA", player.UID, true); player.MessageFrom("LegitRaid", "You can now open all the chests"); file = new System.IO.StreamWriter(PathLog, true); file.WriteLine(DateTime.Now + " " + player.Name + "-" + player.SteamID + " entered all loot mode"); file.Close(); } else { DataStore.GetInstance().Remove("LegitRaidA", player.UID); player.MessageFrom("LegitRaid", "Disabled"); file = new System.IO.StreamWriter(PathLog, true); file.WriteLine(DateTime.Now + " " + player.Name + "-" + player.SteamID + " quit all loot mode"); file.Close(); } } } }