Did use this plugin as template and made sniper_restriction_limits plugin
here is code if author want update or someone else. Feel free
Code:
#include <sourcemod>
#include <sdktools>
#include <events>
#pragma semicolon 1
#define TEAM_T 2
#define TEAM_CT 3
new Handle:g_Cvar_MinClientsScout = INVALID_HANDLE;
new Handle:g_Cvar_MinScouts = INVALID_HANDLE;
new Handle:g_Cvar_MaxScouts = INVALID_HANDLE;
new bool:g_IsScoutLimit = false;
new Handle:g_Cvar_MinClientsSg550 = INVALID_HANDLE;
new Handle:g_Cvar_MinSg550s = INVALID_HANDLE;
new Handle:g_Cvar_MaxSg550s = INVALID_HANDLE;
new bool:g_IsSg550Limit = false;
new Handle:g_Cvar_MinClientsG3sg1 = INVALID_HANDLE;
new Handle:g_Cvar_MinG3sg1s = INVALID_HANDLE;
new Handle:g_Cvar_MaxG3sg1s = INVALID_HANDLE;
new bool:g_IsG3sg1Limit = false;
new Handle:g_Cvar_MinClientsAWP = INVALID_HANDLE;
new Handle:g_Cvar_MinAWPs = INVALID_HANDLE;
new Handle:g_Cvar_MaxAWPs = INVALID_HANDLE;
new bool:g_IsAWPLimit = false;
new bool:g_hasmani = false;
new bool:g_hasrestrict = false;
public Plugin:myinfo = {
name = "Sniper Restriction Limits",
author = "8Kuula",
description = "Restricts sniper rifles based on number of players in game.",
version = "1.0",
}
public OnPluginStart() {
new Handle:hnMani = INVALID_HANDLE;
if ((hnMani = FindConVar("mani_admin_plugin_version")) != INVALID_HANDLE) {
CloseHandle(hnMani);
g_hasmani = true;
}
if (FindPluginByFile("restrict.smx") != INVALID_HANDLE) {
g_hasrestrict = true;
}
g_Cvar_MinClientsScout = CreateConVar("sm_srl_min_clients_scout", "4", "Min players required to unrestrict the scout.");
g_Cvar_MinScouts = CreateConVar("sm_srl_min_scout", "0", "Number of scouts allowed per team before threshold is reached.");
g_Cvar_MaxScouts = CreateConVar("sm_srl_max_scout", "1", "Number of scouts allowed per team after threshold is reached.");
g_Cvar_MinClientsSg550 = CreateConVar("sm_srl_min_clients_sg550", "6", "Min players required to unrestrict the sg550.");
g_Cvar_MinSg550s = CreateConVar("sm_srl_min_sg550", "0", "Number of sg550s allowed per team before threshold is reached.");
g_Cvar_MaxSg550s = CreateConVar("sm_srl_max_sg550", "1", "Number of sg550s allowed per team after threshold is reached.");
g_Cvar_MinClientsG3sg1 = CreateConVar("sm_srl_min_clients_g3sg1", "8", "Min players required to unrestrict the g3sg1.");
g_Cvar_MinG3sg1s = CreateConVar("sm_srl_min_g3sg1", "0", "Number of g3sg1s allowed per team before threshold is reached.");
g_Cvar_MaxG3sg1s = CreateConVar("sm_srl_max_g3sg1", "1", "Number of g3sg1s allowed per team after threshold is reached.");
g_Cvar_MinClientsAWP = CreateConVar("sm_srl_min_clients_awp", "10", "Min players required to unrestrict the AWP.");
g_Cvar_MinAWPs = CreateConVar("sm_srl_min_awp", "0", "Number of AWPs allowed per team before threshold is reached.");
g_Cvar_MaxAWPs = CreateConVar("sm_srl_max_awp", "1", "Number of AWPs allowed per team after threshold is reached.");
if (!HookEvent("round_start", Event_LimitCheck, EventHookMode_PostNoCopy)) {
SetFailState("Could not hook the round_start event.");
}
}
public Action:Event_LimitCheck(Handle:event, const String:name[], bool:dontBroadcast) {
LimitCheck();
}
public OnMapStart() {
g_IsScoutLimit = false;
g_IsSg550Limit = false;
g_IsG3sg1Limit = false;
g_IsAWPLimit = false;
}
LimitCheck() {
if (((GetConVarInt(g_Cvar_MinClientsScout) > 0) && ((GetTeamClientCount(TEAM_T) + GetTeamClientCount(TEAM_CT)) < GetConVarInt(g_Cvar_MinClientsScout)))) {LimitScoutMin();}
else {LimitScoutMax();}
if (((GetConVarInt(g_Cvar_MinClientsSg550) > 0) && ((GetTeamClientCount(TEAM_T) + GetTeamClientCount(TEAM_CT)) < GetConVarInt(g_Cvar_MinClientsSg550)))) {LimitSg550Min();}
else {LimitSg550Max();}
if (((GetConVarInt(g_Cvar_MinClientsG3sg1) > 0) && ((GetTeamClientCount(TEAM_T) + GetTeamClientCount(TEAM_CT)) < GetConVarInt(g_Cvar_MinClientsG3sg1)))) {LimitG3sg1Min();}
else {LimitG3sg1Max();}
if (((GetConVarInt(g_Cvar_MinClientsAWP) > 0) && ((GetTeamClientCount(TEAM_T) + GetTeamClientCount(TEAM_CT)) < GetConVarInt(g_Cvar_MinClientsAWP)))) {LimitAWPMin();}
else {LimitAWPMax();}
}
LimitScoutMin() {
if (!g_IsScoutLimit) {
g_IsScoutLimit = true;
if(g_hasmani) {
ServerCommand("ma_restrict scout %i", GetConVarInt(g_Cvar_MinScouts));
} else {
if (g_hasrestrict) ServerCommand("sm_restrict scout %i", GetConVarInt(g_Cvar_MinScouts));
}
}
}
LimitScoutMax() {
if (g_IsScoutLimit) {
g_IsScoutLimit = false;
if(g_hasmani) {
ServerCommand("ma_restrict scout %i", GetConVarInt(g_Cvar_MaxScouts));
} else {
if (g_hasrestrict) ServerCommand("sm_restrict scout %i", GetConVarInt(g_Cvar_MaxScouts));
}
}
}
LimitSg550Min() {
if (!g_IsSg550Limit) {
g_IsSg550Limit = true;
if(g_hasmani) {
ServerCommand("ma_restrict sg550 %i", GetConVarInt(g_Cvar_MinSg550s));
} else {
if (g_hasrestrict) ServerCommand("sm_restrict sg550 %i", GetConVarInt(g_Cvar_MinSg550s));
}
}
}
LimitSg550Max() {
if (g_IsSg550Limit) {
g_IsSg550Limit = false;
if(g_hasmani) {
ServerCommand("ma_restrict sg550 %i", GetConVarInt(g_Cvar_MaxSg550s));
} else {
if (g_hasrestrict) ServerCommand("sm_restrict sg550 %i", GetConVarInt(g_Cvar_MaxSg550s));
}
}
}
LimitG3sg1Min() {
if (!g_IsG3sg1Limit) {
g_IsG3sg1Limit = true;
if(g_hasmani) {
ServerCommand("ma_restrict g3sg1 %i", GetConVarInt(g_Cvar_MinG3sg1s));
} else {
if (g_hasrestrict) ServerCommand("sm_restrict g3sg1 %i", GetConVarInt(g_Cvar_MinG3sg1s));
}
}
}
LimitG3sg1Max() {
if (g_IsG3sg1Limit) {
g_IsG3sg1Limit = false;
if(g_hasmani) {
ServerCommand("ma_restrict g3sg1 %i", GetConVarInt(g_Cvar_MaxG3sg1s));
} else {
if (g_hasrestrict) ServerCommand("sm_restrict g3sg1 %i", GetConVarInt(g_Cvar_MaxG3sg1s));
}
}
}
LimitAWPMin() {
if (!g_IsAWPLimit) {
g_IsAWPLimit = true;
if(g_hasmani) {
ServerCommand("ma_restrict awp %i", GetConVarInt(g_Cvar_MinAWPs));
} else {
if (g_hasrestrict) ServerCommand("sm_restrict awp %i", GetConVarInt(g_Cvar_MinAWPs));
}
}
}
LimitAWPMax() {
if (g_IsAWPLimit) {
g_IsAWPLimit = false;
if(g_hasmani) {
ServerCommand("ma_restrict awp %i", GetConVarInt(g_Cvar_MaxAWPs));
} else {
if (g_hasrestrict) ServerCommand("sm_restrict awp %i", GetConVarInt(g_Cvar_MaxAWPs));
}
}
}
I hope all works, did wank with bots to try scenarios, and seemed to work ok with mani-admin-plugin restrictions. But never know...
Cvars:
Code:
// Sniper Restriction Limits.
// Requires: sniper_restriction_limits.smx
sm_srl_max_awp 1 // Number of AWPs allowed per team after threshold is reached.
sm_srl_max_g3sg1 1 // Number of g3sg1s allowed per team after threshold is reached.
sm_srl_max_scout 1 // Number of scouts allowed per team after threshold is reached.
sm_srl_max_sg550 1 // Number of sg550s allowed per team after threshold is reached.
sm_srl_min_scout 0 // Number of scouts allowed per team before threshold is reached.
sm_srl_min_sg550 0 // Number of sg550s allowed per team before threshold is reached.
sm_srl_min_g3sg1 0 // Number of g3sg1s allowed per team before threshold is reached.
sm_srl_min_awp 0 // Number of AWPs allowed per team before threshold is reached.
sm_srl_min_clients_scout 6 // Min players required to unrestrict the scout.
sm_srl_min_clients_sg550 8 // Min players required to unrestrict the sg550.
sm_srl_min_clients_g3sg1 8 // Min players required to unrestrict the g3sg1.
sm_srl_min_clients_awp 10 // Min players required to unrestrict the AWP.