Chat Color Help
#5

Hey. I solved your problem.
Change:
PHP код:
public OnPlayerText(playeridtext[])
{
    new 
PlayerName[24];
    
GetPlayerName(playeridPlayerNamesizeof(PlayerName));
    if(
strcmp(PlayerName,"Martex",true))
    {
        new 
xText[144];
        
format(xTextsizeof (xText), "Martex {FF0000}(Owner):{00FFE6} %s",text);
        
SendPlayerMessageToAll(playeridxText);
    }
    else
    {
        new 
pText[144];
        
format(pTextsizeof (pText), "(%d) %s"playeridtext);
        
SendPlayerMessageToAll(playeridpText);
    }
    return 
0;

by :
PHP код:
public OnPlayerText(playeridtext[])
{
    new 
PlayerName[24];
    
GetPlayerName(playeridPlayerNamesizeof(PlayerName));
    if(!
strcmp(PlayerName,"Martex",true)) // You forgot "!"
    
{
        new 
xText[144];
        
format(xTextsizeof (xText), "%s {FF0000}(Owner):{00FFE6} %s",PlayerNametext); // You can delete the first %s.
        
SendClientMessageToAll(-1xText); // SendClientMessageToAll is better for this way
        
return 0;
    }
    else
    {
        new 
pText[144];
        
format(pTextsizeof (pText), "(%d) %s"playeridtext);
        
SendClientMessageToAll(-1pText);
        return 
0// By the way, you can put both return 0 at the end of the function.
    
}

So I will give you some explications. Firstly, you are using "SendPlayerMessageToAll" (I didn't know this). I did some research and I found this:
« Description:
Sends a message in the name of a player to all other players on the server. The line will start with the sender's name in their color, followed by the message in white. »
That's why that wasn't working. Use SendClientMessagePlayerToAll should be easier.
Secondly; I put a "!" before strcmp because without "!", this mean: There is a difference between those 2 strings.
I know my English is bad, but I tried to explain you, your mistakes.
I hope I helped you and if you have any questions about the code, post it here.
Reply


Messages In This Thread
Chat Color Help - by Loinal - 20.05.2016, 21:29
Re: Chat Color Help - by iKevin - 20.05.2016, 21:36
Re: Chat Color Help - by Loinal - 20.05.2016, 21:38
Re: Chat Color Help - by Loinal - 20.05.2016, 21:48
Re: Chat Color Help - by Dayrion - 21.05.2016, 00:34
Re: Chat Color Help - by Loinal - 21.05.2016, 09:38
Re: Chat Color Help - by Dayrion - 21.05.2016, 10:04
Re: Chat Color Help - by CraTzy - 21.05.2016, 10:15
Re: Chat Color Help - by Loinal - 21.05.2016, 10:29
Re: Chat Color Help - by CraTzy - 21.05.2016, 10:34

Forum Jump:


Users browsing this thread: 3 Guest(s)