Chat range
#1

fixed
Reply
#2

any1? im sure its simple
Reply
#3

The chat range between OOC chat (/b) and normal chat is likely same.
Reply
#4

I made a very quick search and this came up.

Quote:
ProxDetector (proximity detector)

For those who don't know, the famous ProxDetector function was introduced in The Godfather Roleplay. Every time a player would type something into the main chat, it would send the message to the nearby players only, and according to their distance from a player, the message would appear darker or lighter. For instance, if I was 30 feet from a player and they typed in the normal chat, the message would come to me dark. If I were to move closer, the message would become lighter. This function was responsible for making the server chat 'realistic' by sending the message to only the players nearby.
Note: Using the easier-to-understand version, the changing in color in light of the player distance will not be featured.

PHP код:
stock ProxDetector(Float:radiplayeridstring[],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);
        }
    }

Still confused? I'll break it down for you.

This line defines floats that will hold the position of the player. It is important you use the "Float:" tag, because coordinates are decimal numbers.
PHP код:
new Float:x,Float:y,Float:z
Using the native function GetPlayerPos we grab the floats defined above, get the player's position, and store the coordinates into the floats.
PHP код:
GetPlayerPos(playeridxyz); 
Using foreach, we will efficiently loop through all the players and store the playerids into the variable " i " which is in the second parameter.
PHP код:
foreach(Playeri
With the foreach loop in the line above, we will now check for every player that is 'in range' of the desired player by using the native function IsPlayerInRangeOfPoint. The " i " in the first parameter represents every player that is in range of the desired player. The second parameter is the range the player has to be in. So if you put 2 in this parameter, then the player has to be within two GTA units of the desired player in order for the statement to be true. Now remember those three floats x, y, and z we defined earlier? This is where it comes in. The last three parameters are the coordinates the player has to be in range of, in this case they have to be in range of the desired player.
PHP код:
if(IsPlayerInRangeOfPoint(i,radi,x,y,z)) 
Finally, with all the code above, we send the message to every player who is in range using SendClientMessage. The variable " i " represents all the players in range.
PHP код:
SendClientMessage(i,color,string); 
Reply
#5

Ye, I've already saw that, but i still don't understand it. Where do I place it?
Reply
#6

Post the /b code here, please.
Reply
#7

ight here man
Quote:

CMD:b(playerid, params[])
{
new string[128];
if(sscanf(params, "s[128]", params)) return SendClientMessage(playerid, COLOR_WHITE, "Usage: /b [text] (Local OOC Chat)");
if(AntiAdv(playerid, params)) return 1;
format(string, sizeof(string), "(( Local OOC: %s: %s ))", NAMEGET(playerid), params);
NearMessageSender(playerid, 12, string, COLOR_FADE2,COLOR_FADE2,COLOR_FADE2,COLOR_FADE2,CO LOR_FADE2);
return 1;
}

Reply
#8

thisis what you need just change the 30.0 if want more range you can do it also in /b

EDIT: added /b
pawn Код:
public OnPlayerText(playerid, text[])
{
    if (realchat)
    {
        if (IsDead[playerid] == 1)
        {
            SCM(playerid,-1,"You can't do that this time");
        }
        else
        {
            new string[128];
            format(string, sizeof(string), "%s says: %s", GetName(playerid), text);
            ProxDetector(30.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
            format(string, sizeof(string), "says: %s", text);
            SetPlayerChatBubble(playerid,string,COLOR_WHITE,5.0,5000);
            ApplyAnimation(playerid,"PED","IDLE_CHAT",2.0,1,0,0,1,1);
        }
        return 0;
    }
    return 1;
}

CMD:b(playerid,params[])
{

    new string[128];
    if(isnull(params)) return SCM(playerid, -1,"USAGE: /b [local ooc]");
    format(string, sizeof(string), "%s: (( %s ))", GetName(playerid), params);
    ProxDetector(30.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    return 1;
}
added proxdetector function just copy it into your gamemode
pawn Код:
public ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5)
{
    if(IsPlayerConnected(playerid))
    {
        new Float:posx, Float:posy, Float:posz;
        new Float:oldposx, Float:oldposy, Float:oldposz;
        new Float:tempposx, Float:tempposy, Float:tempposz;
        GetPlayerPos(playerid, oldposx, oldposy, oldposz);
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
            if(IsPlayerConnected(i))
            {
                GetPlayerPos(i, posx, posy, posz);
                tempposx = (oldposx -posx);
                tempposy = (oldposy -posy);
                tempposz = (oldposz -posz);
                new playerworld, player2world;
                playerworld = GetPlayerVirtualWorld(playerid);
                player2world = GetPlayerVirtualWorld(i);
                if(playerworld == player2world)
                {
                    if (((tempposx < radi/16) && (tempposx > -radi/16)) && ((tempposy < radi/16) && (tempposy > -radi/16)) && ((tempposz < radi/16) && (tempposz > -radi/16)))
                    {
                        SCM(i, col1, string);
                    }
                    else if (((tempposx < radi/8) && (tempposx > -radi/8)) && ((tempposy < radi/8) && (tempposy > -radi/8)) && ((tempposz < radi/8) && (tempposz > -radi/8)))
                    {
                        SCM(i, col2, string);
                    }
                    else if (((tempposx < radi/4) && (tempposx > -radi/4)) && ((tempposy < radi/4) && (tempposy > -radi/4)) && ((tempposz < radi/4) && (tempposz > -radi/4)))
                    {
                        SCM(i, col3, string);
                    }
                    else if (((tempposx < radi/2) && (tempposx > -radi/2)) && ((tempposy < radi/2) && (tempposy > -radi/2)) && ((tempposz < radi/2) && (tempposz > -radi/2)))
                    {
                        SCM(i, col4, string);
                    }
                    else if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
                    {
                        SCM(i, col5, string);
                    }
                }
                else
                {
                    SCM(i, col1, string);
                }
            }
        }
    }
    return 1;
}
Reply
#9

/b is fine, but this is some errors i get from normal chat


C:\Users\Jamie\Desktop\server\gamemodes\LondonRP.p wn(146) : error 017: undefined symbol "realchat"
C:\Users\Jamie\Desktop\server\gamemodes\LondonRP.p wn(14 : error 017: undefined symbol "IsDead"
C:\Users\Jamie\Desktop\server\gamemodes\LondonRP.p wn(14 : warning 215: expression has no effect
C:\Users\Jamie\Desktop\server\gamemodes\LondonRP.p wn(14 : error 001: expected token: ";", but found "]"
C:\Users\Jamie\Desktop\server\gamemodes\LondonRP.p wn(14 : error 029: invalid expression, assumed zero
C:\Users\Jamie\Desktop\server\gamemodes\LondonRP.p wn(14 : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


5 Errors.

edit: is that the normal chat?
Reply
#10

its just an example haha but here you go
pawn Код:
public OnPlayerText(playerid, text[])
{

    new string[128];
    format(string, sizeof(string), "%s says: %s", GetName(playerid), text);
        ProxDetector(30.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
    format(string, sizeof(string), "says: %s", text);
    SetPlayerChatBubble(playerid,string,COLOR_WHITE,5.0,5000);
    ApplyAnimation(playerid,"PED","IDLE_CHAT",2.0,1,0,0,1,1);
    return 1;  
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)