Skip to content

Commit

Permalink
Add a new stock for clarity and remove an old stock (#370)
Browse files Browse the repository at this point in the history
* Fix: `surftimer_OnNewWRCP` forwards formatted time

* Fix: Time formatting

* Add a new stock for clarity
  • Loading branch information
Sarrus1 authored Jan 18, 2022
1 parent 9486405 commit c2c898f
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 43 deletions.
8 changes: 4 additions & 4 deletions addons/sourcemod/scripting/surftimer/buttonpress.sp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public void CL_OnStartTimerPress(int client)
if (fGetGameTime - g_fErrorMessage[client] > 1.0)
{
CPrintToChat(client, "%t", "BPress1", g_szChatPrefix);
ClientCommand(client, "play buttons\\button10.wav");
EmitSoundToClientNoPreCache(client, "play buttons\\button10.wav", false);
g_fErrorMessage[client] = fGetGameTime;
}
return;
Expand All @@ -22,7 +22,7 @@ public void CL_OnStartTimerPress(int client)
if (fGetGameTime - g_fErrorMessage[client] > 1.0)
{
CPrintToChat(client, "%t", "BPress2", g_szChatPrefix);
ClientCommand(client, "play buttons\\button10.wav");
EmitSoundToClientNoPreCache(client, "play buttons\\button10.wav", false);
g_fErrorMessage[client] = fGetGameTime;
}
return;
Expand All @@ -32,7 +32,7 @@ public void CL_OnStartTimerPress(int client)
if (fGetGameTime - g_fErrorMessage[client] > 1.0)
{
CPrintToChat(client, "%t", "BPress3", g_szChatPrefix);
ClientCommand(client, "play buttons\\button10.wav");
EmitSoundToClientNoPreCache(client, "play buttons\\button10.wav", false);
g_fErrorMessage[client] = fGetGameTime;
}
return;
Expand Down Expand Up @@ -176,7 +176,7 @@ public void CL_OnEndTimerPress(int client)
// If timer is not on, play error sound and return
if (!g_bTimerRunning[client])
{
ClientCommand(client, "play buttons\\button10.wav");
EmitSoundToClientNoPreCache(client, "play buttons\\button10.wav", false);
return;
}
else
Expand Down
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/surftimer/commands.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1326,7 +1326,7 @@ public Action Command_Restart(int client, int args)
g_fClientRestarting[client] = GetGameTime();
g_bClientRestarting[client] = true;
CPrintToChat(client, "%t", "Commands34", g_szChatPrefix);
ClientCommand(client, "play ambient/misc/clank4");
EmitSoundToClientNoPreCache(client, "play ambient/misc/clank4", false);
return Plugin_Handled;
}
}
Expand Down
73 changes: 36 additions & 37 deletions addons/sourcemod/scripting/surftimer/misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -1124,8 +1124,7 @@ public void PlayButtonSound(int client)
{
char buffer[255];
GetConVarString(g_hSoundPath, buffer, 255);
Format(buffer, sizeof(buffer), "play %s", buffer);
ClientCommand(client, buffer);
EmitSoundToClientNoPreCache(client, buffer);
}

// Spectators button sound
Expand All @@ -1141,8 +1140,7 @@ public void PlayButtonSound(int client)
{
char szsound[255];
GetConVarString(g_hSoundPath, szsound, 256);
Format(szsound, sizeof(szsound), "play %s", szsound);
ClientCommand(i, szsound);
EmitSoundToClientNoPreCache(client, szsound);
}
}
}
Expand Down Expand Up @@ -1535,8 +1533,7 @@ public void PlayRecordSound(int iRecordtype)
{
if (IsValidClient(i) && !IsFakeClient(i) && g_bEnableQuakeSounds[i] == true)
{
Format(buffer, sizeof(buffer), "play %s", g_szRelativeSoundPathWR);
ClientCommand(i, buffer);
EmitSoundToClientNoPreCache(i, buffer);
}
}
}
Expand All @@ -1546,8 +1543,7 @@ public void PlayRecordSound(int iRecordtype)
{
if (IsValidClient(i) && !IsFakeClient(i) && g_bEnableQuakeSounds[i] == true)
{
Format(buffer, sizeof(buffer), "play %s", g_szRelativeSoundPathWR);
ClientCommand(i, buffer);
EmitSoundToClientNoPreCache(i, buffer);
}
}
}
Expand All @@ -1557,8 +1553,7 @@ public void PlayRecordSound(int iRecordtype)
{
if (IsValidClient(i) && !IsFakeClient(i) && g_bEnableQuakeSounds[i] == true)
{
Format(buffer, sizeof(buffer), "play %s", g_szRelativeSoundPathTop);
ClientCommand(i, buffer);
EmitSoundToClientNoPreCache(i, buffer);
}
}
}
Expand All @@ -1568,19 +1563,18 @@ public void PlayRecordSound(int iRecordtype)
{
if (IsValidClient(i) && !IsFakeClient(i) && g_bEnableQuakeSounds[i] == true)
{
Format(buffer, sizeof(buffer), "play %s", g_szRelativeSoundPathTop);
ClientCommand(i, buffer);
EmitSoundToClientNoPreCache(i, buffer);
}
}
}
}

