Local/GLobal Chat [Fast help need]
#1

Hey guys is there a way to make a Global chat when player use symbol @ before the text
and local chat without symbols
like
[GLOBAL]@ Someone Says: Hello (The message can see all players)

[LOCAL]Someone Says: Hello World (the message would be typed without a symbol before all the text and only players in range of 8 will see it )
and if possible bubble chat for Local chat .


i might to use it on this codes..
if possible thanks
pawn Код:
public OnPlayerText(playerid, text[])
{
    return 1;
}
Reply
#2

Im not sure this maybe work :P

Quote:

public OnPlayerText(playerid,text[])
{
if(text[0] == '@') {
new string[128]; GetPlayerName(playerid,string,sizeof(string));
format(string,sizeof(string),"Main Chat: %s: %s",string,text[1]); SendClientMessageToAll(-1,string);}else{
new Float: x ,Float:y,Float:z;
GetPlayerPos(playerid,x,y,z);
for(new i=0;i<MAX_PLAYERS;i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInRangeOfPoint(i,10.0,x,y,z))
{
new string[128]; GetPlayerName(playerid,string,sizeof(string));
format(string,sizeof(string),"Local Chat: %s: %s",string,text[1]); SendClientMessage(i,-1,string);
}
}
}
}
}

Reply
#3

Here is my code.

