rons0n Posted January 24, 2015 Share Posted January 24, 2015 (edited) HiHi, just need a quick answer! So lately i've been getting comments on how my Character does not start out with the weapon i gave her.It works fine when the host plays her, but when guest join the game they have a used slot with the invisible weapon inside it. Why is it that only the hosts starts with the weapon?I thought it could be related to assets so i crammed the weapon assets to my characters prefab and the modmain file but it crashed the game. For modmain i added:Asset( "IMAGE", "images/inventoryimages/weapon.tex" ),Asset( "ATLAS", "images/inventoryimages/weapon.xml" ), Asset( "IMAGE", "images/inventoryimages/swap_weapon.tex" ),Asset( "ATLAS", "images/inventoryimages/swap_weapon.xml" ),Inside my CHARACTERS prefab i added:Asset( "ANIM", "anim/weapon.zip" ), Asset( "ANIM", "anim/swap_weapon" ), ...But then it probably has nothing to do with assets and i'm just a bad speculator x_x Edited January 24, 2015 by rons0n Link to comment Share on other sites More sharing options...
DarkXero Posted January 24, 2015 Share Posted January 24, 2015 Did you put inst.entity:AddNetwork() on the weapon?Did your client have the mod, with the assets? Link to comment Share on other sites More sharing options...
rons0n Posted January 24, 2015 Author Share Posted January 24, 2015 Did you put inst.entity:AddNetwork() on the weapon?Did your client have the mod, with the assets? hi Dark, sorry for the late response. I added inst.entity:AddNetwork() within the weapon prefab with ASSETS on. Crashed on startup. Then added inst.entity:AddNetwork() WITHOUT the assets in both modmain and prefab and now it just goes into blackscreen when i join as a guest. Still works fine on host though. Link to comment Share on other sites More sharing options...
Kzisor Posted January 24, 2015 Share Posted January 24, 2015 @rons0n, inst.entity:AddNetwork() needs to be in your main function which is called when you initialize your custom weapon. It needs to be after the 'inst.entity' lines, but before the line 'if not TheWorld.ismastersim then' otherwise you might get strange crashes. Also make sure your custom weapon has the code 'if not TheWorld.ismastersim then return end' before you add any components otherwise you might get strange crashes on the client side. If this still doesn't work, post your lua file so we may assist you further. Link to comment Share on other sites More sharing options...
rons0n Posted January 24, 2015 Author Share Posted January 24, 2015 @rons0n, inst.entity:AddNetwork() needs to be in your main function which is called when you initialize your custom weapon. It needs to be after the 'inst.entity' lines, but before the line 'if not TheWorld.ismastersim then' otherwise you might get strange crashes. Also make sure your custom weapon has the code 'if not TheWorld.ismastersim then return end' before you add any components otherwise you might get strange crashes on the client side. If this still doesn't work, post your lua file so we may assist you further. @Kzisor Oh man, I found the 'inst.entity' lines you speak of but not the 'TheWorld.ismasterim then line'.But I did add 'inst.entity:AddNetwork() right below the inst.entity and now the screen goes black then closes on its own. Heres how i added it:Also, i don't know if you need my character prefab too since the character comes with the weapon but theres also that file.kendostick.luasaber.lua Link to comment Share on other sites More sharing options...
Kzisor Posted January 24, 2015 Share Posted January 24, 2015 @rons0n, try the following code for your kendostick.lua local assets={ Asset("ANIM", "anim/kendostick.zip"), Asset("ANIM", "anim/swap_kendostick.zip"), Asset("ATLAS", "images/inventoryimages/kendostick.xml"), Asset("IMAGE", "images/inventoryimages/kendostick.tex"),}local function OnEquip(inst, owner) owner.AnimState:OverrideSymbol("swap_object", "swap_kendostick", "swap_kendostick") 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")endlocal function fn() local inst = CreateEntity() inst.entity:AddTransform() inst.entity:AddAnimState() inst.entity:AddNetwork() MakeInventoryPhysics(inst) inst.AnimState:SetBank("kendostick") inst.AnimState:SetBuild("kendostick") inst.AnimState:PlayAnimation("idle") inst:AddTag("sharp") if not TheWorld.ismastersim then return inst end inst.entity:SetPristine() inst:AddComponent("weapon") inst.components.weapon:SetDamage(35) inst:AddComponent("inspectable") inst:AddComponent("inventoryitem") inst.components.inventoryitem.imagename = "kendostick" inst.components.inventoryitem.atlasname = "images/inventoryimages/kendostick.xml" inst:AddComponent("equippable") inst.components.equippable:SetOnEquip( OnEquip ) inst.components.equippable:SetOnUnequip( OnUnequip ) return instendreturn Prefab("common/inventory/kendostick", fn, assets) This should produce the results you are looking to achieve. Link to comment Share on other sites More sharing options...
rons0n Posted January 24, 2015 Author Share Posted January 24, 2015 This should produce the results you are looking to achieve. @Kzisor@DarkXero Thank you both!its fixed! I'll make sure to come back and look at this thread whenever i have problems related to weapons not appearing.I'll be on my way! Link to comment Share on other sites More sharing options...
prfella Posted February 28, 2015 Share Posted February 28, 2015 Hey guys. Sorry to hijack a thread for use but I'm having a similar problem with a weapon mod created by the user Boo on the Steam forums. I went over Kzisor's excellent post numerous times but no matter what I do, the weapon doesnt show up on the client side, only for the host side. I was wondering if someone could take a look at it and tell me whats wrong. Thnx in advance.adventure_sword.lua Link to comment Share on other sites More sharing options...
Kzisor Posted February 28, 2015 Share Posted February 28, 2015 Hey guys. Sorry to hijack a thread for use but I'm having a similar problem with a weapon mod created by the user Boo on the Steam forums. I went over Kzisor's excellent post numerous times but no matter what I do, the weapon doesnt show up on the client side, only for the host side. I was wondering if someone could take a look at it and tell me whats wrong. Thnx in advance. It's best not to hijack threads, however, I will say your problem is the exact same as the OP's problem. Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now