]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Return pretty names in chat for spectating/observing/dead instead of the engine's...
authorMario <mario.mario@y7mail.com>
Mon, 30 Dec 2019 14:31:58 +0000 (00:31 +1000)
committerMario <mario.mario@y7mail.com>
Mon, 30 Dec 2019 14:31:58 +0000 (00:31 +1000)
qcsrc/server/miscfunctions.qc

index ded47a6387f97920ce32f2fa41851a7b8ec32dea..38ce9f3e5fe79434c6d4f0a37742ac3367556449 100644 (file)
@@ -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;