Skip to content

Commit

Permalink
Refactor PrintQueue function to add color formatting for player posit…
Browse files Browse the repository at this point in the history
…ions and improve readability
  • Loading branch information
altair-sossai committed Oct 20, 2024
1 parent cf1df7e commit b1954de
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
Binary file modified addons/sourcemod/plugins/optional/l4d2_queue.smx
Binary file not shown.
17 changes: 16 additions & 1 deletion addons/sourcemod/scripting/l4d2_queue.sp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#define L4D2_TEAM_SURVIVOR 2
#define L4D2_TEAM_INFECTED 3

#define MAX_MESSAGE_NAMES 6

ArrayList h_Queue;

enum struct Player
Expand Down Expand Up @@ -188,7 +190,7 @@ void PrintQueue(int target)

bool isNewGame = IsNewGame();

for (int i = 0, position = 1; i < h_Queue.Length; i++)
for (int i = 0, c = 1, position = 1; i < h_Queue.Length; i++, c = c == MAX_MESSAGE_NAMES ? 1 : c + 1)
{
h_Queue.GetArray(i, player);

Expand All @@ -214,8 +216,21 @@ void PrintQueue(int target)
Format(output, sizeof(output), "%s %s%dº {default}%N", output, color, position, client);

position++;

if (c == MAX_MESSAGE_NAMES)
{
if (target == 0)
CPrintToChatAll(output);
else
CPrintToChat(target, output);

output[0] = '\0';
}
}

if (strlen(output) == 0)
return;

if (target == 0)
CPrintToChatAll(output);
else
Expand Down

0 comments on commit b1954de

Please sign in to comment.