SA-MP Forums Archive
[Help]system Mysql - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Server (https://sampforum.blast.hk/forumdisplay.php?fid=6)
+--- Forum: Server Support (https://sampforum.blast.hk/forumdisplay.php?fid=19)
+--- Thread: [Help]system Mysql (/showthread.php?tid=573219)



[Help]system Mysql login - Okrs - 05.05.2015

Hi all, i have a problem I cannot login in my server, closed, I can only register. thanks


Re: [Help]system Mysql - FernandoLight - 05.05.2015

To be honest, it's annoying and I don't get why people don't understand it, let me tell you something.
SEARCH BEFORE STARTING A NEW TOPIC, DON'T BE LAZY! USE ****** TO SEARCH!
Thanks for understanding.


Re: [Help]system Mysql - Michael B - 05.05.2015

Can you tell more details please? The ones you provided are not enough.
Do you get any error message? Can you post your server's log? Does the MySQL plugin loads, at least?


Respuesta: Re: [Help]system Mysql - Okrs - 05.05.2015

Quote:
Originally Posted by Michael B
Посмотреть сообщение
Can you tell more details please? The ones you provided are not enough.
Do you get any error message? Can you post your server's log? Does the MySQL plugin loads, at least?
if you load , and if I can register
But I can not login

thanks for answering


AW: [Help]system Mysql - Mencent - 06.05.2015

Hello!

Can you post your login and register code.
By the way: Do you get any errors in the mysql.log.txt?


Respuesta: AW: [Help]system Mysql - Okrs - 06.05.2015

Quote:
Originally Posted by Mencent
Посмотреть сообщение
Hello!

Can you post your login and register code.
By the way: Do you get any errors in the mysql.log.txt?
stock MySQL_Login(playerid)
{
new query[300], pname[24], savingstring[20];

GetPlayerName(playerid, pname, 24);
format(query, sizeof(query), "SELECT * FROM playerdata WHERE user = '%s'", pname);
mysql_query(query);
mysql_store_result();
while(mysql_fetch_row_format(query,"|"))
{
mysql_fetch_field_row(savingstring, "scores"); SetPlayerScore(playerid, strval(savingstring));
mysql_fetch_field_row(savingstring, "money"); GivePlayerMoney(playerid, strval(savingstring));
mysql_fetch_field_row(savingstring, "adminlevel"); PlayerInfo[playerid][pAdmin] = strval(savingstring);
mysql_fetch_field_row(savingstring, "helperlevel"); PlayerInfo[playerid][pHelper] = strval(savingstring);
mysql_fetch_field_row(savingstring, "kills"); PlayerInfo[playerid][pKills] = strval(savingstring);
mysql_fetch_field_row(savingstring, "deaths"); PlayerInfo[playerid][pDeaths] = strval(savingstring);
}
mysql_free_result();
printf("1");
MySQL_vLogin(playerid); //vip log in
printf("2");
PlayerInfo[playerid][pLogged] = 1;
return 1;



if(dialogid == R_DIALOG)
{
if(!response) return Kick(playerid);
if(!strlen(inputtext) || strlen(inputtext) > 100)
{
SendClientMessage(playerid, RED,"[ADMIn]: Password lenght must be greater than 1 and lesser than 100 words!");
ShowPlayerDialog(playerid, R_DIALOG, DIALOG_STYLE_PASSWORD,"Register","Your account is "cred"not "corange"registered\nPlease type your password to register","Register","");
}
else if(strlen(inputtext) > 0 && strlen(inputtext) < 100)
{
new escapepass[100];
mysql_real_escape_string(inputtext, escapepass);
new query[200], IP[16];
GetPlayerIp(playerid, IP, 16);
format(query, sizeof(query),"INSERT INTO playerdata(user, password, IP, money, scores, adminlevel, helperlevel, kills, deaths) VALUES('%s', SHA1('%s'), '%s', 0, 0, 0, 0, 0, 0)", escpname(playerid), escapepass, IP);
mysql_query(query);
PlayerInfo[playerid][pLogged] = 1;
SendClientMessage(playerid, GREEN,"[ACCOUNT]: You have been successfully registered!");
SendClientMessage(playerid, -1,"Generating your password...");
format(gString, SOS,"Your password is: "cgreen"%s", inputtext);
SendClientMessage(playerid, RED, gString);
SetTimerEx("login_dialog", 100, 0, "i", playerid);

}
}
if(dialogid == L_DIALOG)
{
if(!response) return 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 `user` FROM playerdata WHERE `user` = '%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, GREEN,"[ACCOUNT]: You stats has been successfully loaded!");
SetTimerEx("login_dialog", 100, 0, "i", playerid);
}
if(!numrows)
{
PlayerInfo[playerid][FailLogin]++;
format(gString, SOS, "LOGIN: You have failed to login | Attempt (%d)", PlayerInfo[playerid][FailLogin] );
SendClientMessage(playerid, red, gString);
ShowPlayerDialog(playerid, L_DIALOG, DIALOG_STYLE_PASSWORD,"Login",""corange"Your account is already registered\nPlease type your password to login","Login","Quit");
if(PlayerInfo[playerid][FailLogin] == MAX_FAIL_LOGINS)
{
format(gString, sizeof(gString), "%s has been kicked (Failed Logins)", PlayerName(playerid));
SendClientMessageToAll(red, gString);
Kick(playerid);
}
}
}
mysql_free_result();
}
return 1;
}