• 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!

create item

verdehile95

Member
Joined
Jan 31, 2024
Messages
47
Reaction score
5
hello, I would like to create an item that, when used, increases the player's statistics and adds a magical effect to the outfit that is displayed all the time on the outfit, the duration of the item is to be 5 minutes tfs 1.5 downgraded by nekiro 8.6
 
Lua:
-- Configuration for the item effect
local config = {
    itemId = 6558,                  -- ID of the item that triggers the effect
    durationSeconds = 300,          -- Total duration of effect in seconds (5 minutes)
    regenMana = 2000,               -- Mana regeneration value
    regenHealth = 2000,             -- Health regeneration value
    outfitLookType = 1500,          -- Temporary player outfit's look type
    storageValue = 4512,            -- Storage value to track if the effect has been used
    skillAmount = 10,               -- Amount of temporary skill increase for the player
    effect = 300,                   -- ID of the visual effect to be shown during the effect
}


function applyItemEffect(player)
    local playerGuid = player:getGuid()
    local currentOutfit = player:getOutfit()
    player:setOutfit({ lookType = config.outfitLookType })

   
    local Regen = Condition(CONDITION_REGENERATION)
    Regen:setParameter(CONDITION_PARAM_TICKS, 30000)
    Regen:setParameter(CONDITION_PARAM_HEALTHGAIN, config.regenHealth)
    Regen:setParameter(CONDITION_PARAM_HEALTHTICKS, 1)
    Regen:setParameter(CONDITION_PARAM_MANAGAIN, config.regenMana)
    Regen:setParameter(CONDITION_PARAM_MANATICKS, 1)
    player:addCondition(Regen)

    -- Adds conditions to temporarily increase player skills
    local skill = Condition(CONDITION_ATTRIBUTES)
    skill:setParameter(CONDITION_PARAM_TICKS, config.durationSeconds * 1000) -- Convert seconds to milliseconds

    -- Uncomment the lines below to include additional skills in the temporary skill increase
    skill:setParameter(CONDITION_PARAM_SKILL_SWORD, config.skillAmount)     -- Increases sword skill
    --skill:setParameter(CONDITION_PARAM_SKILL_CLUB, config.skillAmount)      -- Increases club skill
    --skill:setParameter(CONDITION_PARAM_SKILL_AXE, config.skillAmount)       -- Increases axe skill
    -- skill:setParameter(CONDITION_PARAM_SKILL_DISTANCE, config.skillAmount)  -- Increases distance fighting skill (commented out)
    -- skill:setParameter(CONDITION_PARAM_SKILL_SHIELD, config.skillAmount)    -- Increases shield skill (commented out)
    -- skill:setParameter(CONDITION_PARAM_SKILL_FIST, config.skillAmount)      -- Increases fist skill (commented out)
    -- skill:setParameter(CONDITION_PARAM_SKILL_FISHING, config.skillAmount)  -- Increases fishing skill (commented out)
    -- skill:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, config.skillAmount)  -- Increases magic level (commented out)

    player:addCondition(skill)
    player:setStorageValue(config.storageValue, 1)

    local function sendEffect(playerGuid)
        local player = Player(playerGuid)
        if player then
            player:getPosition():sendMagicEffect(config.effect)
        end
    end

    local function startEffectTimer(playerGuid, duration)
        for i = 1, duration do
            addEvent(sendEffect, i * 1000, playerGuid)
        end
    end

    startEffectTimer(playerGuid, config.durationSeconds)
    addEvent(function(playerGuid)
        local player = Player(playerGuid)
        if player then
            player:setOutfit(currentOutfit)
            player:removeCondition(CONDITION_ATTRIBUTES)
            player:setStorageValue(config.storageValue, 0)
            player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "The temporary effects have ended.")
        end
    end, config.durationSeconds * 1000)
end

local statistics = Action()

function statistics.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getStorageValue(config.storageValue) == 1 then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have already used the effect. Please wait for it to finish.")
        return false
    end

    if item:getId() == config.itemId then
        applyItemEffect(player)
        item:remove(1)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You used the item and your stats, skills, and outfit were temporarily increased!")
    else
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You cannot use this item.")
    end

    return true
end

statistics:id(config.itemId)
statistics:register()
 
Last edited:
Back
Top