pawn Код:
new LightOn;
new LightOff;
stock IsVehicleUnoccupied(vehicleid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(!IsPlayerInVehicle(i, vehicleid)) return 1;
}
}
return 0;
}
public OnPlayerEnterVehicle(playerid, vehicleid)
{
KillTimer(LightOn);
KillTimer(LightOff);
return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
for(new v = 0; v < MAX_VEHICLES; v++)
{
if(IsVehicleUnoccupied(v))
{
SetTimer("LightsOn", 1000, false);
}
}
return 1;
}
forward LightsOn();
public LightsOn()
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, engine, 1, alarm, doors, bonnet, boot, 0);
KillTimer(LightOn);
SetTimer("LightsOff", 1000, true);
return 1;
}
forward LightsOff();
public LightsOff()
{
new vehicleid = GetPlayerVehicleID(playerid);
new engine, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, engine, 0, alarm, doors, bonnet, boot, 0);
KillTimer(LightOff);
SetTimer("LightsOn", 1000, true);
return 1;
}