random from loop
#1

alright so this might be a bit complex

I want of the player to spectate player that is alive (well his vehicle) which I got working. Now my main problem is, how do I randomize it.

For example: players alive ID's are 1,2,3,4. If I use my loop, its just gonna spectate first one it finds, I want of it to spectate random alive player, not first in line

This is a working code, I just need to get random from all those results or something... I though about making an array and storing all ID's in it and then just randomEx to get the result but Im not sure how it should work basically because I have to switch some ID's etc.
PHP код:
    new savedid;
    for(new 
0MAX_PLAYERSi++) {
        if(
IsPlayerConnected(i)) {
            if(
IsPlayerInAnyVehicle(i)) {
                if(
playerid != i) {
                    
savedid i;
                }
            }
        }
    }
    
PlayerSpectateVehicle(playeridGetPlayerVehicleID(savedid)); 
So my main problem is, how do I randomize it?
Simple randomEx wouldn't work this way simply because some of the ID's wouldnt be alive etc
Reply


Messages In This Thread
random from loop - by TwinkiDaBoss - 27.05.2016, 02:27
Re: random from loop - by Kaliber - 27.05.2016, 03:11
Re: random from loop - by Vince - 27.05.2016, 08:36
Re: random from loop - by TwinkiDaBoss - 27.05.2016, 14:37

Forum Jump:


Users browsing this thread: 2 Guest(s)