Hello.
Ive got weird problem with fakeclients, heres part of the code:
Code:
checkbots()
{
if(GetConVarInt(maxplayers)>TotalSurvivors())
{
while(GetConVarInt(maxplayers)!=TotalSurvivors())
{
l4dbot();
}
}else
{
new botstoremove=TotalSurvivors()-GetConVarInt(maxplayers)
for(new i = 1; i <= MaxClients; i++)
{
if(IsClientConnected(i) && IsClientInGame(i))
{
if((GetClientTeam(i) == TEAM_SURVIVORS) && IsAlive(i))
{
if(IsFakeClient(i) && !HasIdlePlayer(i))
{
if(botstoremove>0)
{
KickClient(i,"")
botstoremove--
}else
{
break
}
}
}
}
}
}
for(new i = 1; i <= MaxClients; i++)
{
}
}
public l4dbot()
{
new bot = CreateFakeClient("I am not real.");
ChangeClientTeam(bot,2);
DispatchKeyValue(bot,"classname","SurvivorBot");
DispatchSpawn(bot);
CreateTimer(3.0,kickbot,bot);
}
public Action:kickbot(Handle:timer, any:value)
{
KickClient(value,"fake player");
return Plugin_Stop;
}
checkbots() is called when i change number of bots and when player spawns in round.
All works good for first round but after next round ive got bunch of fakeclients standing in the saferoom and unable to play :/
What am i doing wrong?