SA-MP Forums Archive
Password check with mysql problem - 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 check with mysql problem (/showthread.php?tid=538330)



Password check with mysql problem - klaus1n3 - 20.09.2014

My problem:


Код:
CheckPassword(playerid, password[])
{
    new query[255], password_escaped[25];
    if(strlen(password) > 0)
	{
	    mysql_escape_string(password, password_escaped, db_handle);
	    format(query, sizeof(query), "SELECT * FROM user WHERE username='%s' AND password='%s'",                       getPlayerName(playerid), password_escaped);
	    mysql_function_query(db_handle, query, TRUE, "OnPasswordCheck", "i", playerid);
	}
	else
	{
	       return 0;
	}
}
forward OnPasswordCheck(playerid);
public OnPasswordCheck(playerid)
{
	new num_fields, num_rows;
	cache_get_data(num_rows, num_fields, db_handle);
	if(num_rows == 1)
	{
	    //Passwort richtig
            return 1;
	}
	else
	{
	    //Passwort falsch
            return 0;
	}
}

I want that CheckPassword does return me the truth.

How can I get the returned data from the query to my function?