CLIENT/SERVER: Draw character name on match start

This commit is contained in:
cypress 2023-11-21 22:35:25 -05:00
parent f5ec11b472
commit 2672e94387
8 changed files with 35 additions and 0 deletions

View file

@ -97,6 +97,7 @@ float stext;
float scrollopacity;
float scrollheight;
float nameprint_time;
float HUD_Change_time;
float Hitmark_time;
float crosshair_spread_time;

View file

@ -341,6 +341,22 @@ void(float width, float height) HUD_Points =
}
}
/************************
* HUD_CharacterName *
************************/
void(float width, float height) HUD_CharacterName =
{
float x = 100 + GetUltraWideOffset();
float alpha = 1;
if (nameprint_time - 1 < time) {
alpha = (nameprint_time - time);
}
drawstring([x, height - 92 - ((getstatf(STAT_PLAYERNUM) - 1) * 25)], getstats(STAT_PLAYERNAME), [12, 12], [1, 1, 1], alpha, 0);
}
/*******************
* HUD_Grenades *
*******************/
@ -1643,6 +1659,9 @@ void(float width, float height) HUD_Draw =
if (vmodel.model == GetWeaponModel(getstatf(STAT_ACTIVEWEAPON), FALSE) && vmodel.model != "")
HUD_AmmoString();
if (nameprint_time > time)
HUD_CharacterName(width, height);
if (bettyprompt_time > time)
HUD_BouncingBetty(width, height);

View file

@ -246,6 +246,7 @@ noref void() CSQC_WorldLoaded =
Achievement_Init();
Init_Particles();
nameprint_time = time + 12;
huddir = "gfx/hud/";
};

View file

@ -254,6 +254,7 @@ void() SUB_Null2 = {};
#define VEC_VIEW_OFS '0 0 32'
.string name;
vector trace_plane_normal;
//

View file

@ -271,6 +271,7 @@ void ()
void (entity who) grenade_pulse = #502;
float () nzp_maxai = #503;
void (entity who) nzp_bettyprompt = #504;
void (entity who, string name) nzp_setplayername = #505;
//
// constants

View file

@ -321,6 +321,7 @@ void() worldspawn =
clientstat(STAT_FACINGENEMY, EV_FLOAT, facingenemy);
clientstat(STAT_VIEWZOOM, EV_FLOAT, viewzoom);
clientstat(STAT_MAXHEALTH, EV_FLOAT, max_health);
clientstat(STAT_PLAYERNAME, EV_STRING, name);
#endif // FTE

View file

@ -478,6 +478,13 @@ void() PlayerPostThink =
if(self.isspec)
return;
#ifndef FTE
if (time < 5 && self.name != "")
nzp_setplayername(self, self.name);
#endif // FTE
//landsound
if((self.oldvelocity_z < -212) && (self.flags & FL_ONGROUND))
{
@ -722,6 +729,9 @@ void() Player_PickSpawnPoint =
found_viable_spawn = true;
}
// Give them their name
self.name = spawn_point.name;
// Set their location
self.origin = spawn_point.origin + '0 0 1';
self.angles = spawn_point.angles;

View file

@ -227,6 +227,7 @@ const float EVENT_CHATMESSAGE = 45;
#define STAT_PLAYERSTANCE 65
#define STAT_FACINGENEMY 66
#define STAT_MAXHEALTH 67
#define STAT_PLAYERNAME 68
.float playernum;