MySQL Thread - 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: MySQL Thread (
/showthread.php?tid=546864)
MySQL Thread -
Kebab- - 18.11.2014
Hello,
I'm having a problem. I'm running a query which select a username, however the thread takes for ever. So before I even manage to get the username from the thread, my script has already printed out a name which is blank. Now, I'm using a stock and I know that you can print out a message through the thread, but I don't want it done that way. I'm using SetPVar and GetPVar. The thread sets a PVar and the stock sends the PVar to a player.
Thanks.
Re: MySQL Thread -
Simeon87 - 18.11.2014
I suggest that you separate the query and the code that processes the result. Most plugins have an OnQueryFinish callback such as:
Код:
public OnQueryFinish(query[], resultid, extraid, connectionHandle)
{
if(resultid == something)
{
//Process result
}
return 1;
}
This will guarantee that your code will not execute until the query has finished.