Local and global chat
#1

Can anyone help me make a local chat and then a command like /g for global chat?
Reply
#2

can we see what you've attempted?
Reply
#3

Try this code below... Say if there is a bug or if it worked!

pawn Код:
#define COLOR_FADE1 0xE6E6E6E6
#define COLOR_FADE2 0xC8C8C8C8
#define COLOR_FADE3 0xAAAAAAAA
#define COLOR_FADE4 0x8C8C8C8C
#define COLOR_FADE5 0x6E6E6E6E
#define COLOR_OOC 0xE0FFFFAA
new realchat = 1; // at the top
forward OOCOff(color,const string[]); // put at top!
forward ProxDetector(Float:radi, playerid, string[],col1,col2,col3,col4,col5); // put at top!
public OOCOff(color,const string[]) // at the bottom of GM
{
    foreach (Player, i)
    {
        if(!gOoc[i])
        {
            SendClientMessage(i, color, string);
        }
    }
}
// put this where are your other commands
    if(strcmp(cmd, "/global", true) == 0 || strcmp(cmd, "/g", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[128];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_WHITE, "Use: (/g)lobal [global chat]");
                return 1;
            }
            format(string, sizeof(string), "(( %s: %s )) " , sendername, result);
            OOCOff(COLOR_OOC,string);
        }
        return 1;
    }
// this is for local chat
public OnPlayerText(playerid, text[])
{
    new sendername[MAX_PLAYER_NAME];
    if (realchat)
    {
        GetPlayerName(playerid, sendername, sizeof(sendername));
        if(!IsPlayerInAnyVehicle(playerid))
        {
                format(string, sizeof(string), "%s: %s", sendername, text);
                ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        }
        return 0;
    }
    return 1;
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)