Get vehicle free seat ID
#1

Help with this...If the vehicle seat is not full,return seat ID or return -1
Reply
#2

You could use a loop to check whoever in the vehicle, then using GetPlayerVehicleSeat function to check whether seats are full or not.
Reply
#3

Mhm, I think this could help you:

Код:
stock getSeatStatus(const vID, const seatID)
{
	for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
	{
		if(GetPlayerVehicleID(i) == vID && GetPlayerVehicleSeat(i) == seatID)
			return true; 
	}
	return false; 
}
Reply
#4

Quote:
Originally Posted by ranme15
Посмотреть сообщение
You could use a loop to check whoever in the vehicle, then using GetPlayerVehicleSeat function to check whether seats are full or not.
Quote:
Originally Posted by Dennis12
Посмотреть сообщение
Mhm, I think this could help you:

Код:
stock getSeatStatus(const vID, const seatID)
{
	for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
	{
		if(GetPlayerVehicleID(i) == vID && GetPlayerVehicleSeat(i) == seatID)
			return true; 
	}
	return false; 
}
Thank a lot bro
Reply
#5

I'm not sure if GetPlayerVehicleSeat always works. It didn't used to work at times for some reason.
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)