08.11.2015, 15:25
is this piece of code invalid or outdated?
i've tried debugging it, and its not using the skeleton.
(using the latest mysql plugin)
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; }