Sorry for my poor English.
hello. im stuck in a adding enable/disable cvar on plugin.
source code here. this plugin is use sm_knife to get a knifes,this plugin for csgo mg server.
I added g_hEnablePlugin but not work.
Code:
#include <sourcemod>
#include <sdktools>
#include <sdkhooks>
Handle g_hEnablePlugin = INVALID_HANDLE;
public void OnPluginStart()
{
RegConsoleCmd("sm_knife", Knife, "", 0);
RegConsoleCmd("sm_knife", Knife);
g_hEnablePlugin = CreateConVar("sm_knife_enable", "1", "Disabled/enabled [0/1]", 0, true, 0.0, true, 1.0);
}
public Action:Knife(client, args)
{
if (!IsTeamOneSide())
{
return Action:3;
}
if (!IsValidEntity(GetPlayerWeaponSlot(client, 2)))
{
if(GetConVarBool(g_hEnablePlugin))
{
GivePlayerItem(client, "weapon_knife", 0);
}
}
return Action:3;
}
GetCountsPlayingInTeam(team)
{
int iPlaysNum;
int i = 1;
while (i <= MaxClients)
{
if (IsClientConnected(i) && IsClientInGame(i))
{
if (team == GetClientTeam(i))
{
iPlaysNum++;
}
}
i++;
}
return iPlaysNum;
}
bool IsTeamOneSide()
{
if ((GetCountsPlayingInTeam(2) > 0 && GetCountsPlayingInTeam(3)) || (GetCountsPlayingInTeam(3) > 0 && GetCountsPlayingInTeam(2)))
{
return true;
}
return false;
}