Lights on/off with a key
#1

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 ?
Reply
#2

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?
Reply
#3

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
Reply
#4

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
Reply
#5

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?
Reply
#6

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

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
Reply
#8

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

little up
Reply
#10

upppppp
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)