#1

I need a function to check if the front passenger seat of your vehicle is occupied.
Reply
#2

Quote:
Originally Posted by lordturhan
View Post
I need a function to check if the front passenger seat of your vehicle is occupied.
You can check the player's seat by the following function:-

pawn Code:
GetPlayerVehicleSeat(playerid);

// following is an example:-

CMD:yourseat( playerid, params[ ] )
{
    new CheckSeat = GetPlayerVehicleSeat(playerid);
    if( !IsPlayerInAnyVehicle ) return SendClientMessage( playerid, -1, "you are not in any vehicle" );
    if( CheckSeat == 0 )
    {
        SendClientMessage( playerid, -1, "You are a driver" );
    }
    else if( CheckSeat == 1 )
    {
        SendClientMessage( playerid, -1, "You are a co-driver" );
    }
    else if( CheckSeat == 2 || CheckSeat == 3 )
    {
        SendClientMessage( playerid, -1, "You are a passenger" );
    }
    return 1;
}
https://sampwiki.blast.hk/wiki/GetPlayerVehicleSeat

Remember: Seat ID (-1 if the player is not in a vehicle, 0 driver, 1 co-driver, 2&3 back seat passengers, 4+ if the vehicle has enough seats (i.e coach)).


-FalconX
Reply
#3

Oh forgot to mention i need to check if the player is not in vehicle but checking last vehicle he entered
Reply
#4

Quote:
Originally Posted by lordturhan
View Post
Oh forgot to mention i need to check if the player is not in vehicle but checking last vehicle he entered
Okay, kinda sleepy but this is what came in my mind, if someone has even better way you can feel free to correct me.

pawn Code:
public OnPlayerStateChange( playerid, newstate, oldstate )
{
    if( oldstate == PLAYER_STATE_DRIVER && newstate == PLAYER_STATE_ONFOOT ) // when player exits the vehicle
    {
        SetPVarInt( playerid, "LASTVEHICLE", GetVehicleModel( GetPlayerVehicleID( playerid ) ) );
    }
    return 1;
}

// now the following code wherever you want:-

if( GetPvarInt( playerid, "LASTVEHICLE" ) == 411 ) // MODEL_ID can be replaced with your own vehicle model like "411" is infernus
{
    SendClientMessage( playerid, -1, "You are in infernus, enjoy!" );
}
-FalconX
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)