Sorry, i forget to post the full func.
PHP Code:
void SpawnInfected(int class)
{
if( !g_gamemode_on || g_has_round_end)
return;
int cheat_client = -1;
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i))
{
cheat_client = i;
break;
}
}
if( cheat_client == -1 )
{
LogMessage("当前没有找到合法玩家执行 cmd 命令, 正在重新查找.");
CreateTimer(1.0,Timer_CreateInfectedBotByClass,class,TIMER_FLAG_NO_MAPCHANGE);
return;
}
if( !L4D_GetRandomPZSpawnPosition(cheat_client,class,5,{0.0,0.0,0.0}) )//这个玩家附近的位置, 类型, 次数, 无用的vec
{
LogMessage("找位失败, 正在重新找位.");
CreateTimer(1.0,Timer_CreateInfectedBotByClass,class,TIMER_FLAG_NO_MAPCHANGE);
return;
}
int bot = CreateFakeClient("Infected Bot");
if( bot != 0 )
{
ChangeClientTeam(bot,TEAM_INFECTED);
KickClient(bot);
switch(class)
{
case CLASS_CHARGER:
CheatCommand(cheat_client, "z_spawn_old", "charger auto");
case CLASS_HUNTER:
CheatCommand(cheat_client, "z_spawn_old", "hunter auto");
case CLASS_JOCKEY:
CheatCommand(cheat_client, "z_spawn_old", "jockey auto");
case CLASS_SMOKER:
CheatCommand(cheat_client, "z_spawn_old", "smoker auto");
case CLASS_BOOMER:
CheatCommand(cheat_client, "z_spawn_old", "boomer auto");
case CLASS_SPITTER:
CheatCommand(cheat_client, "z_spawn_old", "spitter auto");
}
}
else
{
LogMessage("FakeClient 创建失败, 正在重新创建.");
CreateTimer(1.0,Timer_CreateInfectedBotByClass,class,TIMER_FLAG_NO_MAPCHANGE);
}
}
Most of thing is copy from l4d_infectedbot plugin, i just change some judge condition.
The problem is "Couldn't find a xxx spawn position in 5 tires"... This problem can't be fixed, so i want to hook this warning so that i can create a new timer to spawn it agian.
If don't do this, the amount of SI will not equal to the convar setting beacause it actually not create in game but plugin thought it has been created...
Create a repeat timer to check the count of SI seems not good and timely, i thought...
Sorry for my english.