• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Stamina Ring

_M4G0_

Intermediate OT User
Joined
Feb 6, 2016
Messages
550
Solutions
17
Reaction score
108
This Script from Lua - Soul ring
onDeEquip or ring expire, still continues to gain stamina/soul

LUA:
runningAddstaminaEvents = {}
local staminaBonus = 2
local function Addstamina(cid)
    local player = Player(cid)
    if not player then
        return
    end
    player:setStamina(player:getStamina() + staminaBonus)
    runningAddstaminaEvents[cid] = addEvent(Addstamina, 1000, cid)
end
function onEquip(player, item, slot)
    -- only execute it once since the bug still exists where equip triggers twice
    local slotItem = player:getSlotItem(slot)
    if slotItem and slotItem == item then
        Addstamina(player:getId())
     end
    return true
end
function onDeEquip(player, item, slot)
    stopEvent(runningAddstaminaEvents[player:getGuid()])
    runningAddstaminaEvents[player:getGuid()] = nil
    return true
end


Tfs 1.2
 
I've never found success using stopEvent like that.

idk the difference between player:getGuid() and player:getId()
I'm just going to change them all to getId()

try this
LUA:
local runningAddstaminaEvents = {}
local staminaBonus = 2
local function Addstamina(cid)
    local player = Player(cid)
    if not player then
        return
    end
    if runningAddstaminaEvents[cid] == 1 then
        player:setStamina(player:getStamina() + staminaBonus)
        addEvent(Addstamina, 1000, cid)
    end
end
 
function onEquip(player, item, slot)
    -- only execute it once since the bug still exists where equip triggers twice
    local slotItem = player:getSlotItem(slot)
    if slotItem and slotItem == item then
        runningAddstaminaEvents[player:getId()] = 1
        Addstamina(player:getId())
    end
    return true
end
function onDeEquip(player, item, slot)
    runningAddstaminaEvents[player:getId()] = nil
    return true
end
 
I've never found success using stopEvent like that.

idk the difference between player:getGuid() and player:getId()
I'm just going to change them all to getId()

try this
LUA:
local runningAddstaminaEvents = {}
local staminaBonus = 2
local function Addstamina(cid)
    local player = Player(cid)
    if not player then
        return
    end
    if runningAddstaminaEvents[cid] == 1 then
        player:setStamina(player:getStamina() + staminaBonus)
        addEvent(Addstamina, 1000, cid)
    end
end
 
function onEquip(player, item, slot)
    -- only execute it once since the bug still exists where equip triggers twice
    local slotItem = player:getSlotItem(slot)
    if slotItem and slotItem == item then
        runningAddstaminaEvents[player:getId()] = 1
        Addstamina(player:getId())
    end
    return true
end
function onDeEquip(player, item, slot)
    runningAddstaminaEvents[player:getId()] = nil
    return true
end
don't work :'(
thanks for help
 
Back
Top