11.03.2015, 14:41
If you want to keep your logic coupled, I recommend using y_inline from YSI:
pawn Код:
#include <YSI\y_va>
#include <YSI\y_inline>
#include <a_mysql>
//(...)
public OnPlayerConnect(playerid)
{
new
query[64]
;
mysql_format(dbHandle, sizeof(query), "SELECT job FROM `players` WHERE `userid` = %d", hereID);
inline YourHandle() {
new
rows = cache_get_row_count(dbHandle)
;
//Playerid is still available here!
if (!rows) {
va_SendClientMessage(playerid, 0xBADA55AA, "Sorry, there is not a single job for player %d", hereID);
return;
}
new
jobID
;
for (new row = 0; row != rows; ++i) {
jobID = cache_get_field_content_int(0, "job", dbHandle);
printf("Fetched job %d", jobID);
}
}
mysql_tquery_inline(dbHandle, query, using inline Yourhandle, "");
//Watch out, outside that inline you can't be sure that the query was already finished
}