Empty vehicle ?
#1

Hello.

I just want to know if there is a predefined function that lets you know if a vehicle is empty.

This is a function to respawn vehicles empty on a shelf, and it would be heavy to loop for each player in a loop for each vehicle ...

Thank you!
Reply
#2

https://sampwiki.blast.hk/wiki/Category:...tions#Vehicles

You can see a list of standard vehicle functions here, the particular one you are looking for is not included in the SA-MP API.
Reply
#3

I believe this is exactly what you're looking for.
pawn Код:
stock IsVehicleEmpty( vehicleid )
{
    for ( new playerid = 0; playerid < MAX_PLAYERS; playerid++ )
    {
        if ( !IsPlayerConnected( playerid ) )
            continue;

        if ( GetPlayerVehicleID( playerid ) == vehicleid )
            return false;
    }

    return true;
}
A rep+ would be appriciated.
Reply
#4

I've watched the official page.

The function does not interest me because it is precisely the overhead I mentioned ... There will be more than 30,000 entries in the loop, but ...

Thank !
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)