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

Readyup - New feature and translation of the panel #803

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
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
Loading