SA-MP Forums Archive
MySQL problem - 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 problem (/showthread.php?tid=374822)



MySQL problem - Dan.. - 04.09.2012

Hello!

I'm using MySQL R7 plugin and this is my problem: Whenever I call "rcon gmx" or "rcon exit" I have to save using MySQL all in-game data like factions, gang zones, players, vehicles and some other settings. But, if I do that in OnGameModeExit using the mysql_function_query function, it'll start another thread which will end later than the one in which OnGameModeExit is running, so the server will close before all queries are executed/data is saved.
Could you give me any idea about how I can work this out? I need to find a way to sleep the server thread while MySQL queries are executed.
I asked a few more guys and followed some other threads about this issue, but there was no solution that actually works. I've been trying to use a while (!...) { }, where ... was a function that would check if all queries have finished, but I found out that it freezes everything.

Thank you very much!


Re: MySQL problem - Deal-or-die - 04.09.2012

Once it's called could you create a timer for 5seconds or what ever while it saves then closes?


Re: MySQL problem - Dan.. - 05.09.2012

Quote:
Originally Posted by Deal-or-die
Посмотреть сообщение
Once it's called could you create a timer for 5seconds or what ever while it saves then closes?
I don't know what interval to set for that timer. I'm afraid if there are some lag spikes data might not be saved.


Re: MySQL problem - Deal-or-die - 05.09.2012

You're not really in too much of a rush when GMXing or exiting, so I think 10-15 seconds should do the trick.


Re: MySQL problem - Edvin - 05.09.2012

"OnGameModeExit using the mysql_function_query function, it'll start another thread which will end later than the one in which OnGameModeExit is running, so the server will close before all queries are executed/data is saved. "

This problem I have too ... with Gang Zones / Teritories.