26.01.2015, 17:08
Hi guys! I have a problem.
I just installed my server on mysql plugin (R39-2) with cache and I got a problem. When I enter on server, I always have to register my account again (even if it is already created on mysql table).
I put this in OnPlayerConnect:
This in OnPlayerRequestClass
And this is the CallBack (OnQueryFinish)
Did you see any wrong? Thanks!
I just installed my server on mysql plugin (R39-2) with cache and I got a problem. When I enter on server, I always have to register my account again (even if it is already created on mysql table).
I put this in OnPlayerConnect:
PHP код:
new string[128];
format(string, sizeof(string), "SELECT * FROM `accounts` WHERE `username` = '%s'", plname);
mysql_function_query(dbHandle, string, true, "OnQueryFinish", "ii", THREAD_CHECK_ACCOUNT_CONNECT, playerid);
PHP код:
switch(gPlayerAccount[playerid])
{
case 0: DisplayDialogForPlayer(playerid, 2); //register
case 1: DisplayDialogForPlayer(playerid, 1); //login
}
PHP код:
public OnQueryFinish(resultid, playerid, ConnectionHandle)
{
new szRows, szFields;
if(resultid != THREAD_NO_RESULT)
{
cache_get_data(szRows, szFields);
}
switch(resultid)
{
case THREAD_CHECK_ACCOUNT_CONNECT:
{
if (szRows) {
new data[130];
cache_get_field_content(0, "Registered", data);
PlayerInfo[playerid][pReg] = strval(data);
if (PlayerInfo[playerid][pReg] == 1)
gPlayerLogged[playerid] = 1;
else
gPlayerLogged[playerid] = 0;
} else {
gPlayerLogged[playerid] = 0;
}
}
}
return 1;
}