GameText
#1

hi I got a /cnn and if I type /cnnn ~k people get crash how can I stop allowing "~" in /cnnn
Reply
#2

It would help if you could show the code
Reply
#3

here you go


PHP код:
if(strcmp(cmd"/cnnn"true) == 0
    {
        if(
IsPlayerConnected(playerid))
        {
            if (
PlayerInfo[playerid][pAdmin] >= 4)
            {
                
tmp strtok(cmdtextidx);
                new 
txtid;
                if(!
strlen(tmp))
                {
                    
SendClientMessage(playeridCOLOR_GRAD2"USAGE: /cnnn <type> [cnnc textformat ~n~=Newline ~r~=Red ~g~=Green ~b~=Blue ~w~=White ~y~=Yellow]");
                    return 
1;
                }
                
txtid strval(tmp);
                if(
txtid == 2)
                {
                    
SendClientMessage(playeridCOLOR_GRAD2"You can not select 2");
                    return 
1;
                }
                new 
length strlen(cmdtext);
                while ((
idx length) && (cmdtext[idx] <= ' '))
                {
                    
idx++;
                }
                new 
offset idx;
                new 
result[128];
                while ((
idx length) && ((idx offset) < (sizeof(result) - 1)))
                {
                    
result[idx offset] = cmdtext[idx];
                    
idx++;
                }
                
result[idx offset] = EOS;
                if(!
strlen(result))
                {
                    
SendClientMessage(playeridCOLOR_GRAD2"USAGE: /cnnn <type> [cnnc textformat ~n~=Newline ~r~=Red ~g~=Green ~b~=Blue ~w~=White ~y~=Yellow]");
                    return 
1;
                }
                
format(stringsizeof(string), "[ADMIN]: %s Has CNNN'd [%s]."sendername result);
                
ABroadCast(COLOR_LIGHTRED,string5);
                
format(string,sizeof(string),"%s",(result));
                
GameTextForAll(string,5000,txtid);
                new 
ymd;
                new 
h,mi,s;
                
getdate(y,m,d);
                
gettime(h,mi,s);
                
format(string,sizeof(string), "(%d/%d/%d)[%d:%d:%d] %s Has CNNN'd: [%s]",d,m,y,h,mi,s,sendername,result);
                
AnnounceLog(string);
                return 
1;
            }
            else
            {
                
SendClientMessage(playeridCOLOR_GRAD1"   you are not authorized to use that command!");
                return 
1;
            }
        }
        return 
1;
    } 
Reply
#4

anyone know?
Reply
#5

Is it when they use just ~ on it's own, or when they try and do a colour with something like ~y~ for yellow?
Reply
#6

whem they try to type ~r or ~k .. just like the crash function
Reply
#7

Код:
for(new i = 0; i < strlen(string); i++)
{
    if(strfind(string, "~", true) != -1)
    {
        new pos = strfind(string, "~", true);
        strdel(string, pos, pos+1);
    }
    else
    {
        break;
    }
}
Reply
#8

still gives me crash .. I typed ~r ..
Reply
#9

Certain color letter crashes the game https://sampwiki.blast.hk/wiki/GameTextStyle
Reply
#10

i've changed color codes from ~letter~ to -letter- in order to prevent the use of "~" in the text

Код:
if(strfind(string, "~", true) != -1)
{ 
    return SendClientMessage(playerid, YOUR_COLOR, "invalid text, put here your error message");
}
else
{
    for(new i = 0; i < strlen(string); i++)
    {
        if((strfind(string, "-n-", true) != -1) ||
        (strfind(string, "-r-", true) != -1) ||
        (strfind(string, "-g-", true) != -1) ||
        (strfind(string, "-b-", true) != -1) ||
        (strfind(string, "-w-", true) != -1) ||
        (strfind(string, "-y-", true) != -1))
        {
            new pos = strfind(string, "-n-", true);
            if(pos != -1)
            {
                strdel(string, pos, pos+3);
                strins(string, "~n~", pos);
            }
            pos = strfind(string, "-r-", true);
            if(pos != -1)
            {
                strdel(string, pos, pos+3);
                strins(string, "~r~", pos);
            }
            pos = strfind(string, "-g-", true);
            if(pos != -1)
            {
                strdel(string, pos, pos+3);
                strins(string, "~g~", pos);
            }
            pos = strfind(string, "-b-", true);
            if(pos != -1)
            {
                strdel(string, pos, pos+3);
                strins(string, "~b~", pos);
            }
            pos = strfind(string, "-w-", true);
            if(pos != -1)
            {
                strdel(string, pos, pos+3);
                strins(string, "~w~", pos);
            }
            pos = strfind(string, "-y-", true);
            if(pos != -1)
            {
                strdel(string, pos, pos+3);
                strins(string, "~y~", pos);
            }
        }
        else
        {
            break;
        }
    }
    //Show the GameText and do all other stuff here
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)