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;
}