Jump to content

Bazim-287de2db6951663e

NULL pointer to instance

Recommended Posts

Hello, I have this Expansion code in my init.c file:

#ifdef EXPANSIONMODQUESTS
	override void Expansion_OnQuestStart(ExpansionQuest quest)
	{
		switch (quest.GetQuestConfig().GetID())
		{
			case 4:
			{
				SpawnQuestHolder_4000(quest);
			}
			break;
			
			case 5:
			{
				if (!ExpansionQuestModule.GetModuleInstance().IsOtherQuestInstanceActive(4))
					ExpansionQuestModule.GetModuleInstance().DeleteQuestHolder(4000, ExpansionQuestNPCType.AI);
			}
			break;
		}
	}

	override void Expansion_OnQuestCompletion(ExpansionQuest quest)
	{
		switch (quest.GetQuestConfig().GetID())
		{
			case 5:
			{
				if (!ExpansionQuestModule.GetModuleInstance().IsOtherQuestInstanceActive(4))
					ExpansionQuestModule.GetModuleInstance().DeleteQuestHolder(4000, ExpansionQuestNPCType.AI);
			}
			break;
		}
	}
	
	override void Expansion_OnQuestCancel(ExpansionQuest quest)
	{
		if (!quest || !ExpansionQuestModule.GetModuleInstance())
			return;
		
		switch (quest.GetQuestConfig().GetID())
		{
			case 5:
			{
				SpawnQuestHolder_4000(quest);
			}
			break;
		}
	}
	
	protected void SpawnQuestHolder_4000(ExpansionQuest quest)
	{
        if (!quest || !ExpansionQuestModule || !ExpansionQuestModule.GetModuleInstance())
            return;
        
        if (ExpansionQuestModule.GetModuleInstance().TempQuestHolderExists(4000))
            return;
		
		ExpansionTempQuestHolder questHolder = new ExpansionTempQuestHolder(4000, "ExpansionQuestNPCAIFrida", "Marina Sidorova", "There is nothing to do here for you...");
		if (!questHolder)
			return;

		questHolder.SetNPCEmoteID(EmoteConstants.ID_EMOTE_SITA);
		questHolder.SetLoadoutName("SurvivorLoadout");
		ExpansionTempQuestHolderPosition questHolderPos = new ExpansionTempQuestHolderPosition("8548.216797 301.957672 7561.185547", "153.331528 0 -0"); 
		ExpansionQuestModule.GetModuleInstance().SpawnQuestHolder(questHolder, questHolderPos);
	}
#endif

and it throws this error:

 0:05:26 SCRIPT    (E): NULL pointer to instance
Class:      'ExpansionQuestModule'
Function: 'TempQuestHolderExists'
Stack trace:
DayZExpansion/Quests/Scripts/4_World/dayzexpansion_quests\systems\quests\expansionquestmodule.c:5276
$CurrentDir:mpmissions/dayz.enoch/init.c:88
$CurrentDir:mpmissions/dayz.enoch/init.c:42
DayZExpansion/Quests/Scripts/4_World/dayzexpansion_quests\systems\quests\expansionquest.c:372
DayZExpansion/Quests/Scripts/4_World/dayzexpansion_quests\systems\quests\expansionquestmodule.c:1550
DayZExpansion/Quests/Scripts/4_World/dayzexpansion_quests\systems\quests\expansionquestmodule.c:1441
DayZExpansion/Core/Scripts/3_Game/dayzexpansion_core\expansionrpcmanager.c:541
DayZExpansion/Core/Scripts/3_Game/dayzexpansion_core\expansionrpcmanager.c:506
DayZExpansion/Core/Scripts/3_Game/dayzexpansion_core\dayzgame.c:293

can you help me with that? The programmer from Expansion Discord helped me with the lines

        if (!quest || !ExpansionQuestModule || !ExpansionQuestModule.GetModuleInstance())
            return;
        
        if (ExpansionQuestModule.GetModuleInstance().TempQuestHolderExists(4000))
            return;

but it is still not working.

Share this post


Link to post
Share on other sites
  On 2/1/2025 at 11:10 PM, Bazim-287de2db6951663e said:

Hello, I have this Expansion code in my init.c file:

