From: Mario Date: Mon, 30 Dec 2019 14:31:58 +0000 (+1000) Subject: Return pretty names in chat for spectating/observing/dead instead of the engine's... X-Git-Tag: xonotic-v0.8.5~1105^2~61 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=aa51ab610992f62c9d80eb1853ca57907b8523c3;p=xonotic%2Fxonotic-data.pk3dir.git Return pretty names in chat for spectating/observing/dead instead of the engine's magic numbers --- diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index ded47a638..38ce9f3e5 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -228,6 +228,18 @@ string AmmoNameFromWeaponentity(Weapon wep) return ammoitems; } +string PlayerHealth(entity this) +{ + float myhealth = floor(GetResource(this, RES_HEALTH)); + if(myhealth == -666) + return "spectating"; + else if(myhealth == -2342) + return "observing"; + else if(myhealth <= 0 || IS_DEAD(this)) + return "dead"; + return ftos(myhealth); +} + string formatmessage(entity this, string msg) { float p, p1, p2; @@ -281,7 +293,7 @@ string formatmessage(entity this, string msg) case "\\":replacement = "\\"; break; case "n": replacement = "\n"; break; case "a": replacement = ftos(floor(GetResource(this, RES_ARMOR))); break; - case "h": replacement = ftos(floor(GetResource(this, RES_HEALTH))); break; + case "h": replacement = PlayerHealth(this); break; case "l": replacement = NearestLocation(this.origin); break; case "y": replacement = NearestLocation(cursor); break; case "d": replacement = NearestLocation(this.death_origin); break;