pBlueG / SA-MP-MySQL

MySQL plugin for San Andreas Multiplayer
BSD 3-Clause "New" or "Revised" License
198 stars 79 forks source link

PawnPlus & MySQL #231

Closed Demon-hash closed 4 years ago

Demon-hash commented 4 years ago
amx_forked(fork_data)
{
CompareKeys = task_new();
amx_forked(.use_data = true)
{
threaded(sync_explicit)
{
thread_sync();
new query[224];
mysql_format(Base, query, sizeof(query), "SELECT u.ID aid, u.Name nm, ui.last_log la_log FROM users u JOIN userinfo ui ON ui.id = u.id WHERE u.kie LIKE '%e%%' GROUP BY ui.aid ORDER BY ui.last_log DESC;", "test");
mysql_tquery(Base, query, "UsersCompareKeys");
}
}
await CompareKeys;
printf("%d", task_get_result(CompareKeys));
task_delete(CompareKeys);
}

Result: [15:01:10] [ERROR] CCallback::Execute - invalid AMX instance

Following the information on how this works, PawnPlus creates a new amx and works with it, because of which the address changes. If you do not use the newly created amx - this loads the processor up to 100%. This is half the code that I showed, I want to use this for significant optimization in future code. Is it possible to add an optional parameter here that will work not only with one amx, but also with the amx that the user enters?

Something like this: mysql_tquery_ext(MySQL:handle, const query[], const callback[] = "", Amx:source = amxthis(), const format[] = "", {Float,}:...);

tr1xy commented 4 years ago

https://pastebin.com/pMnXSMpN