Looping through victims for zombie
#4

Your code is good. All I would improve, would be getting the NPC/Zombie position once, not on every iteration.
pawn Code:
new ids[MAX_PLAYERS], count = 0;
new Float:x, Float:y, Float:z;
FCNPC_GetPosition(npcid, x, y, z);

for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
{
    if(!IsPlayerNPC(playerid) && IsPlayerConnected(playerid))
    {
        if(IsPlayerInRangeOfPoint(playerid, GetVictimDetectRange[playerid], x, y, z) && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT && GetPlayerInterior(playerid) == 0 && GetPlayerVirtualWorld(playerid) == 0)
        {
            ids[count] = playerid;
            count++;
        }
    }
}
if(count != 0)
{
    return ids[random(count)];
}

return INVALID_PLAYER_ID;
Other problem you might run into is how often you run this, it might make the zombie twitch between each player
Reply


Messages In This Thread
Looping through victims for zombie - by StrikerZ - 27.09.2017, 15:36
Re: Looping through victims for zombie - by Misiur - 27.09.2017, 15:47
Re: Looping through victims for zombie - by StrikerZ - 27.09.2017, 15:51
Re: Looping through victims for zombie - by Misiur - 27.09.2017, 15:59
Re: Looping through victims for zombie - by StrikerZ - 27.09.2017, 16:03
Re: Looping through victims for zombie - by StrikerZ - 29.09.2017, 06:04
Re: Looping through victims for zombie - by Misiur - 29.09.2017, 06:21
Re: Looping through victims for zombie - by StrikerZ - 29.09.2017, 06:24
Re: Looping through victims for zombie - by Misiur - 29.09.2017, 06:26
Re: Looping through victims for zombie - by AbyssMorgan - 29.09.2017, 06:32

Forum Jump:


Users browsing this thread: 1 Guest(s)