SA-MP Forums Archive
ProxDetector more efficient? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: ProxDetector more efficient? (/showthread.php?tid=268121)



ProxDetector more efficient? - ||123|| - 11.07.2011

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.


Re: ProxDetector more efficient? - Macluawn - 11.07.2011

a snippet I made two days ago. Not sure about efficiency, but at least there is no need to enter multiple colors.
radi - The radius of which the message will be sent.
x,y,z - coordinates of point from where the message will be sent.
color - the color of the message to be sent. The further it goes, the darker the color gets.
text - the text to be sent.

pawn Код:
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;
    }
}



Re: ProxDetector more efficient? - Shadoww5 - 11.07.2011

PHP код:
//======================================[ sDetector ]======================================

public sDetector(Float:radiplayeridstring[], color1color2color3)
{
    if(
IsPlayerConnected(playerid))
    {
        new 
Float:Pos[3];
        
GetPlayerPos(playeridPos[0], Pos[1], Pos[2]);
        for(new 
0MAX_PLAYERS++)
        {
            if(
IsPlayerInRangeOfPoint(iradiPos[0], Pos[1], Pos[2]))
            {
                
SendClientMessage(icolor1string);
            }
            if(
IsPlayerInRangeOfPoint(iradi/2Pos[0], Pos[1], Pos[2]) && !IsPlayerInRangeOfPoint(iradiPos[0], Pos[1], Pos[2]))
            {
                
SendClientMessage(icolor2string);
            }            
            if(
IsPlayerInRangeOfPoint(iradi/3Pos[0], Pos[1], Pos[2]) && !IsPlayerInRangeOfPoint(iradi/2Pos[0], Pos[1], Pos[2]))
            {
                
SendClientMessage(icolor3string);
            }
        }
    }
    return 
1;
}

//======================================[ sDetector ]====================================== 



Re: ProxDetector more efficient? - Macluawn - 11.07.2011

And what's the difference between sdetector and proxdetector?


Re: ProxDetector more efficient? - ||123|| - 11.07.2011

Quote:
Originally Posted by Shadoww5
Посмотреть сообщение
PHP код:
//======================================[ sDetector ]======================================
public sDetector(Float:radiplayeridstring[], color1color2color3)
{
    if(
IsPlayerConnected(playerid))
    {
        new 
Float:Pos[3];
        
GetPlayerPos(playeridPos[0], Pos[1], Pos[2]);
        for(new 
0MAX_PLAYERS++)
        {
            if(
IsPlayerInRangeOfPoint(iradiPos[0], Pos[1], Pos[2]))
            {
                
SendClientMessage(icolor1string);
            }
            if(
IsPlayerInRangeOfPoint(iradi/2Pos[0], Pos[1], Pos[2]) && !IsPlayerInRangeOfPoint(iradiPos[0], Pos[1], Pos[2]))
            {
                
SendClientMessage(icolor2string);
            }            
            if(
IsPlayerInRangeOfPoint(iradi/3Pos[0], Pos[1], Pos[2]) && !IsPlayerInRangeOfPoint(iradi/2Pos[0], Pos[1], Pos[2]))
            {
                
SendClientMessage(icolor3string);
            }
        }
    }
    return 
1;
}
//======================================[ sDetector ]====================================== 
I want it something like this, but this doesn't work. The chat shows up in the same color no matter how far I went.


Re: ProxDetector more efficient? - Shadoww5 - 11.07.2011

Quote:
Originally Posted by ||123||
Посмотреть сообщение
I want it something like this, but this doesn't work. The chat shows up in the same color no matter how far I went.
color1, color2 and color3 are differents ?


Re: ProxDetector more efficient? - ||123|| - 11.07.2011

I want the code given in the second reply, but it's not working. The colors are the same and don't change no matter how far I go, please help.


Re: ProxDetector more efficient? - ||123|| - 11.07.2011

Post edited.


Re: ProxDetector more efficient? - Shadoww5 - 11.07.2011

I'll try to find out the error.

I'll try ...