SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 19/11/2011, 02:34 PM   #1
budelis
Huge Clucker
 
Join Date: Jun 2011
Posts: 453
Reputation: 7
Default Vehicle Lights.

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...
budelis is offline   Reply With Quote
Old 19/11/2011, 02:37 PM   #2
gecatahh
Big Clucker
 
Join Date: Mar 2008
Posts: 85
Reputation: 0
Default Re: Vehicle Lights.

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);
gecatahh is offline   Reply With Quote
Old 19/11/2011, 02:46 PM   #3
GangsTa_
High-roller
 
GangsTa_'s Avatar
 
Join Date: May 2010
Location: Republic of Moldova
Posts: 1,029
Reputation: 51
Default Re: Vehicle Lights.

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?
__________________
i5-5200U @ 2.6 GHz
GTX 950M 2GB GDDR3 128-bit
8,00GB DDR3 RAM
128GB SSD, 1TB 5400RPM HDD
Windows 10 Pro x64
GangsTa_ is offline   Reply With Quote
Old 19/11/2011, 02:48 PM   #4
MP2
Godfather
 
MP2's Avatar
 
Join Date: Jan 2011
Location: England
Posts: 6,236
Reputation: 1004
Default Re: Vehicle Lights.

It's on the same line but for some reason far away, scroll right in the box.
__________________
Owner and developer of Mike's Cops and Robbers.

Click here to visit our site and find out more. Click here to view trailers.
Enter referral code SAMPFORUM after registering for a $5000 starting bonus!
MP2 is offline   Reply With Quote
Old 17/12/2011, 01:17 PM   #5
leong124
High-roller
 
leong124's Avatar
 
Join Date: Jun 2008
Location: Hong Kong, China
Posts: 1,496
Reputation: 134
Default Re: Vehicle Lights.

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.
__________________
[KDT_MS]hk_shade

Sorry for my bad English and my weakness in expressing myself.
leong124 is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
vehicle lights Stefans94 Scripting Help 0 10/10/2011 03:59 PM
0.3c vehicle,lights etc The_J0ker Help Archive 14 09/07/2011 08:08 AM
Vehicle lights Mikkel_RE Help Archive 2 27/06/2011 10:38 AM
Need help with my vehicle lights Shidony Help Archive 1 20/06/2011 10:56 AM


All times are GMT. The time now is 04:45 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.