Q: MySQL
#8

This is what I do

Quote:

public OnPlayerRequestClass(playerid, classid)
{
if(IsPlayerNPC(playerid)) return 1;

if (!PlayerData[playerid][pAccount] && !PlayerData[playerid][pKicked])
{
/*new
time[3];

gettime(time[0], time[1], time[2]);
SetPlayerTime(playerid, time[0], time[1]);*/

PlayerData[playerid][pAccount] = 1;
TogglePlayerSpectating(playerid, 1);

SetPlayerColor(playerid, DEFAULT_COLOR);
SetTimerEx("AccountCheck", 400, false, "d", playerid); // 400 ms
}
return true;
}

Quote:

forward AccountCheck(playerid);
public AccountCheck(playerid)
{
//SetPlayerPos(playerid, -1988.752075, -72.294998, 38.647026);
//SetPlayerCameraPos(playerid, -1988.752075, -72.294998, 58.647026);
//SetPlayerCameraLookAt(playerid, -2006.489868, -72.107597, 55.977474);

SetCameraData(playerid);
SQL_CheckAccount(playerid);
return true;
}

Quote:

SQL_CheckAccount(playerid)
{
new
query[128];

format(query, sizeof(query), "SELECT `Username` FROM `characters` WHERE `Character` = '%s'", ReturnName(playerid));
mysql_tquery(g_iHandle, query, "OnQueryFinished", "dd", playerid, THREAD_FIND_USERNAME);
}

Quote:

OnQueryFinished
..
case THREAD_FIND_USERNAME:
{
static
query[1000]; // previous: 128

cache_get_row_count(rows);
cache_get_field_count(fields);

if (rows)
{
new
name[MAX_PLAYER_NAME + 1];

cache_get_value_index(0, 0, name);

if (strcmp(name, PlayerData[extraid][pUsername], false) != 0)
{
format(PlayerData[extraid][pUsername], sizeof(name), name);
SetPlayerName(extraid, name);
}
}
format(query, sizeof(query), "SELECT * FROM `accounts` WHERE `Username` = '%s'", PlayerData[extraid][pUsername]);
mysql_tquery(g_iHandle, query, "OnQueryFinished", "dd", extraid, THREAD_CHECK_ACCOUNT);
}

Quote:

case THREAD_CHECK_ACCOUNT:
{
//cache_get_data(rows, fields, g_iHandle);
cache_get_row_count(rows);
cache_get_field_count(fields);

if (rows)
{
static
loginDate[36];

cache_get_value_index(0, 0, loginDate);

format(PlayerData[extraid][pLoginDate], 36, loginDate);

PlayerData[extraid][pExam] = cache_get_field_int(0, "Exam");

cache_get_value_name(0, "SecurityQuestion1", PlayerData[extraid][pSecurityQuestion1], 12;
cache_get_value_name(0, "SecurityAnswer1", PlayerData[extraid][pSecurityAnswer1], 65);

cache_get_value_name(0, "SecurityQuestion2", PlayerData[extraid][pSecurityQuestion2], 12;
cache_get_value_name(0, "SecurityAnswer2", PlayerData[extraid][pSecurityAnswer2], 65);

cache_get_value_name(0, "SecurityQuestion3", PlayerData[extraid][pSecurityQuestion3], 12;
cache_get_value_name(0, "SecurityAnswer3", PlayerData[extraid][pSecurityAnswer3], 65);

Dialog_Show(extraid, LoginScreen, DIALOG_STYLE_PASSWORD, "Account Login", "Welcome back to Asauth RPG!\n\nYour account was last seen on: %s.\n\nPlease enter your password below to login to your account:", "Login", "Cancel", PlayerData[extraid][pLoginDate]);
}
else
{
Dialog_Show(extraid, RegisterScreen, DIALOG_STYLE_PASSWORD, "Account Registration", "Welcome to Asauth RPG, %s.\n\nNotice: Your account is not registered yet. Please enter your desired password:", "Register", "Cancel", ReturnName(extraid));
}
}

In the logs it says no active cache, which could be the factor why the exam system keeps detecting that the player pExam value is 0..
Reply


Messages In This Thread
Q: MySQL - by Uberanwar - 25.06.2018, 20:58
Re: Q: MySQL - by Calisthenics - 25.06.2018, 21:32
Re: Q: MySQL - by Uberanwar - 25.06.2018, 23:25
Re: Q: MySQL - by div - 26.06.2018, 03:05
Re: Q: MySQL - by Sew_Sumi - 26.06.2018, 05:18
Re: Q: MySQL - by Calisthenics - 26.06.2018, 07:04
Re: Q: MySQL - by GTLS - 26.06.2018, 08:19
Re: Q: MySQL - by Uberanwar - 06.07.2018, 06:58
Re: Q: MySQL - by Calisthenics - 06.07.2018, 07:10
Re: Q: MySQL - by Uberanwar - 06.07.2018, 07:29

Forum Jump:


Users browsing this thread: 2 Guest(s)