private void RespawnNPC(NetworkCommandArgs args) { string text = String.Empty; try { SpawnAnimals.reset(); text = "Successfully respawned all zombies & animals"; byte[] serverbuffer = Encoding.UTF8.GetBytes(text); args.sender.SendBytes(serverbuffer); } catch { text = "Error occured while tried to Respawn all NPC"; byte[] serverbuffer = Encoding.UTF8.GetBytes(text); args.sender.SendBytes(serverbuffer); } }
public void onReady() { SpawnAnimals.model = GameObject.Find(Application.loadedLevelName).transform.FindChild("animals").gameObject; SpawnAnimals.reset(); }
private void ResetZombies(CommandArgs args) { SpawnAnimals.reset(); NetworkChat.sendAlert(args.sender.name + " has respawned all zombies"); }
public void checkForCommands() { if (getLastMessageText().StartsWith("/")) { UpdatePlayerList(true); String sender = getLastMessagePlayerName(); String commando = getLastMessageText(); string groupString = getLastMessageGroup(); lastUsedCommand = commando; if (loggingCommands) { LogCommand(sender + ":" + commando); } //commands for non-admins if (commando.Equals("/online")) { resetChat(); getNetworkChat().askChat("There are " + names.Count + " players online.", 2, getNetworkPlayerByPlayerName(sender)); return; } else if (commando.StartsWith("/time")) { resetChat(); NetworkChat.sendAlert("Time: " + Sun.getTime()); return; } else if (commando.Equals("/sethome")) { resetChat(); if (usePlayerHomes) { Vector3 location = NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(sender)).transform.position; setHome(getSteamIDByPlayerName(sender), location); getNetworkChat().askChat("Home set.", 2, getNetworkPlayerByPlayerName(sender)); } return; } else if (commando.Equals("/home")) { resetChat(); if (usePlayerHomes) { //getNetworkChat().askChat("Teleporting home in 5 seconds...", 2, getNetworkPlayerByPlayerName(sender)); //Thread.Sleep(5000); // what use has a delay if I cant check if the player moves while waiting ... home(sender, getSteamIDByPlayerName(sender)); getNetworkChat().askChat("Teleported home. Don't move for 5 seconds if you don't wanna get kicked", 2, getNetworkPlayerByPlayerName(sender)); } return; } if (isAdmin(sender) || (usingConsole && groupString.Equals(ConsolePassword))) { if (!groupString.Equals(ConsolePassword) && requireCommandConfirmation && !commandconfirmed && commando.ToUpper().Equals("/" + confirmationString.ToUpper())) { resetChat(); commandconfirmed = true; sendAdminTextToHost(tempCommand); return; } if (!groupString.Equals(ConsolePassword) && requireCommandConfirmation && !commandconfirmed) { resetChat(); tempCommand = commando; tempSender = sender; confirmationString = RandomString(4); Tell(getNetworkPlayerByPlayerName(sender), "Please confirm your command, type /" + confirmationString); return; } /*if (getAdminLevel(sender) == -1 && sender != tempSender) * { * getNetworkChat().askChat("An error occured! You appear to not have Admin Rights!", 2, getNetworkPlayerByPlayerName(sender)); * return; * }*/ //int permLvl = getAdminLevel(sender); int permLvl = 4; if (commando.StartsWith("/repeat") && permLvl >= 1) { resetChat(); NetworkChat.sendAlert(commando.Substring(8)); } else if (commando.StartsWith("/ban") && permLvl >= 1) { resetChat(); String naam = commando.Substring(5); if (naam.Length < 3) { naam = names[Convert.ToInt32(naam)]; tempBanName = naam; getNetworkChat().askChat("Reason for banning " + naam + " ? /reason <reason> to ban", 2, getNetworkPlayerByPlayerName(sender)); } else { tempBanName = naam; getNetworkChat().askChat("Reason for banning " + naam + " ? /reason <reason> to ban", 2, getNetworkPlayerByPlayerName(sender)); } } else if (commando.StartsWith("/kick") && permLvl >= 1) { resetChat(); String naam = commando.Substring(6); if (naam.Length < 3) { naam = names[Convert.ToInt32(naam)]; getNetworkChat().askChat("Kick " + naam + " ? /y to confirm", 2, getNetworkPlayerByPlayerName(sender)); tempKickName = naam; } else { playerName = naam; KICK(); } } else if (commando.Equals("/y")) { // kick resetChat(); playerName = tempKickName; KICK(); } else if (commando.StartsWith("/reason") && permLvl >= 1) { resetChat(); reason = commando.Substring(8); playerID = getSteamIDByPlayerName(tempBanName); if (!playerID.Equals("")) { playerName = tempBanName; BAN(); } } else if (commando.StartsWith("/resetitems") && permLvl >= 2) { resetChat(); SpawnItems.reset(); NetworkChat.sendAlert(sender + " has respawned all items"); } else if (commando.StartsWith("/repairvehicles") && permLvl >= 1) { resetChat(); Vehicle[] vehicles = UnityEngine.Object.FindObjectsOfType(typeof(Vehicle)) as Vehicle[]; foreach (Vehicle vehicle in vehicles) { vehicle.networkView.RPC("tellExploded", RPCMode.All, new object[] { false }); vehicle.networkView.RPC("tellWrecked", RPCMode.All, new object[] { false }); vehicle.heal(1000); } NetworkChat.sendAlert(sender + " has repaired " + vehicles.Length + " vehicles"); } else if (commando.StartsWith("/refuelvehicles") && permLvl >= 1) { resetChat(); Vehicle[] vehicles = UnityEngine.Object.FindObjectsOfType(typeof(Vehicle)) as Vehicle[]; foreach (Vehicle vehicle in vehicles) { vehicle.fill(1000); } NetworkChat.sendAlert(sender + " has refueled " + vehicles.Length + " vehicles"); } else if (commando.StartsWith("/sirens") && permLvl >= 1) { resetChat(); Vehicle[] vehicles = UnityEngine.Object.FindObjectsOfType(typeof(Vehicle)) as Vehicle[]; foreach (Vehicle vehicle in vehicles) { vehicle.networkView.RPC("tellSirens", RPCMode.All, new object[] { true }); } } else if (commando.Equals("/sirensoff") && permLvl >= 1) { resetChat(); Vehicle[] vehicles = UnityEngine.Object.FindObjectsOfType(typeof(Vehicle)) as Vehicle[]; foreach (Vehicle vehicle in vehicles) { vehicle.networkView.RPC("tellSirens", RPCMode.All, new object[] { false }); } } else if (commando.StartsWith("/resetzombies") && permLvl >= 2) { resetChat(); SpawnAnimals.reset(); NetworkChat.sendAlert(sender + " has respawned all zombies"); } else if (commando.StartsWith("/killzombies") && permLvl >= 2) { resetChat(); Zombie[] Zombies = UnityEngine.Object.FindObjectsOfType(typeof(Zombie)) as Zombie[]; foreach (Zombie Zombie in Zombies) { Zombie.damage(500); } NetworkChat.sendAlert(sender + " has killed " + Zombies.Length + " zombies"); } else if (commando.StartsWith("/reloadbans") && permLvl >= 3) { resetChat(); NetworkBans.load(); } else if (commando.StartsWith("/setitemsdelay") && permLvl == 4) { resetChat(); String seconds = commando.Substring(15); setItemResetIntervalInSeconds(Convert.ToInt32(seconds)); } else if (commando.StartsWith("/setannouncedelay") && permLvl >= 3) { resetChat(); String seconds = commando.Substring(18); setAnnounceIntervalInSeconds(Convert.ToInt32(seconds)); } else if (commando.StartsWith("/reloadCommands") && permLvl >= 4) { resetChat(); reloadCommands(); } else if (commando.StartsWith("/logmsg") && permLvl >= 4) { resetChat(); for (int i = 0; i < 80; i++) { Log(getNetworkChatFieldByNum(i)); } } else if (commando.StartsWith("/enablewhitelist") && permLvl >= 3) { resetChat(); usingWhitelist = true; NetworkChat.sendAlert("Whitelist enabled."); } else if (commando.StartsWith("/disablewhitelist") && permLvl >= 3) { resetChat(); usingWhitelist = false; NetworkChat.sendAlert("Whitelist disabled."); } else if (commando.StartsWith("/whitelist add") && permLvl >= 3) { resetChat(); String naam = commando.Substring(15); System.IO.StreamWriter file = new StreamWriter("Unturned_Data/Managed/mods/AdminCommands/UnturnedWhitelist.txt", true); file.WriteLine(""); file.WriteLine(naam); file.Close(); reloadCommands(); } else if (commando.StartsWith("/whitelist remove ") && permLvl >= 3) { resetChat(); String naam = commando.Substring(18); string[] lines = System.IO.File.ReadAllLines(@"Unturned_Data/Managed/mods/AdminCommands/UnturnedWhitelist.txt"); File.Delete("Unturned_Data/Managed/mods/AdminCommands/UnturnedWhitelist.txt"); System.IO.StreamWriter file = new StreamWriter("Unturned_Data/Managed/mods/AdminCommands/UnturnedWhitelist.txt", true); for (int i = 0; i < lines.Length; i++) { if (!lines[i].Equals(naam)) { file.WriteLine(lines[i]); } } file.Close(); reloadCommands(); } else if (commando.StartsWith("/unban") && permLvl >= 1) { resetChat(); String name = commando.Substring(7); unban(name); } else if (commando.StartsWith("/tpto ") && permLvl >= 1) { resetChat(); String locString = commando.Substring(6); Quaternion rotation = NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(sender)).transform.rotation; float x = float.Parse(locString.Split(' ')[0]); float y = float.Parse(locString.Split(' ')[1]); float z = float.Parse(locString.Split(' ')[2]); //NetworkChat.sendAlert(x + " , " + y + " , " + z); NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(sender)).GetComponent <Life>().networkView.RPC("tellStatePosition", RPCMode.All, new object[] { new Vector3(x, y, z), rotation }); } else if (commando.StartsWith("/tptome") && permLvl >= 1) { resetChat(); String name = commando.Substring(8); if (name.Length < 3) { name = names[Convert.ToInt32(name)]; } //big ass line incoming NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(name)).transform.position = NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(sender)).transform.position; NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(name)).GetComponent <Life>().networkView.RPC("tellStatePosition", RPCMode.All, new object[] { NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(sender)).transform.position, NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(sender)).transform.rotation }); } else if (commando.Equals("/tpall") && permLvl >= 2) { resetChat(); Vector3 location = NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(sender)).transform.position; Quaternion rotation = NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(sender)).transform.rotation; foreach (String name in names) { //There's probably a shorter way to this teleport stuff but hey this works xD NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(name)).transform.position = location; NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(name)).GetComponent <Life>().networkView.RPC("tellStatePosition", RPCMode.All, new object[] { location, rotation }); } } else if (commando.StartsWith("/tp ") && permLvl >= 1) //make sure this goes under /tptome { resetChat(); String name = commando.Substring(4); if (name.Length < 3) { name = names[Convert.ToInt32(name)]; } NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(sender)).transform.position = NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(name)).transform.position; NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(sender)).GetComponent <Life>().networkView.RPC("tellStatePosition", RPCMode.All, new object[] { NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(name)).transform.position, NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(name)).transform.rotation }); } else if (commando.StartsWith("/kill") && permLvl >= 2) { resetChat(); //All of these things are buggy as f**k String naam = commando.Substring(6); // NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(naam)).GetComponent<Life>().tellAllLife(10,0,0,0,true,true); // NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(naam)).GetComponent<Life>().tellDead(true, "You were shot in the face with a rocket launcher"); NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(naam)).GetComponent <Life>().damage(500, "You were struck down by the Wrath of the Gods!!!"); } else if (commando.Equals("/heal") && permLvl >= 1) { resetChat(); NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(sender)).GetComponent <Life>().heal(100, true, true); } else if (commando.StartsWith("/heal") && permLvl >= 1) { resetChat(); String naam = commando.Substring(6); NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(naam)).GetComponent <Life>().heal(100, true, true); } else if (commando.StartsWith("/promote") && permLvl >= 4) { resetChat(); String naam = commando.Substring(9); System.IO.StreamWriter file = new StreamWriter("Unturned_Data/Managed/mods/AdminCommands/UnturnedAdmins.txt", true); file.WriteLine(""); file.WriteLine(naam + ":" + getSteamIDByPlayerName(naam) + ":1"); file.Close(); NetworkChat.sendAlert(naam + " was promoted to the role of Moderator. (Level 1 Admin)"); reloadCommands(); } else if (commando.Equals("/commands") && permLvl >= 1) { resetChat(); String string1 = " /ban, /kick, /unban, /repeat, /reason, /repairvehicles, /refuelvehicles, /car"; String string2 = " /heal, /sirens, /sirensoff, /tp, /tpto <x> <y> <z>, /tptome, /home, /sethome"; String string3 = " /tpall, /kill, /resetZombies, /resetItems, /i, /killzombies, /kit "; String string4 = " /enablewhitelist, /disablewhitelist, /whitelist add & remove, /setannouncedelay"; String string5 = " /setItemDelay <seconds>, /reloadCommands, /reloadBans /promote, /logmsg"; getNetworkChat().askChat(string1, 2, getNetworkPlayerByPlayerName(sender)); getNetworkChat().askChat(string2, 2, getNetworkPlayerByPlayerName(sender)); if (permLvl >= 2) { getNetworkChat().askChat(string3, 2, getNetworkPlayerByPlayerName(sender)); } if (permLvl >= 3) { getNetworkChat().askChat(string4, 2, getNetworkPlayerByPlayerName(sender)); } if (permLvl >= 4) { getNetworkChat().askChat(string5, 2, getNetworkPlayerByPlayerName(sender)); } } else if (commando.StartsWith("/car") && permLvl >= 1) { resetChat(); Vector3 location = NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(sender)).transform.position; Quaternion rotation = NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(sender)).transform.rotation; Vehicle[] mapVehicles = UnityEngine.Object.FindObjectsOfType(typeof(Vehicle)) as Vehicle[]; int random = UnityEngine.Random.Range(0, mapVehicles.Length); Vehicle randomVehicle = mapVehicles[random]; Vector3 newPos = new Vector3(location[0] + 5, location[1] + 50, location[2]); randomVehicle.updatePosition(newPos, rotation); randomVehicle.transform.position = newPos; } else if (commando.StartsWith("/i ") && permLvl >= 2) { resetChat(); int itemid = Convert.ToInt32(commando.Split(' ')[1]); int amount = 1; if (commando.Split(' ').Length > 2) { amount = Convert.ToInt32(commando.Split(' ')[2]); } Vector3 location = NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(sender)).transform.position; for (int i = 0; i < amount; i++) { SpawnItems.spawnItem(itemid, 1, location); } } else if (commando.Equals("/kit") && permLvl >= 2) { resetChat(); int[] itemids = new int[] { 0x7d4, 0x1b60, 0x2ee0, 0x232c, 0x2711, 0x2afb, 0x465e, 0x465e, 0x465e, 0x465e, 0x465e, 0x465e, 0x465e, 0xfb1, 0x1399, 11, 0x32c8, 0x32c8, 0x36c6, 0x36c6, 0x1f4f, 0x1f4d, 0xbba }; Vector3 location = NetworkUserList.getModelFromPlayer(getNetworkPlayerByPlayerName(sender)).transform.position; foreach (int itemid in itemids) { SpawnItems.spawnItem(itemid, 1, location); } } } // end of isAdmin() else { // KICK(sender, "Did you just kick yourself?"); } commandconfirmed = false; } // end of text.startswith("/") }//end checkForCommands()