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 bettyprompt_time;
double nameprint_time;
char player_name[16];
extern cvar_t waypoint_mode;
@ -1392,6 +1395,21 @@ void HUD_BettyPrompt (void)
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
@ -1430,6 +1448,9 @@ void HUD_Draw (void)
if (bettyprompt_time > sv.time)
HUD_BettyPrompt();
if (nameprint_time > sv.time)
HUD_PlayerName();
HUD_Blood();
HUD_Rounds();
HUD_Perks();

View File

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

View File

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

View File

@ -3300,6 +3300,35 @@ void PF_BettyPrompt(void)
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
@ -3918,6 +3947,7 @@ PF_MaxAmmo, // #501
PF_GrenadePulse, // #502
PF_MaxZombies, // #503
PF_BettyPrompt, // #504
PF_SetPlayerName, // #505
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_pulse 46
#define svc_bettyprompt 47
#define svc_playername 48
//
// client to server