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

Solved [ACTIONS] Health over time item -> Randomly Recieved

Lightonia

Lightonia.servegame.com
Joined
Jun 4, 2007
Messages
492
Reaction score
9
Hi, i want to make this script that you randomly get HP between two amount's for example 10, 20
Thanks!


Heres the script
Lua:
local config = {
    amount = 50, -- HPs by second
    time = 4, -- seconds
    exhaust = {
        storage = 1000,
        time = 4, -- Exhaust time seconds~
    }
}

local function doRegeneration(cid, amount, seconds)
    if seconds <= 0 then
        return false
    end
    doCreatureAddHealth(cid, amount)
    doSendAnimatedText(getThingPos(cid), "+" .. amount, COLOR_LIGHTBLUE)
    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    return addEvent(doRegeneration, 1000, cid, amount, seconds - 1)
end

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if exhaustion.check(cid, config.exhaust.storage) then        
        return doPlayerSendCancel(cid, "You can only this kind of potion once every four seconds.")
    end    
    doRemoveItem(item.uid, 1)
    doRegeneration(cid, config.amount, config.time)
    exhaustion.set(cid, config.exhaust.storage, config.exhaust.time)
    return true
end
 
Lua:
local config = {
    time = 4, -- seconds
    exhaust = {
        storage = 1000,
        time = 4, -- Exhaust time seconds~
    }
}
 
local function doRegeneration(cid, seconds)
    if seconds <= 0 then
        return false
    end
    amount = math.random(10, 20)
    doCreatureAddHealth(cid, amount)
    doSendAnimatedText(getThingPos(cid), "+" .. amount, COLOR_LIGHTBLUE)
    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
    return addEvent(doRegeneration, 1000, cid, seconds - 1)
end
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if exhaustion.check(cid, config.exhaust.storage) then        
        return doPlayerSendCancel(cid, "You can only this kind of potion once every four seconds.")
    end    
    doRemoveItem(item.uid, 1)
    doRegeneration(cid, config.time)
    exhaustion.set(cid, config.exhaust.storage, config.exhaust.time)
    return true
end
 
Back
Top