15.05.2015, 13:25
PHP код:
stock RespawnAllVehicles( )
{
for( new i = 1; i <= GetVehiclePoolSize( ); i++ ) //vehicle IDs start at 1.
{
for( new p = 0; p <= GetPlayerPoolSize( ); p++ ) // looping through connected players
{
if( IsPlayerInVehicle( p, i ) ) // if someone's driving the current vehicle we're checking
continue; // exit the player loop as we don't need to check any further
}
if( IsVehicleTrailer( i ) && IsVehicleAttachedToTrailer( i ) ) // if it's a trailer, and if it's attached to some vehicle
continue; // tell the loop to continue on to the next vehicle as this one is a trailer attached to a vehicle
SetVehicleToRespawn( i ); // respawn the vehicle if it's unoccupied and not attached to any vehicle
}
return 1;
}
IsVehicleTrailer( vehicleid )
{
switch( GetVehicleModel( vehicleid ) )
{
case 435, 450, 584, 591: return true; // if it's a trailer
default: return false; // if not
}
return false; // return false by default
}
IsVehicleAttachedToTrailer( trailerid )
{
for( new i = 1; i < GetVehiclePoolSize( ); i++ )
{
if( GetVehicleTrailer( i ) == trailerid ) // if the trailer attached to this vehicle is the trailer
return true;
}
return false;
}