Jump to content

How to get this item to work in multiplayer?


Recommended Posts

So I was fixing up an outdated broken mod (For personal use) and the item that comes with it doesnt work in the slightest.

local assets={     Asset("ANIM", "anim/item.zip"),    Asset("ANIM", "anim/swap_item.zip"),     Asset("ATLAS", "images/inventoryimages/item.xml"),}local prefabs = {}local function fn(sim)    local function OnEquip(inst, owner)         owner.AnimState:OverrideSymbol("swap_object", "swap_item", "swap_spear")        owner.AnimState:Show("ARM_carry")         owner.AnimState:Hide("ARM_normal") 		    end    local function OnUnequip(inst, owner)         owner.AnimState:Hide("ARM_carry")         owner.AnimState:Show("ARM_normal") 		    end    local inst = CreateEntity()    local trans = inst.entity:AddTransform()    local anim = inst.entity:AddAnimState()    MakeInventoryPhysics(inst)        anim:SetBank("spear")    anim:SetBuild("item")    anim:PlayAnimation("idle")        if not TheWorld.ismastersim then        return inst    end    	inst:AddComponent("weapon")  inst.components.weapon:SetDamage(40.8)    inst:AddComponent("inspectable")            inst:AddComponent("inventoryitem")    inst.components.inventoryitem.atlasname = "images/inventoryimages/item.xml"        inst:AddComponent("equippable")    inst.components.equippable:SetOnEquip( OnEquip )    inst.components.equippable:SetOnUnequip( OnUnequip )	    return instendreturn  Prefab("common/inventory/item", fn, assets, prefabs)

You see when I spawn (Not as host.), I dont start with the item and one item slot has to be free at all times (Like it's there.), and when it is spawned with commands it's shows up, however, when it's picked up it doesn't show up in the hand slot. (Despite showing up on the character.)

 

Any help would be appreciated.

Link to comment
Share on other sites

@Laidbackuser:

No AddNetwork(), no client item.

local assets = { 	Asset("ANIM", "anim/item.zip"),	Asset("ANIM", "anim/swap_item.zip"), 	Asset("ATLAS", "images/inventoryimages/item.xml"),}local function OnEquip(inst, owner) 	owner.AnimState:OverrideSymbol("swap_object", "swap_item", "swap_spear")	owner.AnimState:Show("ARM_carry")	owner.AnimState:Hide("ARM_normal")endlocal function OnUnequip(inst, owner) 	owner.AnimState:Hide("ARM_carry")	owner.AnimState:Show("ARM_normal")endlocal function fn()	local inst = CreateEntity()	inst.entity:AddTransform()	inst.entity:AddAnimState()	inst.entity:AddNetwork()	MakeInventoryPhysics(inst)	inst.AnimState:SetBank("spear")	inst.AnimState:SetBuild("item")	inst.AnimState:PlayAnimation("idle")	inst.entity:SetPristine()	if not TheWorld.ismastersim then		return inst	end	inst:AddComponent("weapon")	inst.components.weapon:SetDamage(40.8)	inst:AddComponent("inspectable")	inst:AddComponent("inventoryitem")	inst.components.inventoryitem.atlasname = "images/inventoryimages/item.xml"	inst:AddComponent("equippable")	inst.components.equippable:SetOnEquip(OnEquip)	inst.components.equippable:SetOnUnequip(OnUnequip)	return instendreturn Prefab("common/inventory/item", fn, assets)
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...