#ifdef EXPANSIONMODQUESTS
	override void Expansion_OnQuestStart(ExpansionQuest quest)
	{
		switch (quest.GetQuestConfig().GetID())
		{
			case 4:
			{
				SpawnQuestHolder_4000(quest);
			}
			break;
			
			case 5:
			{
				if (!ExpansionQuestModule.GetModuleInstance().IsOtherQuestInstanceActive(4))
					ExpansionQuestModule.GetModuleInstance().DeleteQuestHolder(4000, ExpansionQuestNPCType.AI);
			}
			break;
		}
	}

	override void Expansion_OnQuestCompletion(ExpansionQuest quest)
	{
		switch (quest.GetQuestConfig().GetID())
		{
			case 5:
			{
				if (!ExpansionQuestModule.GetModuleInstance().IsOtherQuestInstanceActive(4))
					ExpansionQuestModule.GetModuleInstance().DeleteQuestHolder(4000, ExpansionQuestNPCType.AI);
			}
			break;
		}
	}
	
	override void Expansion_OnQuestCancel(ExpansionQuest quest)
	{
		if (!quest || !ExpansionQuestModule.GetModuleInstance())
			return;
		
		switch (quest.GetQuestConfig().GetID())
		{
			case 5:
			{
				SpawnQuestHolder_4000(quest);
			}
			break;
		}
	}
	
	protected void SpawnQuestHolder_4000(ExpansionQuest quest)
	{
        if (!quest || !ExpansionQuestModule || !ExpansionQuestModule.GetModuleInstance())
            return;
        
        if (ExpansionQuestModule.GetModuleInstance().TempQuestHolderExists(4000))
            return;
		
		ExpansionTempQuestHolder questHolder = new ExpansionTempQuestHolder(4000, "ExpansionQuestNPCAIFrida", "Marina Sidorova", "There is nothing to do here for you...");
		if (!questHolder)
			return;

		questHolder.SetNPCEmoteID(EmoteConstants.ID_EMOTE_SITA);
		questHolder.SetLoadoutName("SurvivorLoadout");
		ExpansionTempQuestHolderPosition questHolderPos = new ExpansionTempQuestHolderPosition("8548.216797 301.957672 7561.185547", "153.331528 0 -0"); 
		ExpansionQuestModule.GetModuleInstance().SpawnQuestHolder(questHolder, questHolderPos);
	}
#endif

and it throws this error:

 0:05:26 SCRIPT    (E): NULL pointer to instance
Class:      'ExpansionQuestModule'
Function: 'TempQuestHolderExists'
Stack trace:
DayZExpansion/Quests/Scripts/4_World/dayzexpansion_quests\systems\quests\expansionquestmodule.c:5276
$CurrentDir:mpmissions/dayz.enoch/init.c:88
$CurrentDir:mpmissions/dayz.enoch/init.c:42
DayZExpansion/Quests/Scripts/4_World/dayzexpansion_quests\systems\quests\expansionquest.c:372
DayZExpansion/Quests/Scripts/4_World/dayzexpansion_quests\systems\quests\expansionquestmodule.c:1550
DayZExpansion/Quests/Scripts/4_World/dayzexpansion_quests\systems\quests\expansionquestmodule.c:1441
DayZExpansion/Core/Scripts/3_Game/dayzexpansion_core\expansionrpcmanager.c:541
DayZExpansion/Core/Scripts/3_Game/dayzexpansion_core\expansionrpcmanager.c:506
DayZExpansion/Core/Scripts/3_Game/dayzexpansion_core\dayzgame.c:293

can you help me with that? The programmer from Expansion Discord helped me with the lines

        if (!quest || !ExpansionQuestModule || !ExpansionQuestModule.GetModuleInstance())
            return;
        
        if (ExpansionQuestModule.GetModuleInstance().TempQuestHolderExists(4000))
            return;

but it is still not working.

Well not matter how and why, I bet that's your code is fine, but DayZ has a bug or you not properly understanding the loading sequence or DZ. The init.c start's BEFORE any other mod, and all code inside the init.c will be executed without support of mods and etc, so all yours "#ifdef EXPANSIONMODQUESTS" amd sub modules from Expansion will failed to operate in yours mission, that's why in most of the cases you will get NULL-POINTER error.

The best how you can fix that is implement addon (idk is it will be the Server or Cliet or even Both sides addon).

I tried to fight with that long time and was failed over and over again.

 

I hope that will give ideas what do you done wrong and suggestions how to override it with the right way.

 

And anyway init.c is not that field where you shall fighting with the mods...

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×