[FilterScript] [0.3.7] Flashing Police Lights (ELM)
#1

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
Reply
#2

Nice work !
Reply
#3

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;
}
Reply
#4

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
Reply
#5

keep up the work !
Reply
#6

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;
}
Reply
#7

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
Reply
#8

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
Reply
#9

Nice !
Reply
#10

Good work!
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)