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

Solved [L4D2]Database not connecting until player connects


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Morning
Member
Join Date: May 2021
Old 01-26-2024 , 06:35   [L4D2]Database not connecting until player connects
Reply With Quote #1

I'm connecting to mysql database using threaded connection OnPluginStart(). In my connect callback, I have function to retreive some test data with SQL_TQuery which inserts into some global vars and then PrintToConsole to test that it ran.

My problem is, when I launch my server, none of these functions seem to run. It's only when a client connects that the database decides to connect and function as it should. I need this data before any players connect - am I doing something wrong? I've tried this with non-threaded connect/query and it works as expected.

I've made a little progress - it seems because the server is booting up in hibernation mode. Once the server is running and I check "sm_cvar sv_hibernate_when_empty" it returns 1. If I switch it off, it boots and connects to the database. I've added "sm_cvar sv_hibernate_when_empty 0" however, when the server starts first time and runs the configs, it automatically goes into back into hibernation:
Code:
[SM] Changed cvar "sv_hibernate_when_empty" to "0".
Server waking up from hibernation
[SM] Changed cvar "sv_allow_wait_command" to "0".
[SM] Changed cvar "sv_pausable" to "0".
[SM] Changed cvar "sv_voiceenable" to "1".
[SM] Changed cvar "sv_alltalk" to "1".
Server is hibernating
How would I go about starting out of hibernation mode the first time the server boots. Seems like it wants to force itself into hibernation mode on it's first boot and that means I can't even set up a timer to force it to unhibernate.

edit: well, I noticed that after server was forcing itself into hibernation, the l4d2 event round_end was firing. So I hooked it and set "sm_cvar sv_hibernate_when_empty 0" there, which works to wake it up and launch database functions. It's messy but it works for now.

Last edited by Morning; 02-02-2024 at 08:05.
Morning is offline
Bacardi
Veteran Member
Join Date: Jan 2010
Location: mom's basement
Old 01-26-2024 , 11:18   Re: [L4D2]Database not connecting until player connects
Reply With Quote #2

yes. place sm_cvar sv_hibernate_when_empty 0 in ...cfg/sourcemod/sourcemod.cfg it should work

Last edited by Bacardi; 01-26-2024 at 11:18.
Bacardi 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 00:43.


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