Dialog wont appear
#1

Hello, my MYSQL Login Dialog wont appear also i can register an Account all works but when i log off etc and i log in with the same Name the Register Dialog appear he didnt create the Account.
here the OnDialogResponse:

Код:
switch(dialogid)
    {
    	case DIALOG_REGISTER:
	    {
	        if(response)
	        {
	            if(!strlen(inputtext) || strlen(inputtext) > 128)
	            {
	                new string[128], str[300];
	                SendClientMessage(playerid, -1, ""chat" You must insert a password between 1-128 characters!");
                 	format(string,sizeof(string),""chat" {FFFFB2}Hello %s to "NAME"",PlayerName(playerid));
        			ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD,str,""chat" {FFFFFF}Welcome to "NAME"!\n» You're not registered yet!\n» Please enter your desired Password and click register.","Register","Quit");
	            }
	            else if(strlen(inputtext) > 0 && strlen(inputtext) < 128)
	            {
   		        	new escpass[100];
			        mysql_real_escape_string(inputtext, escpass);
			        MySQL_Register(playerid, escpass);
	            }
	        }
	        if(!response)
	        {
				ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_MSGBOX,"{F7FC84}Kicked",""chat" You got kicked because you cancelled the Login/Register."NAME"","Close","");
 				SendClientMessage(playerid,-1,""chat""COL_LGREEN" You must register/login to play on Zombie Attack!");
				Kick(playerid);
	        }
	    }

	    case DIALOG_LOGIN:
	    {
	        if(!response)
	        {
 				ShowPlayerDialog(playerid,DIALOG_REGISTER,DIALOG_STYLE_MSGBOX,"{F7FC84}Kicked",""chat"You got kicked because you cancelled the Login/Register. "NAME"","Close","");
				Kick(playerid);
	        }
	        if(response)
			{
	            new query[200], pname[24], escapepass[100];
	            GetPlayerName(playerid, pname, 24);
	            mysql_real_escape_string(inputtext, escapepass);
	            format(query, sizeof(query), "SELECT `Username` FROM users WHERE Username = '%s' AND password = SHA1('%s')", pname, escapepass);
	            mysql_query(query);
	            mysql_store_result();

	            new numrows = mysql_num_rows();
	            if(numrows == 1) MySQL_Login(playerid);
	            SendClientMessage(playerid,-1,""chat""COL_LGREEN"You have successfully logged in! Welcome back!");

	            if(!numrows)
	            {
	                new string[256];
                	SendClientMessage(playerid,-1,""chat""COL_LIGHTGREEN" This password is wrong! Please enter a correct password or connect with other nick.");
			        format(string,sizeof(string),""chat" {F7FC84}Welcome Back %s!",PlayerName(playerid));
			       	ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD,string,""chat" {FFFFFF}Welcome to Zombie Attack!\n» This Nick is registered.\n» Please login below or choose another nick.","Login","Quit");
	            }
	            mysql_free_result();
	        }
	    }
Here the 2 stocks MySQL_LOGIN and MYSQL_Register:

Код:
stock MySQL_Register(playerid, passwordstring[])
{
    new Query[500],IP[16];
    GetPlayerIp(playerid, IP, sizeof(IP));

	strcat(Query,"INSERT INTO `users` (`Username`,`Password`,`pXP`,`pKills`,`pDeaths`,`pRank`, `pLevel`,`pAdminLevel`");
	strcat(Query,",`pVipLevel`, `pHour`, `pMin`, `pSec`, `pMapsPlayed`, `pCookies`, `pIP`) VALUES ('%s', sha1('%s'),1,0,0,0,0,0,0,0,0,0,0,0,'%s')");
	format(Query,sizeof(Query),Query,PlayerName(playerid),passwordstring,IP);
	mysql_query(Query);

	playedtimer[playerid] = SetTimerEx("TimeOnServer", 1000, 1, "i", playerid);
    pInfo[playerid][pLogged] = 1;
    CheckBan(playerid);
    new str[400];
    format(str, sizeof(str),"» * {00FF00}%s {FFFFFF}created an account.",PlayerName(playerid));
    SendClientMessageToAll(-1,str);
    return 1;
}

stock MySQL_Login(playerid)
{
    new Query[600];
	format(Query, sizeof(Query), "SELECT * FROM `users` WHERE Username = '%s'", PlayerName(playerid));
	mysql_query(Query);
	mysql_store_result();
	mysql_fetch_row_format(Query, "|");
	//sscanf(Query, "e<p<|>s[24]s[128]iiiiiiiiiis[16]i",pInfo[playerid]);

    sscanf(Query, "p<|>s[24]s[128]iiiiiiiiiiii",pInfo[playerid][pUsername],
	pInfo[playerid][pPassword],pInfo[playerid][pXP],pInfo[playerid][pKills],pInfo[playerid][pDeaths],
	pInfo[playerid][pRank],pInfo[playerid][pEvac],pInfo[playerid][pAdminLevel],pInfo[playerid][pVipLevel],
	pInfo[playerid][pHour],pInfo[playerid][pMin],pInfo[playerid][pSec],pInfo[playerid][pMapsPlayed],pInfo[playerid][pCookies]);
	printf("%s",Query);
    pInfo[playerid][pLogged] = 1;
    mysql_free_result();
    CheckBan(playerid);
    playedtimer[playerid] = SetTimerEx("TimeOnServer", 1000, 1, "i", playerid);
	return 1;
}
Reply
#2

Does that printed message appear in the console?
pawn Код:
stock MySQL_Login(playerid)
{
    new Query[600];
    format(Query, sizeof(Query), "SELECT * FROM `users` WHERE Username = '%s'", PlayerName(playerid));
    mysql_query(Query);
    mysql_store_result();
    mysql_fetch_row_format(Query, "|");
    //sscanf(Query, "e<p<|>s[24]s[128]iiiiiiiiiis[16]i",pInfo[playerid]);

    sscanf(Query, "p<|>s[24]s[128]iiiiiiiiiiii",pInfo[playerid][pUsername],
    pInfo[playerid][pPassword],pInfo[playerid][pXP],pInfo[playerid][pKills],pInfo[playerid][pDeaths],
    pInfo[playerid][pRank],pInfo[playerid][pEvac],pInfo[playerid][pAdminLevel],pInfo[playerid][pVipLevel],
    pInfo[playerid][pHour],pInfo[playerid][pMin],pInfo[playerid][pSec],pInfo[playerid][pMapsPlayed],pInfo[playerid][pCookies]);
    [b]printf("%s",Query);[/b]
    pInfo[playerid][pLogged] = 1;
    mysql_free_result();
    CheckBan(playerid);
    playedtimer[playerid] = SetTimerEx("TimeOnServer", 1000, 1, "i", playerid);
    return 1;
}
Reply
#3

In the server log no, it dont create any Account on the MYSQL Database.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)