syntax fixes and cleanup
This commit is contained in:
parent
2520e5d6ec
commit
534d1a55ca
@ -1,24 +0,0 @@
|
|||||||
#if defined _AFKManager_Included
|
|
||||||
#endinput
|
|
||||||
#endif
|
|
||||||
#define _AFKManager_Included
|
|
||||||
|
|
||||||
native int GetClientIdleTime(int client);
|
|
||||||
|
|
||||||
public SharedPlugin __pl_AFKManager =
|
|
||||||
{
|
|
||||||
name = "AFKManager",
|
|
||||||
file = "AFKManager.smx",
|
|
||||||
#if defined REQUIRE_PLUGIN
|
|
||||||
required = 1,
|
|
||||||
#else
|
|
||||||
required = 0,
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
#if !defined REQUIRE_PLUGIN
|
|
||||||
public __pl_AFKManager_SetNTVOptional()
|
|
||||||
{
|
|
||||||
MarkNativeAsOptional("GetClientIdleTime");
|
|
||||||
}
|
|
||||||
#endif
|
|
@ -5,6 +5,8 @@
|
|||||||
#include <AFKManager>
|
#include <AFKManager>
|
||||||
#include <mapchooser_extended>
|
#include <mapchooser_extended>
|
||||||
|
|
||||||
|
#pragma newdecls required
|
||||||
|
|
||||||
int g_iAdminAFKTime;
|
int g_iAdminAFKTime;
|
||||||
int g_iSelfMaxExtendsAmount;
|
int g_iSelfMaxExtendsAmount;
|
||||||
int g_iSelfExtendsTime;
|
int g_iSelfExtendsTime;
|
||||||
@ -28,9 +30,6 @@ public Plugin myinfo =
|
|||||||
|
|
||||||
public void OnPluginStart()
|
public void OnPluginStart()
|
||||||
{
|
{
|
||||||
g_iSelfExtends = 0;
|
|
||||||
g_bSelfExtendsAllowed = false;
|
|
||||||
|
|
||||||
RegAdminCmd("sm_checkadmins", Command_DisplayActiveAdmins, ADMFLAG_GENERIC, "Check if there are any active Admins online or not.");
|
RegAdminCmd("sm_checkadmins", Command_DisplayActiveAdmins, ADMFLAG_GENERIC, "Check if there are any active Admins online or not.");
|
||||||
RegConsoleCmd("sm_selfextend", Command_SelfExtend, "Is available when all regular extends are depleted and there is no active admin online. Makes it possible for players to extend the map themselves");
|
RegConsoleCmd("sm_selfextend", Command_SelfExtend, "Is available when all regular extends are depleted and there is no active admin online. Makes it possible for players to extend the map themselves");
|
||||||
|
|
||||||
@ -49,7 +48,7 @@ public void OnPluginStart()
|
|||||||
|
|
||||||
g_cvarTimeLimit = FindConVar("mp_timelimit");
|
g_cvarTimeLimit = FindConVar("mp_timelimit");
|
||||||
|
|
||||||
AutoExecConfig(true, "plugin.NoAdminTools");
|
AutoExecConfig();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Cvar_AdminAFKTime(ConVar convar, const char[] oldValue, const char[] newValue)
|
public void Cvar_AdminAFKTime(ConVar convar, const char[] oldValue, const char[] newValue)
|
||||||
@ -82,19 +81,14 @@ public bool ActiveAdminPresent()
|
|||||||
for(int i = 1; i <= MaxClients; i++)
|
for(int i = 1; i <= MaxClients; i++)
|
||||||
{
|
{
|
||||||
if(IsValidClient(i) && CheckCommandAccess(i, "", ADMFLAG_GENERIC) && (GetClientIdleTime(i) < g_iAdminAFKTime))
|
if(IsValidClient(i) && CheckCommandAccess(i, "", ADMFLAG_GENERIC) && (GetClientIdleTime(i) < g_iAdminAFKTime))
|
||||||
{
|
|
||||||
return true;
|
return true;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnClientDisconnect(int client)
|
public void OnClientDisconnect(int client)
|
||||||
{
|
{
|
||||||
if(g_bSelfExtends[client])
|
g_bSelfExtends[client] = false;
|
||||||
g_bSelfExtends[client] = false;
|
|
||||||
|
|
||||||
CheckRatio();
|
CheckRatio();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -111,10 +105,7 @@ public void OnMapStart()
|
|||||||
CreateTimer(g_fSelfExtendsDelay, Timer_DelaySelfExtend, _, TIMER_FLAG_NO_MAPCHANGE);
|
CreateTimer(g_fSelfExtendsDelay, Timer_DelaySelfExtend, _, TIMER_FLAG_NO_MAPCHANGE);
|
||||||
|
|
||||||
for(int i; i <= MaxClients; i++)
|
for(int i; i <= MaxClients; i++)
|
||||||
{
|
g_bSelfExtends[i] = false;
|
||||||
if(g_bSelfExtends[i])
|
|
||||||
g_bSelfExtends[i] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnMapEnd()
|
public void OnMapEnd()
|
||||||
@ -130,98 +121,79 @@ public Action Timer_DelaySelfExtend(Handle timer)
|
|||||||
public Action Command_DisplayActiveAdmins(int client, int args)
|
public Action Command_DisplayActiveAdmins(int client, int args)
|
||||||
{
|
{
|
||||||
if(ActiveAdminPresent())
|
if(ActiveAdminPresent())
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] There are active Admins online.");
|
ReplyToCommand(client, "[SM] There are active Admins online.");
|
||||||
}
|
|
||||||
else
|
else
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] There are no active Admins online.");
|
ReplyToCommand(client, "[SM] There are no active Admins online.");
|
||||||
}
|
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action Command_SelfExtend(int client, int args)
|
public Action Command_SelfExtend(int client, int args)
|
||||||
{
|
{
|
||||||
|
if(GetExtendsLeft() > 0)
|
||||||
|
{
|
||||||
|
ReplyToCommand(client, "[SM] Not available because not all regular extends have been depleted.");
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
if(ActiveAdminPresent())
|
||||||
|
{
|
||||||
|
ReplyToCommand(client, "[SM] Not available because there is atleast one active Admin who can extend. Please ask the Admins.");
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
if(!g_bSelfExtendsAllowed)
|
||||||
|
{
|
||||||
|
ReplyToCommand(client, "[SM] Not available because it's still too early in the map.");
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
if(g_iSelfMaxExtendsAmount <= g_iSelfExtends)
|
if(g_iSelfMaxExtendsAmount <= g_iSelfExtends)
|
||||||
{
|
{
|
||||||
ReplyToCommand(client, "[SM] Not available because this map was already self-extended %d times.", g_iSelfMaxExtendsAmount);
|
ReplyToCommand(client, "[SM] Not available because this map was already self-extended %d times.", g_iSelfMaxExtendsAmount);
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
else if(GetExtendsLeft() > 0)
|
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] Not available because not all regular extends have been depleted.");
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
else if(ActiveAdminPresent())
|
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] Not available because there is atleast one active Admin who can extend. Please ask the Admins.");
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
else if(!g_bSelfExtendsAllowed)
|
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] Not available because it's still too early in the map.");
|
|
||||||
return Plugin_Handled;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
char sName[32];
|
|
||||||
GetClientName(client, sName, sizeof(sName));
|
|
||||||
|
|
||||||
if(!g_bSelfExtends[client])
|
|
||||||
{
|
|
||||||
g_bSelfExtends[client] = true;
|
|
||||||
PrintToChatAll("[SM] %s wants to self-extend the map.", sName);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
ReplyToCommand(client, "[SM] You have already voted to self-extend the map.");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if(!g_bSelfExtends[client])
|
||||||
|
{
|
||||||
|
g_bSelfExtends[client] = true;
|
||||||
|
PrintToChatAll("[SM] %N wants to self-extend the map.", client);
|
||||||
CheckRatio();
|
CheckRatio();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
ReplyToCommand(client, "[SM] You have already voted to self-extend the map.");
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action CheckRatio()
|
public void CheckRatio()
|
||||||
{
|
{
|
||||||
if(!g_bSelfExtendsAllowed)
|
if(!g_bSelfExtendsAllowed)
|
||||||
return Plugin_Handled;
|
return;
|
||||||
|
|
||||||
float Players;
|
int iPlayers;
|
||||||
float SelfExtendsPlayers;
|
int iSelfExtendsPlayers;
|
||||||
float PlayersNeeded;
|
int iPlayersNeeded;
|
||||||
|
|
||||||
for(int i = 1; i <= MaxClients; i++)
|
for(int i = 1; i <= MaxClients; i++)
|
||||||
{
|
{
|
||||||
if(IsValidClient(i))
|
if(IsValidClient(i))
|
||||||
{
|
iPlayers++;
|
||||||
Players++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if(g_bSelfExtends[i])
|
if(g_bSelfExtends[i])
|
||||||
{
|
iSelfExtendsPlayers++;
|
||||||
SelfExtendsPlayers++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayersNeeded = Players * g_fSelfExtendsRatio;
|
int iPlayersNeeded = RoundToFloor(float(iSelfExtendsPlayers) * g_fSelfExtendsRatio);
|
||||||
|
|
||||||
if(SelfExtendsPlayers >= PlayersNeeded)
|
if(iSelfExtendsPlayers >= iPlayersNeeded)
|
||||||
{
|
{
|
||||||
PrintToChatAll("[SM] Enough Players voted to self-extend the map. Adding %d minutes to the timelimit.", g_iSelfExtendsTime);
|
PrintToChatAll("[SM] Enough Players voted to self-extend the map. Adding %d minutes to the timelimit.", g_iSelfExtendsTime);
|
||||||
g_iSelfExtends++;
|
g_iSelfExtends++;
|
||||||
g_cvarTimeLimit.IntValue += g_iSelfExtendsTime;
|
g_cvarTimeLimit.IntValue += g_iSelfExtendsTime;
|
||||||
|
|
||||||
for(int j; j <= MaxClients; j++)
|
for(int j; j <= MaxClients; j++)
|
||||||
{
|
g_bSelfExtends[j] = false;
|
||||||
if(g_bSelfExtends[j])
|
|
||||||
g_bSelfExtends[j] = false;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return Plugin_Handled;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
static stock bool IsValidClient(int client)
|
static stock bool IsValidClient(int client)
|
||||||
|
Loading…
Reference in New Issue
Block a user