11.07.2011, 13:03
Is there any efficient way of ProxDetector using IsPlayerInRangeOfPoint, and which gives different colors according to the distance, as the current ProxDetector is un-efficient.
SendChatMessage(Float:radi, Float:x,Float:y,Float:z, color, text[])
{
new red,green,blue,
bool:received[MAX_PLAYERS];
red = (color >> 24) & 0xFF;
green = (color >> 16) & 0xFF;
blue = (color >> 8) & 0xFF;
for(new i = 0; i < 5; i++)
{
foreach(Player, j)
{
if(IsPlayerInRangeOfPoint(j, Float:radi / 8 * (i * 2), Float:x, Float:y, Float:z) && received[j] == false)
{
SendClientMessage(j, ((red * 0x1000000) + (green * 0x10000) + (blue * 0x100) + 0xFF), text);
received[j] = true;
}
}
if(red >= 25) red = red - 25;
else red = 0;
if(green >= 25) green = green - 25;
else green = 0;
if(blue >= 25) blue = blue - 25;
else blue = 0;
}
}
//======================================[ sDetector ]======================================
public sDetector(Float:radi, playerid, string[], color1, color2, color3)
{
if(IsPlayerConnected(playerid))
{
new Float:Pos[3];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
for(new i = 0; i < MAX_PLAYERS; i ++)
{
if(IsPlayerInRangeOfPoint(i, radi, Pos[0], Pos[1], Pos[2]))
{
SendClientMessage(i, color1, string);
}
if(IsPlayerInRangeOfPoint(i, radi/2, Pos[0], Pos[1], Pos[2]) && !IsPlayerInRangeOfPoint(i, radi, Pos[0], Pos[1], Pos[2]))
{
SendClientMessage(i, color2, string);
}
if(IsPlayerInRangeOfPoint(i, radi/3, Pos[0], Pos[1], Pos[2]) && !IsPlayerInRangeOfPoint(i, radi/2, Pos[0], Pos[1], Pos[2]))
{
SendClientMessage(i, color3, string);
}
}
}
return 1;
}
//======================================[ sDetector ]======================================
PHP код:
|