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

Lua Optimizing food script.

elnelson

Lunaria World Dev
Joined
Jun 20, 2009
Messages
595
Solutions
2
Reaction score
66
Location
México
Hello, otlanders :) i have this script made by myself, but its messy and i need to optimize it.
i'd like to add a notification when the buff ends, also it has a minor bug when someone eat the first it says "you are exhausted".
it would be great if it could say +15 mana each time it restores.

this is my script:

LUA:
local condition = createConditionObject(CONDITION_REGENERATION)
setConditionParam(condition, CONDITION_PARAM_SUBID, 11)
setConditionParam(condition, CONDITION_PARAM_BUFF_SPELL, true)
setConditionParam(condition, CONDITION_PARAM_TICKS, 1 * 60 * 1000)
setConditionParam(condition, CONDITION_PARAM_MANAGAIN, 15)
setConditionParam(condition, CONDITION_PARAM_MANATICKS, 3000)
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 1 * 60 * 1000)

function onUse(cid, item, fromPosition, itemEx, toPosition)
   if getPlayerStorageValue(cid, 4447798) == -1 then
doPlayerPopupFYI(cid, "[Tutorial]: Blueberries!\n\
Use it to add +15 mana regeneration each second\
You can get this farming.\
")
setPlayerStorageValue(cid, 4447798, 1)
end
if(hasCondition(cid, CONDITION_EXHAUST)) then
doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
doCreatureSay(cid, "You cant eat so fast.",TALKTYPE_ORANGE_1)
else
local exhausted_seconds = 60
local exhausted_storagevalue = 1263
if (os.time() > getPlayerStorageValue(cid, exhausted_storagevalue)) then
doPlayerSendCancel(cid, "You are exhausted.")
   if(not isSorcerer(cid) and not isDruid(cid)) then
   local pos = getPlayerPosition(cid)
       doAddCondition(cid, condition)
       doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
       setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
       doRemoveItem(item.uid,1)
       doPlayerFeed(cid, 12)
       doSendAnimatedText(pos, "[+15] Mana gain.", 112)
       return true
   end

   if(not isKnight(cid) and not isPaladin(cid)) then
       local pos = getPlayerPosition(cid)
       doSendMagicEffect(pos, CONST_ME_MAGIC_BLUE)
       setPlayerStorageValue(cid, exhausted_storagevalue, os.time() + exhausted_seconds)
       doRemoveItem(item.uid,1)
       doPlayerFeed(cid, 12)
       doAddCondition(cid, condition)
       doSendAnimatedText(pos, "[+15] Mana gain.", 112)
   end

   return true
end
end
end
 
Back
Top