SA-MP Forums Archive
need help with vehicles - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: need help with vehicles (/showthread.php?tid=495938)



need help with vehicles - karolis11234 - 19.02.2014

how can i check if the player entered a car when its created like this : new masina = CreateVehicle(489, 2117.9717, -2137.3484, 13.8255, -98.0000, 0, 0, 100);


Re: need help with vehicles - Konstantinos - 19.02.2014

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
    {
        if (GetPlayerVehicleID(playerid) == masina)
        {
            // player entered that vehicle..
        }
    }
    return 1;
}
This checks if the player enters a vehicle as driver or passenger and if the vehicleid is the one masina holds. If you want to check only for driver, change:
pawn Код:
if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
to:
pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
This one checks if the player is in that vehicle which can be used anywhere else.
pawn Код:
if (IsPlayerInVehicle(playerid, masina))
{
    // player is in that vehicle..
}