ALS Hook question
#1

just a quick question.

I'm running an intialisation routine during OnGameModeInit OR OnFilterScriptInit in my include.

If I hook both OnGameModeInit and OnFilterScriptInit am I gonna have problems with the initialisation routine running twice on a GM where the person uses a filterscript?

OR

do i need to add a check to see if OnFilterScriptInit has been called yet and prevent it from initialising during OnGameModeInit?
Reply
#2

Same happend to me today. Anyone have answer?
Reply
#3

I don't get you...
But if you mean that you have code for OnGameModeInit and a code for OnFilterScriptInit.
Then you can use this:
PHP код:
#if defined FILTERSCRIPT
public  OnFilterScriptInit()
{
}
#else
public OnGameModeInit()
{
}
#endif 
And of course you must have FILTERSCRIPT defined in you FILTERSCRIPT.

E: you can replace public with hook.
Reply
#4

Only the relevant callback is called. If the script is a gamemode, OGMI is called, if it's a FS, OFSI is called. You don't have to worry about that.
Reply
#5

If you want to hook both callbacks and prevent collision between them, use a boolean to know whether one among them had been called or not. It doesn't usually get called together but there used to be a report that both of them sometimes get called when server loads up.

pawn Код:
new
    g_InitCalled = false;

public OnFilterScriptInit() {

    if(!g_InitCalled) {

        //codes
        g_InitCalled = true;
    }
    return 1;
}

public OnGameModeInit() {

    if(!g_InitCalled) {
   
        //Codes
        g_InitCalled = true;
    }
    return 1;
}
Reply
#6

Partially related: YSI defines hookable OnScriptInit and OnScriptExit callbacks (y_scriptinit)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)