31.12.2014, 20:32
Here's an array that I've generated with 100 colors gradually going from pure red to green.
You could decide the max distance a player can read the message. (for example 50 units). Then calculate the percentage of the players distance against the max distance and let the script pick the right color.
You might wanna reverse the order of the array to have the nearest players receive green messages and the furthest away players get red-messages.
pawn Код:
new RedToGreen[100] =
{
0xFF0000FF,0xFC0300FF,0xFA0500FF,0xF70800FF,0xF50A00FF,0xF20D00FF,0xF00F00FF,0xED1200FF,0xEB1400FF,0xE81700FF,
0xE51900FF,0xE31C00FF,0xE01F00FF,0xDE2100FF,0xDB2400FF,0xD92600FF,0xD62900FF,0xD42B00FF,0xD12E00FF,0xCF3000FF,
0xCC3300FF,0xC93600FF,0xC73800FF,0xC43B00FF,0xC23D00FF,0xBF4000FF,0xBD4200FF,0xBA4500FF,0xB84700FF,0xB54A00FF,
0xB24D00FF,0xB04F00FF,0xAD5200FF,0xAB5400FF,0xA85700FF,0xA65900FF,0xA35C00FF,0xA15E00FF,0x9E6100FF,0x9C6300FF,
0x996600FF,0x966900FF,0x946B00FF,0x916E00FF,0x8F7000FF,0x8C7300FF,0x8A7500FF,0x877800FF,0x857A00FF,0x827D00FF,
0x7F8000FF,0x7D8200FF,0x7A8500FF,0x788700FF,0x758A00FF,0x738C00FF,0x708F00FF,0x6E9100FF,0x6B9400FF,0x699600FF,
0x669900FF,0x639C00FF,0x619E00FF,0x5EA100FF,0x5CA300FF,0x59A600FF,0x57A800FF,0x54AB00FF,0x52AD00FF,0x4FB000FF,
0x4CB300FF,0x4AB500FF,0x47B800FF,0x45BA00FF,0x42BD00FF,0x40BF00FF,0x3DC200FF,0x3BC400FF,0x38C700FF,0x36C900FF,
0x33CC00FF,0x30CF00FF,0x2ED100FF,0x2BD400FF,0x29D600FF,0x26D900FF,0x24DB00FF,0x21DE00FF,0x1FE000FF,0x1CE300FF,
0x19E600FF,0x17E800FF,0x14EB00FF,0x12ED00FF,0x0FF000FF,0x0DF200FF,0x0AF500FF,0x08F700FF,0x05FA00FF,0x03FC00FF
};
You might wanna reverse the order of the array to have the nearest players receive green messages and the furthest away players get red-messages.
pawn Код:
forward Float:GetPercentage(Float:current, Float:max);
Float:GetPercentage(Float:current, Float:max)
{
new Float:percentage;
percentage = floatdiv(current, max)*100;
return percentage;
}
pawn Код:
//Your sendnearbymessage-stock:
foreach(Player, i)
{
if(IsPlayerLoggedIn(i))
{
if(GetPlayerInterior(playerid) == GetPlayerInterior(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
{
GetPlayerPos(i, ix, iy, iz);
new Float:Distance = GetPlayerDistanceFromPoint(playerid, ix, iy, iz);
new Float:Percentage = GetPercentage(Distance, 50.0);
SendClientMessage(i, RedToGreen[floatround(Percentage)], string);
}
}
}