SA-MP Forums Archive
Special letters - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Special letters (/showthread.php?tid=585926)



Special letters - Lajko1 - 17.08.2015

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..


Re : Special letters - Dutheil - 17.08.2015

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;




Re: Special letters - Lajko1 - 18.08.2015

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.


Re: Special letters - Evocator - 18.08.2015

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



Re: Special letters - Lajko1 - 18.08.2015

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



AW: Special letters - Nero_3D - 18.08.2015

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