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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: MySQL problem (
/showthread.php?tid=158384)
MySQL problem -
Mr Artur. - 09.07.2010
When i start my server and try to log in and nothing happens. I checked the script, but i couldn't find anything that could cause it.
Pastebin:
http://pawn.pastebin.com/8husMPmD
MySQL part was taken from CWRP
Re: MySQL problem -
Mr Artur. - 10.07.2010
Bring
Up
My
Post
Re: MySQL problem -
Grim_ - 10.07.2010
It's not good to post code from other scripts.
But have you created the database needed? Have you connected to the database in OnGameModeInit?
Re: MySQL problem -
Mr Artur. - 11.07.2010
Problem is in OnPlayerLogin, OnPlayerRegister inserts user to database.
Re: MySQL problem -
Grim_ - 11.07.2010
Well does it send you any messages? Does your server crash after logging in?
Re: MySQL problem -
Mr Artur. - 11.07.2010
It doesn't send anything.. If I press Spawn it says: "You need to log in before spawn" and so on..
Re: MySQL problem -
Grim_ - 11.07.2010
And when you do login (with /login or whatever it is) it just doesn't do anything?
Can I see the /login code?
Re: MySQL problem -
Mr Artur. - 11.07.2010
Its in dialog.
Код:
if(dialogid == 12346)
{
if(response == 1)
{
if(strlen(inputtext))
{
new tmppass[64];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
OnPlayerLogin(playerid,tmppass);
}
else
{
format(string,sizeof(string),"Tere tulemast meie serverisse, %s\n\nPalun sisesta oma parool, kui Sa oled registreeritud\nSisesta parool ja vajuta Registreeri, kui Sul pole veel kasutajat",GetPlayerNameEx(playerid));
ShowPlayerDialog(playerid,12346,DIALOG_STYLE_INPUT,"Sisse logimine",string,"Logi sisse","Registreeri");
}
}
else
{
if(strlen(inputtext) >= 30 && strlen(inputtext) < 3)
{
format(string,sizeof(string),"Tere tulemast meie serverisse, %s\n\nPalun sisesta oma parool, kui Sa oled registreeritud\nSisesta parool ja vajuta Registreeri, kui Sul pole veel kasutajat",GetPlayerNameEx(playerid));
ShowPlayerDialog(playerid,12346,DIALOG_STYLE_INPUT,"Registreerumine",string,"Logi sisse","Registreeri");
return 1;
}
else
{
if (gPlayerAccount[playerid])
{
SendClientMessage(playerid, COLOR_YELLOW, "See nimi on juba vхetud,palun vali mхni muu!.");
Kick(playerid);
return 1;
}
new tmppass[64];
strmid(tmppass, inputtext, 0, strlen(inputtext), 255);
OnPlayerRegister(playerid,tmppass);
}
}
}
Re: MySQL problem -
Grim_ - 11.07.2010
Well I dont' see 'PlayerInfo[playerid][pKey]' being set anywhere, is it auto-set when they enter the server or what?
If that's not the problem, I'm not sure. Try debugging each line of code, and see where it stops.
Re: MySQL problem -
Mr Artur. - 11.07.2010
MySQLFetchAcctSingle does it( MySQLFetchAcctSingle(PlayerInfo[playerid][pSQLID], "Password", PlayerInfo[playerid][pKey]); )
Re: MySQL problem -
Grim_ - 11.07.2010
Yeah, I've never heard of that function. Let me see it please.
Re: MySQL problem -
Mr Artur. - 11.07.2010
Sure
Код:
MySQLFetchAcctSingle(sqlplayerid, sqlvalname[], sqlresult[])
{
new query[128];
format(query, sizeof(query), "SELECT %s FROM Players WHERE id = %d LIMIT 1", sqlvalname, sqlplayerid);
mysql_query(query);
//if (DEBUG) SQLLog(query);
mysql_store_result();
if(mysql_fetch_row(sqlresult)==1)
{
mysql_free_result();
return 1;
}
return 0;
}