. . . Posted August 27, 2016 Share Posted August 27, 2016 (edited) Hello, I need help . So, when my character goes insane i'd like him to unequip any backpack he currently has equipped. I already have code for him not to equip any backpacks local packs = { icepack = true, backpack = true, piggyback = true, krampus_sack = true, } inst:ListenForEvent("equip", function(inst, data) if packs[data.item.prefab] and not inst.components.sanity:IsSane() then inst:DoTaskInTime(0, function(inst) inst.components.inventory:GiveItem(data.item) end) inst.components.talker:Say("BaGs Be FoR bAbIeS!!!") end end) I just need if someone can help me make him unequip any backpacks when he goes insane because this code just prevents him from equipping backpacks when he's already insane. I would really appreciate any kind of help, thanks a lot for reading my problem !! Edited August 27, 2016 by SuperDavid Link to comment https://forums.kleientertainment.com/forums/topic/69798-solved-how-to-make-character-unequip-backpack-when-insane/ Share on other sites More sharing options...
Lumina Posted August 27, 2016 Share Posted August 27, 2016 Maybe you could look at the code of woodie ? If i remember well, he drops his equipement when he transform, so i guess there is a code like the one you are searching. Link to comment https://forums.kleientertainment.com/forums/topic/69798-solved-how-to-make-character-unequip-backpack-when-insane/#findComment-807523 Share on other sites More sharing options...
Maris Posted August 27, 2016 Share Posted August 27, 2016 Try inst.components.inventory:Unequip(EQUIPSLOTS.BACK or EQUIPSLOTS.BODY) or local backpack --We will save here link to backpack. if EQUIPSLOTS.BACK then --Extra Equip Slots mod backpack = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.BACK) -- inst == player else --Get the link: local try_backpack = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.BODY) --It may be just an armor. Check it using tags: backpack = try_backpack and try_backpack:HasTag("backpack") and try_backpack end if backpack then --Found it! inst.components.inventory:DropItem(backpack) --Drop it! end Link to comment https://forums.kleientertainment.com/forums/topic/69798-solved-how-to-make-character-unequip-backpack-when-insane/#findComment-807619 Share on other sites More sharing options...
. . . Posted August 27, 2016 Author Share Posted August 27, 2016 17 minutes ago, Maris said: inst.components.inventory:Unequip(EQUIPSLOTS.BACK or EQUIPSLOTS.BODY) This code would just delete the backpack .This code worked great, thank you very, very much !!!! local backpack --We will save here link to backpack. if EQUIPSLOTS.BACK then --Extra Equip Slots mod backpack = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.BACK) -- inst == player else --Get the link: local try_backpack = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.BODY) --It may be just an armor. Check it using tags: backpack = try_backpack and try_backpack:HasTag("backpack") and try_backpack end if backpack then --Found it! inst.components.inventory:DropItem(backpack) --Drop it! end Link to comment https://forums.kleientertainment.com/forums/topic/69798-solved-how-to-make-character-unequip-backpack-when-insane/#findComment-807622 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