Special letters
#1

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..
Reply
#2

I made a function for you :
PHP код:
IsLetterOrNumber(const string[], sizeof(string))
{
    for(new 
0li++)
        switch(
string[i])
        {
            case 
'A' .. 'Z': continue;
            case 
'a' .. 'z': continue;
            case 
'0' .. '9': continue;
            default: return 
0;
        }
    
    return 
1;

Reply
#3

May you just help me to figure out how to use that OnPlayerDialogResponse and inputtext ? cuz I'm getting some errors whatever I'm trying to do with this function.
Reply
#4

Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	if (!IsLetterOrNumber(inputtext))
	{
		SendClientMessage(playerid, -1, "You can only use letters or numbers.");
		return 1;
	}		
}
Reply
#5

pawn Код:
warning 224: indeterminate array size in "sizeof" expression (symbol "l")
Reply
#6

That's because the array size of inputtext is unknown, use that instead
pawn Код:
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;
}
Just to mention, a space (' ') isn't valid either, well you could simply add it if you want
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)