Vehicle lights flickering -
Lidor124 - 12.03.2014
I know how to do it but im just getting troubled with this.
im using GetVehicleParamsEx(vehicleid, engine, lights, alarm, doors, bonnet, boot, objective); and set lights to 1.
Can someone make a quick code? lights flick every 500 milliseconds... even when player leave the vehicle (PLAYER_STATE_FOOT) vehicle lights will keep flickering?
+REP
Re: Vehicle lights flickering -
AnonScripter - 12.03.2014
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;
}
Re: Vehicle lights flickering -
Lidor124 - 12.03.2014
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);
Re: Vehicle lights flickering -
AnonScripter - 12.03.2014
Quote:
Originally Posted by Lidor124
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);
|
you're welcome, maybe you'll find some bugs in it but you got the idea so you can fix everything.
i haven't used objective till now, so i don't know what is it for and honestly i don't care of it :p