GameText -
Ugaustin - 12.02.2016
hi I got a /cnn and if I type /cnnn ~k people get crash how can I stop allowing "~" in /cnnn
Re: GameText -
Chilli9434 - 12.02.2016
It would help if you could show the code
Re: GameText -
Ugaustin - 12.02.2016
here you go
PHP код:
if(strcmp(cmd, "/cnnn", true) == 0)
{
if(IsPlayerConnected(playerid))
{
if (PlayerInfo[playerid][pAdmin] >= 4)
{
tmp = strtok(cmdtext, idx);
new txtid;
if(!strlen(tmp))
{
SendClientMessage(playerid, COLOR_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(playerid, COLOR_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(playerid, COLOR_GRAD2, "USAGE: /cnnn <type> [cnnc textformat ~n~=Newline ~r~=Red ~g~=Green ~b~=Blue ~w~=White ~y~=Yellow]");
return 1;
}
format(string, sizeof(string), "[ADMIN]: %s Has CNNN'd [%s].", sendername , result);
ABroadCast(COLOR_LIGHTRED,string, 5);
format(string,sizeof(string),"%s",(result));
GameTextForAll(string,5000,txtid);
new y, m, d;
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(playerid, COLOR_GRAD1, " you are not authorized to use that command!");
return 1;
}
}
return 1;
}
Re: GameText -
Ugaustin - 12.02.2016
anyone know?
Re: GameText -
Rukka - 12.02.2016
Is it when they use just ~ on it's own, or when they try and do a colour with something like ~y~ for yellow?
Re: GameText -
Ugaustin - 13.02.2016
whem they try to type ~r or ~k .. just like the crash function
Re: GameText -
Adeon - 13.02.2016
Код:
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;
}
}
Re: GameText -
Ugaustin - 13.02.2016
still gives me crash .. I typed ~r ..
Re: GameText -
Joron - 13.02.2016
Certain color letter crashes the game
https://sampwiki.blast.hk/wiki/GameTextStyle
Re: GameText -
Adeon - 13.02.2016
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
}