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

[Otx2] Bug mod Exp Pot

Magnanimo

New Member
Joined
May 19, 2017
Messages
14
Solutions
1
Reaction score
1
Otx2 version 8.6.


Hey guys
Recently a player reported to me a problem that is happening with the exppot script that I use.

The bug works as follows.
The player buys several exppot and activates a macro to use them all the time.
Each exppot lasts 120 minutes. When the exppot effect ends, the macro quickly activates another one, thus doubling the exp bonus provided by the pot.

The macro is so fast that the player is not even shown the message that the exppot is over.
I believe that the bug occurs in the onThink function, I believe that it lacks some check function in it or in the onUse function.

XML:
<?xml version="1.0" encoding="ISO-8859-1"?>
<mod name="Exp Potion" version="1.0" author="Vodkart" contact="DISCORD: vodkart#6090" enabled="yes">
<config name="exppotion"><![CDATA[
exp_info = {rate = 2, storage = {354870,354871,354872}, minutes = 120} -- rate 2 = 200%
function convertTime(a)
  if(type(tonumber(a)) == "number" and a > 0) then
    if (a <= 3599) then
      local minute = math.floor(a/60)
      local second = a - (60 * minute)
      if(second == 0) then
        return ((minute)..((minute > 1) and " minutos" or " minuto"))
      else
        return ((minute ~= 0) and ((minute>1) and minute.." minutos e " or minute.." minuto e ").. ((second>1) and second.." segundos" or second.." segundo") or ((second>1) and second.." segundos" or second.. " segundo"))
      end
    else
      local hour = math.floor(a/3600)
      local minute = math.floor((a - (hour * 3600))/60)
      local second = (a - (3600 * hour) - (minute * 60))
      if (minute == 0 and second > 0) then
        return (hour..((hour > 1) and " horas e " or " hora e "))..(second..((second > 1) and " segundos" or " segundo"))
      elseif (second == 0 and minute > 0) then
        return (hour..((hour > 1) and " horas e " or " hora e "))..(minute..((minute > 1) and " minutos" or " minuto"))
      elseif (second == 0 and minute == 0) then
        return (hour..((hour > 1) and " horas" or " hora"))
      end
      return (hour..((hour > 1) and " horas, " or " hora, "))..(minute..((minute > 1) and " minutos e " or " minuto e "))..(second..((second > 1) and " segundos" or " segundo"))
    end
  end
end
]]></config>
<event type="login" name="ExpPotionLogin" event="script"><![CDATA[
domodlib('exppotion')
function onLogin(cid)
    if getPlayerStorageValue(cid, exp_info.storage[1]) - os.time() > 0 then
        registerCreatureEvent(cid, "ExpPotionThink")
        local rates = getPlayerRates(cid)
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você ainda tem "..convertTime(getPlayerStorageValue(cid, exp_info.storage[1]) - os.time()).." de Exp Paper.")
        doPlayerSetExperienceRate(cid, rates[SKILL__LEVEL]+exp_info.rate)
        setPlayerStorageValue(cid, exp_info.storage[3], 1) -- registro
    end
    return true
end]]></event>
<event type="think" name="ExpPotionThink" event="script"><![CDATA[
domodlib('exppotion')
function onThink(cid, interval)
    if getPlayerStorageValue(cid, exp_info.storage[3]) > 0 and getPlayerStorageValue(cid, exp_info.storage[1]) - os.time() <= 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Sua Exp Paper acabou!")
        -- doPlayerSetExperienceRate(cid, getPlayerStorageValue(cid, exp_info.storage[2]))
        local rates = getPlayerRates(cid)
        doPlayerSetExperienceRate(cid, rates[SKILL__LEVEL]-exp_info.rate)
        setPlayerStorageValue(cid, exp_info.storage[3], 0) -- registro
    end
    return true
end]]></event>
<talkaction words="!exppaper;/exppaper;!exp;/exp" event="buffer"><![CDATA[
domodlib('exppotion')
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, getPlayerStorageValue(cid, exp_info.storage[1]) - os.time() <= 0 and "Você não possui Exp Paper ativa no momento." or "Você tem "..convertTime(getPlayerStorageValue(cid, exp_info.storage[1]) - os.time()).." de exp paper.")]]></talkaction>
<action itemid="11563" event="script"><![CDATA[
domodlib('exppotion')
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, exp_info.storage[1]) - os.time() > 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você não pode usar outra Exp Paper pois ainda possui uma ativa. Ainda restam: "..convertTime(getPlayerStorageValue(cid, exp_info.storage[1]) - os.time())..".") return true
    end
    
    local rates = getPlayerRates(cid)
    -- setPlayerStorageValue(cid, exp_info.storage[2], rates[SKILL__LEVEL])
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você ativou Exp paper por "..exp_info.minutes.." minutos! Durante este tempo, você receberá +200% exp de monstros. Para saber o tempo, digite: /exppaper")
    setPlayerStorageValue(cid, exp_info.storage[1], os.time()+exp_info.minutes*60)
    setPlayerStorageValue(cid, exp_info.storage[3], 1) -- registro
    doPlayerSetExperienceRate(cid, rates[SKILL__LEVEL]+exp_info.rate)
    registerCreatureEvent(cid, "ExpPotionThink")
    doRemoveItem(item.uid,1)
    return true
end]]></action>
</mod>
 
