17.12.2011, 13:17
Have you set the PVar for the player?
Sorry to push this old post, but I found it when I'm searching for something, and it is not solved.
pawn Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
new engine,lights,alarm,doors,bonnet,boot,objective;
new vehicleid = GetPlayerVehicleID(playerid);
if(IsPlayerInAnyVehicle(playerid) && newkeys & KEY_ANALOG_UP)
{
if(GetPVarInt(playerid, "Lights") == 1)//1 for on and 0 for off is easier to understand.
{
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,engine,false,alarm,doors,bonnet,boot,objective);
SetPVarInt(playerid, "Lights", 0);
}
else if(GetPVarInt(playerid, "Lights") == 0)
{
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,engine,true,alarm,doors,bonnet,boot,objective);
SetPVarInt(playerid, "Lights", 1);
}
//You missed a bracket here.
}
}
return 1;