Callback Function not Working - tmysql4

I’m using tsmysql4. I can INSERT and it is successful, however the callback function doesn’t seem to run. This is the same for SELECT - I believe it runs, but can’t check the results as the callback function doesn’t seem to run.

Lobby.Database = SGN.SQLConnect( "", "USERNAME", "PASSWORD", "SGN_Lobby", 3306 )

The below I put in console using lua_run and it INSERTS successfully.

Lobby.Database:Query( "INSERT INTO lobby_server ( game_id, address, active, enabled, participants_id ) VALUES ( 1, '', 1, 1, 1 )", function(result) PrintTable(result) end  )

Here is the code I want to run:

function Lobby.Game.FindServer(id)
	Lobby.Database:Query( "SELECT * FROM lobby_server WHERE game_id = " .. id .. " AND active = 0 AND enabled = 1", function( result )
	        PrintTable( result )
	end )

It does seem to run without an issue, but nothing outputs. I’ve tried print(“WORKED”) in the callback function but that doesn’t run either.

For reference, here is the tmysql4 documentation for queries:

Query from a database

Database:Query( String query, Function callback, Object anything, Boolean ColumnNumbers )

Callback structure

function callback( Table results )

Final note: I have tried running the above query in phpmyadmin ( replacing id with 1 ) and it returns a single row. I have also tried replacing the in-line function with a function name, and that still doesn’t work ( it doesn’t see to be running the function parameter )

If the server is empty, the callbacks won’t run. Add a bot and then it should work.

The server is empty? Do you mean the mysql table or the gmod server?

Gmod server

I’ll give that a try. But really? What if the server’s empty and needs to do a query? Can it not act on the results as there’s no one on the server?

[editline]17th February 2016[/editline]

That’s really strange, I just tried one last time and it worked :confused: even though nothing’s changed. I pressed up in the console to get the last ran command so it was exactly the same. I also then disconnected and it still worked :confused:

Once someone connects, the Tick hook starts to get ran which is what he module uses. Once you disconnect it will stay running.

I think there was a newly added cvar to disable server hibernation, which would allow the module to work when the server firsts starts.

sv_hibernate_think I think is what you want

Thanks a lot. I hadn’t even attempted to join - works fine now :slight_smile:

Thanks for the cvar as well.