public void PlayUnstoppableSound(int client)
{
char buffer[255];
Format(buffer, sizeof(buffer), "play %s", g_szRelativeSoundPathPB);
if (!IsFakeClient(client) && g_bEnableQuakeSounds[client])
ClientCommand(client, buffer);
{
EmitSoundToClientNoPreCache(client, g_szRelativeSoundPathPB);
}
// Spec Stop Sound
for (int i = 1; i <= MaxClients; i++)
{
Expand All @@ -1591,7 +1585,9 @@ public void PlayUnstoppableSound(int client)
{
int Target = GetEntPropEnt(i, Prop_Send, "m_hObserverTarget");
if (Target == client && g_bEnableQuakeSounds[i])
ClientCommand(i, buffer);
{
EmitSoundToClientNoPreCache(i, g_szRelativeSoundPathPB);
}
}
}
}
Expand All @@ -1604,8 +1600,7 @@ public void PlayWRCPRecord()
{
if (IsValidClient(i) && !IsFakeClient(i) && g_bEnableQuakeSounds[i] == true)
{
Format(buffer, sizeof(buffer), "play %s", g_szRelativeSoundPathWRCP);
ClientCommand(i, buffer);
EmitSoundToClientNoPreCache(i, buffer);
}
}
}
Expand Down Expand Up @@ -2813,25 +2808,6 @@ stock int BooltoInt(bool status)
return (status) ? 1:0;
}

public void PlayQuakeSound_Spec(int client, char[] buffer)
{
int SpecMode;
for (int x = 1; x <= MaxClients; x++)
{
if (IsValidClient(x) && !IsPlayerAlive(x))
{
SpecMode = GetEntProp(x, Prop_Send, "m_iObserverMode");
if (SpecMode == 4 || SpecMode == 5)
{
int Target = GetEntPropEnt(x, Prop_Send, "m_hObserverTarget");
if (Target == client)
if (g_bEnableQuakeSounds[x])
ClientCommand(x, buffer);
}
}
}
}

public void AttackProtection(int client, int &buttons)
{
if (GetConVarBool(g_hAttackSpamProtection))
Expand Down Expand Up @@ -5337,3 +5313,26 @@ void RemoveColors(char[] message, int maxlength)
CRemoveTags(message, maxlength);
CRemoveColors(message, maxlength);
}


/**
* Emit a sound to a client without having to precache the sound.
* See https://wiki.alliedmods.net/Csgo_quirks#The_.22play.22_client_command for more details.
*
* @param client The client's id.
* @param szPath The path of the sound with or without "play " as a suffix.
* @param addPlay Whether or not "play " should be append to the begining of szPath (default = true).
*/
stock void EmitSoundToClientNoPreCache(int client, const char[] szPath, bool addPlay = true)
{
char szBuffer[256];
if(addPlay)
{
Format(szBuffer, sizeof szBuffer, "play %s", szPath);
}
else
{
strcopy(szBuffer, sizeof szBuffer, szPath);
}
ClientCommand(client, szBuffer);
}
2 changes: 1 addition & 1 deletion addons/sourcemod/scripting/surftimer/surfzones.sp
Original file line number Diff line number Diff line change
Expand Up @@ -594,7 +594,7 @@ public void EndTouch(int client, int action[3])
if (g_bNoClip[client] || (!g_bNoClip[client] && (GetGameTime() - g_fLastTimeNoClipUsed[client]) < 3.0))
{
CPrintToChat(client, "%t", "SurfZones1", g_szChatPrefix);
ClientCommand(client, "play buttons\\button10.wav");
EmitSoundToClientNoPreCache(client, "play buttons\\button10.wav", false);
// fluffys
// ClientCommand(client, "sm_stuck");
}
Expand Down

0 comments on commit c2c898f

Please sign in to comment.