forward OnLightFlash(vehicleid);
public OnLightFlash(vehicleid)
{
new panels, doors, lights, tires;
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
new states[ 3 ] =
{
2, 4, 5
};
new currstate = states[ random( 3 ) ];
UpdateVehicleDamageStatus( vehicleid, panels, doors, currstate, tires );
return 1;
}
Nice work, optimized the code a lil bit for you.
NOTE: it's untested, but it should work, can't test it right now but should work fine. pawn Code:
|
that won't be consistant though (For example, you might get the same random 4 times and that light would stay lit)
I did it that way to change states every 115ms, in the following pattern: left, off, left, right, off, right |
forward OnLightFlash(vehicleid);
public OnLightFlash(vehicleid)
{
new panels, doors, lights, tires;
GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires);
new states[ 3 ] =
{
2, 4, 5
};
new idx = random( 3 );
idx = ( ( states[ idx ] == Flash[ vehicleid ] ) ? ( idx == 2 ? 0 : ( idx + 1 ) ) : idx );
UpdateVehicleDamageStatus( vehicleid, panels, doors, states[ idx ], tires );
Flash[ vehicleid ] = states[ idx ];
return 1;
}
public OnVehicleSirenStateChange(playerid, vehicleid, newstate) { if(newstate) { FlashTime[vehicleid] = SetTimerEx("OnLightFlash", flashtime, true, "d", vehicleid); } if(!newstate) { new panels, doors, lights, tires; KillTimer(FlashTime[vehicleid]); GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires); UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires); } return 1; }
for(new i=0; i<GetVehiclePoolSize(); i++) { KillTimer(FlashTime[i]); GetVehicleDamageStatus(i, panels, doors, lights, tires); UpdateVehicleDamageStatus(i, panels, doors, 0, tires); } return 1; } #endif
how do i fix this /
C:\Users\\Desktop\lights.pwn(45) : warning 235: public function lacks forward declaration (symbol "OnVehicleSirenStateChange") C:\Users\\Desktop\lights.pwn(6 : error 017: undefined symbol "GetVehiclePoolSize" Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase 1 Error. line 45: Code:
public OnVehicleSirenStateChange(playerid, vehicleid, newstate) { if(newstate) { FlashTime[vehicleid] = SetTimerEx("OnLightFlash", flashtime, true, "d", vehicleid); } if(!newstate) { new panels, doors, lights, tires; KillTimer(FlashTime[vehicleid]); GetVehicleDamageStatus(vehicleid, panels, doors, lights, tires); UpdateVehicleDamageStatus(vehicleid, panels, doors, 0, tires); } return 1; } Code:
for(new i=0; i<GetVehiclePoolSize(); i++) { KillTimer(FlashTime[i]); GetVehicleDamageStatus(i, panels, doors, lights, tires); UpdateVehicleDamageStatus(i, panels, doors, 0, tires); } return 1; } #endif |