Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Addition] Show Prestrafe speed in CSD #593

Merged
merged 3 commits into from
Aug 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions addons/sourcemod/scripting/SurfTimer.sp
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,9 @@ public void OnClientDisconnect(int client)
return;
}

// Clear hudPrestrafe value
g_szPrespeedValue[client][0] = '\0';

// Database
if (IsValidClient(client) && !g_bRenaming)
{
Expand Down
6 changes: 6 additions & 0 deletions addons/sourcemod/scripting/surftimer/buttonpress.sp
Original file line number Diff line number Diff line change
Expand Up @@ -895,7 +895,13 @@ public void CL_OnStartWrcpTimerPress(int client)
Format(preMessage, sizeof(preMessage), "%t", "StagePrestrafe", g_szChatPrefix, g_Stage[0][client], szSpeed, szPersonalDifference, szRecordDifference);

if (g_iPrespeedText[client])
{
CPrintToChat(client, preMessage);

// Add Prestrafe to global VAR
FormatEx(g_szPrespeedValue[client], sizeof(g_szPrespeedValue), "\n(%i)", prestrafe);
CreateTimer(2.0, hudPrestrafe, GetClientUserId(client));
}

for (int i = 1; i <= MaxClients; i++) {
if (!IsClientInGame(i))
Expand Down
6 changes: 3 additions & 3 deletions addons/sourcemod/scripting/surftimer/commands.sp
Original file line number Diff line number Diff line change
Expand Up @@ -3135,7 +3135,7 @@ void CenterSpeedDisplay(int client, bool menu = false)

SetHudTextParams(fCSD_PosX, fCSD_PosY, update_rate / g_fTickrate + 0.1, displayColor[0], displayColor[1], displayColor[2], 255, 0, 0.0, 0.0, 0.0);

Format(szSpeed, sizeof(szSpeed), "%i", RoundToNearest(g_fLastSpeed[client]));
Format(szSpeed, sizeof(szSpeed), "%i%s", RoundToNearest(g_fLastSpeed[client]), g_szPrespeedValue[client]);
}
// player not alive (check wether spec'ing a bot or another player)
else {
Expand Down Expand Up @@ -3199,7 +3199,7 @@ void CenterSpeedDisplay(int client, bool menu = false)

SetHudTextParams(fCSD_PosX, fCSD_PosY, update_rate / g_fTickrate + 0.1, displayColor[0], displayColor[1], displayColor[2], 255, 0, 0.0, 0.0, 0.0);

Format(szSpeed, sizeof(szSpeed), "%i", RoundToNearest(fSpeedHUD));
Format(szSpeed, sizeof(szSpeed), "%i%s", RoundToNearest(fSpeedHUD), g_szPrespeedValue[ObservedUser]);
}
// spec'ing player
else {
Expand All @@ -3213,7 +3213,7 @@ void CenterSpeedDisplay(int client, bool menu = false)

SetHudTextParams(fCSD_PosX, fCSD_PosY, update_rate / g_fTickrate + 0.1, displayColor[0], displayColor[1], displayColor[2], 255, 0, 0.0, 0.0, 0.0);

Format(szSpeed, sizeof(szSpeed), "%i", RoundToNearest(g_fLastSpeed[ObservedUser]));
Format(szSpeed, sizeof(szSpeed), "%i%s", RoundToNearest(g_fLastSpeed[ObservedUser]), g_szPrespeedValue[ObservedUser]);
}
}
}
Expand Down
1 change: 1 addition & 0 deletions addons/sourcemod/scripting/surftimer/globals.sp
Original file line number Diff line number Diff line change
Expand Up @@ -797,6 +797,7 @@ int g_iTeleSide[MAXPLAYERS + 1];

// Prestrafe Message
bool g_iPrespeedText[MAXPLAYERS + 1];
char g_szPrespeedValue[MAXPLAYERS + 1][64];

// Silent Spectate
bool g_iSilentSpectate[MAXPLAYERS + 1];
Expand Down
13 changes: 13 additions & 0 deletions addons/sourcemod/scripting/surftimer/timer.sp
Original file line number Diff line number Diff line change
Expand Up @@ -654,3 +654,16 @@ public Action DatabaseUpgrading(Handle timer)

return Plugin_Handled;
}

// Clear global prestrafe var for the client
public Action hudPrestrafe(Handle timer, any userid)
{
int client = GetClientOfUserId(userid);

if(IsValidClient(client) && IsClientInGame(client))
{
g_szPrespeedValue[client][0] = '\0';
}

return Plugin_Handled;
}