MySQL login system - 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: MySQL login system (
/showthread.php?tid=522530)
MySQL login system -
Rufio - 28.06.2014
Hello guys, I was reading a MySQL login/register tutorial. I was going to edit it for my needs as soon as I make sure it is working perfect. Everything is fine, it says MySQL database is connected etc. But when I connect to server, I see no log-in nor register dialogs. Here is the codes:
pawn Код:
public OnPlayerConnect(playerid)
{
SendClientMessage(playerid,-1,"{FF0000}(( {00FF00}[INFO]: {FFFFFF}Please wait while you are getting synced with the database. {FF0000}))");
StopStats(playerid);
new query[128];
GetPlayerName(playerid, Name[playerid], 24);
mysql_format(mysql, query, sizeof(query),"SELECT `Password`, `ID` FROM `server` WHERE `Username` = '%e' LIMIT 1", Name[playerid]);
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
return 1;
}
and here is the "OnAccountCheck" callback:
pawn Код:
forward OnAccountCheck(playerid);
public OnAccountCheck(playerid)
{
new rows, fields;
cache_get_data(rows, fields, mysql);
if(rows)
{
cache_get_field_content(0, "PASS", pInfo[playerid][Password], mysql, 129);
pInfo[playerid][sqlID] = cache_get_field_content_int(0, "sqlID");
ShowPlayerDialog(playerid, 0, DIALOG_STYLE_INPUT, "Login", "In order to play, you need to login", "Login", "Quit");
}
else
{
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_INPUT, "Register", "In order to play, you need to register.", "Register", "Quit");
}
return 1;
}
Re: MySQL login system -
AiRaLoKa - 28.06.2014
try to use
mysql_escape_string instead of "%e".
sometime i got this error too while using "%e"
Re: MySQL login system -
Jack_Leslie - 28.06.2014
Put this under OnGameModeInit if you haven't:
pawn Код:
mysql_log(LOG_ERROR | LOG_WARNING | LOG_DEBUG);
Then go in game and run the server, and then go and check mysql_log.txt and show us what it said. Also just add:
Under:
pawn Код:
mysql_tquery(mysql, query, "OnAccountCheck", "i", playerid);
And let us know what that says too.