• 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 Double exp per time - ERRO

_Aion_

Nothing Else
Joined
Jan 19, 2010
Messages
401
Solutions
4
Reaction score
10
Location
Jequie,Bahia,Brazil
Hello, I have a big problem.
I'm using a script that doubles exp for 5 hours, but is giving error.

ERROR
Code:
Error - CreatureScript Interface]
data/creaturescripts/scripts/extraExpRate.lua:onLogin
Description:
data/creaturescripts/scripts/extraExpRate.lua:14: attempt to compare number with string
stack traceback:
        data/creaturescripts/scripts/extraExpRate.lua:14: in function <data/creaturescripts/scripts/extraExpRate.lua:12>

SCRIPT
Code:
local config = {
	rate = 1.6, -- 4x More Experience
	storage = 20012
}
local function endExpRate(cid)
	if isPlayer(cid) == TRUE then
		doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
		setPlayerStorageValue(cid, config.storage, -1)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Sua Token ja terminou.")
	end
end
function onLogin(cid)
	local str = getPlayerStorageValue(cid, config.storage)
	if(str >= 0 and (str - os.time()) > 0) then 
		doPlayerSetRate(cid, SKILL__LEVEL, config.rate)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sua Double Exp Token vai até: " .. os.date("%X", str))
		addEvent(endExpRate, (str - os.time()) * 1000, cid)
	else
		doPlayerSetRate(cid, SKILL__LEVEL, 1) -- config.lua rate
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Voce nao possui Token.")
		setPlayerStorageValue(cid, config.storage, -1)
	end
	return TRUE
end

i'm using TFS 0.3.6

I will not be giving the reason for these bug, not just in this script.
has to do with the sourcer?

NOTE: This script was originally made for TFS 0.3.4, I believe that these changes must have changed something in the script if they can help me


Thanks
 
Last edited:
EDIT: This is actions for item to get double exp, are you mean something else? Didn't understand you correct


Try this script instead:

Code:
local otswe = {
    storage = 10000, -- Put Unused Storage Here
    time_end = 120*60*1000, -- Edit Time Here
    end_text = "The powers of the gods has expired.", -- Editable Text
    cancel_text = "Sorry, but you already effected by the gods.", -- Editable Text
    text_onuse = "2X", -- Editable Magic Text Max 8 letters
    exp_rate = 2.0, -- New Exprience Rate
    old_rate = 1.0 -- Old Exprience Rate
}

function onUse(cid, item, frompos, item2, topos)
    if getPlayerStorageValue(cid,otswe.storage) == 1 then
        doPlayerSendTextMessage(cid,MESSAGE_STATUS_CONSOLE_ORANGE, otswe.cancel_text)
        return false
    end
   
    if isPlayer(cid) then
        doCreatureSay(cid, "You have gained powers from the gods! You will gain twice faster exprience now! ", TALKTYPE_ORANGE_1)
        doSendAnimatedText(getCreaturePosition(cid), otswe.text_onuse ,TEXTCOLOR_RED)
        doSendMagicEffect(getCreaturePosition(cid), math.random(28, 30))
        doPlayerSetRate(cid, SKILL__LEVEL, 2)
        addEvent(otswe_exp_scroll,otswe.time_end,cid)
        setPlayerStorageValue(cid, otswe.storage, 1)
        doRemoveItem(item.uid, 1)
    end
    return true
end

function otswe_exp_scroll(rate, cid)
    if isPlayer(rate) then
        doPlayerSetRate(rate, SKILL__LEVEL, otswe.old_rate)
        doPlayerSendTextMessage(rate,MESSAGE_STATUS_CONSOLE_RED, otswe.end_text)
        setPlayerStorageValue(rate, otswe.storage, 0)
    end
end
 
Last edited:
Back
Top