SA-MP Forums Archive
Lights on/off with a key - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Lights on/off with a key (/showthread.php?tid=419331)



Lights on/off with a key [Resolved] - Arpatos - 28.02.2013

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 ?


Re: Lights on/off with a key - Luis- - 28.02.2013

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?


Re: Lights on/off with a key - =WoR=Varth - 28.02.2013

Use pawn tag [PAWN]

And what is this PharesAllumer[vehicleid]?

https://sampwiki.blast.hk/wiki/GetVehicleParamsEx
https://sampwiki.blast.hk/wiki/SetVehicleParamsEx
https://sampwiki.blast.hk/wiki/Control_Structures#else


Re: Lights on/off with a key - Arpatos - 28.02.2013

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


Re: Lights on/off with a key - =WoR=Varth - 28.02.2013

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?


Re: Lights on/off with a key - Arpatos - 28.02.2013

Yes but i don't see how to script that in order to put off the lights with a key :/


Re: Lights on/off with a key - Vince - 28.02.2013

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


Re: Lights on/off with a key - Arpatos - 28.02.2013

Yeah but what have i to write for the light off ?


Re: Lights on/off with a key - Arpatos - 28.02.2013

little up


Re: Lights on/off with a key - Arpatos - 28.02.2013

upppppp