I'm updating some old gamemode, and I have situation like this:
pawn Код:
new
LevelOfMudkipLikeness[MAX_PLAYERS char] = { 0, ... };
public OnPlayerConnect(playerid)
{
inline DatHandler()
{
if(cache_num_rows()) {
LevelOfMudkipLikeness{playerid} = cache_get_row_int(0, 0, handle);
}
}
mysql_tquery_inline(handle, "SELECT mudkipzlove FROM foobar WHERE 1 = 1", using inline DatHandler, "");
return 1;
}
public OnPlayerRequestClass(playerid, classid)
{
if(LevelOfMudkipLikeness{playerid} > 69) {
//do something
}
return 1;
}
I can't do anything about the callback structure. I must have the variable ready in OPRC. Now, often the query isn't finished before OnPlayerRequestClass, so the condition fails, even though player likes mudkipz. How can I make sure that the query was executed? I have few propositions:
1.
Unthreaded query. Though, I'm afraid of server choking on that
2. While loop in OPRC, waiting for some another variable like "queryfinished" - again, server choking hazard
3. mysql_unprocessed_queries, but the information is too vague, and some other query might be running
Suggestions are very welcome
@down: ah, that's what I meant to write in 1, thanks