SA-MP Forums Archive
Carlights command - 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: Carlights command (/showthread.php?tid=317245)



Carlights command - taifu - 10.02.2012

I want,when I am in a car,with a buttons press, to turn on/off the carlights. could you help me?


Re: Carlights command - Nonameman - 10.02.2012

Try this:

pawn Код:
#define PRESSED(%0) \
    (((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if (PRESSED(KEY_SUBMISSION/* Button 2 */) && IsPlayerInAnyVehicle(playerid)) {
        new vehicleid = GetPlayerVehicleID(playerid), turnTo;
        new engine, lights, alarm, doors, bonnet, boot, objective;
        GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
        turnTo = (lights == 0) ? (1) : (0);
        SetVehicleParamsEx(vehicleid, engine, turnTo, alarm, doors, bonnet, boot, objective);
    }
    return 1;
}