Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom Logic #1

Open
Vasily-X opened this issue Oct 30, 2017 · 2 comments
Open

Custom Logic #1

Vasily-X opened this issue Oct 30, 2017 · 2 comments

Comments

@Vasily-X
Copy link

Vasily-X commented Oct 30, 2017

Hello, what kind of logic is this meant for?

// Here is place for custom logic

Is there any way to know which OnGameModeInit is going to be called first? Did you add another callback for that purpose?

Is the call function defined on YSI? May you explain ALS_DO_GroupInit please?

Thank you.

@Vasily-X Vasily-X changed the title Custom Logic Custom logic and include conditions Oct 30, 2017
@Vasily-X Vasily-X changed the title Custom logic and include conditions Custom Logic Oct 30, 2017
@Misiur
Copy link
Contributor

Misiur commented Oct 31, 2017

Hello!

First #include "Y\Y" includes all headers, i.e. in my interpretation files which define all macros, enums, arrays and global variables. After that you can add anything you want and can access those things there, but before "core" Y functionality is defined. So, custom hooks executed before Y GM hooks (so you could stop other hooks if you want and override everything). I'm not good at designing architecture of my code, but in theory I wanted users to leave core Y files alone (to be able to update them easily), and add all custom stuff in this place.

Counting on OnGameModeInit order unfortunately is a russian roulette. You could create an empty public, then create hook right away and include it first, and then it should be executed first. To ensure stuff is executed as I want, I had to create custom callbacks, such as OnGroupInit (executed after groups are created so command permissions are set up correctly).

As for call: I see you've asked on YSI issues here. For example of OnPlayerStats, I had to define it here

Cheers

@Vasily-X
Copy link
Author

Yesterday I've been discussing about this with Southclaws, seems you might call X callback before other hooks just using an ALS hook before using y_hooks. For example, after #if !defined Y_@@@@_HEADER (before including headers - they contain YSI and probably hooks):

#if !defined Y_@@@@_HEADER

        /* --------------------- */
        public OnPlayerConnect(playerid)
        {
	    OnPlayerConnect_First(playerid);
            // OnPlayerConnect_First will be called before any other OnPlayerConnect hooks.

            #if defined my_OnPlayerConnect
                return my_OnPlayerConnect(playerid);
            #else
                return 1;
	    #endif
        }
        #if defined _ALS_OnPlayerConnect
	    #undef OnPlayerConnect
        #else
	    #define _ALS_OnPlayerConnect
        #endif
        #define OnPlayerConnect my_OnPlayerConnect
        #if defined my_OnPlayerConnect
	    forward my_OnPlayerConnect(playerid);
        #endif
      /* --------------------- */

	#include "core\header"

	// [...]

	#define Y_@@@@_HEADER
#elseif !defined Y_@@@@_END

On the other hand, there is a OnScriptInit callback on YSI which is called before any OnGameModeInit or OnFilterScriptInit, doesn't matter how many times you hook it.

I like the Y_@@@@_HEADER and Y_@@@@_END method tho. I'm new to modular PAWN gamemodes, and I'm kinda curious, why are you defining/unefining _inc_header and _inc_impl on each file? Does it have any special effect?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants