Draw character name on match start

This commit is contained in:
cypress 2023-11-21 22:35:13 -05:00
parent faed910a9c
commit 6560bf5632
5 changed files with 59 additions and 0 deletions

View file

@ -67,6 +67,9 @@ void M_DrawPic (int x, int y, qpic_t *pic);
double HUD_Change_time;//hide hud when not chagned double HUD_Change_time;//hide hud when not chagned
double bettyprompt_time; double bettyprompt_time;
double nameprint_time;
char player_name[16];
extern cvar_t waypoint_mode; extern cvar_t waypoint_mode;
@ -1392,6 +1395,21 @@ void HUD_BettyPrompt (void)
Draw_Pic (x + 20*8 - 4, 56, GetButtonIcon("+grenade")); Draw_Pic (x + 20*8 - 4, 56, GetButtonIcon("+grenade"));
} }
/*
===============
HUD_PlayerName
===============
*/
void HUD_PlayerName (void)
{
int alpha = 255;
if (nameprint_time - sv.time < 1)
alpha = (int)((nameprint_time - sv.time)*255);
Draw_ColoredString(70, 170, player_name, 255, 255, 255, alpha, 1);
}
/* /*
=============== ===============
HUD_Draw HUD_Draw
@ -1430,6 +1448,9 @@ void HUD_Draw (void)
if (bettyprompt_time > sv.time) if (bettyprompt_time > sv.time)
HUD_BettyPrompt(); HUD_BettyPrompt();
if (nameprint_time > sv.time)
HUD_PlayerName();
HUD_Blood(); HUD_Blood();
HUD_Rounds(); HUD_Rounds();
HUD_Perks(); HUD_Perks();

View file

@ -49,5 +49,7 @@ typedef struct achievement_list_s
void Achievement_Init (void); void Achievement_Init (void);
extern achievement_list_t achievement_list[MAX_ACHIEVEMENTS]; extern achievement_list_t achievement_list[MAX_ACHIEVEMENTS];
extern qpic_t *achievement_locked; extern qpic_t *achievement_locked;
extern char player_name[16];
extern double nameprint_time;
void HUD_Parse_Achievement (int ach); void HUD_Parse_Achievement (int ach);

View file

@ -1119,6 +1119,11 @@ void CL_ParseServerMessage (void)
bettyprompt_time = sv.time + 4; bettyprompt_time = sv.time + 4;
break; break;
case svc_playername:
nameprint_time = sv.time + 11;
strcpy(player_name, MSG_ReadString());
break;
case svc_stufftext: case svc_stufftext:
Cbuf_AddText (MSG_ReadString ()); Cbuf_AddText (MSG_ReadString ());
break; break;

View file

@ -3300,6 +3300,35 @@ void PF_BettyPrompt(void)
MSG_WriteByte (&client->message, svc_bettyprompt); MSG_WriteByte (&client->message, svc_bettyprompt);
} }
/*
=================
PF_SetPlayerName
sends the name string to
the client, avoids making
a protocol extension and
spamming strings.
nzp_setplayername()
=================
*/
void PF_SetPlayerName(void)
{
client_t *client;
int entnum;
char* s;
entnum = G_EDICTNUM(OFS_PARM0);
s = G_STRING(OFS_PARM1);
if (entnum < 1 || entnum > svs.maxclients)
return;
client = &svs.clients[entnum-1];
MSG_WriteByte (&client->message, svc_playername);
MSG_WriteString (&client->message, s);
}
/* /*
================= =================
PF_MaxZombies PF_MaxZombies
@ -3918,6 +3947,7 @@ PF_MaxAmmo, // #501
PF_GrenadePulse, // #502 PF_GrenadePulse, // #502
PF_MaxZombies, // #503 PF_MaxZombies, // #503
PF_BettyPrompt, // #504 PF_BettyPrompt, // #504
PF_SetPlayerName, // #505
PF_Fixme, PF_Fixme,
}; };

View file

@ -152,6 +152,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define svc_maxammo 45 #define svc_maxammo 45
#define svc_pulse 46 #define svc_pulse 46
#define svc_bettyprompt 47 #define svc_bettyprompt 47
#define svc_playername 48
// //
// client to server // client to server