PHP код:
CMD:toggc(playeridparams[])
{
    if(
GlobalChat[playerid] == 0)
    {
        
SendClientMessage(playeridCOLOR_WHITE"You have enabled global chat, use /g to chat.");
        
GlobalChat[playerid] = 1;
    }
    else if(
GlobalChat[playerid] == 1)
    {
        
SendClientMessage(playeridCOLOR_WHITE"You have disabled global chat.");
        
GlobalChat[playerid] = 0;
    }
    return 
1;
}
CMD:g(playeridparams[])
{
    if(
gPlayerLogged[playerid] == 0)
    {
        
SendClientMessage(playeridCOLOR_GREY"You're not logged in.");
        return 
1;
    }
    if(
PlayerInfo[playerid][pGCMuted] > 0)
    {
        
SendClientMessage(playeridCOLOR_GREY"You're muted from this channel.");
        return 
1;
    }
    new 
string[128];
    if(
GlobalChatTimer[playerid] > 0)
    {
        
format(stringsizeof(string), "You must wait %d seconds before speaking again in this channel."GlobalChatTimer[playerid]);
        
SendClientMessage(playeridCOLOR_GREYstring);
        return 
1;
    }
    if(
GlobalChat[playerid] == 0)
    {
        
SendClientMessage(playeridCOLOR_WHITE"You're not in the global chat, type /toggc.");
        return 
1;
    }
    if(
isnull(params))
        return 
SendClientMessage(playeridCOLOR_WHITE"USAGE: (/g) [text]");
    if(
strlen(params) > 80)
        return 
SendClientMessage(playeridCOLOR_GREY"Your message is too long - the limit is 80 characters.");
    if(
AntiAdv(playeridparams)) return 1;
    if(
PlayerInfo[playerid][pAdmin] < && PlayerInfo[playerid][pDonator] == 1)
    {
        
format(stringsizeof(string), "(( Pearl VIP %s: %s ))"GetPlayerNameEx(playerid), params);
        
GlobalChatTimer[playerid] = 5;
    }
    else if(
PlayerInfo[playerid][pAdmin] < && PlayerInfo[playerid][pDonator] == 2)
    {
        
format(stringsizeof(string), "(( Emerald VIP %s: %s ))"GetPlayerNameEx(playerid), params);
        
GlobalChatTimer[playerid] = 5;
    }
    else if(
PlayerInfo[playerid][pAdmin] < && PlayerInfo[playerid][pDonator] == 3)
    {
        
format(stringsizeof(string), "(( Diamond VIP %s: %s ))"GetPlayerNameEx(playerid), params);
        
GlobalChatTimer[playerid] = 5;
    }
    else if(
PlayerInfo[playerid][pHelper] == 1)
    {
        
format(stringsizeof(string), "(( Junior Helper %s: %s ))"GetPlayerNameEx(playerid), params);
        
GlobalChatTimer[playerid] = 2;
    }
    else if(
PlayerInfo[playerid][pHelper] == 2)
    {
        
format(stringsizeof(string), "(( General Helper %s: %s ))"GetPlayerNameEx(playerid), params);
        
GlobalChatTimer[playerid] = 2;
    }
    else if(
PlayerInfo[playerid][pHelper] == 3)
    {
        
format(stringsizeof(string), "(( Senior Helper %s: %s ))"GetPlayerNameEx(playerid), params);
        
GlobalChatTimer[playerid] = 2;
    }
    else if(
PlayerInfo[playerid][pHelper] == 4)
    {
        
format(stringsizeof(string), "(( Head Helper %s: %s ))"GetPlayerNameEx(playerid), params);
        
GlobalChatTimer[playerid] = 2;
    }
    else if(
PlayerInfo[playerid][pAdmin] < && PlayerInfo[playerid][pDonator] == 1)
    {
        
format(stringsizeof(string), "(( Level %d Player %s: %s ))"PlayerInfo[playerid][pLevel], GetPlayerNameEx(playerid), params);
        
GlobalChatTimer[playerid] = 5;
    }
    else if(
PlayerInfo[playerid][pAdmin] < && PlayerInfo[playerid][pDonator] == 0)
    {
        
format(stringsizeof(string), "(( Level %d Player %s: %s ))"PlayerInfo[playerid][pLevel], GetPlayerNameEx(playerid), params);
        
GlobalChatTimer[playerid] = 5;
    }
    else if(
PlayerInfo[playerid][pAdmin] == 1)
    {
        
format(stringsizeof(string), "(( Trial Moderator %s: %s ))"GetPlayerNameEx(playerid), params);
    }
    else if(
PlayerInfo[playerid][pAdmin] == 2)
    {
        if(
AdminDuty[playerid] == 1)
             
format(stringsizeof(string), "(( Junior Admin %s: %s ))"GetPlayerNameEx(playerid), params);
        else
            
format(stringsizeof(string), "(( Level %d Player %s: %s ))"PlayerInfo[playerid][pLevel], GetPlayerNameEx(playerid), params);
    }
    else if(
PlayerInfo[playerid][pAdmin] == 3)
    {
        if(
AdminDuty[playerid] == 1)
             
format(stringsizeof(string), "(( General Admin %s: %s ))"GetPlayerNameEx(playerid), params);
        else
            
format(stringsizeof(string), "(( Level %d Player %s: %s ))"PlayerInfo[playerid][pLevel], GetPlayerNameEx(playerid), params);
    }
    else if(
PlayerInfo[playerid][pAdmin] == 4)
    {
        if(
AdminDuty[playerid] == 1)
             
format(stringsizeof(string), "(( Senior Admin %s: %s ))"GetPlayerNameEx(playerid), params);
        else
            
format(stringsizeof(string), "(( Level %d Player %s: %s ))"PlayerInfo[playerid][pLevel], GetPlayerNameEx(playerid), params);
    }
    else if(
PlayerInfo[playerid][pAdmin] == 5)
    {
        if(
AdminDuty[playerid] == 1)
             
format(stringsizeof(string), "(( Head Admin %s: %s ))"GetPlayerNameEx(playerid), params);
        else
            
format(stringsizeof(string), "(( Level %d Player %s: %s ))"PlayerInfo[playerid][pLevel], GetPlayerNameEx(playerid), params);
    }
    else if(
PlayerInfo[playerid][pAdmin] == 6)
    {
        if(
AdminDuty[playerid] == 1)
             
format(stringsizeof(string), "(( Server Management %s: %s ))"GetPlayerNameEx(playerid), params);
        else
            
format(stringsizeof(string), "(( Level %d Player %s: %s ))"PlayerInfo[playerid][pLevel], GetPlayerNameEx(playerid), params);
    }
    foreach(
Playeri)
    {
        if(
GlobalChat[i] == 1)
        {
            
SendClientMessage(iCOLOR_NEWSstring);
        }
    }
    return 
1;

REP +1 me if i helped you.
Reply
#4

He want when type @... no CMD -.-
Reply
#5

My code :

PHP код:
public OnPlayerText(playeridtext[])
{
   if (
text[0] == '@')
    {
             new 
pname[24];
    new 
string[128];
    
GetPlayerName(playerid,pname,sizeof(pname));
         
format(string,sizeof(string)," %s(%d): {FFFFFF}%s.",pname,playerid,text[1]);
         
SendClientMessageToAll(COLOR_WHITE,string);
         return 
0;
    }
    return 
1;

So easy.
Reply
#6

lel i do the same but mine, if does not type @ it will send like whisper(only the players who is near him)
Reply
#7

Thanks Guys im gonna test it now
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)