07.02.2014, 10:56
It's a good tutorial. It'd be nice if you used ID for each player and use orm_setkey function as well. When a player disconnects, orm_update should be used so it will update the row of that player.
Something last:
It can become:
Good effort though.
Something last:
pawn Code:
// OnPlayerMysqlFinish:
if(cache_num_rows() == 1)
{
new ORM:ormid = PlayerInfo[playerid][pORM_ID] = orm_create("accounts");
orm_addvar_string(ormid, PlayerInfo[playerid][pPassword], 128, "Password");
orm_addvar_int(ormid, PlayerInfo[playerid][pKills], "Kills");
orm_addvar_int(ormid, PlayerInfo[playerid][pDeaths], "Deaths");
orm_addvar_int(ormid, PlayerInfo[playerid][pMoney], "Money");
orm_apply_cache();
ShowPlayerDialog(playerid, DIALOG_ACCOUNT_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome to my server", "Please insert your password down below.", "Login", "Exit");
}
else if(!cache_num_rows())
{
ShowPlayerDialog(playerid, DIALOG_ACCOUNT_REGISTER, DIALOG_STYLE_PASSWORD, "Welcome to my server", "Please insert your password down below\nNotice! You'll need to save it to login under this account.", "Register", "Exit");
}
else {}
pawn Code:
if(cache_num_rows())
{
new ORM:ormid = PlayerInfo[playerid][pORM_ID] = orm_create("accounts");
orm_addvar_string(ormid, PlayerInfo[playerid][pPassword], 128, "Password");
orm_addvar_int(ormid, PlayerInfo[playerid][pKills], "Kills");
orm_addvar_int(ormid, PlayerInfo[playerid][pDeaths], "Deaths");
orm_addvar_int(ormid, PlayerInfo[playerid][pMoney], "Money");
orm_apply_cache();
ShowPlayerDialog(playerid, DIALOG_ACCOUNT_LOGIN, DIALOG_STYLE_PASSWORD, "Welcome to my server", "Please insert your password down below.", "Login", "Exit");
}
else ShowPlayerDialog(playerid, DIALOG_ACCOUNT_REGISTER, DIALOG_STYLE_PASSWORD, "Welcome to my server", "Please insert your password down below\nNotice! You'll need to save it to login under this account.", "Register", "Exit");