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

RevScripts Smart Cap items

Lbtg

Advanced OT User
Joined
Nov 22, 2008
Messages
2,394
Reaction score
162
Hi amazing souls!


please i want to ask for help in making a Smart Cap Items, for tfs 1.2++

Idea:

use XXX item, gain XX soul, if full soul cant use + effect, on use to gain soul also effect, + Orange text XX soul gained.
in script i would like to add multiple items, with different xx soul gain, different cancel/gain etc...

I hope i explain it well and someone can try making one :)
 
LUA:
local config = {
    [7249] = { soulAmount = 100, effect = CONST_ME_HOLYAREA },
    [7250] = { soulAmount = 70, effect = CONST_ME_HOLYAREA }
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
  
    local soulItem = config[item.itemid]
    if not soulItem then
        return true
    end
  
    if player:getSoul() >= player:getMaxSoul() then
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have max soul.')
        player:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS) -- Change to your effect
        return true
    end
  
    player:sendTextMessage(MESSAGE_INFO_DESCR, 'your soul has been refilled by '..soulItem.soulAmount..'.')
    player:addSoul(soulItem.soulAmount)
    player:getPosition():sendMagicEffect(soulItem.effect)
    item:remove(1)
    return true
end

for v, k in pairs(config) do
    action:id(v)
end

action:register()
 
LUA:
local config = {
    [7249] = { soulAmount = 100, effect = CONST_ME_HOLYAREA },
    [7250] = { soulAmount = 70, effect = CONST_ME_HOLYAREA }
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
 
    local soulItem = config[item.itemid]
    if not soulItem then
        return true
    end
 
    if player:getSoul() >= player:getMaxSoul() then
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have max soul.')
        player:getPosition():sendMagicEffect(CONST_ME_GIFT_WRAPS) -- Change to your effect
        return true
    end
 
    player:sendTextMessage(MESSAGE_INFO_DESCR, 'your soul has been refilled by '..soulItem.soulAmount..'.')
    player:addSoul(soulItem.soulAmount)
    player:getPosition():sendMagicEffect(soulItem.effect)
    item:remove(1)
    return true
end

for v, k in pairs(config) do
    action:id(v)
end

action:register()
works epic, tho wanted if i can setup different canceleffects if max soul differentlly on every items , if can change please ?

also would like to ask to add thats for all items in config, a cooldown to use for 30 seconds
Post automatically merged:

This kind of script exists like 200 times on otland :D
show me some if you see 200 easy xdd i been looking kinda alot didint find anything usefull
 
works epic, tho wanted if i can setup different canceleffects if max soul differentlly on every items , if can change please ?

also would like to ask to add thats for all items in config, a cooldown to use for 30 seconds
Post automatically merged:


show me some if you see 200 easy xdd i been looking kinda alot didint find anything usefull
LUA:
local config = {
    [7249] = { soulAmount = 100, effect = CONST_ME_HOLYAREA, maxSoulEffect = CONST_ME_GIFT_WRAPS, cooldown = 10 },
    [7250] = { soulAmount = 70, effect = CONST_ME_HOLYAREA, maxSoulEffect = CONST_ME_FIREWORK_YELLOW, cooldown = 15 }
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local soulItem = config[item.itemid]
    if not soulItem then
        return true
    end

    local storageKey = 10000 + item.itemid -- unique storage for each item ID to apply cooldown
    local lastUse = player:getStorageValue(storageKey)
    local currentTime = os.time()

    if lastUse > 0 and currentTime < (lastUse + soulItem.cooldown) then
        local remainingTime = (lastUse + soulItem.cooldown) - currentTime
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'You need to wait ' .. remainingTime .. ' seconds to use this item again.')
        return true
    end

    if player:getSoul() >= player:getMaxSoul() then
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have max soul.')
        player:getPosition():sendMagicEffect(soulItem.maxSoulEffect)
        return true
    end

    player:sendTextMessage(MESSAGE_INFO_DESCR, 'Your soul has been refilled by ' .. soulItem.soulAmount .. '.')
    player:addSoul(soulItem.soulAmount)
    player:getPosition():sendMagicEffect(soulItem.effect)
    item:remove(1)
   
    player:setStorageValue(storageKey, currentTime)
    return true
end

for itemId, _ in pairs(config) do
    action:id(itemId)
end

action:register()
 
LUA:
local config = {
    [7249] = { soulAmount = 100, effect = CONST_ME_HOLYAREA, maxSoulEffect = CONST_ME_GIFT_WRAPS, cooldown = 10 },
    [7250] = { soulAmount = 70, effect = CONST_ME_HOLYAREA, maxSoulEffect = CONST_ME_FIREWORK_YELLOW, cooldown = 15 }
}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local soulItem = config[item.itemid]
    if not soulItem then
        return true
    end

    local storageKey = 10000 + item.itemid -- unique storage for each item ID to apply cooldown
    local lastUse = player:getStorageValue(storageKey)
    local currentTime = os.time()

    if lastUse > 0 and currentTime < (lastUse + soulItem.cooldown) then
        local remainingTime = (lastUse + soulItem.cooldown) - currentTime
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'You need to wait ' .. remainingTime .. ' seconds to use this item again.')
        return true
    end

    if player:getSoul() >= player:getMaxSoul() then
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have max soul.')
        player:getPosition():sendMagicEffect(soulItem.maxSoulEffect)
        return true
    end

    player:sendTextMessage(MESSAGE_INFO_DESCR, 'Your soul has been refilled by ' .. soulItem.soulAmount .. '.')
    player:addSoul(soulItem.soulAmount)
    player:getPosition():sendMagicEffect(soulItem.effect)
    item:remove(1)
  
    player:setStorageValue(storageKey, currentTime)
    return true
end

for itemId, _ in pairs(config) do
    action:id(itemId)
end

action:register()
EPIC bro! thanks!
 
Back
Top