Global Chat Help?
#1

Hi. I'm sure this is an easy as fix. But I'm making a global chat that doesn't have a range point on it. So it's global. I've created this:
PHP код:
        new str[256], playername[MAX_PLAYER_NAME];
        
GetPlayerName(playeridplayernamesizeof(playername));
        
format(strsizeof(str), "%s: {FFFFFF}%s"playernametext);
        
SendClientMessageToAll(DEFAULT_YELLOWstr); 
However once I go ingame it displays:
Код:
[22:06:59] <Bob>: Test

[22:06:59] 

[22:07:06] <Bob>: Test.

[22:07:06]
Any ideas? Also how would you possible make it like

Код:
[22:07:06] <Bob> {FF0000}[0] {FFFFFF}: Test.
As always whom ever successfully helps will get a +1 Rep.

Thanks in advance for your help.
Reply
#2

PHP код:
new str[144], playername[MAX_PLAYER_NAME]; 
        
GetPlayerName(playeridplayernamesizeof(playername)); 
        
format(strsizeof(str), "%s {FF0000}[%d]: {FFFFFF}%s"playername,playeridtext); 
        
SendClientMessageToAll(DEFAULT_YELLOWstr); 
Reply
#3

Change your code to this:
PHP код:
        new str[256], playername[MAX_PLAYER_NAME]; 
        
GetPlayerName(playeridplayernamesizeof(playername)); 
        
format(strsizeof(str), "%s{FF0000}[%d]: {FFFFFF}%s"playernameplayeridtext); 
        
SendClientMessageToAll(DEFAULT_YELLOWstr); 
Always BloodyRP faster than me :P
Reply
#4

That worked with the ID adding. Thank you. But I still keep getting the added enter after I press enter...

Код:
[15:47:01] BoB{FF0000}[0]: {FFFFFF}Test
[15:47:01] 
[15:47:03] BoB{FF0000}[0]: {FFFFFF}Test
[15:47:03]
Any ideas?
Reply
#5

What else have you got in that callback, because it'll be that.
Reply
#6

