Show your test code..
Also i hope you noticed i am using break in the loop if no bots were found!
Also i don't see it as a problem calling get_players 30 times if you wish to call it less add two new parameters to the function iPlayers and iNum or create both of them globally but you know i just made it easy to use.
And TBH its not recommended to be used in a loop.
You can use a repeated task to give each bot a new extra item.
Like the following...
PHP Code:
public give_item_task(taskid)
{
static iMaxBots = 0;
if(taskid == TASK_STARTGIVE) iMaxbots = 0;
if(!iMaxBots) iMaxBots = get_pcvar_num(cvar_max_bots);
static id, oldbots[MAX_PLAYERS], oldbots_count;
if(! (id = get_random_bot(oldbots, oldbots_count)) )
{
oldbots_count = 0;
return;
}
if (!zp_get_user_zombie(id) && !g_has_item[id])
set_task(1.0, "give_item", id+TASK_GIVEITEM);
iMaxbots--;
if(iMaxbots)
{
set_task(0.5, "give_item_task", TASK_STARTGIVE + 1);
}
}
For the OP use the code from crazy's in post #6
__________________