PHP Code:
#pragma semicolon 1
#include <sourcemod>
#include <cstrike>
#include <sdktools>
#pragma newdecls required
int iAWPBroughThisRoundCT, iAWPBroughThisRoundT;
public void OnPluginStart()
{
HookEvent("round_start", OnRoundStart);
}
public Action OnRoundStart(Handle pHndl, const char[] Name, bool bNoBCast)
{
iAWPBroughThisRoundCT = 0;
iAWPBroughThisRoundT = 0;
}
public Action CS_OnBuyCommand(int Client, const char[] sWpnName)
{
if(StrEqual(sWpnName, "awp", true))
{
if(GetClientTeam(Client) == CS_TEAM_CT)
{
float AlowedAWPs = float(((33 / 100) * GetTeamClientCount(CS_TEAM_CT)));
PrintToChat(Client, "debug AWPS = %f", AlowedAWPs);
if (iAWPBroughThisRoundCT < AlowedAWPs)
return Plugin_Stop;
iAWPBroughThisRoundCT++;
}
if(GetClientTeam(Client) == CS_TEAM_T)
{
float AlowedAWPs = float(((33 / 100) * GetTeamClientCount(CS_TEAM_T)));
PrintToChat(Client, "debug AWPS = %f", AlowedAWPs);
if (iAWPBroughThisRoundT < AlowedAWPs)
return Plugin_Stop;
iAWPBroughThisRoundT++;
}
return Plugin_Continue;
}
/*if (strcmp(sWpnName, "weapon_negev") == 0)return Plugin_Stop;
if (strcmp(sWpnName, "weapon_m249") == 0)return Plugin_Stop;
if (strcmp(sWpnName, "weapon_scar20") == 0)return Plugin_Stop;
if (strcmp(sWpnName, "weapon_g3sg1") == 0)return Plugin_Stop;*/
if(StrEqual(sWpnName, "m249", true) || StrEqual(sWpnName, "negev", true) || StrEqual(sWpnName, "scar20", true) || StrEqual(sWpnName, "g3sg1", true))
{
PrintToChat(Client, "\x01 \x02VIP★ Info\x01 :: \x09 You Can Not buy This Weapon");
return Plugin_Stop;
}
return Plugin_Continue;
}
here's my code.
what i'm trying to do is make a restriction that works like this: there are alowed only 33% of the players to have AWP.. so the number of the purchaseable AWPs is (33/100) * PlayersCount where PlayersCount = players only from CT or T
__________________