Page MenuHomeFeedback Tracker

NULL pointer problem I cannot find out how to solve
Closed, ResolvedPublic

Description

I've made a custom WoodStorage that canhold a few logs and planks. I've appointed it to Contianer_Base and also tried DeployableContainer_Base to verify that I'm not doing anytrhing wrong.
I get a NULL pointer in the CanReveiveAttachment bool as I insert a WoodenLog into the slots.

	override bool CanReceiveAttachment(EntityAI attachment, int slotId)
	{
		PlayerBase player = PlayerBase.Cast( GetGame().GetPlayer() );
		EntityAI item_in_hands = player.GetHumanInventory().GetEntityInHands();

	 	if (item_in_hands != NULL)
	 	{
			if (!super.CanReceiveAttachment(attachment, slotId))
			{
				return false;
			}

	        if (item_in_hands && item_in_hands.IsKindOf("WoodStorage"))
	 	    {
	 	       	return false;
	 	    }

		}
		
		return true;
	}

Also made it that if you carry the WoodStorage , that you cannot fill it up with logs using this line:

	        if (item_in_hands && item_in_hands.IsKindOf("WoodStorage"))
	 	    {
	 	       	return false;

Error in the crashlog say:

NULL pointer to instance
Class:      'WoodStorage'
Entity id:2970718

Function: 'CanReceiveAttachment'
Stack trace:
DO_WoodStorage\Scripts\4_World/woodstorage\woodstorage.c:24 <-Line 24 is the Entity_AI item_in_hands line

Details

Severity
Crash
Resolution
Open
Reproducibility
Always
Operating System
Windows 10 x64
Operating System Version
Latest Server 2019
Category
General
Steps To Reproduce

Placing log into attachment slot makes crash

Event Timeline

Geez closed this task as Resolved.Jun 17 2022, 4:40 PM
Geez claimed this task.
Geez added a subscriber: Geez.

Hello gjvdheuvel.
CanReceiveAttachment is called on server and client
GetGame().GetPlayer() will only return a player on Client, on Server it will return null as it can not know which player was meant

Also, please try to report only issues related to in game problems and bugs, as feedback tracker is not ment for scripting support.
Regards,
Geez

Sorry bout that Geez, thanks for helping! Have a nice weekend