Skip to content

Commit

Permalink
Readyup - New feature and translation of the panel
Browse files Browse the repository at this point in the history
l4d_ready_unready_limit: If different from 0, it will indicate how many times a player can cancel the countdown, this affects only when intentionally cancelled.

Panel: The panel's translations will be based on the client's language.
  • Loading branch information
lechuga16 committed Aug 13, 2024
1 parent b2a47fd commit dbcc077
Show file tree
Hide file tree
Showing 10 changed files with 484 additions and 110 deletions.
Binary file modified addons/sourcemod/plugins/optional/readyup.smx
Binary file not shown.
13 changes: 11 additions & 2 deletions addons/sourcemod/scripting/readyup.sp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#undef REQUIRE_PLUGIN
#include <caster_system>

#define PLUGIN_VERSION "10.2.5"
#define PLUGIN_VERSION "10.2.6"

public Plugin myinfo =
{
Expand Down Expand Up @@ -80,7 +80,7 @@ ConVar
// sound
l4d_ready_enable_sound, l4d_ready_notify_sound, l4d_ready_countdown_sound, l4d_ready_live_sound, l4d_ready_autostart_sound, l4d_ready_chuckle, l4d_ready_secret,
// action
l4d_ready_delay, l4d_ready_force_extra, l4d_ready_autostart_delay, l4d_ready_autostart_wait, l4d_ready_autostart_min, l4d_ready_unbalanced_start, l4d_ready_unbalanced_min;
l4d_ready_delay, l4d_ready_force_extra, l4d_ready_autostart_delay, l4d_ready_autostart_wait, l4d_ready_autostart_min, l4d_ready_unbalanced_start, l4d_ready_unbalanced_min, l4d_ready_unready_limit;

// Server Name
ConVar
Expand Down Expand Up @@ -129,6 +129,10 @@ char g_sDisruptReason[disruptType_SIZE][] =
"Admin aborted"
};


// Limit Cancel Ready
StringMap g_smUnreadyCount;

// Sub modules are included here
#include "readyup/action.inc"
#include "readyup/command.inc"
Expand Down Expand Up @@ -158,6 +162,7 @@ public void OnPluginStart()
SetupConVars();
SetupCommands();

g_smUnreadyCount = new StringMap();
nativeFooter = new Footer();

readySurvFreeze = l4d_ready_survivor_freeze.BoolValue;
Expand Down Expand Up @@ -383,6 +388,10 @@ public Action L4D_OnFirstSurvivorLeftSafeArea(int client)
ReturnPlayerToSaferoom(client, false);
return Plugin_Handled;
}

if(l4d_ready_unready_limit.BoolValue)
g_smUnreadyCount.Clear();

return Plugin_Continue;
}

Expand Down
57 changes: 53 additions & 4 deletions addons/sourcemod/scripting/readyup/action.inc
Original file line number Diff line number Diff line change
Expand Up @@ -230,19 +230,26 @@ void CancelFullReady(int client, disruptType type)
{
if (readyUpMode == ReadyMode_AutoStart)
return;

if (s_readyCountdownTimer != null)
{
if (l4d_ready_unready_limit.BoolValue && type == readyStatus && !AddUnReadyCount(client))
return;

delete s_readyCountdownTimer;
InitiateReadyUp(false);

SetTeamFrozen(L4D2Team_Survivor, l4d_ready_survivor_freeze.BoolValue);
if (type == teamShuffle) // fix spectating
SetClientFrozen(client, false);

PrintHintTextToAll("%t", "LiveCountdownCancelled");
CPrintToChatAllEx(client, "%t", g_sDisruptReason[type], client);


if (l4d_ready_unready_limit.BoolValue && type == readyStatus)
CPrintToChatAllEx(client, "%t %t", g_sDisruptReason[type], client, "CountUnReady", GetUnReadyCount(client), l4d_ready_unready_limit.IntValue);
else
CPrintToChatAllEx(client, "%t", g_sDisruptReason[type], client);

if (g_hCountdownCancelledForward.FunctionCount)
{
Call_StartForward(g_hCountdownCancelledForward);
Expand All @@ -253,6 +260,7 @@ void CancelFullReady(int client, disruptType type)
}
}


void RespectateSpectators()
{
for (int client = 1; client <= MaxClients; ++client)
Expand All @@ -262,4 +270,45 @@ void RespectateSpectators()
FakeClientCommand(client, "sm_spectate");
}
}
}

/**
* Adds an unready count for a client.
*
* @param client The client index.
* @return True if the unready count was successfully added, false otherwise.
*/
bool AddUnReadyCount(int client)
{
char authId[18];
GetClientAuthId(client, AuthId_SteamID64, authId, sizeof(authId));
int unReadyCount = 0;
g_smUnreadyCount.GetValue(authId, unReadyCount);

if (unReadyCount >= l4d_ready_unready_limit.IntValue)
{
CPrintToChat(client, "%t", "UnReadyLimit", l4d_ready_unready_limit.IntValue);
return false;
}

unReadyCount++;
g_smUnreadyCount.SetValue(authId, unReadyCount);

return true;
}

/**
* Returns the number of unready(s) for a given client.
*
* @param client The client index.
* @return The number of unready players.
*/
int GetUnReadyCount(int client)
{
char authId[18];
GetClientAuthId(client, AuthId_SteamID64, authId, sizeof(authId));
int unReadyCount = 0;
g_smUnreadyCount.GetValue(authId, unReadyCount);

return unReadyCount;
}
Loading

0 comments on commit dbcc077

Please sign in to comment.