From 1139fd89d0fbc61d48b02302954442ad0aa1654e Mon Sep 17 00:00:00 2001 From: jenz Date: Sat, 4 Jul 2026 16:54:07 +0200 Subject: [PATCH] improved the check and tells how many people still are needed for self extend --- NoAdminTools/scripting/NoAdminTools.sp | 43 ++++++++++++++++---------- 1 file changed, 26 insertions(+), 17 deletions(-) diff --git a/NoAdminTools/scripting/NoAdminTools.sp b/NoAdminTools/scripting/NoAdminTools.sp index 8dcf1c7..734abf8 100644 --- a/NoAdminTools/scripting/NoAdminTools.sp +++ b/NoAdminTools/scripting/NoAdminTools.sp @@ -37,7 +37,7 @@ public void OnPluginStart() ConVar cvar; HookConVarChange((cvar = CreateConVar("sm_admin_afk_time", "30", "Time in seconds until an admin is considered as AFK.")), Cvar_AdminAFKTime); g_iAdminAFKTime = cvar.IntValue; - HookConVarChange((cvar = CreateConVar("sm_selfextend_amount", "2", "Amount of sm_selfextend's allowed.")), Cvar_SelfExtendsAmount); + HookConVarChange((cvar = CreateConVar("sm_selfextend_amount", "2", "Amount of sm_selfextends allowed.")), Cvar_SelfExtendsAmount); g_iSelfMaxExtendsAmount = cvar.IntValue; HookConVarChange((cvar = CreateConVar("sm_selfextend_time", "10", "How long to extend in minutes when sm_selfextend passes through.")), Cvar_SelfExtendsTime); g_iSelfExtendsTime = cvar.IntValue; @@ -175,24 +175,14 @@ public Action Command_DisplayActiveAdmins(int client, int args) public Action Command_SelfExtend(int client, int args) { - int iAdminActivity = 0; - for(int i = 1; i <= MaxClients; i++) - if(g_bActiveAdmin[i]) - iAdminActivity++; - if(GetExtendsLeft() > 0) { ReplyToCommand(client, "[SM] Not available because not all regular extends have been depleted."); return Plugin_Handled; } - if(iAdminActivity > 0) - { - 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."); + ReplyToCommand(client, "[SM] Not available because its still too early in the map."); return Plugin_Handled; } if(g_iSelfMaxExtendsAmount <= g_iSelfExtends) @@ -201,14 +191,34 @@ public Action Command_SelfExtend(int client, int args) return Plugin_Handled; } + int iPlayers; + int iSelfExtendsPlayers; + int iPlayersNeeded; + + for(int i = 1; i <= MaxClients; i++) + { + if(IsValidClient(i)) + iPlayers++; + + if(g_bSelfExtends[i]) + iSelfExtendsPlayers++; + } + iPlayersNeeded = RoundToFloor(float(iPlayers) * g_fSelfExtendsRatio); + + if (iPlayersNeeded == 0) + { + iPlayersNeeded = 1; + } if(!g_bSelfExtends[client]) { g_bSelfExtends[client] = true; - PrintToChatAll("[SM] %N wants to self-extend the map.", client); + PrintToChatAll("[SM] %N wants to self-extend the map. %i/%i", client, iSelfExtendsPlayers + 1, iPlayersNeeded); CheckRatio(); } else - ReplyToCommand(client, "[SM] You have already voted to self-extend the map."); + { + ReplyToCommand(client, "[SM] You have already voted to self-extend the map. %i/%i", iSelfExtendsPlayers, iPlayersNeeded); + } return Plugin_Handled; } @@ -233,7 +243,7 @@ public void CheckRatio() iPlayersNeeded = RoundToFloor(float(iPlayers) * g_fSelfExtendsRatio); - if(iSelfExtendsPlayers >= iPlayersNeeded && iPlayersNeeded != 0) + if(iSelfExtendsPlayers >= iPlayersNeeded && iSelfExtendsPlayers > 0) { PrintToChatAll("[SM] Enough Players voted to self-extend the map. Adding %d minutes to the timelimit.", g_iSelfExtendsTime); LogMessage("Enough Players voted to self-extend the map. Adding %d minutes to the timelimit.", g_iSelfExtendsTime); @@ -243,7 +253,6 @@ public void CheckRatio() for(int j; j <= MaxClients; j++) g_bSelfExtends[j] = false; } - return; } @@ -257,4 +266,4 @@ static stock bool IsValidClient(int client) { return false; } -} \ No newline at end of file +}