23.07.2014, 13:46
Hello guys, I am trying to make a color chat. So when you type #R the text will be red, #Y the text will be yellow etc...
Example: #RHe#Yll#Bo
Here is my code in OnPlayerText:
But I get this error:
I also have /fakechat command that WORKS when I use colors like #R for example:
Can anyone help me?
Example: #RHe#Yll#Bo
Here is my code in OnPlayerText:
pawn Код:
for(new i = 0, len = strlen(text); i < len; i++)
{
if(text[i] == '#')
{
i++;
if(text[i] == 'R')
{
text[i-1] = '{';
text[i] = 'F';
strins(text, "F0000}", i+1, 128);
}
else if(text[i] == 'G')
{
text[i-1] = '{';
text[i] = '0';
strins(text, "0FF00}", i+1, 128);
}
else if(text[i] == 'Y')
{
text[i-1] = '{';
text[i] = 'F';
strins(text, "FFF00}", i+1, 128);
}
else if(text[i] == 'B')
{
text[i-1] = '{';
text[i] = '0';
strins(text, "000FF}", i+1, 128);
}
print(text);
}
}
Код:
[16:46:05] [debug] Run time error 10: "Native function failed" [16:46:05] [debug] strins [16:46:05] [debug] AMX backtrace:
pawn Код:
CMD:fakechat(playerid, params[])
{
new playa, cmd[128];
if(Admin(playerid) < 8) return SendClientMessage(playerid, COLOR_ERROR, "You are not allowed to use this command.");
if(sscanf(params, "us[128]", playa, cmd)) return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /fakechat [playerid/ part of name] [text]");
OnPlayerText(playa, cmd);
return 1;
}