• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.
outfit bonus table

outfit bonus table

abdala ragab

Excellent OT User
Joined
Aug 18, 2018
Messages
752
Solutions
19
Reaction score
580
Location
gamelaots.online
abdala ragab submitted a new resource:

outfit bonus table - outfit bonus table Two different Script:

Two different script: A script if you were to give all the outfits the same reward or some of them with the same reward, and a script with different rewards.
Here is the first script of the consolidated rewards
LUA:
local addonBonus = CreatureEvent("AddonBonus")

function addonBonus.onLogin(player)
    -- Define conditions
    local conditions = {
        mage = Condition(CONDITION_ATTRIBUTES),
        noble = Condition(CONDITION_ATTRIBUTES),
        Citizen =...

Read more about this resource...
 
Hello, the script looks very good and interesting, but I tried to use it in TFS 1.3 OTG base but it is necessary to relog for the attribute to appear, could you adjust it for us please?
 
Last edited:
All conditions and their parameters are not set using any player value (his level etc.).
They should be created and configured above function addonBonus.onLogin(player) ex.
LUA:
-- Define different conditions
local conditions = {
    mage = Condition(CONDITION_ATTRIBUTES),
    noble = Condition(CONDITION_ATTRIBUTES),
    Citizen = Condition(CONDITION_ATTRIBUTES),
    hunter = Condition(CONDITION_ATTRIBUTES),
    Knight = Condition(CONDITION_ATTRIBUTES),
    Summoner = Condition(CONDITION_ATTRIBUTES),
    Warrior = Condition(CONDITION_ATTRIBUTES),
    Barbarian = Condition(CONDITION_ATTRIBUTES),
    Druid = Condition(CONDITION_ATTRIBUTES),
    Wizard = Condition(CONDITION_ATTRIBUTES),
    Oriental = Condition(CONDITION_ATTRIBUTES),
    Custom = Condition(CONDITION_ATTRIBUTES)
}

-- Set parameters for each condition

conditions.noble:setParameter(CONDITION_PARAM_TICKS, -1)
conditions.noble:setParameter(CONDITION_PARAM_SKILL_SHIELD, 15)
conditions.noble:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 50)
conditions.noble:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 50)
conditions.noble:setParameter(CONDITION_PARAM_SKILL_MELEE, 50)
conditions.noble:setParameter(CONDITION_PARAM_SKILL_FIST, 50)

-- HERE rest of conditions

function addonBonus.onLogin(player)
-- HERE code related to player starts:
    -- Getting the player's outfit directly
    local outfit = player:getOutfit()
    local lookType = outfit.lookType
    local lookAddons = outfit.lookAddons

All code inside function addonBonus.onLogin(player) is executed every time player logins into game. So it creates 12 new conditions in C++, set their values and then only add some of them or none in ex. player:addCondition(conditions.Knight). At end of execution of addonBonus.onLogin it will remove them all from Lua (they are local inside that function). I'm not sure, if it will remove these Conditions from C++ at all!

Code above function addonBonus.onLogin(player) is executed only once at server start (also on /reload xx), so making it create variables saves a lot of CPU.
You can apply same condition to multiple players using player:addCondition(conditions.Knight). That's what all Spells do with Conditions and Combats.

EDIT:
To make it easier to understand. Your Lua script may look like this:
LUA:
local loginMessage = CreatureEvent("LoginMessage")

local loginCounter = 0

function loginMessage.onLogin(player)
    loginCounter = loginCounter + 1

    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Players logins into game " .. loginCounter)

    return true
end

loginMessage:register()
whenever any player relogs, it will increase count +1. Variable is outside "callback" function, it's shared between function executions.

You don't have to understand C++. From Lua point of view (what C++ "does"): when new player logins, it executes in Lua (imagine it's pasted at end of your .lua file):
LUA:
local playerLoggingIn = Player(123)
loginMessage:onLogin(playerLoggingIn)
Second player with GUID 567 logins, it executes:
Code:
local playerLoggingIn = Player(567)
loginMessage:onLogin(playerLoggingIn)
Third player with GUID 789 logins, it executes:
Code:
local playerLoggingIn = Player(789)
loginMessage:onLogin(playerLoggingIn)
so everytime some player logins into game, it defines new local variables at end of file ex. local playerLoggingIn = Player(567) and pass it as parameter to your function ex. loginMessage.onLogin(playerLoggingIn).
 
Last edited:
All conditions and their parameters are not set using any player value (his level etc.).
They should be created and configured above function addonBonus.onLogin(player) ex.
Hey, I followed your advice about the functions and the things you mentioned and made all the changes. Could you check if the script is better now or if it still has bugs? Does it need further improvement? Thank you, as I'm learning TFS 1.x. XD

