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

Lua [TFS 0.3.7] Item that completely fills mana and life

potinho

Well-Known Member
Joined
Oct 11, 2009
Messages
678
Solutions
15
Reaction score
52
Location
Brazil
Hello everyone, everything good? I need a script to put in an item (action on use) that fully completes a player's mana and life (like the new tibia foods). can you help me?
 
Solution
Works, let me ask a improvement (if u can):

*remove on use
*cooldown of 10 minutes
*message if is in cooldown
*message success, like "you feel reborning", something like that
Lua:
local config = {
   remove = true,
   -- If you want to disable cooldown, simply set a number less than 1
   cooldown = {
      time = 60, -- seconds
      storage = 000
   },
     effect = CONST_ME_STUN
}

function onUse(cid, item, fromPos, itemEx, toPos)
   if config.cooldown.time >= 1 then
      if getCreatureStorage(cid, config.cooldown.storage) > os.time() then
         return doPlayerSendCancel(cid, "You can only use this item every " .. config.cooldown.time .. " seconds, please wait.")
      end
      doCreatureSetStorage(cid...

Rombadr

Premium User
Premium User
Joined
Jan 19, 2020
Messages
299
Solutions
34
Reaction score
188
Should look something like this, I can't recall if those are the function names, but you can figure that out
Lua:
function onUse(cid, item, fromPos, itemEx, toPos)
    doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
    doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
end
 
OP
OP
potinho

potinho

Well-Known Member
Joined
Oct 11, 2009
Messages
678
Solutions
15
Reaction score
52
Location
Brazil
Should look something like this, I can't recall if those are the function names, but you can figure that out
Lua:
function onUse(cid, item, fromPos, itemEx, toPos)
    doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
    doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
end
Works, let me ask a improvement (if u can):

*remove on use
*cooldown of 10 minutes
*message if is in cooldown
*message success, like "you feel reborning", something like that
 

Alberto Cabrera

Well-Known Member
Joined
Sep 17, 2020
Messages
47
Solutions
14
Reaction score
51
Location
México
Works, let me ask a improvement (if u can):

*remove on use
*cooldown of 10 minutes
*message if is in cooldown
*message success, like "you feel reborning", something like that
Lua:
local config = {
   remove = true,
   -- If you want to disable cooldown, simply set a number less than 1
   cooldown = {
      time = 60, -- seconds
      storage = 000
   },
     effect = CONST_ME_STUN
}

function onUse(cid, item, fromPos, itemEx, toPos)
   if config.cooldown.time >= 1 then
      if getCreatureStorage(cid, config.cooldown.storage) > os.time() then
         return doPlayerSendCancel(cid, "You can only use this item every " .. config.cooldown.time .. " seconds, please wait.")
      end
      doCreatureSetStorage(cid, config.cooldown.storage, os.time() + config.cooldown.time)
   end
   if config.remove then
      doRemoveItem(item.uid)
   end
   if config.effect then
      doSendMagicEffect(getThingPosition(cid), config.effect)
   end

   -- doPlayerSendTextMessage(cid, MESSAGE_EVENT_ORANGE, "You feel reborning.")
   doCreatureSay(cid, "You feel reborning.", TALKTYPE_ORANGE_2)
   doCreatureAddHealth(cid, getCreatureMaxHealth(cid) - getCreatureHealth(cid))
   doCreatureAddMana(cid, getCreatureMaxMana(cid) - getCreatureMana(cid))
   return true
end
 
Solution
Top