Hello,
original plugin from SirCoding (BasicFixes)
PHP Code:
/* Plugin Template generated by Pawn Studio */
#include <sourcemod>
#include <sdktools>
#include <l4d2util>
#include <sdkhooks>
#include <smlib>
#include <colors>
new Handle:g_hPubBlock = INVALID_HANDLE;
new bool: bHandled = false;
new Handle: hTimer = INVALID_HANDLE;
new Handle: g_hReady = INVALID_HANDLE;
new Handle:cvar_delay = INVALID_HANDLE;
new Handle:readyCountdownTimer;
new readyDelay;
new Float:delay;
public OnPluginStart()
{
g_hPubBlock = CreateConVar("GSTF_BlockPub", "1", "Only allow Competitive Games on Server?");
g_hReady = FindConVar("l4d_ready_enabled");
cvar_delay = CreateConVar("sm_timer_repeat_delay", "50.0", "Timer", 0, true, 50.0);
delay = GetConVarFloat(cvar_delay);
HookConVarChange(cvar_delay, CvarChanged);
bHandled = false;
}
public OnClientPostAdminCheck(client)
{
if (bHandled && IsAdminHere() > 0) Handled();
if(!GetConVarBool(g_hPubBlock) || bHandled || GetConVarBool(g_hReady) || IsAdminHere() > 0 || !CheckMaps()) return;
if(IsValidClient(client) && !IsFakeClient(client))
{
bHandled = true;
CreateTimer(25.0, NotifyPubs, _, TIMER_REPEAT);
hTimer = CreateTimer(delay, KickPubs);
if (readyCountdownTimer == INVALID_HANDLE)
{
readyDelay = (delay-40);
readyCountdownTimer = CreateTimer(40.0, ReadyCountdownDelay_Timer, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
}
}
/*
public OnClientDisconnect_Post(client)
{
if(GetRealClientCount() == 0) Handled();
else
{
if(!GetConVarBool(g_hPubBlock) || bHandled || GetConVarBool(g_hReady) || IsAdminHere() > 0 || !CheckMaps()) return;
if(IsValidClient(client) && !IsFakeClient(client))
{
bHandled = true;
CreateTimer(25.0, NotifyPubs, _, TIMER_REPEAT);
hTimer = CreateTimer(50.0, KickPubs);
}
}
}
*/
public Action:ReadyCountdownDelay_Timer(Handle:timer)
{
if (readyDelay == 0)
{
return Plugin_Stop;
}
else
{
// Counter start at 10 ?
CPrintToChatAll("{blue}Kick all players in {blue}%d {green}seconds", readyDelay);
readyDelay--;
}
return Plugin_Continue;
}
public Action:NotifyPubs(Handle:timer)
{
if(!bHandled) return Plugin_Stop;
CPrintToChatAll("{default}<{blue}PubBlocker{default}> {blue}Only use this server for {default}Competitive Play.");
CPrintToChatAll("{default}<{blue}PubBlocker{default}> {blue}Everyone will be kicked unless a {default}!match {blue}config is loaded.");
CPrintToChatAll("{default}<{blue}PubBlocker{default}> {blue}Play on Pub {default}: {blue}mm_dedicated_force_servers 46.18.93.40:27015 {default}in your console.");
return Plugin_Continue;
}
public Action:KickPubs(Handle:timer)
{
ServerCommand("sm_kick @all Only Competitive Play on this Server");
Handled();
}
bool:IsValidClient(client)
{
if (client <= 0 || client > MaxClients) return false;
if (!IsClientInGame(client)) return false;
if (IsClientSourceTV(client) || IsClientReplay(client)) return false;
return true;
}
GetRealClientCount()
{
new clients = 0;
for (new i = 1; i <= GetMaxClients(); i++)
{
if(IsClientInGame(i) && IsClientConnected(i) && !IsFakeClient(i)) clients++;
}
return clients;
}
IsAdminHere()
{
new clients = 0;
for (new i = 1; i <= GetMaxClients(); i++)
{
if(IsClientInGame(i) && IsClientConnected(i) && Client_IsAdmin(i)) clients++;
}
return clients;
}
Handled()
{
bHandled = false;
if (hTimer != INVALID_HANDLE)
{
KillTimer(hTimer);
hTimer = INVALID_HANDLE;
}
}
// Check if Config has to be loaded - Makes exception for Custom Map play.
CheckMaps()
{
decl String:mapname[128];
GetCurrentMap(mapname, sizeof(mapname));
if (strncmp(mapname, "c1", 2) == 0
|| strncmp(mapname, "c2", 2) == 0
|| strncmp(mapname, "c3", 2) == 0
|| strncmp(mapname, "c4", 2) == 0
|| strncmp(mapname, "c6", 2) == 0
|| strncmp(mapname, "c7", 2) == 0
|| strncmp(mapname, "c8", 2) == 0
|| strncmp(mapname, "c9", 2) == 0
|| strncmp(mapname, "c10", 3) == 0
|| strncmp(mapname, "c11", 3) == 0
|| strncmp(mapname, "c12", 3) == 0
|| strncmp(mapname, "c13", 3) == 0) return true;
else if (strncmp(mapname, "c5", 2) == 0)
{
if (strncmp(mapname, "c5m1_dark", 9) != 0
&& strncmp(mapname, "c5m2_dark", 9) != 0
&& strncmp(mapname, "c5m3_dark", 9) != 0
&& strncmp(mapname, "c5m4_dark", 9) != 0
&& strncmp(mapname, "c5m5_dark", 9) != 0) return true;
}
return false;
}
I wanted to know if it was okay?
It sets the variable to 10 with subtraction (50-40), we create the timer and when the timer reaches 10, the countdown is displayed to players
PHP Code:
if (readyCountdownTimer == INVALID_HANDLE)
{
readyDelay = (delay-40);
readyCountdownTimer = CreateTimer(40.0, ReadyCountdownDelay_Timer, _, TIMER_REPEAT|TIMER_FLAG_NO_MAPCHANGE);
}
Sincerely,
edit: solved, used coultdown from plugin pause.