SA-MP Forums Archive
Chat display problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Chat display problem (/showthread.php?tid=400616)



Chat display problem - DaRoderick - 19.12.2012

Hi. I made this chat system:

pawn Код:
new textstring[128 + MAX_PLAYER_NAME + 128];
    format(textstring,sizeof(textstring),"%d%d%s%s(%d) | %d%s",Colour[playerid][pNameCol],Tag1[playerid][pTag1],PlayerName(playerid),Tag2[playerid][pTag2],playerid,Colour[playerid][pChat], text);
    SendClientMessageToAll(COLOR_WHITE, textstring);
But when I use this ingame and have variables placed, the chat shows:

1230*playername*(id): 123*text*

1230 and 123 appear instead of the desired variables and colours.
What did I forget/do wrong?


Re: Chat display problem - Lordzy - 19.12.2012

I hope you're trying to code a chat system which shows player's ID in it.

pawn Код:
public OnPlayerText(playerid,text[])
{
  new string[128]; //Creating string of 128 cellsto output the chat.
  new Lname[MAX_PLAYER_NAME]; //Creating name variable to get player's name.
  GetPlayerName(playerid,Lname,sizeof(Lname)); //Executing the variable on 'GetPlayerName' function and getting player's name.
  format(string,sizeof(string),"%s(ID:%d):{FFFFFF}%s", Lname, playerid, text); //Formatting the string and using Lname to output name, playerid for player's id, and text for the chat text.
  new Lcolor[MAX_PLAYERS]; //Creating a variable to get player's color.
  Lcolor[playerid] = GetPlayerColor(playerid); //Getting Player's color by executing our variable.
  SendClientMessageToAll(Lcolor,string); //Sends the chat message to all with the color of the name first and the chat text will be in white because we've used {FFFFFF} while formatting.
  return 0; //If you don't return 0, the original chat will pop out.
}



Re: Chat display problem - Roel - 19.12.2012

What is the Colour[playerid][pNameCol] including?
It should be a string, then you should replace %d with %s, and you should put a HTML Color inside this variable like {FFFFFF} for while.


Re: Chat display problem - DaRoderick - 19.12.2012

[pNameCol] and [pChat] include hex code variables as {FFFFFF}. Also, tried it with %s and doesn't work.


Re: Chat display problem - Roel - 19.12.2012

If you have a html color inside those variables like {FFFFFF} and you are using %s, then there isn't a reason why it shouldn't work...
So the only reason I can come up with is that those variables are not including the correct text.


Re: Chat display problem - SuperViper - 19.12.2012

Make sure that those variables are strings when you define them in the enum.


Re: Chat display problem - DaRoderick - 19.12.2012

enum just says

enum
pNameCol
pChat

as variable now


Re: Chat display problem - Roel - 19.12.2012

put [26] behind them


Re: Chat display problem - DaRoderick - 19.12.2012

pawn Код:
if(dialogid == 1803)
    {
        new file[64];
        format(file, sizeof(file), "users/%s.ini", RPNU(playerid));
        new string[256];
        if(listitem == 0)
        {
        Colour[playerid][pChat] = "{33CC00}";
//        dini_Set(file, "pChat", PlayerInfo[playerid][pChat]);
        }
        if(listitem == 1)
        {
        Colour[playerid][pChat] = "{FF0000}";
//        dini_Set(file, "pChat", PlayerInfo[playerid][pChat]);
        }
        if(listitem == 2)
        {
        Colour[playerid][pChat] = "{FFCC00}";
//        dini_Set(file, "pChat", PlayerInfo[playerid][pChat]);
        }
        format(string,sizeof(string),"{FFFFFF}Your chat text colour has changed to %sThis.",Colour[playerid][pChat]);
        ShowPlayerDialog(playerid,1804,DIALOG_STYLE_MSGBOX,"Congratulations",string,"Finish","");
This is how they get saved. When I do this ingame, choosing it, the colour works. When I /q and connect again, the colour is white again..

pawn Код:
enum pInfo

pChat[9],
pNameCol[9],
pawn Код:
new Colour[MAX_PLAYERS][pInfo];
How they get saved on disconnect:

pawn Код:
dini_Set(file, "pChat", Colour[playerid][pChat]);
            dini_Set(file, "pNameCol", Colour[playerid][pNameCol]);



Re: Chat display problem - DaRoderick - 21.12.2012

Anyone an idea about this? Why doesn't it show properly?