AkaiNight Posted August 1, 2017 Share Posted August 1, 2017 Well i'm holding it short. If it is possible to make my character can't wear any backpacks except my custom item can't wear anything except my custom item can't use chester (can't pick eyebone too) can't use any weapon or tool except my custom item when try to take eyebone must lose 30 sanity if it is possible thanks for helping. Link to comment Share on other sites More sharing options...
RedHairedHero Posted August 1, 2017 Share Posted August 1, 2017 (edited) local function OnEquip(inst) --Get the equipped item local hat = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) local body = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.BODY) local hand = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HAND) --If it doesn't have your unique tag drop it if not hat:HasTag("youruniquetagname") then inst.components.inventory:DropItem(hat) end if not body:HasTag("youruniquetagname") then inst.components.inventory:DropItem(body) end if not hand:HasTag("youruniquetagname") then inst.components.inventory:DropItem(hand) end end local function OnPickup(inst) if data.prefab == "chester_eyebone" then local eyebone = data.prefab inst.components.sanity:DoDelta(-30) inst.components.inventory:DropItem(eyebone) end end --Add to master postinit inst:ListenForEvent("equip", OnEquip) inst:ListenForEvent("onpickup", OnPickup) The easiest thing to do would be to add a tag to your unique items and if nothing has that tag then just unequip/drop any other item. Edited August 1, 2017 by RedHairedHero Link to comment Share on other sites More sharing options...
AkaiNight Posted August 1, 2017 Author Share Posted August 1, 2017 4 minutes ago, RedHairedHero said: local function OnEquip(inst) --Get the equipped item local hat = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HEAD) local body = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.BODY) local hand = inst.components.inventory:GetEquippedItem(EQUIPSLOTS.HAND) --If it doesn't have your unique tag drop it if not hat:HasTag("youruniquetagname") then inst.components.inventory:DropItem(hat) end if not body:HasTag("youruniquetagname") then inst.components.inventory:DropItem(body) end if not hand:HasTag("youruniquetagname") then inst.components.inventory:DropItem(hand) end end local function OnPickup(inst) if data.prefab == "chester_eyebone" then local eyebone = data.prefab inst.components.sanity:DoDelta(-30) inst.components.inventory:DropItem(eyebone) end end --Add to master postinit inst:ListenForEvent("equip", OnEquip) inst:ListenForEvent("onpickup", OnPickup) The easiest thing to do would be to add a tag to your unique items and if nothing has that tag then just unequip/drop any other item. Thank you very much. Link to comment Share on other sites More sharing options...
AkaiNight Posted August 1, 2017 Author Share Posted August 1, 2017 @RedHairedHero Thanks for code it works perfectly so i don't need this topic anymore how can i close it? Link to comment Share on other sites More sharing options...
Lumina Posted August 1, 2017 Share Posted August 1, 2017 No need to close it. It will be archived after some time if no one post on it, and if someone does, then, maybe he needs help about this topic so it's fine. 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