From 4584f9650fa51da6a162f3cf23e8df4574d9ff17 Mon Sep 17 00:00:00 2001 From: Mario Date: Mon, 1 Oct 2018 03:58:53 +1000 Subject: [PATCH] Port kill command to QC so that we can use the health resource --- qcsrc/server/clientkill.qc | 2 -- qcsrc/server/command/cmd.qc | 31 +++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/qcsrc/server/clientkill.qc b/qcsrc/server/clientkill.qc index 8d7293bb0..08758a065 100644 --- a/qcsrc/server/clientkill.qc +++ b/qcsrc/server/clientkill.qc @@ -195,8 +195,6 @@ void ClientKill_Silent(entity this, float _delay) // Called when a client types 'kill' in the console void ClientKill(entity this) { - // TODO: once .health is removed, will need to check it here for the "already dead" message! - if (game_stopped || this.player_blocked || STAT(FROZEN, this)) return; diff --git a/qcsrc/server/command/cmd.qc b/qcsrc/server/command/cmd.qc index 915fea7ee..80716d811 100644 --- a/qcsrc/server/command/cmd.qc +++ b/qcsrc/server/command/cmd.qc @@ -247,6 +247,36 @@ void ClientCommand_join(entity caller, int request) } } +void ClientCommand_kill(entity caller, int request) +{ + switch (request) + { + case CMD_REQUEST_COMMAND: + { + if(IS_SPEC(caller) || IS_OBSERVER(caller)) + return; // no point warning about this, command does nothing + + if(GetResourceAmount(caller, RESOURCE_HEALTH) <= 0) + { + sprint(caller, "Can't die - you are already dead!\n"); + return; + } + + ClientKill(caller); + + return; // never fall through to usage + } + + default: + case CMD_REQUEST_USAGE: + { + sprint(caller, "\nUsage:^3 cmd kill\n"); + sprint(caller, " No arguments required.\n"); + return; + } + } +} + void ClientCommand_physics(entity caller, int request, int argc) { switch (request) @@ -730,6 +760,7 @@ void ClientCommand_(entity caller, int request) CLIENT_COMMAND("autoswitch", ClientCommand_autoswitch(ent, request, arguments), "Whether or not to switch automatically when getting a better weapon") \ CLIENT_COMMAND("clientversion", ClientCommand_clientversion(ent, request, arguments), "Release version of the game") \ CLIENT_COMMAND("join", ClientCommand_join(ent, request), "Become a player in the game") \ + CLIENT_COMMAND("kill", ClientCommand_kill(ent, request), "Become a member of the dead") \ CLIENT_COMMAND("minigame", ClientCommand_minigame(ent, request, arguments, command), "Start a minigame") \ CLIENT_COMMAND("mv_getpicture", ClientCommand_mv_getpicture(ent, request, arguments), "Retrieve mapshot picture from the server") \ CLIENT_COMMAND("physics", ClientCommand_physics(ent, request, arguments), "Change physics set") \ -- 2.39.2