15.01.2013, 11:37
Hey guys, not often I create one of these threads, but I'm very interested in the cache and function query system that R7 offers. So here's my problem.
I re-scripted everything in our script to use both of these together, yet we hit some MAJOR issues. Everything seems to work fine at first, but after a while, some player accounts seem to go missing and reset themselves / get replaced by someone elses.
I THINK the problem is with the cache system, in that it doesn't queue requests into the cache. Therefore, if MySQL function queries were to co-inside with each other at the same time, they might get playerfiles mixed up / reset with someone who is registering.
If anyone has any other suggestions, please let me know, but I think it's an issue that BlueG himself may need to fix.
Thanks in advance.
EDIT: Some examples of the code shown below.
I re-scripted everything in our script to use both of these together, yet we hit some MAJOR issues. Everything seems to work fine at first, but after a while, some player accounts seem to go missing and reset themselves / get replaced by someone elses.
I THINK the problem is with the cache system, in that it doesn't queue requests into the cache. Therefore, if MySQL function queries were to co-inside with each other at the same time, they might get playerfiles mixed up / reset with someone who is registering.
If anyone has any other suggestions, please let me know, but I think it's an issue that BlueG himself may need to fix.
Thanks in advance.
EDIT: Some examples of the code shown below.
pawn Код:
if(!doesFileAccountExist(playername2))
{
print("[DEBUG] Logging into SQL Account");
format(query,sizeof(query),"SELECT * FROM `users` WHERE `Username` = '%s';",playername2);
mysql_function_query(mysql_connection, query, true, "OnSQLPasswordCheck", "is", playerid, password);
return 1;
}
pawn Код:
forward OnSQLPasswordCheck(playerid, password[]);
public OnSQLPasswordCheck(playerid, password[])
{
new rows, fields, string[128], query[256];
cache_get_data(rows, fields);
if(rows)
{
new playername2[24];
GetPlayerName(playerid,playername2,sizeof(playername2));
new TempStr[126];
cache_get_field_content(0, "Key", TempStr);
strmid(PlayerInfo[playerid][pKey], TempStr, 0, strlen(TempStr), 255);
if(strcmp(PlayerInfo[playerid][pKey],password,true) == 0)
{
format(query,sizeof(query),"SELECT * FROM `users` WHERE `Username` = '%s';",playername2);
mysql_function_query(mysql_connection, query, true, "OnSQLPlayerLogin", "i", playerid);
SetPVarInt(playerid, "FirstSpawn", 0);
}
else
{
ShowMainMenuDialog(playerid, 3);
gPlayerLogTries[playerid] += 1;
if(gPlayerLogTries[playerid] == 2) { SendClientMessageEx(playerid, COLOR_RED, "Wrong password, you have been kicked out automatically."); Kick(playerid); }
return 1;
}
}
return 1;
}
pawn Код:
public OnSQLPlayerLogin(playerid)
{
new tmp2[256];
new playername2[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername2, sizeof(playername2));
new rows, fields, string[128], string2[128];
cache_get_data(rows, fields);
if(rows)
{
new temp[12];
cache_get_field_content(0, "Level", temp), PlayerInfo[playerid][pLevel] = strval(temp);
cache_get_field_content(0, "AdminLevel", temp), PlayerInfo[playerid][pAdmin] = strval(temp);
cache_get_field_content(0, "Band", temp), PlayerInfo[playerid][pBanned] = strval(temp);
cache_get_field_content(0, "PermBand", temp), PlayerInfo[playerid][pPermaBanned] = strval(temp);
cache_get_field_content(0, "Warnings", temp), PlayerInfo[playerid][pWarns] = strval(temp);
}
}