Get vehicle free seat ID
#6

I made some function like this quite a while back, and I'm sure many others have been made just like it. This was my version a few years ago:

PHP код:
new const MaxVehicleSeats[212] =
{
    
4222441224222422424244222,
    
1444219122029424122241,
    
21202111222442212124422421,
    
12212242143111442424122244,
    
22222222421121122422112222,
    
22224111222222142222244224,
    
42122222244221244100112,
    
1224244241042222002211,
    
4442222242000400
};
GetFreeSeat(vehicleid)
{
    new 
vehiclemodel GetVehicleModel(vehicleid);
    if(
vehiclemodel)
    {
        new
            
bool:seattaken[10],
            
playerseat = -1
        
;
        foreach(new 
Player)
        {
            if(!
IsPlayerInVehicle(ivehicleid)) continue;
            
playerseat GetPlayerVehicleSeat(i);
            if(
<= playerseat 128)
                
seattaken[playerseat] = true;
        }
        for(new 
0MaxVehicleSeats[vehiclemodel 400]; v++)
        {
            if(
seattaken[v]) continue;
            return 
v;
        }
    }
    return -
1;

There is a slight chance that the array might need to be updated. It does include vehicles that can be driven but not entered, and these are issued with a 'seat count' of 0.
Reply


Messages In This Thread
Get vehicle free seat ID - by 3417512908 - 28.12.2018, 04:07
Re: Get vehicle free seat ID - by ranme15 - 28.12.2018, 07:42
Re: Get vehicle free seat ID - by Dennis12 - 28.12.2018, 11:15
Re: Get vehicle free seat ID - by 3417512908 - 28.12.2018, 11:41
Re: Get vehicle free seat ID - by BeckzyBoi - 28.12.2018, 17:33
Re: Get vehicle free seat ID - by Threshold - 29.12.2018, 10:12

Forum Jump:


Users browsing this thread: 3 Guest(s)