Apokli Posted July 19, 2021 Share Posted July 19, 2021 I've been writing a weapon pack mod these days and I encountered with a few questions. Mainly, I don't get the idea about how things are working with clients and servers. Specifically, I don't know where to use "components" and where to use "replica" and when a wrong usage of these two words will cause a crash on client or server. Also when I'm starting a game with a cave (I suppose this will make me a client server so that I can test things as a client), I don't receive the debug info I printed on the console that should've popped if I am the server. What's going on here? Here is a callback function when an item's finiteuse is depleted in my code that has a problem: local function OnFinished(inst) local owner = inst.components.inventoryitem.owner if TheWorld.ismastersim then for slot, item in pairs(owner.components.inventory.itemslots) do if item.prefab == inst.prefab then owner.components.inventory:Equip(item) break end end else for slot, item in pairs(owner.replica.inventory.itemslots) do if item.prefab == inst.prefab then owner.replica.inventory:Equip(item) break end end end inst:Remove() end What I'm trying to do is to auto-equip a specific weapon when the same kind of weapon is depleted. But this piece of code crashes when the weapon is depleted. And the game just tells me I am disconnected from the server without any debugging details. I really need some help and advice about how to make things work on both client and server machines. THX! Link to comment Share on other sites More sharing options...
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
Already have an account? Sign in here.Sign In Now