SA-MP Forums Archive
[HELP]Keys - 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: [HELP]Keys (/showthread.php?tid=331039)



[HELP]Keys - CJoao - 03.04.2012

I press on the key and light turn on, but when a press again don't turn off.
Help me please!

pawn Код:
new bool: VehicleLightsOn[MAX_VEHICLES];
if (PRESSED(KEY_ACTION))
    {
            if(IsPlayerInAnyVehicle(playerid))
        {
        if (IsPlayerInAnyVehicle(playerid) && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
        {
            if (VehicleLightsOn[GetPlayerVehicleID(playerid)] == false)
            {
                new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
                GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vid, engine, 1, alarm, doors, bonnet, boot, objective);
                VehicleLightsOn[vid] = true;
            }
            else
            {
                new engine, lights, alarm, doors, bonnet, boot, objective, vid = GetPlayerVehicleID(playerid);
                GetVehicleParamsEx(vid, engine, lights, alarm, doors, bonnet, boot, objective);
                SetVehicleParamsEx(vid, engine, 0, alarm, doors, bonnet, boot, objective);
                VehicleLightsOn[vid] = false;
            }
        }
        }
}



Re: [HELP]Keys - CyNiC - 03.04.2012

You need to declare the variable 'VehicleLightsOn' as global(out of the callback).


Re: [HELP]Keys - Reklez - 03.04.2012

replace

pawn Код:
else
with

pawn Код:
else if (VehicleLightsOn[GetPlayerVehicleID(playerid)] == true)



Re: [HELP]Keys - CJoao - 03.04.2012

Quote:
Originally Posted by CyNiC
Посмотреть сообщение
You need to declare the variable 'VehicleLightsOn' as global(out of the callback).
Yeah work's thx


Re: [HELP]Keys - CyNiC - 03.04.2012

There is no problem in this part of code, maybe something is causing conflict or changing the EngineStatus value.


Re: [HELP]Keys - CJoao - 03.04.2012

Quote:
Originally Posted by CyNiC
Посмотреть сообщение
There is no problem in this part of code, maybe something is causing conflict or changing the EngineStatus value.
Yeah it's now works, thx for help!
pawn Код:
TogglePlayerControllable(playerid,0);