Vehicle lights flickering
#3

Quote:
Originally Posted by AnonScripter
Посмотреть сообщение
Try This:
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;
}
Thanks, you gave me the idea.
BTW can you tell me what the hell is objective?
GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective);
SetVehicleParamsEx(vehicleid, engine, 0, alarm, doors, bonnet, boot, 0);
Reply


Messages In This Thread
Vehicle lights flickering - by Lidor124 - 12.03.2014, 19:32
Re: Vehicle lights flickering - by AnonScripter - 12.03.2014, 21:04
Re: Vehicle lights flickering - by Lidor124 - 12.03.2014, 21:18
Re: Vehicle lights flickering - by AnonScripter - 12.03.2014, 21:28

Forum Jump:


Users browsing this thread: 1 Guest(s)