19.01.2012, 23:13
Quote:
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: pawn Код:
pawn Код:
|
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
new vehicle = GetPlayerVehicleID(playerid);
if(vehicle == 25)
{
ShowPlayerDialog(playerid, TRUCKINGDIALOG, DIALOG_STYLE_LIST, "Choose a destination.", "From here to LV Depot /*(listitem 0)*/ \nFrom here to Ocean Docks /*(listitem 1)*/ \nFrom here to Verona/*(listitem 2)*/", "Ok", "Cancel Job");
}
else if(vehicle == 26)
{
ShowPlayerDialog(playerid, TRUCKINGDIALOG, DIALOG_STYLE_LIST, "Choose a destination.", "From here to LV Depot /*(listitem 0)*/ \nFrom here to Ocean Docks /*(listitem 1)*/ \nFrom here to Verona/*(listitem 2)*/", "Ok", "Cancel Job");
}
else if(vehicle == 27)
{
ShowPlayerDialog(playerid, TRUCKINGDIALOG, DIALOG_STYLE_LIST, "Choose a destination.", "From here to LV Depot /*(listitem 0)*/ \nFrom here to Ocean Docks /*(listitem 1)*/ \nFrom here to Verona/*(listitem 2)*/", "Ok", "Cancel Job");
}
return 1;
}