Returning data using threaded queries? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Returning data using threaded queries? (
/showthread.php?tid=622227)
Returning data using threaded queries? -
TwinkiDaBoss - 20.11.2016
Alright so I've been thinking about this, is it even possible to retrieve data from the Tqueries directly from the command itself? For example
(example code)
pawn Код:
CMD:test(playerid,params[]) {
new query[128];
mysql_format(mysql,query,sizeof(query),"SELECT * FROM sometable");
mysql_tquery(mysql,query,"onSomeResponse","i",playerid);
//How to get onSomeResponse return here?
return true;
}
public onSomeResponse(playerid) {
if(rows bla bla bla) {
return true;
}
return false;
}
I've tried YSI inline but couldnt really do much with it, response would still be un-accessiable.
Re: Returning data using threaded queries? -
X337 - 20.11.2016
No, you can't. But you can still do that by using mysql_query().
Example:
Код:
CMD:test(playerid,params[]) {
new query[128], Cache:qcache;
mysql_format(mysql,query,sizeof(query),"SELECT * FROM sometable");
qcache = mysql_query(mysql, query, true); // Remember to save the cache into a variable so you can delete this later to free up your memory
// ... cache_ stuff here
cache_delete(qcache);
return true;
}
Inline example: (You need y_inline from YSI to use tquery_inline)
Код:
CMD:test(playerid,params[]) {
new query[128];
inline InlineCallback(bla)
{
// ... cache_ stuff here
}
mysql_format(mysql,query,sizeof(query),"SELECT * FROM sometable");
mysql_tquery_inline(mysql, query, using inline InlineCallback, "d", playerid);
return true;
}