27.05.2016, 02:27
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.
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
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 i = 0; i < MAX_PLAYERS; i++) {
if(IsPlayerConnected(i)) {
if(IsPlayerInAnyVehicle(i)) {
if(playerid != i) {
savedid = i;
}
}
}
}
PlayerSpectateVehicle(playerid, GetPlayerVehicleID(savedid));
Simple randomEx wouldn't work this way simply because some of the ID's wouldnt be alive etc