IsCarInUse
#1

Is there any way to see if a car is in use or not. I want to use it to periodically delete all cars from my server except the ones in use.
Reply
#2

https://sampwiki.blast.hk/wiki/IsPlayerInVehicle
Reply
#3

The i have to brute force match all cars, but i can give it a try
Reply
#4

pawn Код:
stock IsCarInUse(vehicleid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if (!IsPlayerConnected(i)) continue;
        if (IsPlayerInVehicle(i, vehicleid)) return true;
    }
    return false;
}

stock RemoveAllEmptyVehicles()
{
    for (new i = 0; i < MAX_VEHICLES; i++)
        if (!IsCarInUse(i)) DestroyVehicle(i);
    return true;
}
With this "IsCarInUse" function, you can check if the vehicle is used. With the "RemoveAllEmptyVehicles" function, you can destroy all unused vehicles.
Reply
#5

That's actually a quite good idea. I'll keep that in mind if I ever make such thing for myself.
Reply
#6

I was just writing code, when Kwarde posted the right code, TY. As for ******, the preformance is not a big problem, because I have a limited number of users and enough processing power
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)