Jump to content

"itemget" event for backpack


Recommended Posts

local function Test(inst)
	inst:ListenForEvent("itemget", function(inst, data)   -- "itemget" only work in player inventory. 
		print(data.item.prefab)
	end)	
end

local function pfn(player)
	player:DoTaskInTime(1,function() 
		local inst = _G.ThePlayer
		if not inst or not inst.components.playercontroller then
			player:DoTaskInTime(1,function() pfn(player) end)
			return
		end
		Test(inst)		
	end)
end
AddPlayerPostInit(pfn)

I have a problem. "itemget" event only trigger when item going in player inventory and not trigger when item going in backpack. So do we have event which will work on both player inventory and backpack? And the mod I'm working on is "client_only_mod". Thank in advance.

Link to comment
Share on other sites

4 hours ago, BluesyBuesy said:

gotnewitem works. 

I have problem with gotnewitem now. 

inst:ListenForEvent("gotnewitem", function(inst, data)

inst:ListenForEvent("gotnewitem", function(inst, data)
		if data then print("data") end 
		if data.item then print("data.item") end
		if data.slot then print("data.slot") end
		if data.src_pos then print("data.src_pos") end  -- data.src_pos = nil on host. But it's work fine on dedicated server.
end)

data.src_pos = nil on host. But it's work fine on dedicated server.

And the second question is AddStategraphPostInit for "wilson_client" not work on host too. So any idea? 
And I'm working on client_only_mod. Thank in advance.

Link to comment
Share on other sites

22 minutes ago, zUsername said:

I have problem with gotnewitem now. 

inst:ListenForEvent("gotnewitem", function(inst, data)


inst:ListenForEvent("gotnewitem", function(inst, data)
		if data then print("data") end 
		if data.item then print("data.item") end
		if data.slot then print("data.slot") end
		if data.src_pos then print("data.src_pos") end  -- data.src_pos = nil on host. But it's work fine on dedicated server.
end)

data.src_pos = nil on host. But it's work fine on dedicated server.

And the second question is AddStategraphPostInit for "wilson_client" not work on host too. So any idea? 
And I'm working on client_only_mod. Thank in advance.

It's probable that it's a bug. I came across this issue myself a while back:

Whatever they did fixed the issue enough for my purposes, but you might want to submit another thread in the bug tracker.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
  • Create New...