General > Developers Corner

Load functions only when server.cfg has been read?

<< < (2/3) > >>

Timmy:
The code you posted works okay.

The functions are not being called because servers go to sleep when they don't have any players. You can prevent this from happening by adding sv_hibernate_think 1 to your server.cfg. It is not required though: the server will connect to the database as soon as a player joins anyway. :)

Luk | twitch.tv/doctorluk:
Yeeehaaa! Thank you very much!

I was only able to work with the scripts and monitor the server's log file when I wasn't home. Now it all makes sense again  ;D ;D

EDIT: Regarding your recent EDIT: Everything works fine now. db is defined inside the whole script now since these functions that use the database are only called when players are actively playing, which implies that a connection has been made before.
EDIT2: And that EDIT of yours is gone xD

Timmy:
Yay, glad to hear things are working now. ;D


--- Quote from: Luk | twitch.tv/doctorluk on December 19, 2016, 11:14:08 AM ---EDIT: Regarding your recent EDIT: Everything works fine now. db is defined inside the whole script now since these functions that use the database are only called when players are actively playing, which implies that a connection has been made before.
--- End quote ---
Great! I removed that edit after I noticed you had already replied. I figured that issue would also be solved by 'waking' the server. Didn't think you would notice. :P

An Error Has Occurred!

array_keys(): Argument #1 ($array) must be of type array, null given

[0] Board index

Go to full version