17.08.2015, 20:10
Guys how can I make a little anit special letters in dialogs, so player can insert only letters and numbers but not ć,đ,",#,!,%,$ etc etc - for register system..
IsLetterOrNumber(const string[], l = sizeof(string))
{
for(new i = 0; i < l; i++)
switch(string[i])
{
case 'A' .. 'Z': continue;
case 'a' .. 'z': continue;
case '0' .. '9': continue;
default: return 0;
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if (!IsLetterOrNumber(inputtext)) { SendClientMessage(playerid, -1, "You can only use letters or numbers."); return 1; } }
warning 224: indeterminate array size in "sizeof" expression (symbol "l")
ValidateWord(const string[]) {
for( ; ; ) {
switch(string[0]) {
case 'a'..'z', '0'..'9', 'A'..'Z': {
#emit load.s.pri string
#emit add.c 4
#emit stor.s.pri string
}
case EOS: {
return true;
}
default: {
break;
}
}
}
return false;
}