I think that this Code, crashes my server
I want to know if this code is fine,
I did test and sometimes DEAD T Team can speak.
Code:
#pragma semicolon 1
#define OVER_8000 8001
new gI_MaxClients;
new gH_LRCanSpeak;
public plugin_init()
{
gI_MaxClients = get_maxplayers();
gH_LRCanSpeak = register_cvar("amx_jailbreak_lr_can_speak", "1", 0, 1.0);
register_forward(FM_Voice_SetClientListening, "OnClientSpeak");
}
Code:
public OnClientSpeak(receiver, sender, bool:listen)
{
if(!IsValidClient(receiver) || !IsValidClient(sender))
{
return FMRES_IGNORED;
}
if(get_user_flags(sender) & ADMIN_LEVEL_F)
{
return FMRES_IGNORED;
}
if(cs_get_user_team(sender) == CS_TEAM_CT && is_user_alive(sender))
{
return FMRES_IGNORED;
}
if(get_pcvar_num(gH_LRCanSpeak) && is_user_alive(sender) && cs_get_user_team(sender) == CS_TEAM_T)
{
static count;
count = 0;
static i;
for(i = 1; i <= gI_MaxClients; i++)
{
if(IsValidClient(i, true) && cs_get_user_team(i) == CS_TEAM_T)
{
count++;
}
}
if(count == 1)
{
return FMRES_IGNORED;
}
}
engfunc(EngFunc_SetClientListening, receiver, sender, false);
return FMRES_SUPERCEDE;
}
stock bool:IsValidClient(client, bool:bAlive = false)
{
if(client >= 1 && client <= gI_MaxClients && is_user_connected(client) && (bAlive == false || is_user_alive(client)))
{
return true;
}
return false;
}