Hi there, I wrote this code:
Code:
HookEvent("player_team", Player_SwitchTeam, EventHookMode_Pre);
public Action:Player_SwitchTeam(Handle:event, const String:name[], bool:dontBroadcast)
{
new newTeam = GetEventInt(event, "team");
new oldTeam = GetEventInt(event, "oldteam");
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if ((client < 1) || !IsClientInGame(client) || IsFakeClient(client))
return Plugin_Handled;
//Remove the warden if he switches back to T
if (client == wardenIndex && newTeam == CS_TEAM_T)
RemoveWarden();
//Trying to switch to CT?
if (newTeam == CS_TEAM_CT && oldTeam != CS_TEAM_CT)
{
new countTs = 0;
new countCTs = 0;
//Count players
for (new i = 1; i <= MAXPLAYERS; i++)
{
if (IsClientInGame(i))
{
if (GetClientTeam(i) == CS_TEAM_T)
countTs++;
else if (GetClientTeam(i) == CS_TEAM_CT)
countCTs++;
}
}
new teamRatio = 3;
//Is the ratio going to be unbalanced?
if ((countCTs < (countTs / teamRatio)) || (countCTs <= 0))
return Plugin_Continue;
else
{
EmitSoundToClient(client, RELATIVE_SOUND_PATH_ERROR);
CPrintToChat(client, "{green}[PG]{default} You cannot be a guard as the ratio is not 3:1!");
return Plugin_Handled;
}
}
return Plugin_Continue;
}
However, nothing happens unfortunately. If anyone could help it'd be great, thanks.