PDA

View Full Version : Vehicle Lights.


budelis
19/11/2011, 02:34 PM
Hello peoples.I have one thing with lights. Problem is lights not off and not on at all nothing happines here is a 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") == 0)
{
GetVehicleParamsEx(vehicleid,engine,lights,alarm,d oors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,engine,false,alarm,do ors,bonnet,boot,objective);
}
else if(GetPVarInt(playerid, "Lights") == 1)
{
GetVehicleParamsEx(vehicleid,engine,lights,alarm,d oors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,engine,true,alarm,doo rs,bonnet,boot,objective);
}
}
return 1;
}

I press numpad 8 but how i say nothing happin...

gecatahh
19/11/2011, 02:37 PM
You must activate the manual control of the vehicle. In OnGamemodeInit you must place this ManualVehicleEngineAndLights(); , but now you must edit command for starting the engine.
Here some help:

//for Engine On
GetVehicleParamsEx(vehicleid,engine,lights,alarm,d oors,bonnet,boot,objective); SetVehicleParamsEx(vehicleid,1,lights,alarm,doors, bonnet,boot,objective);
GameTextForPlayer(playerid, "~g~ Engine is On", 3500, 3);

//and for Engine OFF
GetVehicleParamsEx(vehicleid,engine,lights,alarm,d oors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,0,lights,alarm,doors, bonnet,boot,objective);
GameTextForPlayer(playerid, "~r~ Engine is Off", 3500, 3);

GangsTa_
19/11/2011, 02:46 PM
You must activate the manual control of the vehicle. In OnGamemodeInit you must place this ManualVehicleEngineAndLights(); , but now you must edit command for starting the engine.
Here some help:

//for Engine On
GetVehicleParamsEx(vehicleid,engine,lights,alarm,d oors,bonnet,boot,objective); SetVehicleParamsEx(vehicleid,1,lights,alarm,doors, bonnet,boot,objective);
GameTextForPlayer(playerid, "~g~ Engine is On", 3500, 3);

//and for Engine OFF
GetVehicleParamsEx(vehicleid,engine,lights,alarm,d oors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,0,lights,alarm,doors, bonnet,boot,objective);
GameTextForPlayer(playerid, "~r~ Engine is Off", 3500, 3);


And where's the SetVehicleParamsEx for the engine on?

MP2
19/11/2011, 02:48 PM
It's on the same line but for some reason far away, scroll right in the box.

leong124
17/12/2011, 01:17 PM
Have you set the PVar for the player?

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,d oors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,engine,false,alarm,do ors,bonnet,boot,objective);
SetPVarInt(playerid, "Lights", 0);
}
else if(GetPVarInt(playerid, "Lights") == 0)
{
GetVehicleParamsEx(vehicleid,engine,lights,alarm,d oors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,engine,true,alarm,doo rs,bonnet,boot,objective);
SetPVarInt(playerid, "Lights", 1);
}
//You missed a bracket here.
}
}
return 1;

Sorry to push this old post, but I found it when I'm searching for something, and it is not solved.