SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 28/02/2013, 12:23 PM   #1
Arpatos
Big Clucker
 
Join Date: Nov 2012
Posts: 77
Reputation: 0
Post Lights on/off with a key [Resolved]

Hey dudes, i've scripted a little part of my gamemode in order to put on lights with a key:

if((newkeys == KEY_SUBMISSION) || (newkeys & KEY_SPRINT) && (newkeys & KEY_SUBMISSION) || (newkeys & KEY_UP) && (newkeys & KEY_SUBMISSION) || (newkeys & KEY_DOWN) && (newkeys & KEY_SUBMISSION) || (newkeys & KEY_WALK) && (newkeys & KEY_SUBMISSION) || (newkeys & KEY_LEFT) && (newkeys & KEY_SUBMISSION) || (newkeys & KEY_RIGHT) && (newkeys & KEY_SUBMISSION))
{
if(IsPlayerConnected(playerid))
{
if(IsPlayerInAnyVehicle(playerid))
{
new vehicleid = GetPlayerVehicleID(playerid);
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(vehicleid,engine,lights,alarm,d oors,bonnet,boot,objective);

if(PharesAllumer[vehicleid] == 0)
{
SetVehicleParamsEx(vehicleid,engine,VEHICLE_PARAMS _ON,alarm,doors,bonnet,boot,objective);
PharesAllumer[vehicleid] = 1;
}

}
}
}
}

But how to do, in order to put off the lights with the same key ?

Last edited by Arpatos; 01/03/2013 at 09:56 AM.
Arpatos is offline   Reply With Quote
Old 28/02/2013, 12:27 PM   #2
Luis-
High-roller
 
Luis-'s Avatar
 
Join Date: Jan 2010
Location: England
Posts: 3,933
Reputation: 415
Default Re: Lights on/off with a key

I don't actually understand what you want here, plus the code is so messy. Why do you have all those keys? Wouldn't one be enough?
__________________
Luis- is offline   Reply With Quote
Old 28/02/2013, 12:44 PM   #3
=WoR=Varth
High-roller
 
=WoR=Varth's Avatar
 
Join Date: Apr 2011
Location: Indonesia
Posts: 1,988
Reputation: 133
Default Re: Lights on/off with a key

Use pawn tag [PAWN]

And what is this PharesAllumer[vehicleid]?

http://wiki.sa-mp.com/wiki/GetVehicleParamsEx
http://wiki.sa-mp.com/wiki/SetVehicleParamsEx
http://wiki.sa-mp.com/wiki/Control_Structures#else
__________________
(RETIRED)
=WoR=Varth is offline   Reply With Quote
Old 28/02/2013, 12:47 PM   #4
Arpatos
Big Clucker
 
Join Date: Nov 2012
Posts: 77
Reputation: 0
Default Re: Lights on/off with a key

http://pastebin.com/MSARyUdP

PharesAllumer means in french lights on.

At this time, lights get on with a key put don't get off with the same key
Arpatos is offline   Reply With Quote
Old 28/02/2013, 12:53 PM   #5
=WoR=Varth
High-roller
 
=WoR=Varth's Avatar
 
Join Date: Apr 2011
Location: Indonesia
Posts: 1,988
Reputation: 133
Default Re: Lights on/off with a key

You are using "lights" variable to store the light value
pawn Code:
if(lights)//If light is on
{
//Set light off here
}
else//else light is off
{
//Set light on here
}


Have you check the link I gave you?
__________________
(RETIRED)
=WoR=Varth is offline   Reply With Quote
Old 28/02/2013, 12:58 PM   #6
Arpatos
Big Clucker
 
Join Date: Nov 2012
Posts: 77
Reputation: 0
Default Re: Lights on/off with a key

Yes but i don't see how to script that in order to put off the lights with a key :/
Arpatos is offline   Reply With Quote
Old 28/02/2013, 01:20 PM   #7
Vince
Spam Machine
 
Vince's Avatar
 
Join Date: Sep 2007
Location: Belgium
Posts: 10,067
Reputation: 2660
Default Re: Lights on/off with a key

Removed lots of redundant checks. If the player can press a key then he is obviously connected. And if he is the driver then he is obviously in a vehicle.

http://pastebin.com/QwHJNiAh
__________________
Vince is offline   Reply With Quote
Old 28/02/2013, 01:32 PM   #8
Arpatos
Big Clucker
 
Join Date: Nov 2012
Posts: 77
Reputation: 0
Default Re: Lights on/off with a key

Yeah but what have i to write for the light off ?
Arpatos is offline   Reply With Quote
Old 28/02/2013, 02:54 PM   #9
Arpatos
Big Clucker
 
Join Date: Nov 2012
Posts: 77
Reputation: 0
Default Re: Lights on/off with a key

little up
Arpatos is offline   Reply With Quote
Old 28/02/2013, 04:30 PM   #10
Arpatos
Big Clucker
 
Join Date: Nov 2012
Posts: 77
Reputation: 0
Default Re: Lights on/off with a key

upppppp
Arpatos 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
Lights day |||| Lights night PaulDinam Scripting Help 5 27/06/2012 06:14 AM
car lights during day Visio Scripting Help 7 10/06/2012 05:51 AM
lights... GangBang Help Archive 4 20/10/2009 09:11 PM
alarm lights/flash lights CAR Help Archive 2 23/07/2009 02:53 PM


All times are GMT. The time now is 05:54 AM.


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