SA-MP Forums Archive
password ? - 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: password ? (/showthread.php?tid=653492)



password ? - parames3010 - 06.05.2018

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


Re: password ? - FuNkYTheGreat - 06.05.2018

Код:
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
      }
}



Re: password ? - parames3010 - 06.05.2018

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?


Re: password ? - UFF - 06.05.2018

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


Re: password ? - parames3010 - 06.05.2018

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;
			}
		}



Re: password ? - Logic_ - 06.05.2018

Use RegEx instead.