Автор: Johurt(ES.^, Эдгар)
Команда для включения/выключения мерцающих фар: /lights
phpBB [media]
- Код
Code: Select all
/*
jLights by Johurt(ES.^, Edgar).
Date: 2013-07-18
Video: http://www.youtube.com/watch?v=mM2epAmab8c
*/
#include <a_samp>
new pLights[MAX_PLAYERS], bool:LightsOnOff[MAX_PLAYERS];
public OnGameModeInit()
{
SetTimer("Timer", 300, true);
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp("/lights", cmdtext, true, 7))
{
if(!LightsOnOff[playerid])
{
LightsOnOff[playerid] = true;
}
else
{
LightsOnOff[playerid] = false;
new vehicleid = GetPlayerVehicleID(playerid), panels, doors, lights, tires;
if(vehicleid != 0 && GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires);
}
}
return 1;
}
return 0;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
new panels, doors, lights, tires;
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires);
return 1;
}
forward Timer();
public Timer()
{
new p, vehicleid, panels, doors, lights, tires;
for(p = 0; p < MAX_PLAYERS; p++)
{
if(!IsPlayerConnected(p) || IsPlayerNPC(p)) continue;
{
vehicleid = GetPlayerVehicleID(p);
if(vehicleid != 0 && GetPlayerState(p) == PLAYER_STATE_DRIVER)
{
if(LightsOnOff[p])
{
if(pLights[p] != 1 && pLights[p] != 4)
{
pLights[p] = 1;
}
else
{
if(pLights[p] == 1)
{
pLights[p] = 4;
}
else
{
pLights[p] = 1;
}
}
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
UpdateVehicleDamageStatus(vehicleid, panels, doors, pLights[p], tires);
}
}
}
}
return 1;
}