From 88dc68266e930228049dbd37ae93e51677c9c1f6 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 31 Dec 2019 00:53:05 +1000 Subject: [PATCH] If the player has no weapon, return "none" in the chat, also report health 2342 as "observing" during intermission --- qcsrc/server/miscfunctions.qc | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 38ce9f3e5..6082dbc9b 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -7,6 +7,7 @@ #include "ipban.qh" #include #include "../common/t_items.qh" +#include "mapvoting.qh" #include "resources.qh" #include "items.qh" #include "player.qh" @@ -233,13 +234,25 @@ string PlayerHealth(entity this) float myhealth = floor(GetResource(this, RES_HEALTH)); if(myhealth == -666) return "spectating"; - else if(myhealth == -2342) + else if(myhealth == -2342 || (myhealth == 2342 && mapvote_initialized)) return "observing"; else if(myhealth <= 0 || IS_DEAD(this)) return "dead"; return ftos(myhealth); } +string WeaponNameFromWeaponentity(entity this, .entity weaponentity) +{ + entity wepent = this.(weaponentity); + if(!wepent) + return "none"; + else if(wepent.m_weapon != WEP_Null) + return wepent.m_weapon.m_name; + else if(wepent.m_switchweapon != WEP_Null) + return wepent.m_switchweapon.m_name; + return "none"; //Weapons_from(wepent.cnt).m_name; +} + string formatmessage(entity this, string msg) { float p, p1, p2; @@ -297,7 +310,7 @@ string formatmessage(entity this, string msg) case "l": replacement = NearestLocation(this.origin); break; case "y": replacement = NearestLocation(cursor); break; case "d": replacement = NearestLocation(this.death_origin); break; - case "w": replacement = ((this.(weaponentity).m_weapon == WEP_Null) ? ((this.(weaponentity).m_switchweapon == WEP_Null) ? Weapons_from(this.(weaponentity).cnt) : this.(weaponentity).m_switchweapon) : this.(weaponentity).m_weapon).m_name; break; + case "w": replacement = WeaponNameFromWeaponentity(this, weaponentity); break; case "W": replacement = AmmoNameFromWeaponentity(this.(weaponentity).m_weapon); break; case "x": replacement = ((cursor_ent.netname == "" || !cursor_ent) ? "nothing" : cursor_ent.netname); break; case "s": replacement = ftos(vlen(this.velocity - this.velocity_z * '0 0 1')); break; -- 2.39.2