Native function failed (strins)
#1

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:

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);
        }
    }
But I get this error:

Код:
[16:46:05] [debug] Run time error 10: "Native function failed"
[16:46:05] [debug]  strins
[16:46:05] [debug] AMX backtrace:
I also have /fakechat command that WORKS when I use colors like #R for example:

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;
}
Can anyone help me?
Reply
#2

Quote:
Originally Posted by ******
Посмотреть сообщение
You can't use "strins" on "text" - the variable isn't large enough to hold new data.
Ahh... Thanks a lot!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)