PHP код:
public OnPlayerText(playeridtext[])
{
    
// Anti Adv
    
if(AntiAdv(playeridtext)) return 0;
    
// The Rest
    
new string[128];
    
/*format(ircMsg, sizeof(ircMsg), "02[%d] 07%s: %s", playerid, RPN(playerid), text);
    IRC_GroupSay(groupID, IRC_CHANNEL, ircMsg); */
    
if(Mobile[playerid] != INVALID_PLAYER_ID)
    {
        
format(stringsizeof(string), "(Cellphone) %s says: %s"RPN(playerid), text);
        if(
IsPlayerInAnyVehicle(playerid)) { //Windows closed.
            
format(stringsizeof(string), "%s"string);
            
SendNearbyMessage(playerid3.0string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        } else {
            
SendNearbyMessage(playerid3.0string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        }

        if(
Mobile[playerid] == 914)
        {
            if(!
text[0])
            {
                
SendClientMessage(playeridTEAM_CYAN_COLOR"Dispatch: Sorry, I don't understand?");
                return 
0;
            }
            
SendClientMessage(playeridTEAM_CYAN_COLOR"Dispatch: We have alerted all units in the area.");
            
SendClientMessage(playeridTEAM_CYAN_COLOR"Thank you for reporting this incident");

            
format(stringsizeof(string), "Dispatch: All Units IA: Caller: %s",RPN(playerid));
            
SendLSFMDMessage(COLOR_TWPINKstring);
            
format(stringsizeof(string), "Dispatch: Incident: %s",text);
            
SendLSFMDMessage(COLOR_TWPINKstring);
            foreach(
Playeri)
            {
                if(
IsPlayerInRangeOfPoint(i100.01498.6595,-2182.5081,14.1682) || IsPlayerInRangeOfPoint(i25.02408.0505,-1330.7889,879.7735))
                {
                       
PlayAudioStreamForPlayer(i"http://vc-rp.eu/firetone.mp3");
                    
format(stringsizeof(string), "* The fire alarm tone rings out as a call comes in *");
                    
SendClientMessage(iACTIONstring);
                }
            }
            
CalledMedics[playerid] = 1;
            
MedicsCallTime[playerid] = 60;
            
ShowPlayerBeaconForMedics(playerid);
            
SendClientMessage(playeridCOLOR_WHITE"   They hung up...");
            
Mobile[playerid] = INVALID_PLAYER_ID;

            
SetPlayerSpecialAction(playeridSPECIAL_ACTION_STOPUSECELLPHONE);
            
RemovePlayerAttachedObject(playerid9);
            return 
0;
        }
        if(
Mobile[playerid] == 913)
        {
            if(!
text[0])
            {
                
SendClientMessage(playeridCOLOR_ALLDEPT"EMERGENCY: Sorry, I don't understand?");
                return 
0;
            }
            if(
strcmp("no"texttrue) == 0)
            {
                
SendClientMessage(playeridCOLOR_DBLUE"Police HQ: We have alerted all units in the area.");
                
SendClientMessage(playeridCOLOR_DBLUE"Thank you for reporting this crime.");
                
format(stringsizeof(string), "HQ: All Units APB: Reporter: %s",RPN(playerid));
                
SendFBIMessage(COLOR_DBLUEstring);
                
SendCopMessage(COLOR_DBLUEstring);
                
format(stringsizeof(string), "HQ: Crime: %s, Suspect: Unknown",PlayerCrime[playerid][pAccusing]);
                
SendFBIMessage(COLOR_DBLUEstring);
                
SendCopMessage(COLOR_DBLUEstring);
                
CalledCops[playerid] = 1;
                
CopsCallTime[playerid] = 60;
                
ShowPlayerBeaconForCops(playerid);
                
SendClientMessage(playeridCOLOR_WHITE"   They hung up...");
                
Mobile[playerid] = INVALID_PLAYER_ID;

                
SetPlayerSpecialAction(playeridSPECIAL_ACTION_STOPUSECELLPHONE);
                
RemovePlayerAttachedObject(playerid9);
                return 
0;
            }
            new 
badguy playerid;
            if(
IsPlayerConnected(badguy))
            {
                if(
badguy != INVALID_PLAYER_ID)
                {
                    if(
PlayerInfo[badguy][pCrimes] > 0)
                    {
                        
SendClientMessage(playeridCOLOR_DBLUE"Police HQ: Units are already assigned to that case...");
                        
SendClientMessage(playeridCOLOR_DBLUE"Thank you for reporting this crime.");
                        
SendClientMessage(playeridCOLOR_WHITE"   They hung up...");
                        
Mobile[playerid] = INVALID_PLAYER_ID;
                        return 
0;
                    }
                    if(
badguy == playerid)
                    {
                        
SendClientMessage(playeridCOLOR_DBLUE"Police HQ: Don't fool around. This is an emergency line.");
                        
SendClientMessage(playeridCOLOR_WHITE"   They hung up...");
                        
Mobile[playerid] = INVALID_PLAYER_ID;
                        return 
0;
                    }
                    
SendClientMessage(playeridCOLOR_DBLUE"Police HQ: We have alerted all units in the area.");
                    
SendClientMessage(playeridCOLOR_DBLUE"Thank you for reporting this crime.");

                    
format(stringsizeof(string), "HQ: All Units APB: Reporter: %s",RPN(playerid));
                    
SendFBIMessage(COLOR_DBLUEstring);
                    
SendCopMessage(COLOR_DBLUEstring);
                    
format(stringsizeof(string), "HQ: Crime: %s, Suspect: %s",PlayerCrime[playerid][pAccusing], RPN(badguy));
                    
SendFBIMessage(COLOR_DBLUEstring);
                    
SendCopMessage(COLOR_DBLUEstring);
                    
CalledCops[playerid] = 1;
                    
CopsCallTime[playerid] = 60;
                    
ShowPlayerBeaconForCops(playerid);
                    
SendClientMessage(playeridCOLOR_WHITE"   They hung up...");
                    
Mobile[playerid] = INVALID_PLAYER_ID;

                    
SetPlayerSpecialAction(playeridSPECIAL_ACTION_STOPUSECELLPHONE);
                    
RemovePlayerAttachedObject(playerid9);
                    return 
0;
                }
                return 
0;
            }
            else
            {
                
format(stringsizeof(string), "Police HQ: I have no information on %s, are you sure that's the correct name?",text);
                
SendClientMessage(playeridCOLOR_DBLUEstring);
                return 
0;
            }
        }
        if(
Mobile[playerid] == 912)
        {
            if(!
text[0])
            {
                
SendClientMessage(playeridCOLOR_ALLDEPT"EMERGENCY: Sorry, I don't understand?");
                return 
0;
            }
            
strmid(PlayerCrime[playerid][pAccusing], text0strlen(text), 255);
            
SendClientMessage(playeridCOLOR_DBLUE"Police HQ: If you know the assailant's name or part of it say it now or just say no.");
            
Mobile[playerid] = 913;
            return 
0;
        }
        if(
Mobile[playerid] == 911)
        {
            if(!
text[0])
            {
                
SendClientMessage(playeridCOLOR_ALLDEPT"EMERGENCY: Sorry, I don't understand - police or paramedic?");
                return 
0;
            }
            else if(
strcmp("police"texttrue) == 0)
            {
                
SendClientMessage(playeridCOLOR_ALLDEPT"EMERGENCY: I am patching you to police headquarters, please hold...");
                
Mobile[playerid] = 912;
                
SendClientMessage(playeridCOLOR_DBLUE"Police HQ: Please give me a short description of the crime.");
                return 
0;
            }
            else if(
strcmp("paramedic"texttrue) == 0)
            {
                
SendClientMessage(playeridCOLOR_ALLDEPT"EMERGENCY: I am patching you to Medical Emergency Services headquarters, please hold...");
                
Mobile[playerid] = 914;
                
SendClientMessage(playeridTEAM_CYAN_COLOR"Dispatch: Please give me a short description of the incident.");
                return 
0;
            }
            else
            {
                
SendClientMessage(playeridCOLOR_ALLDEPT"EMERGENCY: Sorry, I don't understand - police or paramedic?");
                return 
0;
            }
        }
        if(
IsPlayerConnected(Mobile[playerid]))
        {
            if(
Mobile[Mobile[playerid]] == playerid)
            {
                if(
SpeakerPhone[playerid] != 0)
                {
                    
format(stringsizeof(string), "(speakerphone) %s says: %s"RPN(playerid), text);
                    
SendNearbyMessage(Mobile[playerid], 3.0string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                }
                else
                {
                    
SendClientMessage(Mobile[playerid], COLOR_YELLOWstring);
                }
                if(
PlayerInfo[playerid][pBugged] == 1)
                {
                    
format(stringsizeof(string), "(bug) %s (cellphone): %s"RPN(playerid), text);
                    
SendAdminMessage(COLOR_LIGHTGREEN1string);
                }
            }
        }
        else
        {
            
SendClientMessage(playeridCOLOR_GREY"There's nobody there!");
            
CellTime[playerid] = 0;
            
SendClientMessage(playerid,  COLOR_WHITE"   You hung up.");
            
Mobile[playerid] = INVALID_PLAYER_ID;
            
SetPlayerSpecialAction(playeridSPECIAL_ACTION_STOPUSECELLPHONE);
            
RemovePlayerAttachedObject(playerid9);
        }
        return 
0;
    }
    else if(
Live[playerid])
    {
        if(
IsNewsVehicle(GetPlayerVehicleID(playerid)))
        {
            
format(stringsizeof(string), "** [Live News]: %s: %s"RPN(playerid), text);
            
SendClientMessageToAll(COLOR_LIGHTGREENstring);
            
/*format(ircMsg, sizeof(ircMsg), "3[Live News] %s(%d): %s", RPN(playerid), playerid, text);
            IRC_GroupSay(groupID, IRC_CHANNEL, ircMsg); */
        
}
    }
    else
    {
        new 
str[256], playername[MAX_PLAYER_NAME];
        
GetPlayerName(playeridplayernamesizeof(playername));
        
format(strsizeof(str), "%s{FF0000}[%d]: {FFFFFF}%s"playernameplayeridtext);
        
SendClientMessageToAll(DEFAULT_YELLOWstr);
    }
    
SendNearbyMessage(playerid10stringCOLOR_FADE1COLOR_FADE2COLOR_FADE3COLOR_FADE4COLOR_FADE5);
    
Log("logs/chat.log"string);
    return 
0;

Reply
#7

You're sending string at
PHP код:
 SendNearbyMessage(playerid10stringCOLOR_FADE1COLOR_FADE2COLOR_FADE3COLOR_FADE4COLOR_FADE5); 
while string is empty, simple remove it or format the string >>

PHP код:
public OnPlayerText(playeridtext[])
{
    
// Anti Adv
    
if(AntiAdv(playeridtext)) return 0;
    
// The Rest
    
new string[128];
    
/*format(ircMsg, sizeof(ircMsg), "02[%d] 07%s: %s", playerid, RPN(playerid), text);
    IRC_GroupSay(groupID, IRC_CHANNEL, ircMsg); */
    
if(Mobile[playerid] != INVALID_PLAYER_ID)
    {
        
format(stringsizeof(string), "(Cellphone) %s says: %s"RPN(playerid), text);
        if(
IsPlayerInAnyVehicle(playerid)) { //Windows closed.
            
format(stringsizeof(string), "%s"string);
            
SendNearbyMessage(playerid3.0string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        } else {
            
SendNearbyMessage(playerid3.0string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
        }
        if(
Mobile[playerid] == 914)
        {
            if(!
text[0])
            {
                
SendClientMessage(playeridTEAM_CYAN_COLOR"Dispatch: Sorry, I don't understand?");
                return 
0;
            }
            
SendClientMessage(playeridTEAM_CYAN_COLOR"Dispatch: We have alerted all units in the area.");
            
SendClientMessage(playeridTEAM_CYAN_COLOR"Thank you for reporting this incident");
            
format(stringsizeof(string), "Dispatch: All Units IA: Caller: %s",RPN(playerid));
            
SendLSFMDMessage(COLOR_TWPINKstring);
            
format(stringsizeof(string), "Dispatch: Incident: %s",text);
            
SendLSFMDMessage(COLOR_TWPINKstring);
            foreach(
Playeri)
            {
                if(
IsPlayerInRangeOfPoint(i100.01498.6595,-2182.5081,14.1682) || IsPlayerInRangeOfPoint(i25.02408.0505,-1330.7889,879.7735))
                {
                       
PlayAudioStreamForPlayer(i"http://vc-rp.eu/firetone.mp3");
                    
format(stringsizeof(string), "* The fire alarm tone rings out as a call comes in *");
                    
SendClientMessage(iACTIONstring);
                }
            }
            
CalledMedics[playerid] = 1;
            
MedicsCallTime[playerid] = 60;
            
ShowPlayerBeaconForMedics(playerid);
            
SendClientMessage(playeridCOLOR_WHITE"   They hung up...");
            
Mobile[playerid] = INVALID_PLAYER_ID;
            
SetPlayerSpecialAction(playeridSPECIAL_ACTION_STOPUSECELLPHONE);
            
RemovePlayerAttachedObject(playerid9);
            return 
0;
        }
        if(
Mobile[playerid] == 913)
        {
            if(!
text[0])
            {
                
SendClientMessage(playeridCOLOR_ALLDEPT"EMERGENCY: Sorry, I don't understand?");
                return 
0;
            }
            if(
strcmp("no"texttrue) == 0)
            {
                
SendClientMessage(playeridCOLOR_DBLUE"Police HQ: We have alerted all units in the area.");
                
SendClientMessage(playeridCOLOR_DBLUE"Thank you for reporting this crime.");
                
format(stringsizeof(string), "HQ: All Units APB: Reporter: %s",RPN(playerid));
                
SendFBIMessage(COLOR_DBLUEstring);
                
SendCopMessage(COLOR_DBLUEstring);
                
format(stringsizeof(string), "HQ: Crime: %s, Suspect: Unknown",PlayerCrime[playerid][pAccusing]);
                
SendFBIMessage(COLOR_DBLUEstring);
                
SendCopMessage(COLOR_DBLUEstring);
                
CalledCops[playerid] = 1;
                
CopsCallTime[playerid] = 60;
                
ShowPlayerBeaconForCops(playerid);
                
SendClientMessage(playeridCOLOR_WHITE"   They hung up...");
                
Mobile[playerid] = INVALID_PLAYER_ID;
                
SetPlayerSpecialAction(playeridSPECIAL_ACTION_STOPUSECELLPHONE);
                
RemovePlayerAttachedObject(playerid9);
                return 
0;
            }
            new 
badguy playerid;
            if(
IsPlayerConnected(badguy))
            {
                if(
badguy != INVALID_PLAYER_ID)
                {
                    if(
PlayerInfo[badguy][pCrimes] > 0)
                    {
                        
SendClientMessage(playeridCOLOR_DBLUE"Police HQ: Units are already assigned to that case...");
                        
SendClientMessage(playeridCOLOR_DBLUE"Thank you for reporting this crime.");
                        
SendClientMessage(playeridCOLOR_WHITE"   They hung up...");
                        
Mobile[playerid] = INVALID_PLAYER_ID;
                        return 
0;
                    }
                    if(
badguy == playerid)
                    {
                        
SendClientMessage(playeridCOLOR_DBLUE"Police HQ: Don't fool around. This is an emergency line.");
                        
SendClientMessage(playeridCOLOR_WHITE"   They hung up...");
                        
Mobile[playerid] = INVALID_PLAYER_ID;
                        return 
0;
                    }
                    
SendClientMessage(playeridCOLOR_DBLUE"Police HQ: We have alerted all units in the area.");
                    
SendClientMessage(playeridCOLOR_DBLUE"Thank you for reporting this crime.");
                    
format(stringsizeof(string), "HQ: All Units APB: Reporter: %s",RPN(playerid));
                    
SendFBIMessage(COLOR_DBLUEstring);
                    
SendCopMessage(COLOR_DBLUEstring);
                    
format(stringsizeof(string), "HQ: Crime: %s, Suspect: %s",PlayerCrime[playerid][pAccusing], RPN(badguy));
                    
SendFBIMessage(COLOR_DBLUEstring);
                    
SendCopMessage(COLOR_DBLUEstring);
                    
CalledCops[playerid] = 1;
                    
CopsCallTime[playerid] = 60;
                    
ShowPlayerBeaconForCops(playerid);
                    
SendClientMessage(playeridCOLOR_WHITE"   They hung up...");
                    
Mobile[playerid] = INVALID_PLAYER_ID;
                    
SetPlayerSpecialAction(playeridSPECIAL_ACTION_STOPUSECELLPHONE);
                    
RemovePlayerAttachedObject(playerid9);
                    return 
0;
                }
                return 
0;
            }
            else
            {
                
format(stringsizeof(string), "Police HQ: I have no information on %s, are you sure that's the correct name?",text);
                
SendClientMessage(playeridCOLOR_DBLUEstring);
                return 
0;
            }
        }
        if(
Mobile[playerid] == 912)
        {
            if(!
text[0])
            {
                
SendClientMessage(playeridCOLOR_ALLDEPT"EMERGENCY: Sorry, I don't understand?");
                return 
0;
            }
            
strmid(PlayerCrime[playerid][pAccusing], text0strlen(text), 255);
            
SendClientMessage(playeridCOLOR_DBLUE"Police HQ: If you know the assailant's name or part of it say it now or just say no.");
            
Mobile[playerid] = 913;
            return 
0;
        }
        if(
Mobile[playerid] == 911)
        {
            if(!
text[0])
            {
                
SendClientMessage(playeridCOLOR_ALLDEPT"EMERGENCY: Sorry, I don't understand - police or paramedic?");
                return 
0;
            }
            else if(
strcmp("police"texttrue) == 0)
            {
                
SendClientMessage(playeridCOLOR_ALLDEPT"EMERGENCY: I am patching you to police headquarters, please hold...");
                
Mobile[playerid] = 912;
                
SendClientMessage(playeridCOLOR_DBLUE"Police HQ: Please give me a short description of the crime.");
                return 
0;
            }
            else if(
strcmp("paramedic"texttrue) == 0)
            {
                
SendClientMessage(playeridCOLOR_ALLDEPT"EMERGENCY: I am patching you to Medical Emergency Services headquarters, please hold...");
                
Mobile[playerid] = 914;
                
SendClientMessage(playeridTEAM_CYAN_COLOR"Dispatch: Please give me a short description of the incident.");
                return 
0;
            }
            else
            {
                
SendClientMessage(playeridCOLOR_ALLDEPT"EMERGENCY: Sorry, I don't understand - police or paramedic?");
                return 
0;
            }
        }
        if(
IsPlayerConnected(Mobile[playerid]))
        {
            if(
Mobile[Mobile[playerid]] == playerid)
            {
                if(
SpeakerPhone[playerid] != 0)
                {
                    
format(stringsizeof(string), "(speakerphone) %s says: %s"RPN(playerid), text);
                    
SendNearbyMessage(Mobile[playerid], 3.0string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
                }
                else
                {
                    
SendClientMessage(Mobile[playerid], COLOR_YELLOWstring);
                }
                if(
PlayerInfo[playerid][pBugged] == 1)
                {
                    
format(stringsizeof(string), "(bug) %s (cellphone): %s"RPN(playerid), text);
                    
SendAdminMessage(COLOR_LIGHTGREEN1string);
                }
            }
        }
        else
        {
            
SendClientMessage(playeridCOLOR_GREY"There's nobody there!");
            
CellTime[playerid] = 0;
            
SendClientMessage(playerid,  COLOR_WHITE"   You hung up.");
            
Mobile[playerid] = INVALID_PLAYER_ID;
            
SetPlayerSpecialAction(playeridSPECIAL_ACTION_STOPUSECELLPHONE);
            
RemovePlayerAttachedObject(playerid9);
        }
        return 
0;
    }
    else if(
Live[playerid])
    {
        if(
IsNewsVehicle(GetPlayerVehicleID(playerid)))
        {
            
format(stringsizeof(string), "** [Live News]: %s: %s"RPN(playerid), text);
            
SendClientMessageToAll(COLOR_LIGHTGREENstring);
            
/*format(ircMsg, sizeof(ircMsg), "3[Live News] %s(%d): %s", RPN(playerid), playerid, text);
            IRC_GroupSay(groupID, IRC_CHANNEL, ircMsg); */
        
}
    }
    else
    {
        new 
str[256], playername[MAX_PLAYER_NAME];
        
GetPlayerName(playeridplayernamesizeof(playername));
        
format(strsizeof(str), "%s{FF0000}[%d]: {FFFFFF}%s"playernameplayeridtext);
        
SendClientMessageToAll(DEFAULT_YELLOWstr);
    }
    
format(string,sizeof string,text);
    
SendNearbyMessage(playerid10stringCOLOR_FADE1COLOR_FADE2COLOR_FADE3COLOR_FADE4COLOR_FADE5);
    
Log("logs/chat.log"string);
    return 
0;

Reply
#8

PHP код:
public OnPlayerText(playeridtext[])
[...]
    else
    {
        new 
str[256], playername[MAX_PLAYER_NAME];
        
GetPlayerName(playeridplayernamesizeof(playername));
        
format(strsizeof(str), "%s{FF0000}[%d]: {FFFFFF}%s"playernameplayeridtext);
        
SendClientMessageToAll(DEFAULT_YELLOWstr); // -> 1 message
    
}
    
SendNearbyMessage(playerid10stringCOLOR_FADE1COLOR_FADE2COLOR_FADE3COLOR_FADE4COLOR_FADE5); // -> second message
    
Log("logs/chat.log"string);
    return 
0;

Aren't you sending 2 times a message ? I'm maybe wrong.
Reply
#9

return SendClientMessageToAll(DEFAULT_YELLOW, str); so the code in the callback won't follow or simply remove the last SendNearbyMessage after your chat.
Reply
#10

As jlalt said, string is empty. and it's still sending SendNearbyMessage (Which is simply a renamed ProxDetector).

You also don't need 256 strings because the client can only display 144 characters.

Rather than using your "str", "string" was already defined in the beginning of the callback.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)