SA-MP Forums Archive
[FilterScript] [0.3.7] Flashing Police Lights (ELM) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Filterscripts (https://sampforum.blast.hk/forumdisplay.php?fid=17)
+--- Thread: [FilterScript] [0.3.7] Flashing Police Lights (ELM) (/showthread.php?tid=571926)



[0.3.7] Flashing Police Lights (ELM) - TakeiT - 23.04.2015

This is a fairly simple filterscript that should integrate with any gamemode. It works on any vehicle with sirens (Including ones that have the siren param set in CreateVehicle) and makes the headlights flash like ELM does (except this is server side, so there is no need for a CLEO script).

Feel free to use it in any script, re-release it, whatever (Credits would be appreciated though).

There is no commands, no extra includes required.

NOTE: THIS SCRIPT NEEDS 0.3.7 RC4 TO WORK

[ame]http://www.youtube.com/watch?v=9_VcBGwABT4[/ame]

Pastebin
Github


Re : [0.3.7] Flashing Police Lights (ELM) - XDamienX007 - 23.04.2015

Nice work !


Re: [0.3.7] Flashing Police Lights (ELM) - Smileys - 23.04.2015

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:
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;
}



Re: [0.3.7] Flashing Police Lights (ELM) - TakeiT - 23.04.2015

Quote:
Originally Posted by Smileys
View Post
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:
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;
}
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


Re : [0.3.7] Flashing Police Lights (ELM) - streetpeace - 23.04.2015

keep up the work !


Re: [0.3.7] Flashing Police Lights (ELM) - Smileys - 23.04.2015

Quote:
Originally Posted by TakeiT
View Post
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
aight, can be fixed with 1 line using the ternary operator

pawn Code:
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;
}



Re: [0.3.7] Flashing Police Lights (ELM) - d0nTtoucH - 24.04.2015

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;
}
line 68:
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



Re: [0.3.7] Flashing Police Lights (ELM) - TakeiT - 24.04.2015

Quote:
Originally Posted by d0nTtoucH
View Post
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;
}
line 68:
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
You need to download 0.3.7 RC4 of SA:MP server for this to work.

https://sampforum.blast.hk/showthread.php?tid=559572


Re: [0.3.7] Flashing Police Lights (ELM) - Maximun - 24.04.2015

Nice !


Re: [0.3.7] Flashing Police Lights (ELM) - SpikY_ - 24.04.2015

Good work!