SA-MP Forums Archive
Help-me please - 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)
+--- Thread: Help-me please (/showthread.php?tid=547763)



Help-me please - Clarck - 25.11.2014

Hello , what function should I use to chat not be global??


Re : Help-me please - MCZOFT - 25.11.2014

You mean like the one in Rp Servers ? if i send a text message(ingame) will not apear for evry one , just the closer guys(players) ?? is that what chu want ?


Re: Help-me please - Clarck - 25.11.2014

yes that's right


Re: Help-me please - Sparke - 25.11.2014

I recommend using Prox Detector;

Create a Prox Detector stock some where near the top of your script
pawn Код:
stock ProxDetector(Float:radi, playerid, string[],color)
{
    new Float:x,Float:y,Float:z;
    GetPlayerPos(playerid,x,y,z);
    foreach(Player,i)
    {
        if(IsPlayerInRangeOfPoint(i,radi,x,y,z))
        {
            SendClientMessage(i,color,string);
        }
    }
}
Then add on your OnPlayerText callback

pawn Код:
public OnPlayerText(playerid, text[])
{
    new
        message[128];
    format(message, sizeof(message), "%s says: %s", GetName(playerid), text);
    ProxDetector(30.0, playerid, message, -1);
    return 0;
}
For a in depth tutorial just look in tuts


Re : Help-me please - MCZOFT - 25.11.2014

Then Okay
PHP код:
public OnPlayerText(playerid, text[])
{
    new 
string[128], name[MAX_PLAYER_NAME];
    
GetPlayerName(playerid, name, sizeof (name));
    
format(string, sizeof (string), " %s: %s",  name, text);
    
SendNearbyMessage(playerid, 10, string, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE, COLOR_WHITE);
    return 
0;
} 
PHP код:
stock SendNearbyMessage(playerid, Float:radius, string[], col1, col2, col3, col4, col5)
{
    new 
Float:x, Float:y, Float:z;
    
GetPlayerPos(playerid, x, y, z);
    new 
Float:ix, Float:iy, Float:iz;
    new 
Float:cx, Float:cy, Float:cz;
    foreach(
Player, i)
    {
        if(
IsPlayerLoggedIn{i})
        {
            if(
GetPlayerInterior(playerid) == GetPlayerInterior(i) && GetPlayerVirtualWorld(playerid) == GetPlayerVirtualWorld(i))
            {
                
GetPlayerPos(i, ix, iy, iz);
                
cx = (x - ix);
                
cy = (y - iy);
                
cz = (z - iz);
                if(((
cx < radius/16) && (cx > -radius/16)) && ((cy < radius/16) && (cy > -radius/16)) && ((cz < radius/16) && (cz > -radius/16)))
                {
                    
SendClientMessage(i, col1, string);
                }
                else if(((
cx < radius/8) && (cx > -radius/8)) && ((cy < radius/8) && (cy > -radius/8)) && ((cz < radius/8) && (cz > -radius/8)))
                {
                    
SendClientMessage(i, col2, string);
                }
                else if(((
cx < radius/4) && (cx > -radius/4)) && ((cy < radius/4) && (cy > -radius/4)) && ((cz < radius/4) && (cz > -radius/4)))
                {
                    
SendClientMessage(i, col3, string);
                }
                else if(((
cx < radius/2) && (cx > -radius/2)) && ((cy < radius/2) && (cy > -radius/2)) && ((cz < radius/2) && (cz > -radius/2)))
                {
                    
SendClientMessage(i, col4, string);
                }
                else if(((
cx < radius) && (cx > -radius)) && ((cy < radius) && (cy > -radius)) && ((cz < radius) && (cz > -radius)))
                {
                    
SendClientMessage(i, col5, string);
                }
            }
        }
    }
    return 
1;
} 
Try this it works fine for me


Re: Help-me please - Clarck - 25.11.2014

ok thanks to the 2 I'll try


Re: Help-me please - PinkFloydLover - 25.11.2014

There is also a native function released in 0.3x or 0.3z??

LimitGlobalChatRadius(200.0);

https://sampwiki.blast.hk/wiki/LimitGlobalChatRadius

might wanna check that out.


Re: Help-me please - Clarck - 25.11.2014

I could thank you +Rep for all