• Creating Multiple Conditions Using a Table
    0 replies, posted
Hey guys I am making a nutscript schema and recently developed two armor systems. One of them changes your model while the other adds PAC Editor parts to the player. I am trying to make it so you can't equip pac parts and/or hats when wearing a armor set. Below is what I am trying to do: [CODE] ITEM.outfitCategory = {"armorset", "hat"} [/CODE] What is above does not work because the base is made to only check for one condition. So I proceeded to edit the base for it to allow a table input, but it doesn't work. I don't have any errors it just won't check for the conditions now: [CODE] ITEM.functions.Equip = { name = "Equip", tip = "equipTip", icon = "icon16/tick.png", onRun = function(item) local char = item.player:getChar() local items = char:getInv():getItems() for k, v in pairs(items) do if (v.id != item.id) then local itemTable = nut.item.instances[v.id] if (itemTable.playerModel and item.outfitCategory and itemTable:getData("equip")) then local alreadyEquippedCategory = false if type(itemTable.outfitCategory) == "table" and type(item.outfitCategory) == "table" then for k2, v2 in pairs(itemTable.outfitCategory) do if table.HasValue(item.outfitCategory, v2) then alreadyEquippedCategory = true break end end elseif type(itemTable.outfitCategory) == "table" and type(item.outfitCategory) != "table" then alreadyEquippedCategory = table.HasValue(itemTable.outfitCategory, item.outfitCategory) elseif type(itemTable.outfitCategory) != "table" and type(item.outfitCategory) == "table" then alreadyEquippedCategory = table.HasValue(item.outfitCategory, itemTable.outfitCategory) elseif type(itemTable.outfitCategory) != "table" and type(item.outfitCategory) != "table" then alreadyEquippedCategory = itemTable.outfitCategory == item.outfitCategory end if alreadyEquippedCategory then item.player:notify("You're already equipping this kind of armor") return false end end end end item:setData("equip", true) item:setArmor(item.player) item.player:getChar():setData("ARMORSPEED", item.armorspeed) return false end, onCanRun = function(item) return (!IsValid(item.entity) and item:getData("equip") != true) end } [/CODE]
Sorry, you need to Log In to post a reply to this thread.