12.02.2016, 17:35
hi I got a /cnn and if I type /cnnn ~k people get crash how can I stop allowing "~" in /cnnn
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;
}
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; } }
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 }