LUA:
-- Configuration table for conditions and messages
local conditionConfig = {
    [140] = {name = "noble", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [132] = {name = "noble", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [138] = {name = "mage", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [130] = {name = "mage", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [136] = {name = "Citizen", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [128] = {name = "Citizen", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [137] = {name = "hunter", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [129] = {name = "hunter", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [139] = {name = "Knight", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [131] = {name = "Knight", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [141] = {name = "Summoner", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [133] = {name = "Summoner", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [142] = {name = "Warrior", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [134] = {name = "Warrior", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [147] = {name = "Barbarian", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [143] = {name = "Barbarian", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [148] = {name = "Druid", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [144] = {name = "Druid", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [149] = {name = "Wizard", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [145] = {name = "Wizard", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [150] = {name = "Oriental", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [146] = {name = "Oriental", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [264] = {name = "Custom", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2}
}

-- Function to set up conditions based on config
local conditions = {}

local function setupConditions()
    for _, config in pairs(conditionConfig) do
        local condition = Condition(CONDITION_ATTRIBUTES)
        condition:setParameter(CONDITION_PARAM_TICKS, -1)
        condition:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, config.magic)
        condition:setParameter(CONDITION_PARAM_SKILL_SHIELD, config.shield)
        condition:setParameter(CONDITION_PARAM_SKILL_MELEE, config.melee)
        condition:setParameter(CONDITION_PARAM_SKILL_FIST, config.fist)
        condition:setParameter(CONDITION_PARAM_SKILL_DISTANCE, config.distance)
        conditions[config.name] = condition
    end
end

setupConditions()

local function formatMessage(outfitConfig)
    return string.format("You are eligible for a bonus %s addon.\n[Magic Level] +%d\n[Shield] +%d\n[Sword] +%d\n[Club] +%d\n[Fist] +%d\n[Distance] +%d\n[Axe] +%d",
        outfitConfig.name, outfitConfig.magic, outfitConfig.shield, outfitConfig.melee, outfitConfig.melee, outfitConfig.fist, outfitConfig.distance, outfitConfig.melee)
end

local addonBonus = CreatureEvent("AddonBonus")
function addonBonus.onLogin(player)
    -- Getting the player's outfit directly
    local outfit = player:getOutfit()
    local lookType = outfit.lookType
    local lookAddons = outfit.lookAddons

    local outfitConfig = conditionConfig[lookType]

    if outfitConfig and lookAddons == 3 then
        local message = formatMessage(outfitConfig)
        player:sendTextMessage(MESSAGE_EVENT_ORANGE, message)
        player:addCondition(conditions[outfitConfig.name])
    else
        player:sendTextMessage(MESSAGE_EVENT_ORANGE, "You are not eligible for a bonus addon")
    end

    return true
end
addonBonus:register()
 
Hey, I followed your advice about the functions and the things you mentioned and made all the changes. Could you check if the script is better now or if it still has bugs? Does it need further improvement? Thank you, as I'm learning TFS 1.x. XD

LUA:
-- Configuration table for conditions and messages
local conditionConfig = {
    [140] = {name = "noble", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [132] = {name = "noble", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [138] = {name = "mage", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [130] = {name = "mage", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [136] = {name = "Citizen", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [128] = {name = "Citizen", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [137] = {name = "hunter", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [129] = {name = "hunter", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [139] = {name = "Knight", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [131] = {name = "Knight", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [141] = {name = "Summoner", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [133] = {name = "Summoner", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [142] = {name = "Warrior", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [134] = {name = "Warrior", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [147] = {name = "Barbarian", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [143] = {name = "Barbarian", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [148] = {name = "Druid", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [144] = {name = "Druid", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [149] = {name = "Wizard", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [145] = {name = "Wizard", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [150] = {name = "Oriental", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [146] = {name = "Oriental", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2},
    [264] = {name = "Custom", magic = 2, shield = 2, melee = 2, fist = 2, distance = 2}
}

-- Function to set up conditions based on config
local conditions = {}

local function setupConditions()
    for _, config in pairs(conditionConfig) do
        local condition = Condition(CONDITION_ATTRIBUTES)
        condition:setParameter(CONDITION_PARAM_TICKS, -1)
        condition:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, config.magic)
        condition:setParameter(CONDITION_PARAM_SKILL_SHIELD, config.shield)
        condition:setParameter(CONDITION_PARAM_SKILL_MELEE, config.melee)
        condition:setParameter(CONDITION_PARAM_SKILL_FIST, config.fist)
        condition:setParameter(CONDITION_PARAM_SKILL_DISTANCE, config.distance)
        conditions[config.name] = condition
    end
end

setupConditions()

local function formatMessage(outfitConfig)
    return string.format("You are eligible for a bonus %s addon.\n[Magic Level] +%d\n[Shield] +%d\n[Sword] +%d\n[Club] +%d\n[Fist] +%d\n[Distance] +%d\n[Axe] +%d",
        outfitConfig.name, outfitConfig.magic, outfitConfig.shield, outfitConfig.melee, outfitConfig.melee, outfitConfig.fist, outfitConfig.distance, outfitConfig.melee)
end

local addonBonus = CreatureEvent("AddonBonus")
function addonBonus.onLogin(player)
    -- Getting the player's outfit directly
    local outfit = player:getOutfit()
    local lookType = outfit.lookType
    local lookAddons = outfit.lookAddons

    local outfitConfig = conditionConfig[lookType]

    if outfitConfig and lookAddons == 3 then
        local message = formatMessage(outfitConfig)
        player:sendTextMessage(MESSAGE_EVENT_ORANGE, message)
        player:addCondition(conditions[outfitConfig.name])
    else
        player:sendTextMessage(MESSAGE_EVENT_ORANGE, "You are not eligible for a bonus addon")
    end

    return true
end
addonBonus:register()

Aren't people supposed to relog then to receive their attributes ( if they change their outfit ) ?
Why not using onChangeOutfit function? :D
 
You could reduce:
LUA:
local function setupConditions()
    for _, config in pairs(conditionConfig) do
        local condition = Condition(CONDITION_ATTRIBUTES)
        condition:setParameter(CONDITION_PARAM_TICKS, -1)
        condition:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, config.magic)
        condition:setParameter(CONDITION_PARAM_SKILL_SHIELD, config.shield)
        condition:setParameter(CONDITION_PARAM_SKILL_MELEE, config.melee)
        condition:setParameter(CONDITION_PARAM_SKILL_FIST, config.fist)
        condition:setParameter(CONDITION_PARAM_SKILL_DISTANCE, config.distance)
        conditions[config.name] = condition
    end
end

setupConditions()
to:
Code:
for _, config in pairs(conditionConfig) do
    local condition = Condition(CONDITION_ATTRIBUTES)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, config.magic)
    condition:setParameter(CONDITION_PARAM_SKILL_SHIELD, config.shield)
    condition:setParameter(CONDITION_PARAM_SKILL_MELEE, config.melee)
    condition:setParameter(CONDITION_PARAM_SKILL_FIST, config.fist)
    condition:setParameter(CONDITION_PARAM_SKILL_DISTANCE, config.distance)
    conditions[config.name] = condition
end
but generating conditions inside function make it easier to separate config from script logic, so IDK if it's good idea.
Programmers often make script and then someone else configure them, so it may be a good idea to add some 'function' to make it look like 'code', not 'config'.
Aren't people supposed to relog then to receive their attributes ( if they change their outfit ) ?
It's a good idea. You would need to set unique SUBID for outfit bunuses ex. condition:setParameter(CONDITION_PARAM_SUBID, 12345) and remove old condition, before you add new, to do not stack them.
 
Aren't people supposed to relog then to receive their attributes ( if they change their outfit ) ?
Why not using onChangeOutfit function? :D
It's not for me, it's for him. @abdala ragab asked for his script to be fixed, that's all. But I've already had and implemented that function you mentioned a long time ago. I recommended to him via Discord to use the onChangeOutfit function.
 
@Mateus Robeerto Would it be possible for you to have each vocation receive different bonuses using the same outfit, for example: Sorcerer and knight wearing citizen outfit bonus outfit to receive --> knight +150HP +2 shield / Sorcerer + 150MP +2 Magic Level
 
@Mateus Robeerto Would it be possible for you to have each vocation receive different bonuses using the same outfit, for example: Sorcerer and knight wearing citizen outfit bonus outfit to receive --> knight +150HP +2 shield / Sorcerer + 150MP +2 Magic Level


Try this

LUA:
local addonBonus = CreatureEvent("AddonBonus")

function addonBonus.onLogin(player)
    -- Define conditions for each vocation
    local knightCondition = Condition(CONDITION_ATTRIBUTES)
    knightCondition:setParameter(CONDITION_PARAM_TICKS, -1)
    knightCondition:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTS, 150)
    knightCondition:setParameter(CONDITION_PARAM_SKILL_SHIELD, 2)

    local sorcererCondition = Condition(CONDITION_ATTRIBUTES)
    sorcererCondition:setParameter(CONDITION_PARAM_TICKS, -1)
    sorcererCondition:setParameter(CONDITION_PARAM_STAT_MAXMANAPOINTS, 150)
    sorcererCondition:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 2)

    -- Getting the player's outfit directly
    local outfit = player:getOutfit()
    local lookType = outfit.lookType

    -- Check if the player has the Custom outfit
    if lookType == 144 or lookType == 264 then
        local vocation = player:getVocation():getId()

        if vocation == 4 then -- Knight
            player:sendTextMessage(
                MESSAGE_EVENT_ADVANCE,
                "You are eligible for a Knight bonus using your current outfit"
            )
            player:addCondition(knightCondition)
        elseif vocation == 1 then -- Sorcerer
            player:sendTextMessage(
                MESSAGE_EVENT_ADVANCE,
                "You are eligible for a Sorcerer bonus using your current outfit"
            )
            player:addCondition(sorcererCondition)
        else
            player:sendTextMessage(
                MESSAGE_EVENT_ADVANCE,
                "You are not eligible for a bonus with your vocation"
            )
        end
    else
        player:sendTextMessage(
            MESSAGE_EVENT_ADVANCE,
            "You are not eligible for a bonus Custom addon"
        )
    end

    return true
end

addonBonus:register()
 
Experimente isso

LUA:
local addonBonus = CreatureEvent("AddonBonus")

função addonBonus.onLogin(jogador)
    - Definir condições para cada vocação
    cavaleiro localCondição = Condição(CONDITION_ATTRIBUTES)
    cavaleiroCondição:setParameter(CONDITION_PARAM_TICKS, -1)
    cavaleiroCondição:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTS, 150)
    cavaleiroCondição:setParameter(CONDITION_PARAM_SKILL_SHIELD, 2)

    feiticeiro localCondição = Condição (CONDITION_ATTRIBUTES)
    sorcererCondition:setParameter(CONDITION_PARAM_TICKS, -1)
    sorcererCondition:setParameter(CONDITION_PARAM_STAT_MAXMANAPOINTS, 150)
    sorcererCondition:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 2)

    - Obtendo a roupa do jogador diretamente
    roupa local = player:getOutfit()
    lookType local = outfit.lookType

    -- Verifique se o jogador tem a roupa personalizada
    se lookType == 144 ou lookType == 264 então
        vocação local = player:getVocation():getId()

        se vocação == 4 então -- Cavaleiro
            player:sendTextMessage(
                MESSAGE_EVENT_ADVANCE,
                "Você tem direito a um bônus de Cavaleiro usando sua roupa atual"
            )
            player:addCondição(cavaleiroCondição)
        elseif vocação == 1 then -- Feiticeiro
            player:sendTextMessage(
                MESSAGE_EVENT_ADVANCE,
                "Você tem direito a um bônus de Feiticeiro usando sua roupa atual"
            )
            player:addCondition(sorcererCondition)
        outro
            player:sendTextMessage(
                MESSAGE_EVENT_ADVANCE,
                "Você não tem direito a um bônus com sua vocação"
            )
        fim
    outro
        player:sendTextMessage(
            MESSAGE_EVENT_ADVANCE,
            "Você não é elegível para um complemento personalizado de bônus"
        )
    fim

    retornar verdadeiro
fim

addonBonus:registrar()
[/CÓDIGO]
[/CITAR]
ex:[/CÓDIGO]
[/QUOTE]
Ex:
condição localConfig = {
[140] = {voc = "knight, Elite Knight", escudo = 5, corpo a corpo = 2, punho = 2, health = 500}
[140] = {voc = "Druid, Elder Druid", magia = 2, mana = 200, speed = 200}
[140] = {voc= "Paladin, Royal paladin", magia = 1, distância = 5, criticalchance = 5}
[140] = {voc= "Sorcerer, Master Sorcerer", magia = 2, mana = 200}
}
 
For those who want ready-to-use outfits, there's no need to mess with event/creature.lua using onChangeOutfit. You can just place it directly in data/scripts and configure everything properly. It includes mounts, outfits, wings, and auras. Feel free to grab and use it :).

LUA:
local bonusesConfig = {
    outfits = {
        [{128, 136}] = {
            type = "bonus",
            id = 1,
            params = {
                {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 2},
                {param = CONDITION_PARAM_SKILL_SHIELD, value = 2},
                {param = CONDITION_PARAM_SKILL_MELEE, value = 2},
                {param = CONDITION_PARAM_SKILL_FIST, value = 2},
                {param = CONDITION_PARAM_SKILL_DISTANCE, value = 2}
            }
        },
        [{138, 139}] = {
            type = "bonus",
            id = 2,
            params = {
                {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 2},
                {param = CONDITION_PARAM_SKILL_SHIELD, value = 2},
                {param = CONDITION_PARAM_SKILL_MELEE, value = 2},
                {param = CONDITION_PARAM_SKILL_FIST, value = 2},
                {param = CONDITION_PARAM_SKILL_DISTANCE, value = 2}
            }
        }
    },
    mounts = {
        [{1368, 1369}] = {
            type = "bonus",
            id = 1,
            params = {
                {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 10},
                {param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, value = 110}
            }
        },
        [{1370, 1371}] = {
            type = "bonus",
            id = 2,
            params = {
                {param = CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, value = 200}
            }
        },
        [{368, 369, 370, 371, 372, 373, 374, 375, 376, 378, 379}] = {
            type = "regen",
            id = 1,
            params = {
                {param = CONDITION_PARAM_HEALTHGAIN, value = 500},
                {param = CONDITION_PARAM_HEALTHTICKS, value = 2000},
                {param = CONDITION_PARAM_MANAGAIN, value = 500},
                {param = CONDITION_PARAM_MANATICKS, value = 2000}
            }
        }
    },
    wings = {
        [{1655, 1656}] = {
            type = "bonus",
            id = 1,
            params = {
                {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 10},
                {param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, value = 110}
            }
        },
        [{1657, 1658}] = {
            type = "bonus",
            id = 2,
            params = {
                {param = CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, value = 200}
            }
        },
        [{1658, 1659}] = {
            type = "bonus",
            id = 3,
            params = {
                {param = COMBAT_PARAM_TYPE, value = COMBAT_ICEDAMAGE}
            }
        }
    },
    auras = {
        [{1657, 1658}] = {
            type = "bonus",
            id = 1,
            params = {
                {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 10},
                {param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, value = 110}
            }
        },
        [{1659, 1660}] = {
            type = "bonus",
            id = 2,
            params = {
                {param = CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, value = 200}
            }
        },
        [{1661, 1662}] = {
            type = "bonus",
            id = 3,
            params = {
                {param = COMBAT_PARAM_TYPE, value = COMBAT_ICEDAMAGE}
            }
        }
    }
}

function getBonusCondition(look, bonusTable)
    if look ~= 0 and bonusTable then
        for outfits, bonus in pairs(bonusTable) do
            if table.contains(outfits, look) then
                return bonus
            end
        end
    end
    return nil
end

local function createCondition(type, id, params)
    local conditionType
    if type == "bonus" then
        conditionType = CONDITION_ATTRIBUTES
    elseif type == "regen" then
        conditionType = CONDITION_REGENERATION
    elseif type == "haste" then
        conditionType = CONDITION_HASTE
    else
        return nil
    end

    local condition = Condition(conditionType, CONDITIONID_DEFAULT)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, id)
    for _, paramData in ipairs(params) do
        condition:setParameter(paramData.param, paramData.value)
    end
    return condition
end

local function removeBonus(player, look, bonusTable)
    if look ~= 0 then
        local bonus = getBonusCondition(look, bonusTable)
        if bonus then
            print("Removing bonus with:", bonus.id)
            player:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, bonus.id)
        end
    end
end

local function applyBonus(player, look, bonusTable)
    if look ~= 0 then
        local bonus = getBonusCondition(look, bonusTable)
        if bonus then
            print("Applying bonus with ID:", bonus.id)
            local condition = createCondition(bonus.type, bonus.id, bonus.params)
            if condition then
                player:addCondition(condition)
                local bonusMessage = "Applied bonus with ID: Attributes: "
                local messages = {
                    [CONDITION_PARAM_STAT_MAGICPOINTS] = "Magic Level",
                    [CONDITION_PARAM_SKILL_SHIELD] = "Shield Skill",
                    [CONDITION_PARAM_SKILL_MELEE] = "Melee",
                    [CONDITION_PARAM_SKILL_FIST] = "Fist Skill",
                    [CONDITION_PARAM_SKILL_DISTANCE] = "Distance Skill",
                    [CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT] = "HP%",
                    [CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT] = "MP%",
                    [COMBAT_PARAM_TYPE] = "Combat Type",
                    [CONDITION_PARAM_HEALTHGAIN] = "HP Gain",
                    [CONDITION_PARAM_HEALTHTICKS] = "HP Ticks",
                    [CONDITION_PARAM_MANAGAIN] = "MP Gain",
                    [CONDITION_PARAM_MANATICKS] = "MP Ticks"
                }
                for _, paramData in ipairs(bonus.params) do
                    bonusMessage = bonusMessage .. (messages[paramData.param] or "Unknown") .. ": " .. paramData.value .. " "
                end
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, bonusMessage)
            end
        end
    end
end

local function onChangeOutfit(player, outfit)
    print("Change Outfit Triggered")

    local previousOutfit = player:getOutfit().lookType or 0
    local previousMount = player:getOutfit().lookMount or 0
    local previousWings = player:getOutfit().lookWings or 0
    local previousAura = player:getOutfit().lookAura or 0

    print("Previous Outfit ID:", previousOutfit)
    print("Previous Mount ID:", previousMount)
    print("Previous Wings ID:", previousWings)
    print("Previous Aura ID:", previousAura)

    removeBonus(player, previousOutfit, bonusesConfig.outfits)
    removeBonus(player, previousMount, bonusesConfig.mounts)
    removeBonus(player, previousWings, bonusesConfig.wings)
    removeBonus(player, previousAura, bonusesConfig.auras)

    if outfit.lookAddons == 3 then
        applyBonus(player, outfit.lookType, bonusesConfig.outfits)
    end

    print("Outfit changed to:", outfit.lookType)
    print("Mount changed to:", outfit.lookMount)
    print("Wings changed to:", outfit.lookWings)
    print("Aura changed to:", outfit.lookAura)
    return true
end

local ec = EventCallback
ec.onChangeOutfit = onChangeOutfit
ec:register()

local updateBonusesEvent = CreatureEvent("updateBonuses")
function updateBonusesEvent.onLogin(player)
    print("Login Triggered")
    onChangeOutfit(player, player:getOutfit())
    return true
end
updateBonusesEvent:register()
 
For those who want ready-to-use outfits, there's no need to mess with event/creature.lua using onChangeOutfit. You can just place it directly in data/scripts and configure everything properly. It includes mounts, outfits, wings, and auras. Feel free to grab and use it :).

LUA:
local bonusesConfig = {
    outfits = {
        [{128, 136}] = {
            type = "bonus",
            id = 1,
            params = {
                {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 2},
                {param = CONDITION_PARAM_SKILL_SHIELD, value = 2},
                {param = CONDITION_PARAM_SKILL_MELEE, value = 2},
                {param = CONDITION_PARAM_SKILL_FIST, value = 2},
                {param = CONDITION_PARAM_SKILL_DISTANCE, value = 2}
            }
        },
        [{138, 139}] = {
            type = "bonus",
            id = 2,
            params = {
                {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 2},
                {param = CONDITION_PARAM_SKILL_SHIELD, value = 2},
                {param = CONDITION_PARAM_SKILL_MELEE, value = 2},
                {param = CONDITION_PARAM_SKILL_FIST, value = 2},
                {param = CONDITION_PARAM_SKILL_DISTANCE, value = 2}
            }
        }
    },
    mounts = {
        [{1368, 1369}] = {
            type = "bonus",
            id = 1,
            params = {
                {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 10},
                {param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, value = 110}
            }
        },
        [{1370, 1371}] = {
            type = "bonus",
            id = 2,
            params = {
                {param = CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, value = 200}
            }
        },
        [{368, 369, 370, 371, 372, 373, 374, 375, 376, 378, 379}] = {
            type = "regen",
            id = 1,
            params = {
                {param = CONDITION_PARAM_HEALTHGAIN, value = 500},
                {param = CONDITION_PARAM_HEALTHTICKS, value = 2000},
                {param = CONDITION_PARAM_MANAGAIN, value = 500},
                {param = CONDITION_PARAM_MANATICKS, value = 2000}
            }
        }
    },
    wings = {
        [{1655, 1656}] = {
            type = "bonus",
            id = 1,
            params = {
                {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 10},
                {param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, value = 110}
            }
        },
        [{1657, 1658}] = {
            type = "bonus",
            id = 2,
            params = {
                {param = CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, value = 200}
            }
        },
        [{1658, 1659}] = {
            type = "bonus",
            id = 3,
            params = {
                {param = COMBAT_PARAM_TYPE, value = COMBAT_ICEDAMAGE}
            }
        }
    },
    auras = {
        [{1657, 1658}] = {
            type = "bonus",
            id = 1,
            params = {
                {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 10},
                {param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, value = 110}
            }
        },
        [{1659, 1660}] = {
            type = "bonus",
            id = 2,
            params = {
                {param = CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, value = 200}
            }
        },
        [{1661, 1662}] = {
            type = "bonus",
            id = 3,
            params = {
                {param = COMBAT_PARAM_TYPE, value = COMBAT_ICEDAMAGE}
            }
        }
    }
}

function getBonusCondition(look, bonusTable)
    if look ~= 0 and bonusTable then
        for outfits, bonus in pairs(bonusTable) do
            if table.contains(outfits, look) then
                return bonus
            end
        end
    end
    return nil
end

local function createCondition(type, id, params)
    local conditionType
    if type == "bonus" then
        conditionType = CONDITION_ATTRIBUTES
    elseif type == "regen" then
        conditionType = CONDITION_REGENERATION
    elseif type == "haste" then
        conditionType = CONDITION_HASTE
    else
        return nil
    end

    local condition = Condition(conditionType, CONDITIONID_DEFAULT)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, id)
    for _, paramData in ipairs(params) do
        condition:setParameter(paramData.param, paramData.value)
    end
    return condition
end

local function removeBonus(player, look, bonusTable)
    if look ~= 0 then
        local bonus = getBonusCondition(look, bonusTable)
        if bonus then
            print("Removing bonus with:", bonus.id)
            player:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, bonus.id)
        end
    end
end

local function applyBonus(player, look, bonusTable)
    if look ~= 0 then
        local bonus = getBonusCondition(look, bonusTable)
        if bonus then
            print("Applying bonus with ID:", bonus.id)
            local condition = createCondition(bonus.type, bonus.id, bonus.params)
            if condition then
                player:addCondition(condition)
                local bonusMessage = "Applied bonus with ID: Attributes: "
                local messages = {
                    [CONDITION_PARAM_STAT_MAGICPOINTS] = "Magic Level",
                    [CONDITION_PARAM_SKILL_SHIELD] = "Shield Skill",
                    [CONDITION_PARAM_SKILL_MELEE] = "Melee",
                    [CONDITION_PARAM_SKILL_FIST] = "Fist Skill",
                    [CONDITION_PARAM_SKILL_DISTANCE] = "Distance Skill",
                    [CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT] = "HP%",
                    [CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT] = "MP%",
                    [COMBAT_PARAM_TYPE] = "Combat Type",
                    [CONDITION_PARAM_HEALTHGAIN] = "HP Gain",
                    [CONDITION_PARAM_HEALTHTICKS] = "HP Ticks",
                    [CONDITION_PARAM_MANAGAIN] = "MP Gain",
                    [CONDITION_PARAM_MANATICKS] = "MP Ticks"
                }
                for _, paramData in ipairs(bonus.params) do
                    bonusMessage = bonusMessage .. (messages[paramData.param] or "Unknown") .. ": " .. paramData.value .. " "
                end
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, bonusMessage)
            end
        end
    end
end

local function onChangeOutfit(player, outfit)
    print("Change Outfit Triggered")

    local previousOutfit = player:getOutfit().lookType or 0
    local previousMount = player:getOutfit().lookMount or 0
    local previousWings = player:getOutfit().lookWings or 0
    local previousAura = player:getOutfit().lookAura or 0

    print("Previous Outfit ID:", previousOutfit)
    print("Previous Mount ID:", previousMount)
    print("Previous Wings ID:", previousWings)
    print("Previous Aura ID:", previousAura)

    removeBonus(player, previousOutfit, bonusesConfig.outfits)
    removeBonus(player, previousMount, bonusesConfig.mounts)
    removeBonus(player, previousWings, bonusesConfig.wings)
    removeBonus(player, previousAura, bonusesConfig.auras)

    if outfit.lookAddons == 3 then
        applyBonus(player, outfit.lookType, bonusesConfig.outfits)
    end

    print("Outfit changed to:", outfit.lookType)
    print("Mount changed to:", outfit.lookMount)
    print("Wings changed to:", outfit.lookWings)
    print("Aura changed to:", outfit.lookAura)
    return true
end

local ec = EventCallback
ec.onChangeOutfit = onChangeOutfit
ec:register()

local updateBonusesEvent = CreatureEvent("updateBonuses")
function updateBonusesEvent.onLogin(player)
    print("Login Triggered")
    onChangeOutfit(player, player:getOutfit())
    return true
end
updateBonusesEvent:register()



Hey This is fucking gold thanks for the wings auras and all!
 
For those who want ready-to-use outfits, there's no need to mess with event/creature.lua using onChangeOutfit. You can just place it directly in data/scripts and configure everything properly. It includes mounts, outfits, wings, and auras. Feel free to grab and use it :).

LUA:
local bonusesConfig = {
    outfits = {
        [{128, 136}] = {
            type = "bonus",
            id = 1,
            params = {
                {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 2},
                {param = CONDITION_PARAM_SKILL_SHIELD, value = 2},
                {param = CONDITION_PARAM_SKILL_MELEE, value = 2},
                {param = CONDITION_PARAM_SKILL_FIST, value = 2},
                {param = CONDITION_PARAM_SKILL_DISTANCE, value = 2}
            }
        },
        [{138, 139}] = {
            type = "bonus",
            id = 2,
            params = {
                {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 2},
                {param = CONDITION_PARAM_SKILL_SHIELD, value = 2},
                {param = CONDITION_PARAM_SKILL_MELEE, value = 2},
                {param = CONDITION_PARAM_SKILL_FIST, value = 2},
                {param = CONDITION_PARAM_SKILL_DISTANCE, value = 2}
            }
        }
    },
    mounts = {
        [{1368, 1369}] = {
            type = "bonus",
            id = 1,
            params = {
                {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 10},
                {param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, value = 110}
            }
        },
        [{1370, 1371}] = {
            type = "bonus",
            id = 2,
            params = {
                {param = CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, value = 200}
            }
        },
        [{368, 369, 370, 371, 372, 373, 374, 375, 376, 378, 379}] = {
            type = "regen",
            id = 1,
            params = {
                {param = CONDITION_PARAM_HEALTHGAIN, value = 500},
                {param = CONDITION_PARAM_HEALTHTICKS, value = 2000},
                {param = CONDITION_PARAM_MANAGAIN, value = 500},
                {param = CONDITION_PARAM_MANATICKS, value = 2000}
            }
        }
    },
    wings = {
        [{1655, 1656}] = {
            type = "bonus",
            id = 1,
            params = {
                {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 10},
                {param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, value = 110}
            }
        },
        [{1657, 1658}] = {
            type = "bonus",
            id = 2,
            params = {
                {param = CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, value = 200}
            }
        },
        [{1658, 1659}] = {
            type = "bonus",
            id = 3,
            params = {
                {param = COMBAT_PARAM_TYPE, value = COMBAT_ICEDAMAGE}
            }
        }
    },
    auras = {
        [{1657, 1658}] = {
            type = "bonus",
            id = 1,
            params = {
                {param = CONDITION_PARAM_STAT_MAGICPOINTS, value = 10},
                {param = CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT, value = 110}
            }
        },
        [{1659, 1660}] = {
            type = "bonus",
            id = 2,
            params = {
                {param = CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT, value = 200}
            }
        },
        [{1661, 1662}] = {
            type = "bonus",
            id = 3,
            params = {
                {param = COMBAT_PARAM_TYPE, value = COMBAT_ICEDAMAGE}
            }
        }
    }
}

function getBonusCondition(look, bonusTable)
    if look ~= 0 and bonusTable then
        for outfits, bonus in pairs(bonusTable) do
            if table.contains(outfits, look) then
                return bonus
            end
        end
    end
    return nil
end

local function createCondition(type, id, params)
    local conditionType
    if type == "bonus" then
        conditionType = CONDITION_ATTRIBUTES
    elseif type == "regen" then
        conditionType = CONDITION_REGENERATION
    elseif type == "haste" then
        conditionType = CONDITION_HASTE
    else
        return nil
    end

    local condition = Condition(conditionType, CONDITIONID_DEFAULT)
    condition:setParameter(CONDITION_PARAM_TICKS, -1)
    condition:setParameter(CONDITION_PARAM_SUBID, id)
    for _, paramData in ipairs(params) do
        condition:setParameter(paramData.param, paramData.value)
    end
    return condition
end

local function removeBonus(player, look, bonusTable)
    if look ~= 0 then
        local bonus = getBonusCondition(look, bonusTable)
        if bonus then
            print("Removing bonus with:", bonus.id)
            player:removeCondition(CONDITION_ATTRIBUTES, CONDITIONID_DEFAULT, bonus.id)
        end
    end
end

local function applyBonus(player, look, bonusTable)
    if look ~= 0 then
        local bonus = getBonusCondition(look, bonusTable)
        if bonus then
            print("Applying bonus with ID:", bonus.id)
            local condition = createCondition(bonus.type, bonus.id, bonus.params)
            if condition then
                player:addCondition(condition)
                local bonusMessage = "Applied bonus with ID: Attributes: "
                local messages = {
                    [CONDITION_PARAM_STAT_MAGICPOINTS] = "Magic Level",
                    [CONDITION_PARAM_SKILL_SHIELD] = "Shield Skill",
                    [CONDITION_PARAM_SKILL_MELEE] = "Melee",
                    [CONDITION_PARAM_SKILL_FIST] = "Fist Skill",
                    [CONDITION_PARAM_SKILL_DISTANCE] = "Distance Skill",
                    [CONDITION_PARAM_STAT_MAXHITPOINTSPERCENT] = "HP%",
                    [CONDITION_PARAM_STAT_MAXMANAPOINTSPERCENT] = "MP%",
                    [COMBAT_PARAM_TYPE] = "Combat Type",
                    [CONDITION_PARAM_HEALTHGAIN] = "HP Gain",
                    [CONDITION_PARAM_HEALTHTICKS] = "HP Ticks",
                    [CONDITION_PARAM_MANAGAIN] = "MP Gain",
                    [CONDITION_PARAM_MANATICKS] = "MP Ticks"
                }
                for _, paramData in ipairs(bonus.params) do
                    bonusMessage = bonusMessage .. (messages[paramData.param] or "Unknown") .. ": " .. paramData.value .. " "
                end
                player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, bonusMessage)
            end
        end
    end
end

local function onChangeOutfit(player, outfit)
    print("Change Outfit Triggered")

    local previousOutfit = player:getOutfit().lookType or 0
    local previousMount = player:getOutfit().lookMount or 0
    local previousWings = player:getOutfit().lookWings or 0
    local previousAura = player:getOutfit().lookAura or 0

    print("Previous Outfit ID:", previousOutfit)
    print("Previous Mount ID:", previousMount)
    print("Previous Wings ID:", previousWings)
    print("Previous Aura ID:", previousAura)

    removeBonus(player, previousOutfit, bonusesConfig.outfits)
    removeBonus(player, previousMount, bonusesConfig.mounts)
    removeBonus(player, previousWings, bonusesConfig.wings)
    removeBonus(player, previousAura, bonusesConfig.auras)

    if outfit.lookAddons == 3 then
        applyBonus(player, outfit.lookType, bonusesConfig.outfits)
    end

    print("Outfit changed to:", outfit.lookType)
    print("Mount changed to:", outfit.lookMount)
    print("Wings changed to:", outfit.lookWings)
    print("Aura changed to:", outfit.lookAura)
    return true
end

local ec = EventCallback
ec.onChangeOutfit = onChangeOutfit
ec:register()

local updateBonusesEvent = CreatureEvent("updateBonuses")
function updateBonusesEvent.onLogin(player)
    print("Login Triggered")
    onChangeOutfit(player, player:getOutfit())
    return true
end
updateBonusesEvent:register()
This is the best script on Otland for Outfit so far
 
Back
Top