04.05.2020, 07:42
I have previously had mysql cache login/register system, but i converted it to orm. Now i'm not sure what the issue is, but the dialogs won't show when player joins.
Under OnPlayerConnect
OnPlayerLoad callback
Under OnPlayerConnect
Code:
mysql_race_check[playerid]++; static const empty_player[player_info]; playerdata[playerid] = empty_player; GetName(playerid); new ORM:ormid = playerdata[playerid][orm_id] = orm_create("players", mysql_handle); orm_addvar_int(ormid, playerdata[playerid][id], "id"); orm_addvar_string(ormid, playerdata[playerid][username], MAX_PLAYER_NAME, "username"); orm_addvar_string(ormid, playerdata[playerid][password], PASSWORD_SIZE, "password"); orm_addvar_string(ormid, playerdata[playerid][salt], SALT_SIZE, "salt"); orm_addvar_int(ormid, playerdata[playerid][adminlevel], "adminlevel"); orm_addvar_int(ormid, playerdata[playerid][playerscore], "score"); orm_addvar_int(ormid, playerdata[playerid][playermoney], "money"); orm_addvar_int(ormid, playerdata[playerid][playerskin], "skin"); orm_addvar_float(ormid, playerdata[playerid][playerhealth], "health"); orm_addvar_float(ormid, playerdata[playerid][playerarmour], "armour"); orm_addvar_float(ormid, playerdata[playerid][posx], "posx"); orm_addvar_float(ormid, playerdata[playerid][posy], "posy"); orm_addvar_float(ormid, playerdata[playerid][posz], "posz"); orm_addvar_float(ormid, playerdata[playerid][posa], "posa"); orm_addvar_int(ormid, playerdata[playerid][playerinterior], "interior"); orm_addvar_int(ormid, playerdata[playerid][playervirtualworld], "virtualworld"); orm_setkey(ormid, "username"); orm_load(ormid, "OnPlayerLoad", "dd", playerid, mysql_race_check[playerid]);
Code:
forward OnPlayerLoad(playerid, race_check); public OnPlayerLoad(playerid, race_check) { if(race_check != mysql_race_check[playerid]) return Kick(playerid); orm_setkey(playerdata[playerid][orm_id], "id"); new string[128]; switch (orm_errno(playerdata[playerid][orm_id])) { case ERROR_OK: { format(string, sizeof(string), "Welcome back to the server, {FFFFFF}%s.\n{A9C4E4}Type in your password below to log in to your account.", GetName(playerid)); ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_PASSWORD, "Account Login", string, "Login", "Quit"); } case ERROR_NO_DATA: { format(string, sizeof(string), "Welcome to the server, {FFFFFF}%s.\n{A9C4E4}Type your desired password below to register your account.", GetName(playerid)); ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "Account Register", string, "Register", "Quit"); } } return 1; }