Solution
Lua:
<action itemid="11563" event="script"><![CDATA[
domodlib('exppotion')
function onUse(cid, item, fromPosition, itemEx, toPosition)

if getPlayerStorageValue(cid, exp_info.storage[1]) - os.time() > 0 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você não pode usar outra Exp Paper pois ainda possui uma ativa. Ainda restam: "..convertTime(getPlayerStorageValue(cid, exp_info.storage[1]) - os.time())..".") return true
end

local rates = getPlayerRates(cid)
-- setPlayerStorageValue(cid, exp_info.storage[2], rates[SKILL__LEVEL])
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você ativou Exp paper por "..exp_info.minutes.." minutos! Durante este tempo, você receberá +200% exp de monstros. Para saber o tempo, digite...

darknelson

Member
Joined
Jun 19, 2011
Messages
193
Solutions
1
Reaction score
14
Lua:
<action itemid="11563" event="script"><![CDATA[
domodlib('exppotion')
function onUse(cid, item, fromPosition, itemEx, toPosition)

if getPlayerStorageValue(cid, exp_info.storage[1]) - os.time() > 0 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você não pode usar outra Exp Paper pois ainda possui uma ativa. Ainda restam: "..convertTime(getPlayerStorageValue(cid, exp_info.storage[1]) - os.time())..".") return true
end

local rates = getPlayerRates(cid)
-- setPlayerStorageValue(cid, exp_info.storage[2], rates[SKILL__LEVEL])
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você ativou Exp paper por "..exp_info.minutes.." minutos! Durante este tempo, você receberá +200% exp de monstros. Para saber o tempo, digite: /exppaper")
setPlayerStorageValue(cid, exp_info.storage[1], os.time()+exp_info.minutes*60)
setPlayerStorageValue(cid, exp_info.storage[3], 1) -- registro
doPlayerSetExperienceRate(cid, rates[SKILL__LEVEL]+exp_info.rate)
registerCreatureEvent(cid, "ExpPotionThink")
doRemoveItem(item.uid,1)
return true
end]]></action>


might be the problem is there, maybe putting a manual exhausted ms condition it will prevent that, another than storage value. Storage value on think function doesnt much have to be on that ask @Xikini


for example on tfs i use this

Code:
local exhaust = Condition(CONDITION_EXHAUST)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 700))
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:getCondition(CONDITION_EXHAUST) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return true
    end
 
OP
M

Magnanimo

New Member
Joined
May 19, 2017
Messages
14
Solutions
1
Reaction score
1
Lua:
<action itemid="11563" event="script"><![CDATA[
domodlib('exppotion')
function onUse(cid, item, fromPosition, itemEx, toPosition)

if getPlayerStorageValue(cid, exp_info.storage[1]) - os.time() > 0 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você não pode usar outra Exp Paper pois ainda possui uma ativa. Ainda restam: "..convertTime(getPlayerStorageValue(cid, exp_info.storage[1]) - os.time())..".") return true
end

local rates = getPlayerRates(cid)
-- setPlayerStorageValue(cid, exp_info.storage[2], rates[SKILL__LEVEL])
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você ativou Exp paper por "..exp_info.minutes.." minutos! Durante este tempo, você receberá +200% exp de monstros. Para saber o tempo, digite: /exppaper")
setPlayerStorageValue(cid, exp_info.storage[1], os.time()+exp_info.minutes*60)
setPlayerStorageValue(cid, exp_info.storage[3], 1) -- registro
doPlayerSetExperienceRate(cid, rates[SKILL__LEVEL]+exp_info.rate)
registerCreatureEvent(cid, "ExpPotionThink")
doRemoveItem(item.uid,1)
return true
end]]></action>


might be the problem is there, maybe putting a manual exhausted ms condition it will prevent that, another than storage value. Storage value on think function doesnt much have to be on that ask @Xikini


for example on tfs i use this

Code:
local exhaust = Condition(CONDITION_EXHAUST)
exhaust:setParameter(CONDITION_PARAM_TICKS, (configManager.getNumber(configKeys.EX_ACTIONS_DELAY_INTERVAL) - 700))
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
if player:getCondition(CONDITION_EXHAUST) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return true
    end
thank you darknelson for paying attention to my post.

I added this exhast condition as in the provided example, however it didn't work.

But luckily I managed to solve my problem in 2 ways:

1. Adding doRemoveCreature(cid) in the think event. (only a temporary solution)

2. changing the:
Lua:
if getPlayerStorageValue(cid, exp_info.storage[1]) - os.time() > 0 then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Você não pode usar outra Exp Paper pois ainda possui uma ativa. Ainda restam: "..convertTime(getPlayerStorageValue(cid, exp_info.storage[1]) - os.time())..".") return true
    end

per:
Lua:
if getPlayerStorageValue(cid, exp_info.storage[1]) - os.time() > 0 then
        return doPlayerSendCancel(cid, "Você ja está com um paper ativo, aguarde "..convertTime(getPlayerStorageValue(cid, exp_info.storage[1]) - os.time()).." segundos.")
    end
 
Solution
Top