02.04.2011, 09:08
Might be more efficient doing this, i'm not sure it works but i think it should. Should be more efficient than using nested loops.
In your command
pawn Код:
new bool:bVehicleOccupied[ MAX_VEHICLES ];
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if( newstate == PLAYER_STATE_DRIVER )
{
new
vehicleid = GetPlayerVehicleID( playerid );
bVehicleOccupied[ vehicleid ] = true;
SetPVarInt( playerid, "currentvehicle", vehicleid );
}
else if( oldstate == PLAYER_STATE_DRIVER )
{
bVehicleOccupied[ GetPVarInt( playerid, "currentvehicle") ] = false;
DeletePVar( playerid, "currentvehicle");
}
return 1;
}
pawn Код:
for( new i; i < MAX_VEHICLES; i++ )
{
if( !bVehicleOccupied[ i ] )
SetVehicleToRespawn( i );
}