• 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

Advanced OT User
Joined
Oct 11, 2009
Messages
1,402
Solutions
17
Reaction score
150
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...
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
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
 
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
 
Back
Top