SA-MP Forums Archive
OnPlayerEnterVehicle - 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: OnPlayerEnterVehicle (/showthread.php?tid=469875)



OnPlayerEnterVehicle - AnonScripter - 15.10.2013

pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
    GameTextForPlayer(playerid,"~w~Text",4000,3);
    return 1;
}
Why it shows the text directly when i press enter or F ? how to make it show when the player finish to get into the car ??


Re: OnPlayerEnterVehicle - DanishHaq - 15.10.2013

Put it under OnPlayerStateChange, by using

pawn Код:
if(newstate == PLAYER_STATE_DRIVER)
Edit: Look at the post below for a better example, I'm on my phone at the moment so can't give a full example.


Re: OnPlayerEnterVehicle - PrivatioBoni - 15.10.2013

Try this:

pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER) // Player entered a vehicle as a driver
    {
        GameTextForPlayer(playerid,"~w~Text",4000,3);
    }
    return 1;
}



Re: OnPlayerEnterVehicle - AnonScripter - 15.10.2013

thanks both, but if this is the solution, so what's the usage of OnPlayerEnterVehicle callback?


Re: OnPlayerEnterVehicle - Pottus - 15.10.2013

It's called when a player tries to enter a vehicle that way you can send the message if say it's a faction police car.


Re: OnPlayerEnterVehicle - DanishHaq - 15.10.2013

OnPlayerEnterVehicle is called directly when someone pressed F at a car, it's an old callback, before OnPlayerStateChange. But onentervehicle can be used for some things, not sure for what, maybe anti car jack, if someone is in the car, it would slap the guy trying to rob it.


Re: OnPlayerEnterVehicle - AnonScripter - 15.10.2013

thanks all