Код:
#include <a_samp>
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
new bool: VehicleLightsOn[MAX_VEHICLES];
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if (newstate == 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, 0, alarm, doors, bonnet, boot, objective);
}
else
{
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);
}
}
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (PRESSED(KEY_ACTION))
{
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;
}
}
}
return 1;
}