PDA

View Full Version : Vehicle Problem


Derexi
12/08/2014, 03:58 PM
I have a "Vehicle Pass" code, where if you enter certain vehicles without having purchased a Vehicle Pass, you'll be asked if you'd like to purchase one. If you don't purchase one, it removes you from the vehicle. But my problem is, as soon as you're removed from the vehicle, you're instantly put back in the vehicle for no reason. I can't understand why... here is my code:

Code to show the dialog when the player enters the vehicle:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(oldstate == PLAYER_STATE_ONFOOT && newstate == PLAYER_STATE_DRIVER)
{
new vehicleid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(vehicleid) == 425 || GetVehicleModel(vehicleid) == 432 || GetVehicleModel(vehicleid) == 592 || GetVehicleModel(vehicleid) == 520 || GetVehicleModel(vehicleid) == 577 && pData[playerid][Level] == 1)
{
if(pData[playerid][VehiclePass] < 1)
{
new str[300];
format(str, sizeof(str), "In order to use this vehicle, you must use in-game money to purchase a pass.\nThis pass will unlock all vehicles.\n\nDo you wish to pay $10,000 for a pass?");
ShowPlayerDialog(playerid, 29, DIALOG_STYLE_MSGBOX, "Vehicle Purchase", str, "Purchase", "Cancel");
}
}
}
return 1;
}

Dialog responses code:
if(dialogid == 29)
{
if(!response)
{
RemovePlayerFromVehicle(playerid);
SendClientMessage(playerid, -1, "To purchase a vehicle pass, use /vehiclepass at any time.");
}
else if(response)
{
if(GetPlayerMoney(playerid) < 10000)
{
SendClientMessage(playerid, ERROR, "You do not have enough money to purchase a vehicle pass!");
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
SetPlayerPos(playerid, x+2, y, z+2);
SendClientMessage(playerid, -1, "To purchase a vehicle pass, use /vehiclepass at any time.");
}
else
{
SendClientMessage(playerid, 0xFFFF00FF, "You purchased a vehicle pass for $10,000! You now have unlimited access to all vehicles.");
pData[playerid][VehiclePass] = 1;
}
}
}

As you can see, the code teleports the player out of the vehicle, but he instantly gets put back in the vehicle.

Also: my code is indented perfectly, it just got messed up by the forum.

Derexi
12/08/2014, 04:00 PM
NEVERMIND. It was a problem with my Anti-fall-off-bike code.