View Single Post
Author Message
gromit190
Junior Member
Join Date: Jun 2019
Old 11-24-2022 , 15:00   Database.Connect callback is not invoked until i unload plugin?
Reply With Quote #1

Hello,

I am following the example from the docs:

Code:
Database hDatabase = null;
 
void StartSQL()
{
    Database.Connect(GotDatabase);
}
 
public void GotDatabase(Database db, const char[] error, any data)
{
    PrintToServer("Got database2"); // <--- this won't actually happen until I do: sm plugins unload myplugin
    if (db == null)
    {
        LogError("Database failure: %s", error);
    } 
    else 
    {
        hDatabase = db;
    }
}
But, for some odd reason, the "GotDatabase" is not invoked unless I unload the plugin.

In the GotDatabase function I am calling "PrintToServer", and also I am inserting a row to the db. I monitor both the server console, and the table in the db and nothing happens UNLESS I unload the plugin.

What am I doing wrong?

Last edited by gromit190; 11-24-2022 at 15:00.
gromit190 is offline