Modding - Script Callback issue

Arszi
Scavenger
Posts: 36
Joined: 04 Jan 2018, 06:45

Modding - Script Callback issue

Postby Arszi » 17 Mar 2018, 08:58

I ran into an issue with "actor_on_before_death" script callback.
I register my callback method in on_game_start, based on the Azazeal game mod, but sometimes my actor_on_before_death does not trigger at all, like the subscribtion is lost somehow. If I reload my saved game, then it works again.

I want to re-subscribe the actor_on_before_death in on_game_load, if the subscribtion is lost, because this event triggers both on entering a new map and reloading a game.

My question is: Is it possible to check, if my subscribtion for actor_on_before_death for example, is still exists?

I do not want to subscribe it twice, but can not attempt to remove the subscribtion either, because it yield a nullreference exception, if I attempt to remove a non-existing subscribtion.

sLoPpYdOtBiGhOlE
Scavenger
Posts: 36
Joined: 12 Jun 2017, 23:44

Re: Modding - Script Callback issue

Postby sLoPpYdOtBiGhOlE » 18 Mar 2018, 08:32

Hi,
Just use UnregisterScriptCallback before calling RegisterScriptCallback again from the on_game_load event.

UnregisterScriptCallback checks if the callback is registered before unregistering it.
So even if the callback isn't registered it won't do any harm.

And yep the callbacks are not working as expected all the time which I reported a while ago in the bugs thread with a full example showing what's wrong.

Arszi
Scavenger
Posts: 36
Joined: 04 Jan 2018, 06:45

Re: Modding - Script Callback issue

Postby Arszi » 18 Mar 2018, 11:56

Thank you very much! I moved my subscribtion into on_game_load. Let's hope that it solves my issue.


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest