Raised This Month: $51 Target: $400
 12% 

client_disconnected() <-> plugin_end()


Post New Thread Reply   
 
Thread Tools Display Modes
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 05-21-2019 , 02:58   Re: client_disconnected() <-> plugin_end()
Reply With Quote #11

The only things you can do at this point are:
  1. Get a faster MySQL server/closer to your game server for faster queries
  2. Re-design plugin logic to not require saving upon disconnect
  3. Improve the query to update multiple rows at once (so on server_changelevel() you would build a big query to save everything, and then don't do any queries on client_disconnected() calls that follow
__________________
hleV is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 05-21-2019 , 03:43   Re: client_disconnected() <-> plugin_end()
Reply With Quote #12

Thanks hlev, but what is the meaning of big query? Maybe doing 'update' in for loop of online players?

If mp_chattime is working before server changelevel/plugin_end, that can help for some things
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 05-21-2019 , 05:05   Re: client_disconnected() <-> plugin_end()
Reply With Quote #13

Yes, you'd be looping through all players and building the query string accordingly.

Something like this might work. Basically you'll build a single query for all the players in the server.

Code:
new bool:ChangingLevel = false; public server_changelevel() {     ChangingLevel = true;     // Big query } public client_disconnected(client) {     if (ChangingLevel)         return;     // Normal query }
__________________
hleV is offline
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 05-21-2019 , 05:06   Re: client_disconnected() <-> plugin_end()
Reply With Quote #14

Quote:
Originally Posted by JocAnis View Post
Problem isnt solved...i removed updating rows on mapchange, but present error is:
Code:
Thread worker was unable to start
When does this error get thrown? At mapchange? Map start? First query? At any random point in time?
__________________
klippy is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 05-21-2019 , 06:45   Re: client_disconnected() <-> plugin_end()
Reply With Quote #15

@klipica on mapchange that error was happening..but i guess adding bool to server_changelevel and checking it before sql_threadquery is fix for this (also see the idea about mp_chattime, i think it can help here)

@hlev thanks for the link, but i think doing bigger query in server_changelevel (30 players almost every time) cant be faster than executing plugin_end after server_changelevel, if you know what i mean :/
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)

Last edited by JocAnis; 05-21-2019 at 06:47.
JocAnis is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 05-21-2019 , 09:59   Re: client_disconnected() <-> plugin_end()
Reply With Quote #16

Quote:
Originally Posted by JocAnis View Post
@hlev thanks for the link, but i think doing bigger query in server_changelevel (30 players almost every time) cant be faster than executing plugin_end after server_changelevel, if you know what i mean :/
One big query on mapchange should be more optimal than 30 queries (because client_disconnected() in your case will be called ~30 times before map changes).
__________________
hleV is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 05-21-2019 , 10:13   Re: client_disconnected() <-> plugin_end()
Reply With Quote #17

yeah that is right
but i was reffering to other time intervals:

time of: server_changeleve to plugin_end()
time of: one_big_query to plugin_end()

just hoping server_changelevel is called after passing mp_chattime "seconds"
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 05-22-2019 , 08:13   Re: client_disconnected() <-> plugin_end()
Reply With Quote #18

Can something happen between server_changelevel() and plugin_end() that you would want to save to the database? If so you can simply mark that map is changing, but do the big query on plugin_end().

Code:
new bool:ChangingLevel = false; public server_changelevel() {     ChangingLevel = true; } public plugin_end() {     // Big query } public client_disconnected(client) {     if (ChangingLevel)         return;     // Normal query }
__________________
hleV is offline
JocAnis
Veteran Member
Join Date: Jun 2010
Old 05-22-2019 , 17:56   Re: client_disconnected() <-> plugin_end()
Reply With Quote #19

im a little bad for iLen += format so i still cant make that big query

just more information about the problem:
plugin is being used in DeathrMatch FreeForAll (almost all the time 30/32 players)
so on that server query of UPDATE (kills for attacker and deaths for victim) are being sent every second or even faster, cuz killing are done every moment...so the problem is: duplicated rows in the table (i thought it was of nick characters) but im 90% it is 'slow' connection signal from cs server to mysql databases...so every query is being late for some moments, and before that one is finished, another one is sent and like that in loop...so at mapchange (even with bool at mapchange/server_changelevel) invalid handle is happening (already sent quries arent executed 100%)...

maybe changing to some 'faster' mysql database server is the solution...or that big query, but im not sure anymore :/
__________________
KZ Public Autocup - PrimeKZ

My blog: http://primekz.xyz (in progress...) - not active (dec 2022)
JocAnis is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 05-23-2019 , 07:42   Re: client_disconnected() <-> plugin_end()
Reply With Quote #20

Then don't save on every kill/death. Just save on disconnect AND mapchange. This will only be a problem if server crashes, in which case latest data of connected players won't be saved.
__________________
hleV is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 11:39.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode