diff --git a/source/cl_hud.c b/source/cl_hud.c index a0ecbab..61a5da1 100644 --- a/source/cl_hud.c +++ b/source/cl_hud.c @@ -72,6 +72,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; @@ -1430,6 +1433,21 @@ void HUD_BettyPrompt (void) Draw_Pic (x + 25*8, 60, 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, 203, player_name, 255, 255, 255, alpha, 1); +} + /* =============== HUD_Draw @@ -1467,6 +1485,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(); diff --git a/source/cl_hud.h b/source/cl_hud.h index ac41220..aeb6cdb 100644 --- a/source/cl_hud.h +++ b/source/cl_hud.h @@ -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); diff --git a/source/cl_parse.c b/source/cl_parse.c index 0c2185d..ced0ef9 100644 --- a/source/cl_parse.c +++ b/source/cl_parse.c @@ -1237,6 +1237,11 @@ void CL_ParseServerMessage (void) 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 ()); break; diff --git a/source/pr_cmds.c b/source/pr_cmds.c index 10f3358..af4f223 100644 --- a/source/pr_cmds.c +++ b/source/pr_cmds.c @@ -3324,6 +3324,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 @@ -3677,7 +3706,8 @@ ebfs_builtin_t pr_ebfs_builtins[] = { 501, "nzp_maxammo", PF_MaxAmmo }, { 502, "grenade_pulse", PF_GrenadePulse }, { 503, "nzp_maxai", PF_MaxZombies }, - { 504, "nzp_bettyprompt", PF_BettyPrompt } + { 504, "nzp_bettyprompt", PF_BettyPrompt }, + { 505, "nzp_setplayername", PF_SetPlayerName } // 2001-11-15 DarkPlaces general builtin functions by Lord Havoc end diff --git a/source/protocol.h b/source/protocol.h index b9b88c8..3e6635b 100644 --- a/source/protocol.h +++ b/source/protocol.h @@ -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 //