Problem with proxdetector
#1

It shows text to all players around the world, but it should show it only them, who are in specific area.
pawn Код:
public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
    if(IsPlayerConnected(playerid))
    {
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid,X,Y,Z);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
        if(GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
        {
        if(IsPlayerInRangeOfPoint(playerid,radi,X,Y,Z))
        {
        SendClientMessage(i,col1,string);
        }
        }
        }
    }
    return 1;
}
Reply
#2

It's not meant to look anything like that.

Look here: http://forum.sa-mp.com/showpost.php?...42&postcount=3
Reply
#3

I write it like my way, because the old way didnt work. But either this isnt working.
Reply
#4

try this

pawn Код:
forward ProxDetector(Float:radi, playerid, string[], color);
public ProxDetector(Float:radi, playerid, string[], color)
{
    new Float:posx, Float:posy, Float:posz;
    GetPlayerPos(playerid, posx, posy, posz);
    if(color == COLOR_PURPLE) SetPlayerChatBubble(playerid, string, COLOR_PURPLE, radi, 5000);
    foreach (Player, i)
    {
        if(GetPVarInt(i, "PlayerLogged") == 1) //or gPlayerLogged[i]
        {
            if(GetPlayerVirtualWorld(i) == GetPlayerVirtualWorld(playerid))
            {
                if(IsPlayerInRangeOfPoint(i,radi,posx, posy, posz))
                {
                    if(color == COLOR_FADE)
                    {
                        new Float:radius, feet;
                        radius = GetDistanceBetweenPlayerToPoint(i,posx, posy, posz);
                        feet = floatround(radius);
                        switch(feet)
                        {
                            case 0 .. 10: SendSplitClientMessage(i,0xF0F0F096,string);
                            case 11 .. 15: SendSplitClientMessage(i,0xC9C9C996,string);
                            case 16 .. 20: SendSplitClientMessage(i,0xB5B5B596,string);
                            case 21 .. 25: SendSplitClientMessage(i,0xA3A3A396,string);
                            case 26 .. 100: SendSplitClientMessage(i,0x79797996,string);
                        }
                    }
                    else SendSplitClientMessage(i, color, string);
                }
            }
        }
    }
    return 1;
}

forward Float:GetDistanceBetweenPlayerToPoint(p1,Float:px,Float:py,Float:pz);
public Float:GetDistanceBetweenPlayerToPoint(p1,Float:px,Float:py,Float:pz)
{
    new Float:x1,Float:y1,Float:z1,Float:x2,Float:y2,Float:z2;
    if(!IsPlayerConnected(p1)) return -1.00;
    GetPlayerPos(p1,x1,y1,z1);
    x2 = px;
    y2 = py;
    z2 = pz;
    return floatsqroot(floatpower(floatabs(floatsub(x2,x1)),2)+floatpower(floatabs(floatsub(y2,y1)),2)+floatpower(floatabs(floatsub(z2,z1)),2));
}

stock SendSplitClientMessage(playerid, color, text[], minlen = 110, maxlen = 120)
{
    new str[256];
    if(strlen(text) > maxlen)
    {
        new pos = maxlen;
        while(text[--pos] > ' ') {}
        if(pos < minlen) pos = maxlen;
        format(str, sizeof(str), "%.*s ...", pos, text);
        SendClientMessage(playerid,color,str);
        format(str, sizeof(str), ".... %s", text[pos+1]);
        SendClientMessage(playerid,color,str);
    }
    else format(str, sizeof(str), "%s", text), SendClientMessage(playerid,color,str);
    return true;
}
edited due to a mistake in //or gPlayerLogged part.
Reply
#5

Fixed, i check if player is near player positsion, then it sent message to all.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)