darkmu
Well-Known Member
I'm doing some tests, I put it in the array to activate with citizen, however using the debbuger (print) this is always returning me false ... what should I be missing?
Creature.lua
LIB
RETURN ON PRINT
false
Creature.lua
Lua:
function Creature:onChangeOutfit(outfit)
if not self:isPlayer() then
return true
end
local previousBonusCondition = getBonusOutfitID(self:getOutfit().lookType)
if previousBonusCondition then
self:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, previousBonusCondition)
end
local bonusOutfit = getBonusOutfit(outfit.lookType)
print(bonusOutfit)
if bonusOutfit then
local addons = 1
if self:canWearOutfit(outfit.lookType, 2) then
addons = 3
elseif self:canWearOutfit(outfit.lookType, 1) then
addons = 2
end
local newBonusCondition = createBonusCondition(bonusOutfit, addons)
if newBonusCondition then
self:addCondition(newBonusCondition)
end
end
return true
end
LIB
Lua:
--[[
addions[1] = no addons
addons[2] = 1st addon unlocked
addons[3] = 2nd addon unlocked
]]--
OUTFIT_BONUSES = {
[{136, 128}] = {id = 1, -- +1 each id for new outfits
addons = {
[1] = nil,
[2] = { CONDITION_MAGICLEVELPOINT, 5 },
[3] = { CONDITION_HASTE, 25 }
}
},
[{118, 119}] = {id = 2,
addons = {
[1] = nil,
[2] = { CONDITION_MAGICLEVELPOINT, 5 },
[3] = { CONDITION_HASTE, 25 }
}
}
}
function getBonusOutfit(outfit)
for i, v in pairs(OUTFIT_BONUSES) do
if outfit == i then
return OUTFIT_BONUSES[i]
end
end
return false
end
function createBonusCondition(bonus, addon)
local condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT)
condition:setParameter(CONDITION_PARAM_TICKS, -1)
condition:setParameter(CONDITION_PARAM_SUBID, bonus.id)
for x = 1, addon do
for i = 1, #bonus.addons[x] do
local param = bonus.addons[x][1]
local value = bonus.addons[x][2]
condition:setParameter(param, value)
end
end
return condition
end
function getBonusOutfitID(outfit)
for outfits, bonus in pairs(OUTFIT_BONUSES) do
if table.contains(outfits, outfit) then
return bonus.id
end
end
return nil
end
RETURN ON PRINT
false