• 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 tfs 1.5 Soul Charger

Lbtg

Intermediate OT User
Joined
Nov 22, 2008
Messages
2,306
Reaction score
129
Hey, i want to ask/request i believe for a simple script,
That gives soul to player on eating/using the item.
Example eat item xxxx - gain 50x cap ( on eat of the item give some effects, and red or green message in middle of screen '' your soul has been refilled by 50''
example if eat itemx2 xxxx gain 100x cap(....same)
So i want in one script be able to add as many charge soul items as i want

Revscript would be nicest to have such, as

I hope i made it clear xd

Thanks in advance!
 
Solution
Lua:
local config = {
    [7249] = { soulAmount = 50, effect = CONST_ME_HOLYAREA },
    [7250] = { soulAmount = 50, effect = CONST_ME_FIREAREA }
}

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.')
        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...
Lua:
local config = {
    [7249] = { soulAmount = 50, effect = CONST_ME_HOLYAREA },
    [7250] = { soulAmount = 50, effect = CONST_ME_FIREAREA }
}

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.')
        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()

Something like this?
 
Last edited:
Solution
Lua:
local config = {
    [7249] = { soulAmount = 50, effect = CONST_ME_HOLYAREA },
    [7250] = { soulAmount = 50, effect = CONST_ME_FIREAREA }
}

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.')
        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()

Something like this?
i think ye, will test and will say how it goes :)
Thanks alot!
 
Lua:
local config = {
    [7249] = { soulAmount = 50, effect = CONST_ME_HOLYAREA },
    [7250] = { soulAmount = 50, effect = CONST_ME_FIREAREA }
}

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.')
        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()

Something like this?
Greetings, would it be possible to have a cowdown to use the item again?
 
Greetings, would it be possible to have a cowdown to use the item again?

Lua:
local config = {
    [7249] = { soulAmount = 50, effect = CONST_ME_HOLYAREA },
    [7250] = { soulAmount = 50, effect = CONST_ME_FIREAREA }
}

local exhaustTable = {}

local action = Action()

function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local playerGuid = player:getGuid()
    local timeAmount = exhaustTable[playerGuid]
    if timeAmount and timeAmount > os.time() then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You must wait " .. (timeAmount - os.time()) .. " seconds.")
        return true
    end

    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.')
        return true
    end
 
    exhaustTable[playerGuid] = os.time() + 60 -- 60 seconds
    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:
configuração local = {
    [7249] = { soulAmount = 50, efeito = CONST_ME_HOLYAREA },
    [7250] = { soulAmount = 50, efeito = CONST_ME_FIREAREA }
}

tabela de exaustão local = {}

ação local = Ação()

função action.onUse (jogador, item, fromPosition, alvo, toPosition, isHotkey)
    playerGuid local = player:getGuid()
    hora localAmount = exaustãoTable[playerGuid]
    se timeAmount e timeAmount > os.time() então
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Você deve esperar " .. (timeAmount - os.time()) .. " segundos.")
        retornar verdadeiro
    fim

    soulItem local = config[item.itemid]
    se não for soulItem então
        retornar verdadeiro
    fim
 
    se jogador:getSoul() >= jogador:getMaxSoul() então
        player:sendTextMessage(MESSAGE_INFO_DESCR, 'Você tem alma máxima.')
        retornar verdadeiro
    fim
 
    exaustoTable[playerGuid] = os.time() + 60 - 60 segundos
    player:sendTextMessage(MESSAGE_INFO_DESCR, 'sua alma foi recarregada por '..soulItem.soulAmount..'.')
    jogador:addSoul(soulItem.soulAmount)
    player:getPosition():sendMagicEffect(soulItem.efeito)
    item: remover (1)
    retornar verdadeiro
fim

para v, k em pares (config) faça
    ação:id(v)
fim

ação:registrar()
gratful, perfect work
 
Back
Top