19.01.2012, 22:57
The OnPlayerEnterVehicle is called when a player presses Enter near a vehicle. If you use GetPlayerVehicleID in this callback it will return 0, because the player is not in a vehicle yet.
Solutions:
1) Instead of using OnPlayerEnterVehicle, use OnPlayerStateChange with newstate == PLAYER_STATE_DRIVER
2) Keep using OnPlayerEnterVehicle, but just use the "vehicleid" variable which is already defined in the callback
I would suggest 1, because it's better if the dialog shows up upon entering the vehicle. Also OnPlayerEnterVehicle could cause problems if the player cancels the entry.
And btw for future reference:
This does not make any sense, since the result of GetPlayerVehicleID is not stored in "vehicle". Use this:
Solutions:
1) Instead of using OnPlayerEnterVehicle, use OnPlayerStateChange with newstate == PLAYER_STATE_DRIVER
2) Keep using OnPlayerEnterVehicle, but just use the "vehicleid" variable which is already defined in the callback
I would suggest 1, because it's better if the dialog shows up upon entering the vehicle. Also OnPlayerEnterVehicle could cause problems if the player cancels the entry.
And btw for future reference:
pawn Код:
new vehicle;
GetPlayerVehicleID(playerid);
pawn Код:
new vehicle = GetPlayerVehicleID(playerid);