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.
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>