Color Chat Text[HELP]
#1

Hello! I got this script:
Код:
 public OnPlayerText(playerid, text[])
{
      new string[128];
      new name[24];
      GetPlayerName(playerid,name,sizeof(name));
      format(string,sizeof(string),"%s: %s",name,text);
      SendClientMessageToAll(GetPlayerColor(playerid),string);
      return 0;
}
which adds color to the name AND the text for every player. But when I log in, or anyone else, the default color or w/e is Black. How can I change this? I want it to be random! So when people log in, they will be given random tagcolor.. How is this possible? here some of my #define colors:
Код:
 #define COLOR_BRIGHTRED 0xE60000FF
#define COLOR_VIOLET 0x9955DEEE
#define COLOR_LIGHTRED 0xFF99AADD
#define COLOR_SEAGREEN 0x00EEADDF
#define COLOR_GRAYWHITE 0xEEEEFFC4
#define COLOR_LIGHTNEUTRALBLUE 0xabcdef66
#define COLOR_GREENISHGOLD 0xCCFFDD56
#define COLOR_LIGHTBLUEGREEN 0x0FFDD349
#define COLOR_NEUTRALBLUE 0xABCDEF01
#define COLOR_LIGHTCYAN 0xAAFFCC33
#define COLOR_LEMON 0xDDDD2357
#define COLOR_MEDIUMBLUE 0x63AFF00A
#define COLOR_NEUTRAL 0xABCDEF97
#define COLOR_BLACK 0x00000000
#define COLOR_NEUTRALGREEN 0x81CFAB00
#define COLOR_DARKGREEN 0x12900BBF
#define COLOR_LIGHTGREEN 0x24FF0AB9
#define COLOR_DARKBLUE 0x300FFAAB
#define COLOR_BLUEGREEN 0x46BBAA00
#define COLOR_PINK 0xFF66FFAA
#define COLOR_LIGHTBLUE 0x33CCFFAA
#define COLOR_DARKRED 0x660000AA
#define COLOR_ORANGE 0xFF9900AA
#define COLOR_GRAY 0xAFAFAFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_PURPLE 0x800080AA
#define COLOR_LIGHTGREEN 0x24FF0AB9
#define COLOR_DARKBLUE 0x300FFAAB
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_YELLOW 0xFFFF00AA
#define COLOR_WHITE 0xFFFFFFAA
#define COLOR_BROWN 0x993300AA
#define COLOR_CYAN 0x99FFFFAA
#define COLOR_TAN 0xFFFFCCAA
#define COLOR_PINK 0xFF66FFAA
#define COLOR_KHAKI 0x999900AA
#define COLOR_LIME 0x99FF00AA
#define COLOR_TURQ 0x00A3C0AA
#define COLOR_PLAYER 0xFFFFFFFF
#define COLOR_ADMINRED 0xFB0000FF
#define COLOR_ANNOUNCE 0x00CACAFB
#define COLOR_SYSTEM 0xEFEFF7AA
#define COLOR_NICESKY 0x99FFFFAA
#define COLOR_NICEBLUE 0xa0d3ffAA
#define COLOR_ADMINRED 0xFB0000FF
#define COLOR_AFK 0x6AF7E1FF
#define COLOR_SYSTEM 0xEFEFF7AA
#define COLOR_PLAYERVIEW 0xC0C0C0FF
#define COLOR_GRAD1 0xB4B5B7FF
Reply
#2

HMM TRY random colours here

pawn Код:
//On top of script
enum PlayerCol
{
    Colour,
}
new PlayerColour[11][PlayerCol] =
{
     /*Red*/
    {0xE60000FF},
     /*Blue*/
    {0x1229FAFF},
     /*Green*/
    {0x21DD00FF},
     /*Yellow*/
    {0xFFFF00FF},
    /*Orange*/
    {0xF97804FF},
    /*Light Blue*/
    {0x00C2ECFF},
    /*//Light Green*/
    {0x38FF06FF},
    /*DarkGreen*/
    {0x008040FF},
    /*LightRed*/
    {0xFF0000FF},
    /*Lighest Red!*/
    {0xA50000FF},
    /*Skin Color!*/
    {0x00FFAAFF}
};


public OnPlayerConnect(playerid)
{
    new randomcolor = random(sizeof(PlayerColour));
    SetPlayerColor(playerid,PlayerColour[randomcolor][Colour]);
       return 1;
}
then

OnPlayerText

pawn Код:
public OnPlayerText(playerid, text[])
{
    new String[321];
    format(String,sizeof(String),"%s[%d]: %s",Playername(playerid),playerid,text);
    SendClientMessageToAll(GetPlayerColor(playerid),String);
    return 0;
}
Reply
#3

Got this:
Код:
 error 017: undefined symbol "Playername"
Reply
#4

Try this:
pawn Код:
public OnPlayerText(playerid, text[])
{
    new String[321], name[24];
    GetPlayerName(playerid, name, sizeof(name));
    format(String,sizeof(String),"%s[%d]: %s",name,text);
    SendClientMessageToAll(GetPlayerColor(playerid),String);
    return 0;
}
Reply
#5



The colors atleast worked lol.. but, it got random ID's and what I wrote didn't show up in chat, just my name..
Reply
#6

I fixed it! I removed " [%d] " , cuz it shows my ID, but in this script, there wasn't anything that could get my id, so it's kinda obvious lol
Reply
#7

PHP код:
public OnPlayerText(playeridtext[])
{
    new 
String[128], name[24];
    
GetPlayerName(playeridname24);
    
format(String,sizeof(String),"%s[%d]: %s",name,playerid,text);
    
SendClientMessageToAll(GetPlayerColor(playerid),String);
    return 
0;

Не помню вариант лучше
Reply
#8

P.S: Name[playerid]: text
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)