[Tutorial] Account system with MySQL [R34][ORM]
#2

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:
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 {}
It can become:
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");
Good effort though.
Reply


Messages In This Thread
Account system with MySQL [R34][ORM] - by BullseyeHawk - 07.02.2014, 10:41
Re: Account system with MySQL [R34][ORM] - by Konstantinos - 07.02.2014, 10:56
Re: Account system with MySQL [R34][ORM] - by BullseyeHawk - 07.02.2014, 13:59
Re: Account system with MySQL [R34][ORM] - by iZN - 07.02.2014, 14:23
Re: Account system with MySQL [R34][ORM] - by Konstantinos - 07.02.2014, 14:38
Re: Account system with MySQL [R34][ORM] - by BullseyeHawk - 07.02.2014, 15:07
Re: Account system with MySQL [R34][ORM] - by Dorito - 08.02.2014, 06:00
Re: Account system with MySQL [R34][ORM] - by Lordzy - 08.02.2014, 06:37
Re: Account system with MySQL [R34][ORM] - by yvoms - 08.11.2015, 15:25

Forum Jump:


Users browsing this thread: 2 Guest(s)