Looping through victims for zombie
#10

Simple random player in range and if npc see player.
PHP Code:
stock GetTarget(npcid){
    new 
Float:xFloat:yFloat:zFloat:anglepstate,
        
pool_players[MAX_PLAYERS], pool_upp = -1;
    
    
FCNPC_GetPosition(npcid,x,y,z);
    
angle FCNPC_GetAngle(npcid);
    
Tryg3D::Foreach(i){
        
pstate GetPlayerState(i);
        if(
GetElementsDistance(i,item_player,npcid,item_fcnpc) <= 300.0 && GetPlayerInterior(i) == && GetPlayerVirtualWorld(i) == 0){
            if(
pstate != PLAYER_STATE_SPECTATING && pstate != PLAYER_STATE_WASTED){
                if(
IsElementOnFakeScreen(x,y,z,i,item_player,0.0,angle)){ //for vehicle collision: .veh_col=true
                    
pool_upp++;
                    
pool_players[pool_upp] = i;
                }
            }
        }
    }
    
    if(
pool_upp == -1) return INVALID_PLAYER_ID;
    return 
pool_players[random(pool_upp+1)];

Libs:
3DTryg
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)