Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
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!
local percent = 5
function onEquip(player, item, slot, isCheck)
if isCheck then
return true
end
player:addHealth(player:getMaxHealth() * percent / 100)
return true
end
local percent = 5
function onEquip(player, item, slot, isCheck)
if isCheck then
return true
end
player:addHealth(player:getMaxHealth() * percent / 100)
return true
end
oh im using the following, it works but after the char dies it stops healing even if dequped/requiped
Lua:
local percent = 5
local runningEvents = {}
local function gainHpAndMana(cid)
local player = Player(cid)
if not player then
return
end
player:addMana(player:getMaxMana() * percent / 100)
player:addHealth(player:getMaxHealth() * percent / 100)
runningEvents[1] = addEvent(gainHpAndMana, 1000, player:getId())
return true
end
function onEquip(player, item, slot)
local event = runningEvents[1]
if not event then
event = addEvent(gainHpAndMana, 1000, player:getId())
end
return true
end
function onDeEquip(player, item, slot)
local event = runningEvents[1]
stopEvent(runningEvents[1])
if event then
event = nil
end
return true
end
Not sure what you're trying to make here, but if you want an equipment to just works like a limitless ring of healing, you can do this just by adding some attributes into the items.xml, btw:
Not sure what you're trying to make here, but if you want an equipment to just works like a limitless ring of healing, you can do this just by adding some attributes into the items.xml, btw:
oh im using the following, it works but after the char dies it stops healing even if dequped/requiped
Lua:
local percent = 5
local runningEvents = {}
local function gainHpAndMana(cid)
local player = Player(cid)
if not player then
return
end
player:addMana(player:getMaxMana() * percent / 100)
player:addHealth(player:getMaxHealth() * percent / 100)
runningEvents[1] = addEvent(gainHpAndMana, 1000, player:getId())
return true
end
function onEquip(player, item, slot)
local event = runningEvents[1]
if not event then
event = addEvent(gainHpAndMana, 1000, player:getId())
end
return true
end
function onDeEquip(player, item, slot)
local event = runningEvents[1]
stopEvent(runningEvents[1])
if event then
event = nil
end
return true
end
Yours solution does not work as it allows only one event to be executed (so it only works for one player anywas).
You'd need to store event ID's per player to make that work and handle case when player dies (clean of this guard map)
Alternatively you could rework item attributes to allow to specify some additional attribute like usePercentage (healthPercentage / manaPercentage) (CPP changes required).
Yours solution does not work as it allows only one event to be executed (so it only works for one player anywas).
You'd need to store event ID's per player to make that work and handle case when player dies (clean of this guard map)
Ideally you could rework item attributes to allow to specify some additional attribute like "usePercentage" for "healthGain" (CPP changes required).
The condition I posted as exmaple is default food condition so maybe no to mix things up choose some other one (try to replace CONDITIONID_DEFAULT with respective slot condition e.g. CONDITIONID_RING) , anyway I'm sure you'll manage to make that work without side effect