SA-MP Forums Archive
Turn the Lights on - 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: Turn the Lights on (/showthread.php?tid=352818)



Turn the Lights on - HitmanEyE - 21.06.2012

Hi Guys

How i can turn the Lights on when i press the "H" Button. I have seen many Tutorials but i didnt understood the Tutorials. I'm a Beginner in Scripting. Can anyone tell me how i can script that?


Re: Turn the Lights on - Zerberus - 21.06.2012

Haven't tested it, but normally it works:

pawn Код:
new lighton[MAX_PLAYERS];

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (GetPlayerVehicleSeat(playerid)==0)
    {
        if (newkeys & 2)
        {
            if(lighton[playerid] == 0)
            {
                new engine, alarm, doors, boot, objective;
                SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine, VEHICLE_PARAMS_ON, alarm, doors, bonnet, boot, objective)
                lighton[playerid] = 1;
                return 1;
            }
            else if(lighton[playerid] == 1)
            {
                new engine, alarm, doors, boot, objective;
                SetVehicleParamsEx(GetPlayerVehicleID(playerid),engine, VEHICLE_PARAMS_OFF, alarm, doors, bonnet, boot, objective)
                lighton[playerid] = 0;
                return 1;
            }
        }
        return 1;
    }

    return 1;
}
But look out! It does only work correctly in the night.