17.09.2013, 07:05
I would like a script that will be able to tell if a car is completely empty, and will remove it, I can't seem to figure out how to do it
stock IsVehicleOccupied( vehicleid )
{
for( new i = 0; i < MAX_PLAYERS; i++ )
{
if( IsPlayerInVehicle( i, vehicleid ) ) return 1;
}
return 0;
}
// Where you want to remove the vehicle
// let's say "vehicle" stores the vehicleid (you need to get the vehicleid)
if( !IsVehicleOccupied( vehicle ) DestroyVehicle( vehicle );
// If nobody is in that vehicle, it will destroy/remove it.
forward VehicleOccupied(vehicleid); public VehicleOccupied(vehicleid) { for(new i=0;i<MAX_PLAYERS;i++) { if(IsPlayerInVehicle(i,vehicleid)) return 1; } return 0; } for(new veh = 0; veh < MAX_VEHICLES; veh++) { if(!VehicleOccupied(veh)) return SetVehicleToRespawn(veh); }
forward VehicleOccupied(vehicleid);
public VehicleOccupied(vehicleid)
{
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerInVehicle(i,vehicleid)) return 1;
}
return 0;
}
for(new veh = 0; veh < MAX_VEHICLES; veh++)
{
if(!VehicleOccupied(veh)) return SetVehicleToRespawn(veh);
}