SERVER/CLIENT: Print name of downed/revived players via broadcasts

This commit is contained in:
Steam Deck User 2023-01-13 15:41:27 -05:00
parent e1a11cbcb7
commit c042f4d479
6 changed files with 32 additions and 8 deletions

View file

@ -94,6 +94,7 @@ float crosshair_spread_time;
float zoom_2_time;
float broadcast_time;
float broadcast_type;
string broadcast_string;
float weaponframetime;
float weapon2frametime;

View file

@ -1186,13 +1186,16 @@ void() HUD_Broadcast = {
string broadcast_msg = "";
float health = getstatf(STAT_HEALTH);
switch(broadcast_type) {
case 2: broadcast_msg = "A Player needs to be revived"; break;
default: broadcast_msg = "benis"; break;
}
switch(broadcast_type) {
case 2: broadcast_msg = strcat(broadcast_string, " needs to be revived"); break;
case 3: broadcast_msg = strcat(broadcast_string, " is reviving you"); break;
default: break;
}
float print_width = stringwidth (broadcast_msg, 0, [0.015*g_width, 0.015*g_width, 0]);
float x = (g_width - print_width)/2;
if (broadcast_type == 2 && health > 19)
if (broadcast_msg != "")
drawstring([x, g_height/2, 0], broadcast_msg, [0.015*g_width, 0.015*g_width, 0], [1, 1, 1], 1, 0);
}

View file

@ -1005,6 +1005,7 @@ noref void() CSQC_Parse_Event =
case EVENT_BROADCAST:
broadcast_time = readbyte();
broadcast_type = readbyte();
broadcast_string = readstring();
break;
case EVENT_POINTUPDATE:
float playernum = readbyte();

View file

@ -177,7 +177,7 @@ void(string to, float skin) UpdateV2model =
#endif
}
void(float broadcast_time, float type) BroadcastMessage =
void(entity who, float broadcast_time, float type, string str) BroadcastMessageToClient =
{
#ifndef HANDHELD
#ifndef NX
@ -185,6 +185,22 @@ void(float broadcast_time, float type) BroadcastMessage =
WriteByte(MSG_MULTICAST, EVENT_BROADCAST);
WriteByte(MSG_MULTICAST, broadcast_time);
WriteByte(MSG_MULTICAST, type);
WriteString(MSG_MULTICAST, str);
msg_entity = who;
multicast('0 0 0', MULTICAST_ONE);
#endif
#endif
}
void(float broadcast_time, float type, string str) BroadcastMessage =
{
#ifndef HANDHELD
#ifndef NX
WriteByte(MSG_MULTICAST, SVC_CGAMEPACKET);
WriteByte(MSG_MULTICAST, EVENT_BROADCAST);
WriteByte(MSG_MULTICAST, broadcast_time);
WriteByte(MSG_MULTICAST, type);
WriteString(MSG_MULTICAST, str);
multicast('0 0 0', MULTICAST_ALL);
#endif

View file

@ -221,7 +221,7 @@ void() GetDown =
self.requirespower = point_difference;
// Broadcast that the player has downed.
BroadcastMessage(time + 3, 2);
BroadcastMessage(time + 3, 2, self.netname);
// Reset state
self.velocity = self.zoom = 0;

View file

@ -2304,7 +2304,10 @@ void() CheckPlayer =
useprint (self, 13, 0, 0);
if (self.button7 && !ent.invoke_revive) {
centerprint(ent, "Another player is reviving you...");
// Broadcast that they're being revived
BroadcastMessageToClient(ent, time + 0.1, 3, self.netname);
ent.beingrevived = true;
if (!self.progress_bar_percent) {