Create3DTextLabel("{00FF00}This is green\n{FF0000}This is red", 0xFFFFFFFF, 1350.1772,-1645.8958,13.5969, 15.0, 0, 0);
CMD:label(playerid, params[]) { new string[49], Float:x, Float:y, Float:z; if(sscanf(params, "s[90]", string)) return SendClientMessage(playerid, -1, "/label text"); GetPlayerPos(playerid, x, y, z); Create3DTextLabel(string, 0xFFFFFFFF, x, y, z, 40.0, 0, 0); return 1; }
Hex codes are automatically removed from player input in SA-MP 0.3(e?)+. If you try entering a hex code in SA-MP using the chatbox or a dialog, it will be automatically removed. You need to find an alternative that will replace your input with a hex code.
Example: /label {red}This is red. {yellow}This is yellow. Then you simply replace {red} with {FF0000} and {yellow} with {FFFF00}. |
#define RED {FF0000} #define GREEN {00FF00}
/label {GREEN}This is green{RED}This is red
Код:
/label {GREEN}This is green{RED}This is red |
error 074: #define pattern must start with an alphabetic character
#define {RED} {FF0000}
#define {GREEN} {00FF00}
#define RED {FF0000} #define GREEN {00FF00}
stock strreplace(string[], const search[], const replacement[], bool:ignorecase = false, pos = 0, limit = -1, maxlength = sizeof(string)) {
// No need to do anything if the limit is 0.
if (limit == 0)
return 0;
new
sublen = strlen(search),
replen = strlen(replacement),
bool:packed = ispacked(string),
maxlen = maxlength,
len = strlen(string),
count = 0
;
// "maxlen" holds the max string length (not to be confused with "maxlength", which holds the max. array size).
// Since packed strings hold 4 characters per array slot, we multiply "maxlen" by 4.
if (packed)
maxlen *= 4;
// If the length of the substring is 0, we have nothing to look for..
if (!sublen)
return 0;
// In this line we both assign the return value from "strfind" to "pos" then check if it's -1.
while (-1 != (pos = strfind(string, search, ignorecase, pos))) {
// Delete the string we found
strdel(string, pos, pos + sublen);
len -= sublen;
// If there's anything to put as replacement, insert it. Make sure there's enough room first.
if (replen && len + replen < maxlen) {
strins(string, replacement, pos, maxlength);
pos += replen;
len += replen;
}
// Is there a limit of number of replacements, if so, did we break it?
if (limit != -1 && ++count >= limit)
break;
}
return count;
}
ConvertColors(input[144])
{
strreplace(input, "{RED}", "{FF0000}", true);
strreplace(input, "{GREEN}", "{00FF00}", true);
strreplace(input, "{YELLOW}", "{FFFF00}", true);
strreplace(input, "{BLUE}", "{0000FF}", true);
strreplace(input, "{WHITE}", "{FFFFFF}", true);
return input;
}
CMD:label(playerid, params[])
{
if(!strlen(params)) return SendClientMessage(playerid, -1, "/label text");
new Float:x, Float:y, Float:z, string[144];
strcat(string, params);
format(string, sizeof(string), "%s", ConvertColors(string));
GetPlayerPos(playerid, x, y, z);
Create3DTextLabel(string, 0xFFFFFFFF, x, y, z, 40.0, 0, 0);
return 1;
}