diff --git a/chat_commands/README.md b/chat_commands/README.md index 8699f1b..ce0b7a2 100644 --- a/chat_commands/README.md +++ b/chat_commands/README.md @@ -94,6 +94,19 @@ Note that this does not make the player invisible to bots in the sense that even | `!invisible me` | | `!invisible Resxt` | +## chat_command_kill.gsc + +The player who runs the command kills the targeted player (no matter if they're in the same team or not) + +| # | Argument | Mandatory | +|---|---|---| +| 1 | The name of the player to kill | :white_check_mark: | + +| Examples | +|---| +| `!kill me` | +| `!kill Resxt` | + ## chat_command_map_mode.gsc 3 related commands in one file: diff --git a/chat_commands/chat_command_kill.gsc b/chat_commands/chat_command_kill.gsc new file mode 100644 index 0000000..ecf2146 --- /dev/null +++ b/chat_commands/chat_command_kill.gsc @@ -0,0 +1,53 @@ +#include scripts\chat_commands; + +Init() +{ + CreateCommand(level.commands_servers_ports, "kill", "function", ::KillCommand, ["default_help_one_player"]); +} + + + +/* Command section */ + +KillCommand(args) +{ + if (args.size < 1) + { + return NotEnoughArgsError(1); + } + + error = KillPlayer(args[0]); + + if (IsDefined(error)) + { + return error; + } +} + + + +/* Logic section */ + +KillPlayer(targetedPlayerName) +{ + if (self TargetIsMyself(targetedPlayerName)) + { + self Suicide(); + } + else + { + player = FindPlayerByName(targetedPlayerName); + + if (!IsDefined(player)) + { + return PlayerDoesNotExistError(targetedPlayerName); + } + + playerTeam = self.team; + self.team = "noteam"; // we change the player's team to bypass the friendly fire limitation + + player thread [[level.callbackPlayerDamage]]( self, self, 2147483600, 8, "MOD_SUICIDE", self getCurrentWeapon(), (0,0,0), (0,0,0), "torso", 0 ); + + self.team = playerTeam; // sets the player's team to his original team again + } +} \ No newline at end of file