SA-MP Forums Archive
An mysql query every 1 sec per all_players? - 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: An mysql query every 1 sec per all_players? (/showthread.php?tid=603459)



An mysql query every 1 sec per all_players? - Metharon - 23.03.2016

Ok my question is: If i make a mysql query that check in database which player has 'ToBeKicked = 1' every 1 second, does that function would make lag on server?


Re: An mysql query every 1 sec per all_players? - Abagail - 23.03.2016

Calling a query for every player every second will obviously cause problems. Instead of fetching that type of data from a database, you can directly act on such changes through the Socket plugin(here). The thread contains usage/documentation.


Re: An mysql query every 1 sec per all_players? - Golden96 - 23.03.2016

Yes. It will. It'll also cause other queries you do to get bottlenecked and could take a while for that query to be processed if there's a constant queue.

Why do you need that in the database? Can't you use a variable for it?


Re: An mysql query every 1 sec per all_players? - AmigaBlizzard - 23.03.2016

When do you insert that value in the database?
When the player is online or offline?

In case he's online, just kick him immediately instead of saving a 1 in the database and query it every second.

In case he's offline and should be kicked upon connecting, you can simply read the value during OnPlayerConnect and if it's a 1, kick him.

There is no need to run such a query every second per player.


Re: An mysql query every 1 sec per all_players? - Yashas - 24.03.2016

Why do you even want to use MySQL? Why not simply keep an array, ToBeKicked[MAX_PLAYERS]?

Maybe you want to kick from your control panel? If that is the case, use the Sockets plugin. If you are new to sockets, use SAMP's query mechanism to send RCON commands.