From acb66df1495cc1128a6fda43525b8dc1a62ddc4d Mon Sep 17 00:00:00 2001 From: Resxt <55228336+Resxt@users.noreply.github.com> Date: Sat, 25 Mar 2023 22:33:31 +0100 Subject: [PATCH] chat_command_rounds 1.0.0 --- chat_commands/zm/README.md | 19 ++++ chat_commands/zm/chat_command_rounds.gsc | 129 +++++++++++++++++++++++ 2 files changed, 148 insertions(+) create mode 100644 chat_commands/zm/chat_command_rounds.gsc diff --git a/chat_commands/zm/README.md b/chat_commands/zm/README.md index bf3df10..7a985d5 100644 --- a/chat_commands/zm/README.md +++ b/chat_commands/zm/README.md @@ -15,3 +15,22 @@ These scripts go in `scripts\zm` | setpoints | Changes how much points the targeted player has | (1) the name of the targeted player (2) the new amount of points to set | `!setpoints me 50000` | 3 | | addpoints | Gives points to the targeted player | (1) the name of the targeted player (2) the amount of points to give | `!addpoints Resxt 2500` | 3 | | takepoints | Takes/removes points from the targeted player | (1) the name of the targeted player (2) the amount of points to take from the player | `!takepoints Resxt 500` | 3 | + +## chat_command_rounds.gsc + +4 related commands in one file: + +- Set round +- Change to previous round +- Change to next round +- Restart current round + +| Name | Description | Arguments expected | Example | Permission level | +|---|---|---|---|---| +| setround | Kills all zombies and changes the round to the specified round | (1) the desired round number | `!setround 10` | 4 | +| previousround | Kills all zombies and changes the round to the previous round | none | `!previousround` | 4 | +| nextround | Kills all zombies and changes the round to the next round | none | `!nextround` | 4 | +| restartround | Kills all zombies and restarts the current round | none | `!restartround` | 4 | + +It's recommend to only run these commands after at least one zombie has fully spawned (got out of the ground and starts walking). +Your score and kills don't increase when running these commands even if you're technically the one who kills the zombies. diff --git a/chat_commands/zm/chat_command_rounds.gsc b/chat_commands/zm/chat_command_rounds.gsc new file mode 100644 index 0000000..87d20d4 --- /dev/null +++ b/chat_commands/zm/chat_command_rounds.gsc @@ -0,0 +1,129 @@ +#include scripts\chat_commands; + +Init() +{ + CreateCommand(level.chat_commands["ports"], "setround", "function", ::SetRoundCommand, 4); + CreateCommand(level.chat_commands["ports"], "previousround", "function", ::PreviousRoundCommand, 4); + CreateCommand(level.chat_commands["ports"], "nextround", "function", ::NextRoundCommand, 4); + CreateCommand(level.chat_commands["ports"], "restartround", "function", ::RestartRoundCommand, 4); +} + + + +/* Command section */ + +SetRoundCommand(args) +{ + if (args.size < 1) + { + return NotEnoughArgsError(1); + } + + error = SetRound(args[0], true); + + if (IsDefined(error)) + { + return error; + } + + TellAllPlayers(array("^5" + self.name + " ^7changed the round to round ^5" + args[0])); +} + +PreviousRoundCommand(args) +{ + error = SetRound((level.round_number - 1), true); + + if (IsDefined(error)) + { + return error; + } + + TellAllPlayers(array("^5" + self.name + " ^7changed the round to the ^5previous round")); +} + +NextRoundCommand(args) +{ + error = SetRound((level.round_number + 1), true); + + if (IsDefined(error)) + { + return error; + } + + TellAllPlayers(array("^5" + self.name + " ^7changed the round to the ^5next round")); +} + +RestartRoundCommand(args) +{ + error = SetRound((level.round_number), false); + + if (IsDefined(error)) + { + return error; + } + + TellAllPlayers(array("^5" + self.name + " ^7restarted the ^5current ^7round")); +} + + + +/* Logic section */ + +SetRound(roundNumber, doNukeEffect) +{ + roundNumber = int(roundNumber); + + if (roundNumber <= 0) + { + return InvalidRoundError(roundNumber); + } + + self thread KillAllZombies(doNukeEffect); + + if (level.round_number > 1 || roundNumber > 1 || level.round_number == roundNumber) + { + level.round_number = roundNumber - 1; + } +} + +KillAllZombies(doNukeEffect) +{ + zombies = GetAIArray("axis"); + + level.zombie_total = 0; + playerScore = self.score; + playerKills = self.kills; + + if(IsDefined(zombies)) + { + for(i=0; i < zombies.size; i++) + { + zombies[i] DoDamage(zombies[i].health * 5000, (0,0,0), self); + + wait 0.05; + } + + if (IsDefined(doNukeEffect) && doNukeEffect) + { + self DoNuke(); + } + } + + self.score = playerScore; // reset the player's score to the score he had before calling the command + self.kills = playerKills; // reset the player's kills to the kills he had before calling the command +} + +DoNuke() +{ + foreach(player in level.players) + { + level thread maps\mp\zombies\_zm_powerups::nuke_powerup(self, player.team); + player maps\mp\zombies\_zm_powerups::powerup_vo("nuke"); + + zombies = getaiarray(level.zombie_team); + + player.zombie_nuked = arraysort(zombies, self.origin); + + player notify("nuke_triggered"); + } +} \ No newline at end of file