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

[Action] Item gives health depense on health max.

Midxas

New Member
Joined
Apr 21, 2014
Messages
43
Reaction score
0
Hello guys Im looking for script which gives you hp depense on your hp max or level or something. Doesen't metter.

I have something like this but it doesn't work ;/
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
if not isPlayer(cid) then
return true
end

local x = config[getMaxHealth(cid)]
if isPlayer(itemEx.uid) then
doCreatureAddHealth(itemEx.uid, math.floor(math.random(x.hp[1], x.hp[2]) / (cid == itemEx.uid and 1 or 2)))
doSendMagicEffect(getThingPos(itemEx.uid), 12)
return true
end

And anyone know how to make item which work 100% like uh rune but in actions? I tried copy code from uh to actions script but faild :/ Please answer!
 
To convert spells to actions you just have to change var value.
For UH it's numberToVariant(cid)

Example:
Code:
doCombat(cid, combat, numberToVariant(cid))

Topic:

Your spell isn't working becouse: local x = config[getMaxHealth(cid)], what config? There is no config! It should be like this: local x = getMaxHealth(cid)
Next is that crazy line: doCreatureAddHealth(itemEx.uid, math.floor(math.random(x.hp[1], x.hp[2]) / (cid == itemEx.uid and 1 or 2))), heh.

And this:
Code:
if not isPlayer(cid) then
return true
end
Is totally useless, becouse monsters and NPCs cant't use items. It's logically impossible.

This action should looks like this, ofc I think you aren't using TFS. Becouse TFS haven't things like getMaxHealth. It's getCreatureMaxHealth.
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local x = math.random(getCreatureMaxHealth(cid) * 0.1, getCreatureMaxHealth(cid) * 0.2) -- heals random 10% to 20% hp
    if isPlayer(itemEx.uid) == true then
        doCreatureAddHealth(itemEx.uid, x)
        doSendMagicEffect(getThingPos(itemEx.uid), 12)
    end
    return true
end
 
Back
Top