SA-MP Forums Archive
[Question] Connect to MYSQL in an include - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Question] Connect to MYSQL in an include (/showthread.php?tid=251887)



[Question] Connect to MYSQL in an include - Biesmen - 29.04.2011

I'm working on an include, but I need to connect to MYSQL in that include.
Is it possible to do that?

If yes, how to? Because OnGameModeInit will only get called by the GM itself.

Thanks


Re: [Question] Connect to MYSQL in an include - Vince - 29.04.2011

Quote:
Originally Posted by Biesmen
Посмотреть сообщение
If yes, how to? Because OnGameModeInit will only get called by the GM itself.
Not true.


Re: [Question] Connect to MYSQL in an include - Ash. - 29.04.2011

If you wanted to do it "OnGameModeInit" - why not just hook OnGameModeInit to suit your needs? OR create a stock with no arguments, and just run that in "OnGameModeInit"

eg;
pawn Код:
//In your include
stock MySQL_Connect()
{
     //Connect to sql here
}

//In GM script
public OnGameModeInit()
{
     MySQL_Connect();
     //rest of gminit
}



Re: [Question] Connect to MYSQL in an include - iggy1 - 29.04.2011

Just incase you want to use the ALS hooking method (this way you wont need to do anything outside of the include).

Inside the include
pawn Код:
public OnGameModeInit()
{
    // do stuff here above the funcidx function

    if (funcidx("ig_OnGameModeInit") != -1)
        return CallLocalFunction("ig_OnGameModeInit", "");
    return 1;
}

#if defined _ALS_OnGameModeInit
    #undef OnGameModeInit
#else
    #define _ALS_OnGameModeInit
#endif
#define OnGameModeInit ig_OnGameModeInit
forward ig_OnGameModeInit();



Re: [Question] Connect to MYSQL in an include - Biesmen - 29.04.2011

After I posted this I found the hooking method, I used that.
Thanks