#1

Hello!

I have this loop in my script:
PHP код:
for(new i<MAX_VEHICLES++)
{
    if(
Occupied[i] == false)
    {
        
PutPlayerInVehicle(playeridVehicles[random(2)], 0);
        
Occupied[i] = true;
   }

The loop loops thru all vehicles and checks whetever they're occpupied or not. If not, a random vehicle is picked and the player is put in it, however there is one problem: I need to make that vehicle occupied, so no one can be put in it.

Above you can see that the loop sets all vehicles to occupied. My problem is, I don't know how to recognize the random vehicle the player was put in.

Thank you for help!
Reply
#2

https://sampwiki.blast.hk/wiki/Keywords:Statements#break
Reply
#3

I am not sure if this code - in matters of logic - is correct or not, but it is working.
PHP код:
for(new i<MAX_VEHICLES++)
{
    if(
Occupied[i] == false)
    {
     
PutPlayerInVehicle(playeridVehicles[random(2)], 0);
     
Occupied[i] = true;
     if(
Occupied[Vehicles[random(2)]] == true)
     {
           break;
     }
    }

Or is it false?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)