[HELP]Keys
#1

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;
            }
        }
        }
}
Reply
#2

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

replace

pawn Код:
else
with

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

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

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

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);
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)