orlyx

My mod is unstable in multiplayer

Recommended Posts

orlyx    1

I made character and weapons mod. In single player this mod works very good. I send this file for my friend an he said that when he play with his friend his game crash when not host select mod character and use special weapons.

QrchuckRemastered0.1.rar

Share this post


Link to post
Share on other sites
Ultroman    398
Posted (edited)

Your weapons are lacking both the SetPristine() call and an ismastersim check before adding all the components. Only the server needs components added. The clients are just a "shell".

As an example, your t0 weapon's fn() should be changed like so:

local function fn(colour)
	local inst = CreateEntity()
	local trans = inst.entity:AddTransform()
	local anim = inst.entity:AddAnimState()
	inst.entity:AddMiniMapEntity()
	MakeInventoryPhysics(inst)
	inst.entity:AddNetwork()
	
	inst:AddTag("flute")
	--inst.components.onplayed.sanity:DoDelta(TUNING.SANITY_MED)
	--sanityreward = TUNING.SANITY_MED,

	anim:SetBank("sw_t01")
	anim:SetBuild("sw_t01")
	anim:PlayAnimation("idle")
	
	inst.MiniMapEntity:SetIcon( "images/map_icons/sw_t01.tex")
	
	inst.entity:SetPristine()

	if not TheWorld.ismastersim then
		return inst
	end

	inst:AddComponent("inventoryitem")
	inst.components.inventoryitem.imagename = "sw_t01"
	inst.components.inventoryitem.atlasname = "images/inventoryimages/sw_t01.xml"

	inst:AddComponent("inspectable")
	inst:AddComponent("instrument")
	inst.components.instrument.range = TUNING.PANFLUTE_SLEEPRANGE *1
	inst.components.instrument:SetOnHeardFn(HearPanFlute)
	inst.components.instrument.onplayed = OnPlayed
	--inst.components.instrument.sound_noloop = "scripts/sound/efaja.mp3" 

	inst:AddComponent("tool")
	inst.components.tool:SetAction(ACTIONS.PLAY)

	inst:AddComponent("finiteuses")
	inst.components.finiteuses:SetMaxUses(TUNING.PANFLUTE_USES)
	inst.components.finiteuses:SetUses(TUNING.PANFLUTE_USES)
	inst.components.finiteuses:SetOnFinished( onfinished)
	inst.components.finiteuses:SetConsumption(ACTIONS.PLAY, 1)
	
	return inst
end

 

Edited by Ultroman
  • Like 1

Share this post


Link to post
Share on other sites
orlyx    1

@UltromanThanks but there is still problem. When no host try to select custom character game crashes there is problem with inventoryitem but game works fine for host

Share this post


Link to post
Share on other sites
Ultroman    398

You need to provide these crash reports, otherwise we have no chance of helping you. Also a zip with the newest code. See the newcomer post for information about where to find the logs.

That said, I'm gonna venture a guess that it's because in all your onfinished functions in your prefabs, you call inst:Remove() and then proceed to try to use inst for something after that. inst:Remove() removes the item from the game, so you should do that as the very last thing in onfinished. Also, why are you trying to get the owner from the inventoryitem component, when the owner is already passed to onfinished as a parameter?

Edited by Ultroman

Share this post


Link to post
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