Vehicle Lights.
#1

Hello peoples.I have one thing with lights. Problem is lights not off and not on at all nothing happines here is a code:

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,doors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,engine,false,alarm,doors,bonnet,boot,objective);
}
else if(GetPVarInt(playerid, "Lights") == 1)
{
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,engine,true,alarm,doors,bonnet,boot,objective);
}
}
return 1;
}
I press numpad 8 but how i say nothing happin...
Reply
#2

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:
pawn Code:
//for Engine On
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,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,doors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,0,lights,alarm,doors,bonnet,boot,objective);
GameTextForPlayer(playerid, "~r~ Engine is Off", 3500, 3);
Reply
#3

Quote:
Originally Posted by gecatahh
View Post
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:
pawn Code:
//for Engine On
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,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,doors,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?
Reply
#4

It's on the same line but for some reason far away, scroll right in the box.
Reply
#5

Have you set the PVar for the player?
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;
Sorry to push this old post, but I found it when I'm searching for something, and it is not solved.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)