SendClientMessageToAll Multiple Colors
#1

so basically this is my script

Quote:

public OnPlayerConnect(playerid)
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"%s has joined the server.",pName);
SendClientMessageToAll(COLOR_GREEN,string);
return 1;
}

How do I execute multiple colors? E.G.
Extraordinariness has joined the server.
Reply
#2

Use HEX's
like
{FFFFFF} - White
{FF0000} red ect
Reply
#3

https://sampforum.blast.hk/showthread.php?tid=250389
Reply
#4

Can I use defined ones?
EDIT: +rep'ped.
Reply
#5

Quote:
Originally Posted by Extraordinariness
Посмотреть сообщение
Can I use defined ones?
Yes.
Reply
#6

Thanks :3 +repped
NOTE: Both of you rep'ped
Reply
#7

NOTE, it has to be like this:

pawn Код:
#define YELLOW "{FFFF00}"
#define RED "{FF0000}"
#define GREY "{CCCCCC}"
and then you use it like this:

pawn Код:
public OnPlayerConnect(playerid)
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,""YELLOW"%s "GREY"has joined the "RED"server.",pName);
SendClientMessageToAll(COLOR_GREEN,string);
return 1;
}
This won't work:

pawn Код:
#define YELLOW 0xFFFF00AA
#define RED 0xFF0000AA
#define GREY 0xCCCCCCAA
pawn Код:
public OnPlayerConnect(playerid)
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,""YELLO"%s "GREY"has joined the "RED"server.",pName);
SendClientMessageToAll(COLOR_GREEN,string);
return 1;
}
Reply
#8

It has been answered but... thanks
I still +rep you. :3
Reply
#9

Quote:
Originally Posted by LocMax
Посмотреть сообщение
NOTE, it has to be like this:
pawn Код:
public OnPlayerConnect(playerid)
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,""YELLOW"%s "GREY"has joined the "RED"server.",pName);
SendClientMessageToAll(COLOR_GREEN,string);
return 1;
}
I find that the ugliest way ever.

Putting it like

pawn Код:
format(string,sizeof string,"{808080} %s {FFFF00} has joined the {FF0000} server.",pName);
SendClientMessageToAll(COLOR_GREEN,string);
Neat and tidy!
Reply
#10

But then, if you decide to change color of message you'll need to change it everywhere you use that color, with defines you just change it there and then it's changed in whole scripting instead of changing it in every message.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)