password ?
#1

Hello, I want to know how to write code to filter only enlish+number password can login.

example how to work


if password is: gdfsdจขจครบยรีั่่เ่้ัีะ55889
so, it not only english or english+number kick player when login

if password is:
hdsd55889900
this is ok.


please help, thanks
Reply
#2

Код:
CheckPassword(string[])
{
    for(new i = strlen(string); i > 0; i--)
        if(!('A' <= string[i] <= 'Z') && !('a' <= string[i] <= 'z') && !('0' <= string[i] <= '9')) return false;

    return true;
}
Now check it like that in OnDialogResponse

Код:
new pKick[MAX_PLAYERS];
if(CheckPassword(inputtext))
{
       His password only contains Alphabets + numbers do your code now
}
else
{
      His password has some symbols or other language words,
      pKick[playerid] ++ ; // Adding +1 to his warning
      if(pKick[playerid] >= 10) // He've done this for more than 10 times
      {
            Kick(playerid); // Kicking him
      }
}
Reply
#3

Quote:
Originally Posted by FuNkYTheGreat
Посмотреть сообщение
Код:
CheckPassword(string[])
{
    for(new i = strlen(string); i > 0; i--)
        if(!('A' <= string[i] <= 'Z') && !('a' <= string[i] <= 'z') && !('0' <= string[i] <= '9')) return false;

    return true;
}
Now check it like that in OnDialogResponse

Код:
new pKick[MAX_PLAYERS];
if(CheckPassword(inputtext))
{
       His password only contains Alphabets + numbers do your code now
}
else
{
      His password has some symbols or other language words,
      pKick[playerid] ++ ; // Adding +1 to his warning
      if(pKick[playerid] >= 10) // He've done this for more than 10 times
      {
            Kick(playerid); // Kicking him
      }
}
hi it not work why?
Reply
#4

Quote:
Originally Posted by parames3010
Посмотреть сообщение
hi it not work why?
Show how you pasted it in your script!
Reply
#5

Quote:
Originally Posted by UFF
Посмотреть сообщение
Show how you pasted it in your script!
Код:
		if(dialogid == 1)
		{
	 		if(!response) { SetTimerEx("DialogLogin", 100, 0, "d", playerid); return 1; }
	  		if(!strlen(inputtext)) { SetTimerEx("DialogLogin", 100, 0, "d", playerid); return 1; }
	  		
	  		if(CheckPassword(inputtext)) //аЄз¤ГЛСКјиТ№
			{
                OnPlayerLogin(playerid,inputtext);
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "ГЛСКјиТ№ЁРµйН§дБиБХµСЗНСЎЙГѕФаИЙ ЁРµйН§БХ A-Z бЕР µСЗаЕўа·иТ№Сй№");
   				SetTimerEx("DialogLogin", 100, 0, "d", playerid);
      			pKick[playerid] ++ ; // Adding +1 to his warning
   				if(pKick[playerid] >= 10) // He've done this for more than 10 times
      			{
            		Kick(playerid); // Kicking him
      			}
      			return 1;
			}
	  		
	  		
			
	  		return 1;
		}
Код:
		if(dialogid == 2)
		{
	 		if(!response) { SetTimerEx("DialogRegister", 100, 0, "d", playerid); return 1; }
	  		if(!strlen(inputtext)) { SetTimerEx("DialogRegister", 100, 0, "d", playerid); return 1; }
			if(strlen(inputtext) < 3 || strlen(inputtext) > 20)
			{
			    SetTimerEx("DialogRegister", 100, 0, "d", playerid);
				SendClientMessage(playerid, COLOR_GRAD1, "ГЛСКјиТ№ЁРµСй§дґйµСй§бµи 3 - 20 µСЗНСЎЙГа·иТ№Сй№");
                return 1;
			}
			
			if(CheckPassword(inputtext)) //аЄз¤ГЛСКјиТ№
			{
			    OnPlayerRegister(playerid,inputtext);
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "ГЛСКјиТ№ЁРµйН§дБиБХµСЗНСЎЙГѕФаИЙ ЁРµйН§БХ A-Z бЕР µСЗаЕўа·иТ№Сй№");
				SetTimerEx("DialogRegister", 100, 0, "d", playerid);
      			pKick[playerid] ++ ; // Adding +1 to his warning
   				if(pKick[playerid] >= 10) // He've done this for more than 10 times
      			{
            		Kick(playerid); // Kicking him
      			}
      			return 1;
			}

			
	  		return 1;
		}
Код:
		if(dialogid == 3)
		{
		    if(response)
			{
				SetTimerEx("DialogLogin", 1000, 0, "d", playerid);
			}
			
			if(CheckPassword(inputtext)) //аЄз¤ГЛСКјиТ№
			{
                OnPlayerRegister(playerid,inputtext);
			}
			else
			{
				SendClientMessage(playerid, COLOR_GRAD1, "ГЛСКјиТ№ЁРµйН§дБиБХµСЗНСЎЙГѕФаИЙ ЁРµйН§БХ A-Z бЕР µСЗаЕўа·иТ№Сй№");
				SetTimerEx("DialogLogin", 1000, 0, "d", playerid);
      			pKick[playerid] ++ ; // Adding +1 to his warning
   				if(pKick[playerid] >= 10) // He've done this for more than 10 times
      			{
            		Kick(playerid); // Kicking him
      			}
      			return 1;
			}
		}
Reply
#6

Use RegEx instead.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)