• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

help modify script

famosiin

Member
Joined
Feb 28, 2021
Messages
36
Reaction score
5
Hey guys, I have a script that gives the player a bonus when he has a complete addon, but this script only works when the player is using this addon, I wanted your help in modifying it.

I wanted the script to give the bonus to the player even if he is not using that addon that is complete.

Example:
Citizen addon complete gets +5 speed

Full addon hunter gains +10 speed

adding the two I would have 15 speed if I have the two complete addons, can anyone help me to modify it?

I will post the full script below.

events/scripts/creature.lua
Lua:
function createBonusCondition(id, params)
    local condition = Condition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, id)
    for i = 1, #params do
        local param = params[i].param
        local value = params[i].value
        condition:setParameter(param, value)
    end
    return condition
end

outfitBonus = {
    -- [{male outfit id, female outfit id}] = createBonusCondition(ID, parameters & values)
    [{128, 136}] = createBonusCondition(1, {
            {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 10},
            {param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, value = 110}
        }
    ),
    [{129, 137}] = createBonusCondition(2, {
            {param = CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, value = 200}
        }
    )
}

function getBonusCondition(outfit)
    for outfits, bonus in pairs(outfitBonus) do
        if table.contains(outfits, outfit) then
            return bonus
        end
    end
    return nil
end

function Creature:onChangeOutfit(outfit)
    if not self:isPlayer() then
        return true
    end
    if self:hasOutfit(self:getOutfit().lookType, 3) then
        local previousBonusCondition = getBonusCondition(self:getOutfit().lookType)
        local newBonusCondition = getBonusCondition(outfit.lookType)
        if previousBonusCondition then
            self:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, previousBonusCondition:getSubId())
        end
        if newBonusCondition then
            self:addCondition(newBonusCondition)
        end
    end
    return true
end

creaturescript/scripts/login.lua

Lua:
-- Outfit bonus
    local bonusCondition = getBonusCondition(player:getOutfit().lookType)
    if bonusCondition then
        player:addCondition(bonusCondition)
    end
 
just use storages, every time player get a full addon, increase the storage value by +1 and then just use the storage value as bonus check
 
Back
Top