From: Mario Date: Sun, 30 Sep 2018 17:58:53 +0000 (+1000) Subject: Port kill command to QC so that we can use the health resource X-Git-Tag: xonotic-v0.8.5~1805 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=4584f9650fa51da6a162f3cf23e8df4574d9ff17;p=xonotic%2Fxonotic-data.pk3dir.git Port kill command to QC so that we can use the health resource --- 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") \