19.02.2012, 15:12
(
Last edited by Y_Less; 28/02/2012 at 10:33 AM.
)
Introduction
This is just a very quick include I wrote to slowly fade the colour of a gang zone between one colour and another, then back again. You can control how long it takes to fade from one colour to the other, and how long it pauses at each end. Additionally, you can now specify the time to fade back and wait in the initial colour separately, so you can get all sorts of different effects. See below for four examples.
Download
This library is a part of YSI, which can be found here. Keep your eye on that topic and your server log for updates.
YSI Download Topic
Functions
There are six functions - three start and three stop. "@PlayerSet" is a YSI feature that allows you to use the same function for a single player, multiple players, groups, teams, admins etc. The "ForPlayer" and "ForAll" versions of the function are just macros using the "@PlayerSet" version.
Parameters:
Parameters:
Examples
Fast pulse from red to green for one player:
Slow pulse from salmon to violet for everyone, pausing on the two main colours:
Fade out and destory for the admin group:
Note that the examples above use "y_colours" because frankly it's better than defining your own (comes with around 1300 pre-defined).
Examples 2
I've included four pulse modes for you to try, and you can make your own:
I'm uploading a video of this right now to demonstrate the different effects that can be made.
Options
There is only one option in this include:
If this is set before including the script it will change the default FPS. Currently it is set to 20 FPS (1000 / 50 = 20, set the ms you want, not the FPS) which for this IMHO is smooth enough (unless you stare at it, but people won't generally do that, so it's fine).
This is just a very quick include I wrote to slowly fade the colour of a gang zone between one colour and another, then back again. You can control how long it takes to fade from one colour to the other, and how long it pauses at each end. Additionally, you can now specify the time to fade back and wait in the initial colour separately, so you can get all sorts of different effects. See below for four examples.
Download
This library is a part of YSI, which can be found here. Keep your eye on that topic and your server log for updates.
YSI Download Topic
Functions
pawn Code:
native GangZonePulse(@PlayerSet:ps, zone, from, to, time, delay = ZONE_PULSE_STAGE_TIME, time2 = -1, delay2 = -1);
native GangZonePulseForPlayer(playerid, zone, from, to, time, delay = ZONE_PULSE_STAGE_TIME, time2 = -1, delay2 = -1);
native GangZonePulseForAll(zone, from, to, time, delay = ZONE_PULSE_STAGE_TIME, time2 = -1, delay2 = -1);
native GangZoneStopPulse(@PlayerSet:ps, zone);
native GangZoneStopPulseForPlayer(playerid, zone);
native GangZoneStopPulseForAll(zone);
pawn Code:
native GangZonePulse(@PlayerSet:ps, zone, from, to, time, delay = ZONE_PULSE_STAGE_TIME);
- ps - Player or players to show the zone to.
- zone - The zone.
- from - The initial colour.
- to - The colour to fade to.
- time - Time in ms for the fade. Note that by default the system goes in steps of 50ms.
- delay - How long to pause at each end of the fade (i.e. on the "from" and "to" colours). Note that the fade will start straight away, regardless of this setting - it won't pause on the first colour.
- time2 - Time in ms for the fade back to the original colour. "-1" means same as "time".
- delay2 - How long to pause at the first colour. "-1" means same as "time".
pawn Code:
native GangZoneStopPulse(@PlayerSet:ps, zone);
- ps - Player or players to stop the pulse for.
- zone - The zone.
Examples
Fast pulse from red to green for one player:
pawn Code:
GangZonePulseForPlayer(playerid, myzone, X11_RED, X11_GREEN, 500);
pawn Code:
GangZonePulseForAll(myzone, X11_DARK_SALMON, X11_VIOLET_RED, 1000, 5000);
pawn Code:
new
Group:admins = Group_Create("Admins");
GangZonePulse(admins, X11_GOLD, X11_GOLD & ~0xFF, 5000, 10000);
// Destroy the zone 2 seconds after it becomes invisible.
// This will be called during the 10 seconds when it stays hidden before coming back.
// Note that the instant fade start is designed to support this use case.
SetTimerEx("_GangZoneDestroy", 7000, 0, "i", myzone);
// This code assumes a public function "_GangZoneDestroy" that calls "GangZoneDestroy".
Examples 2
I've included four pulse modes for you to try, and you can make your own:
pawn Code:
#define PULSE_LIGHTHOUSE 700, 700, 700, ZONE_PULSE_STAGE_TIME
#define PULSE_STROBE ZONE_PULSE_STAGE_TIME, 100
#define PULSE_SAWTOOTH 1000, ZONE_PULSE_STAGE_TIME, ZONE_PULSE_STAGE_TIME, ZONE_PULSE_STAGE_TIME
#define PULSE_BLINK 200, 200, 200, 20000
new
gZone[4];
public OnPlayerConnect(playerid)
{
gZone[0] = GangZoneCreate(0.0, 0.0, 100.0, 100.0);
gZone[1] = GangZoneCreate(-100.0, -100.0, 0.0, 0.0);
gZone[2] = GangZoneCreate(-100.0, 0.0, 0.0, 100.0);
gZone[3] = GangZoneCreate(0.0, -100.0, 100.0, 0.0);
GangZonePulse(playerid, gZone[0], 0xFFFF00FF, 0x80800033, PULSE_LIGHTHOUSE);
GangZonePulse(playerid, gZone[1], 0xFF00FFFF, 0x80008033, PULSE_STROBE);
GangZonePulse(playerid, gZone[2], 0xFF0000FF, 0x80000033, PULSE_SAWTOOTH);
GangZonePulse(playerid, gZone[3], 0x00FF00FF, 0x00800033, PULSE_BLINK);
}
Options
There is only one option in this include:
pawn Code:
#define ZONE_PULSE_STAGE_TIME (50)