28.03.2015, 12:11
(
Последний раз редактировалось Oeal; 10.04.2015 в 00:16.
)
pawn Код:
#define THREAD_LoadPlayerLogin (5)
#define THREAD_CompleteLoadPlayer (6)
#define THREAD_CreatePlayer (7)
#define THREAD_CreatedPlayer (8)
#define THREAD_ignoreCallback (1)
pawn Код:
public OnPlayerConnect(playerid)
{
new sql[512];
//mysql_real_escape_string(PlayerName(playerid), sql, mysqlCon1);
format(sql, sizeof sql,"SELECT LastPasswordChange, Password, Banned, UID FROM users WHERE username LIKE '%s' LIMIT 1", PlayerName(playerid));
mysql_function_query(mysqlCon1, sql, true, "onThreadLoadPlayerLogin", "d", playerid);
return 1;
}
pawn Код:
forward onThreadLoadPlayerLogin(playerid);
public onThreadLoadPlayerLogin(playerid)
{
if(IsPlayerConnected(playerid))
{
new rows, fields;
cache_get_data(rows, fields);
if(rows != 1)
{
ShowPlayerDialog(playerid, DIALOG_REG, DIALOG_STYLE_PASSWORD,"Welcome","Type your password below to register a new account","Register","Quit");
}
else
{
new temp[64];
cache_get_row(0,2, temp); //Get player banned state
if(strval(temp) == 0)
{
cache_get_row(0,0, temp);
PlayerInfo[playerid][passGenTime] = strval(temp);
cache_get_row(0,3, temp);
PlayerInfo[playerid][UID] = strval(temp);
cache_get_row(0,1, Passwords[playerid]);
ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_PASSWORD,"Welcome","Type your password below to login !","Login","Quit");
}
else
{
new string[129];
scm(playerid,c_r,"( ! ) Your account is banned from this server.");
format(string, sizeof(string), "( ! ) %s has been banned by AC for: ban evading", PlayerName(playerid));
SendClientMessageToAll(COLOR_RED, string);
Ban(playerid);
return 1;
}
}
Welcome(playerid);
MapIcon(playerid);
}
return 1;
}
pawn Код:
case DIALOG_LOG:
{
if ( !response ) return Kick ( playerid );
if( response )
{
new passHash[129], passHash2[128], bool:updatePassword=false;
valstr(passHash2,udb_hash(inputtext));
if(PlayerInfo[playerid][passGenTime] == 0 && strcmp(passHash2, Passwords[playerid], true)==0 )
{
updatePassword = true;
PlayerInfo[playerid][passGenTime] = gettime();
}
passHash = createPasswordHash(PlayerInfo[playerid][passGenTime],inputtext);
if(updatePassword || strcmp(passHash, Passwords[playerid], true)==0)
{
scm(playerid,COLOR_GREEN,"( ! ) You have logged in !");
new sql[128];
if(updatePassword)
{
format(sql, sizeof sql, "UPDATE users SET passLastUpdate = %d, password = '%s' WHERE UID = %d", PlayerInfo[playerid][passGenTime], passHash,PlayerInfo[playerid][UID]);
mysql_query(sql,THREAD_ignoreCallback,playerid, mysqlCon1);
}
format(sql, sizeof sql, "SELECT key_v, value FROM user_data WHERE UID = %d", PlayerInfo[playerid][UID]);
mysql_function_query(mysqlCon1, sql, true, "onTHREAD_CompleteLoadPlayer", "d", playerid);
}
else
{
printf("%d",PlayerInfo[playerid][passGenTime]);
ShowPlayerDialog(playerid, DIALOG_LOG, DIALOG_STYLE_PASSWORD,"SERVER","You have entered an incorrect password.\nType your password below to login.","Login","Quit");
}
return 1;
}
return 1;
}
How would I fix this? If anyone want the register codes, I will put them too.
Thanks for your time.