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

is this piece of code invalid or outdated?
i've tried debugging it, and its not using the skeleton.

Code:
public OnPlayerConnect(playerid)
{
    print("[Debug] OnplayerConnect is being called.");
    new playerQuery[128]; // Query string.
    GetPlayerName(playerid, playerQuery, sizeof(playerQuery)); // Using on playerQuery to not declare a new expression twice.
    mysql_format(mysql_connectionHandle, playerQuery, sizeof(playerQuery), "SELECT * FROM `accounts` WHERE `username` = '%e'", playerQuery); // mysql format.
    print("[Debug] It checked for the account and calls OnPlayerMysqlFinish");
	mysql_tquery(mysql_connectionHandle, playerQuery, "OnPlayerMysqlFinish", "d", playerid); // mysql tquery is a new mysql thread query, means it will run apart from the server and won't lag if a lot of data is being loaded.
    print("[Debug]	OnPlayerMysqlFinish Passed");
	return 1;
}

Skeleton::OnPlayerMysqlFinish(playerid)
{
	if(cache_num_rows())
	{
	new ORM:ormid = PlayerInfo[playerid][ORM_ID] = orm_create("accounts");
	orm_addvar_string(ormid, PlayerInfo[playerid][Username], MAX_PLAYER_NAME+1, "Username"); // Loading string
	orm_addvar_string(ormid, PlayerInfo[playerid][Password], 128, "Password");
	orm_addvar_int(ormid, PlayerInfo[playerid][Money], "Money");
	orm_addvar_int(ormid, PlayerInfo[playerid][Kills], "Kills");
	orm_addvar_int(ormid, PlayerInfo[playerid][Deaths], "Deaths");
	orm_setkey(ormid, "Username");
	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");
	return 1;
}
(using the latest mysql plugin)
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: 1 Guest(s)