SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Filterscripts

Reply
 
Thread Tools Display Modes
Old 23/04/2015, 06:17 PM   #1
TakeiT
Gangsta
 
Join Date: May 2014
Location: Toronto, Canada
Posts: 710
Reputation: 108
Default [0.3.7] Flashing Police Lights (ELM)

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
TakeiT is offline   Reply With Quote
Old 23/04/2015, 06:42 PM   #2
XDamienX007
High-roller
 
XDamienX007's Avatar
 
Join Date: Jul 2010
Location: France
Posts: 2,379
Reputation: 36
Default Re : [0.3.7] Flashing Police Lights (ELM)

Nice work !
__________________
Donnez moi votre avis sur ma nouvelle compo !
https://soundcloud.com/ldami/mokay

Coder, c'est pas quelque chose que l'on doit percevoir comme chiant, ça doit être une passion avant tout.

Une erreur? Un warning?
Ne posez plus de question inutiles, et visitez d'abord mon tutoriel!
Tout les warnings et les erreurs y sont! (ou presque)

Warnings/Errors list
XDamienX007 is offline   Reply With Quote
Old 23/04/2015, 07:10 PM   #3
Smileys
Huge Clucker
 
Smileys's Avatar
 
Join Date: Dec 2013
Location: Home.
Posts: 401
Reputation: 31
Default Re: [0.3.7] Flashing Police Lights (ELM)

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.

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;
}
__________________
[Include]Teleports.inc - Create teleports with 1 line!
[Filterscript] Vehicle Mapper - Map vehicles with SA-MP's GUI!
[Filterscript] Hotrod minigun, shootable!
[/CENTER][/SIZE][/B]
Smileys is offline   Reply With Quote
Old 23/04/2015, 07:16 PM   #4
TakeiT
Gangsta
 
Join Date: May 2014
Location: Toronto, Canada
Posts: 710
Reputation: 108
Default Re: [0.3.7] Flashing Police Lights (ELM)

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.

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
TakeiT is offline   Reply With Quote
Old 23/04/2015, 07:46 PM   #5
streetpeace
Gangsta
 
streetpeace's Avatar
 
Join Date: May 2013
Posts: 514
Reputation: 2
Default Re : [0.3.7] Flashing Police Lights (ELM)

keep up the work !
streetpeace is offline   Reply With Quote
Old 23/04/2015, 08:03 PM   #6
Smileys
Huge Clucker
 
Smileys's Avatar
 
Join Date: Dec 2013
Location: Home.
Posts: 401
Reputation: 31
Default Re: [0.3.7] Flashing Police Lights (ELM)

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

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;
}
__________________
[Include]Teleports.inc - Create teleports with 1 line!
[Filterscript] Vehicle Mapper - Map vehicles with SA-MP's GUI!
[Filterscript] Hotrod minigun, shootable!
[/CENTER][/SIZE][/B]
Smileys is offline   Reply With Quote
Old 24/04/2015, 11:49 AM   #7
d0nTtoucH
Huge Clucker
 
d0nTtoucH's Avatar
 
Join Date: Feb 2013
Posts: 370
Reputation: -17
Question Re: [0.3.7] Flashing Police Lights (ELM)

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 (c) 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
__________________
GameModes
Filterscripts
d0nTtoucH is offline   Reply With Quote
Old 24/04/2015, 03:01 PM   #8
TakeiT
Gangsta
 
Join Date: May 2014
Location: Toronto, Canada
Posts: 710
Reputation: 108
Default Re: [0.3.7] Flashing Police Lights (ELM)

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 (c) 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.

http://forum.sa-mp.com/showthread.php?t=559572
TakeiT is offline   Reply With Quote
Old 24/04/2015, 03:34 PM   #9
Maximun
Gangsta
 
Join Date: Jan 2014
Location: Localhost
Posts: 654
Reputation: 29
Default Re: [0.3.7] Flashing Police Lights (ELM)

Nice !
Maximun is offline   Reply With Quote
Old 24/04/2015, 04:50 PM   #10
SpikY_
High-roller
 
SpikY_'s Avatar
 
Join Date: Jul 2014
Location: How would i know?
Posts: 1,269
Reputation: 118
Default Re: [0.3.7] Flashing Police Lights (ELM)

Good work!
__________________
SpikY_ is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[FilterScript] Code 2 - flashing police lights KoczkaHUN Filterscripts 28 26/01/2014 08:27 AM
Colored Flashing lights zT KiNgKoNg Scripting Help 2 20/02/2013 10:12 AM
Flashing car lights martynas Help Archive 11 27/09/2010 11:22 AM
Flashing Lights | SRC-Clan.info presentation TheGuardianAngel Screenshots and Videos 5 03/10/2009 08:31 PM


All times are GMT. The time now is 01:10 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.