Код:
/* flashcolor.inc
*
* © Copyright 2009, Emilio "Correlli" Lovriж
*
*/
#if defined _flashcolor_included
#endinput
#endif
#define _flashcolor_included
#pragma library flashcolor
// colors.
#if !defined COLOR_BLUE
#define COLOR_BLUE 0x36A5C2AA
#endif
#if !defined COLOR_RED
#define COLOR_RED 0xFF0000AA
#endif
// one second (1000 miliseconds).
#if !defined SECOND
#define SECOND 1000
#endif
// variables.
new FlashColor[MAX_PLAYERS];
new FlashTimer[MAX_PLAYERS];
// forwards.
forward FlashFunc(playerid, color1, color2);
forward SetPlayerFlashColor(playerid, time_delay, repeat, color1, color2);
forward SetPlayerFlashColorForAll(time_delay, repeat, color1, color2);
forward KillFlashColor(playerid);
forward flash_OnPlayerConnect(playerid);
forward flash_OnPlayerDisconnect(playerid, reason);
// FlashFunc timer (don't change anything here).
public FlashFunc(playerid, color1, color2)
{
if(IsPlayerConnected(playerid))
{
if(GetPlayerColor(playerid) == color1)
{
SetPlayerColor(playerid, color2);
}
else if(GetPlayerColor(playerid) == color2)
{
SetPlayerColor(playerid, color1);
}
}
return 0;
}
/* SetPlayerFlashColor:
* Explanation: this function will flash player's color from color1 to color2.
* @playerid - id of the player you want set flash color.
* @time_delay - timer interval, you can set speed of changing (make sure you'll set timer_delay at least
1000 miliseconds (1 second)).
* @repeat - if you're using SetPlayerFlashColor in timer then put 0 (don't repeat),
but if you're using it at OnPlayerSpawn or any other callback like that,
then set repeat to 1 (repeat).
* @color1 - color1 in hexadecimal code.
* @color2 - color2 in hexadecimal code.
*/
public SetPlayerFlashColor(playerid, time_delay, repeat, color1, color2)
{
if((repeat == 0) || (repeat == 1))
{
if(time_delay < SECOND)
{
printf("Error: timer_delay at SetPlayerFlashColor can't be less than 1 second! Auto-setting it to 1 second.");
if(FlashColor[playerid] == 0)
{
SetPlayerColor(playerid, color1);
FlashColor[playerid] = true;
if(repeat == 1) FlashTimer[playerid] = SetTimerEx("FlashFunc", SECOND, 1, "ixx", playerid, color1, color2);
}
else if(FlashColor[playerid] == 1)
{
FlashTimer[playerid] = SetTimerEx("FlashFunc", SECOND, repeat, "ixx", playerid, color1, color2);
}
}
else
{
if(FlashColor[playerid] == 0)
{
SetPlayerColor(playerid, color1);
FlashColor[playerid] = true;
if(repeat == 1) FlashTimer[playerid] = SetTimerEx("FlashFunc", time_delay, 1, "ixx", playerid, color1, color2);
}
else if(FlashColor[playerid] == 1)
{
FlashTimer[playerid] = SetTimerEx("FlashFunc", time_delay, repeat, "ixx", playerid, color1, color2);
}
}
}
else
{
printf("Error: repeat at SetPlayerFlashColor must be setted to 0 or 1. Auto-setting it to 1 (repeating).");
if(time_delay < SECOND)
{
printf("Error: timer_delay at SetPlayerFlashColor can't be less than 1 second! Auto-setting it to 1 second.");
if(FlashColor[playerid] == 0)
{
SetPlayerColor(playerid, color2);
FlashColor[playerid] = true;
if(repeat == 1) FlashTimer[playerid] = SetTimerEx("FlashFunc", SECOND, 1, "ixx", playerid, color1, color2);
}
else if(FlashColor[playerid] == 1)
{
FlashTimer[playerid] = SetTimerEx("FlashFunc", SECOND, 1, "ixx", playerid, color1, color2);
}
}
else
{
if(FlashColor[playerid] == 0)
{
SetPlayerColor(playerid, color2);
FlashColor[playerid] = true;
if(repeat == 1) FlashTimer[playerid] = SetTimerEx("FlashFunc", time_delay, 1, "ixx", playerid, color1, color2);
}
else if(FlashColor[playerid] == 1)
{
FlashTimer[playerid] = SetTimerEx("FlashFunc", time_delay, 1, "ixx", playerid, color1, color2);
}
}
}
return 1;
}
/* SetPlayerFlashColorForAll:
* Explanation: this function will flash all player's color from color1 to color2.
* @time_delay - timer interval, you can set speed of changing (make sure you'll set timer_delay at least
1000 miliseconds (1 second)).
* @repeat - if you're using SetPlayerFlashColor in timer then put 0 (don't repeat),
but if you're using it at OnPlayerSpawn or any other callback like that,
then set repeat to 1 (repeat).
* @color1 - color1 in hexadecimal code.
* @color2 - color2 in hexadecimal code.
*/
public SetPlayerFlashColorForAll(time_delay, repeat, color1, color2)
{
if((repeat == 0) || (repeat == 1))
{
if(time_delay < SECOND)
{
printf("Error: timer_delay at SetPlayerFlashColorForAll can't be less than 1 second! Auto-setting it to 1 second.");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(FlashColor[i] == 0)
{
SetPlayerColor(i, color2);
FlashColor[i] = true;
if(repeat == 1) FlashTimer[i] = SetTimerEx("FlashFunc", SECOND, 1, "ixx", i, color1, color2);
}
else if(FlashColor[i] == 1)
{
FlashTimer[i] = SetTimerEx("FlashFunc", SECOND, repeat, "ixx", i, color1, color2);
}
}
}
else
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(FlashColor[i] == 0)
{
SetPlayerColor(i, color2);
FlashColor[i] = true;
if(repeat == 1) FlashTimer[i] = SetTimerEx("FlashFunc", time_delay, 1, "ixx", i, color1, color2);
}
else if(FlashColor[i] == 1)
{
FlashTimer[i] = SetTimerEx("FlashFunc", time_delay, repeat, "ixx", i, color1, color2);
}
}
}
}
else
{
printf("Error: repeat at SetPlayerFlashColorForAll must be setted to 0 or 1. Auto-setting it to 1 (repeating).");
if(time_delay < SECOND)
{
printf("Error: timer_delay at SetPlayerFlashColorForAll can't be less than 1 second! Auto-setting it to 1 second.");
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(FlashColor[i] == 0)
{
SetPlayerColor(i, color2);
FlashColor[i] = true;
if(repeat == 1) FlashTimer[i] = SetTimerEx("FlashFunc", SECOND, 1, "ixx", i, color1, color2);
}
else if(FlashColor[i] == 1)
{
FlashTimer[i] = SetTimerEx("FlashFunc", SECOND, 1, "ixx", i, color1, color2);
}
}
}
else
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(FlashColor[i] == 0)
{
SetPlayerColor(i, color2);
FlashColor[i] = true;
if(repeat == 1) FlashTimer[i] = SetTimerEx("FlashFunc", time_delay, 1, "ixx", i, color1, color2);
}
else if(FlashColor[i] == 1)
{
FlashTimer[i] = SetTimerEx("FlashFunc", time_delay, 1, "ixx", i, color1, color2);
}
}
}
}
return 1;
}
public KillFlashColor(playerid)
{
FlashColor[playerid] = false;
KillTimer(FlashTimer[playerid]);
return 1;
}
// OnConnect callback.
public flash_OnPlayerConnect(playerid)
{
FlashColor[playerid] = false; // never remove this (okay, it could be only at Connect or Disconnect, not in both callbacks).
return 1;
}
// OnDisconnect callback.
public flash_OnPlayerDisconnect(playerid, reason)
{
KillFlashColor(playerid);
return 1;
}
i use this inc for flashing names but how do i set just 2 peoples names to flash with it
youre now saying that it needs to set 2 colors to one name :S or something
I don't really get your problem, try to explain it. And next time post in the release topic.