Server Crashing- GUI and %%%%%
#1

Hello.

I have a problem with the server.
When I type in the GUI window, special characters, or%%%
Server to crash on and off.
I lose players through restarts.
How to secure dialogs?

Yours.
Reply
#2

You might want to post your code.
Reply
#3

Command register.

Код:
CMD:register(playerid,cmdtext[]){//Na Dole Mapy!

	if (registerr == 0) {
		SendClientMessage(playerid, COLOR_RED, "Register off!");
		return 1;
	}
	if (users >= maxusers) {
		SendClientMessage(playerid, COLOR_RED, "Max register users!");
		return 1;
	}

	if(Registered[playerid]) {
		SendClientMessage(playerid, COLOR_RED2, "You already register");
		return 1;
	}

	ShowPlayerDialog(playerid,40,1,"Register","To register account \n\nWrite password","Register","Cancel");

	return 1;
	#pragma unused cmdtext
}
Register OnDialogResponse..

Код:
	if(dialogid == 40)
	{
		if(response == 1)
		{

			if(20 < strlen(inputtext) || strlen(inputtext) < 5) {
				SendClientMessage(playerid, COLOR_RED2, "Hasło musi mieć od 5 do 20 znakуw");
				ShowPlayerDialog(playerid,8,1,"Rejestracja","Aby zarejestrowac sie na tym nicku \n\nMusisisz tylko ustawic haslo","Anuluj","Rejestruj");
				return 1;
			}

			if(FindBadSign(inputtext)){
				SendClientMessage(playerid, COLOR_RED2,"Password sign, only [a-z] [A-Z] [0-9]");
				return 1;
			}


			new nick[MAX_PLAYER_NAME];
			GetPlayerName(playerid,nick,sizeof(nick));

			if(mysqluse == 1){
				new string[256];
				format(string, sizeof(string), "INSERT INTO `Players` SET `Nick` = '%s',`Pass` = '%s',`Score` = '0',`Bank` = '0',`Bounty` = '0',`Kills` = '0',`Deaths` = '0',`Suicides` = '0',`Used_Score` = '0',`Skin` = '0',`Row_Kills` = '0',`Arena` = '0',`Drag` = '100000'",nick,inputtext);
				mysql_query(string);
			}

			if(diniuse == 1){
			    new string[128];
			    format(string,sizeof(string),"PSZD/Gracze/%s.ini",nick);
				dini_Create(string);
				new File:fl = fopen(string,io_write);
				format(string,sizeof(string),"Pass=%s\n\rScore=0\n\rBank=0\n\rBounty=0\n\rKills=0\n\rDeaths=0\n\rSuicides=0\n\rUsed_Score=0\n\rSkin=0\n\rRow_Kills=0\n\rArena=0\n\rDrag=100000\n\rTime=0",inputtext);
				fwrite(fl,string);
				fclose(fl);
			}

			users ++;
			SendClientMessage(playerid, COLOR_GREEN, "");
			new string[128];
			format(string, sizeof(string), "You create account: %s , Password: %s", nick, inputtext);
			SendClientMessage(playerid, COLOR_GREEN, string);

			format(Pass[playerid],21,"%s",inputtext);
			format(LoginNick[playerid],MAX_PLAYER_NAME,"%s",nick);
			logged[playerid] = true;
			Registered[playerid] = true;
		}

		if(response == 0){
			SendClientMessage(playerid,COLOR_RED2,"You cancel register");
		}

		return 1;
	}
Login OnDialogResponse:

Код:
	if(dialogid == 39){


		if(response == 1)
		{

			new nick[MAX_PLAYER_NAME];
			GetPlayerName(playerid,nick,sizeof(nick));

			new haslo[21];
			new tmp[256];

			format(haslo,sizeof(haslo),"%s",Pass[playerid]);

			if (udb_hash(inputtext) != udb_hash(haslo)) {
				BadPasCount[playerid] ++;
				if(BadPasCount[playerid] >= 3){
					SendClientMessage(playerid,COLOR_ORANGE,"Zbyt dużo razy wpisałeś(aś) błędne hasło");
					Kick(playerid);
				}
				SendClientMessage(playerid, COLOR_RED2, "Błędne hasło!");
				logged[playerid] = false;
				ShowPlayerDialog(playerid,39,1, "Zaloguj się", ""C_ZOLTY"Błędne hasło "C_JZIELONY""VERSION"!\n"C_CZERWONY"\nSprуbuj ponownie. Zaloguj się:", "OK", "Anuluj");
				return 1;
			}

			format(Pass[playerid],21,"%s",haslo);
			format(LoginNick[playerid],MAX_PLAYER_NAME,"%s",nick);
			logged[playerid] = true;
			format(tmp, sizeof(tmp), "Zostałeś zalogowany(a) jako: %s", nick);
			SendClientMessage(playerid, COLOR_GREEN, tmp);
Reply
#4

FindBadSign, but my public looks:

Код:
forward FindBadSign(string[]);
public FindBadSign(string[]){

/ / Here you can put the code through which we can rule out certain characters in a password
/ / Function currently allows for each character

	return 0;
}
Reply
#5

pawn Код:
forward ReturnStringWithoutBadSign(string[]);
public ReturnStringWithoutBadSign(string[])
{
for(new i=0; i<strlen(string); i++)
{
if(string[i] == '%') string[i] = '#';
}
return string;
}
Then use
[pawn]SendClientMessage(playerid, COLOR, ReturnStringWithoutBadSign(string));//i'm not sure if that works but in theory seems yes...

@edited
Reply
#6

Not work..
Reply
#7

Try with this "FindBadSign":

pawn Код:
forward FindBadSign(string[]);
public FindBadSign(string[])
{
    for(new i; i < strlen(string); i++)
    {
        switch(string[i])
        {
            case 0x30..0x39: continue; //[0-9]
            case 0x41..0x5A: continue; //[A-Z]
            case 0x61..0x7A: continue; //[a-z]
            default: return 1;
        }
    }
    return 0;
}
Reply
#8

It works!
Thanks so much everyone for your help!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)