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

TFS 0.X Players with expboost cant login

fyalhed

Member
Joined
Nov 18, 2017
Messages
156
Reaction score
20
Code:
[0:45:22.069] Axe has logged in.

[0:45:22.070] [Error - CreatureScript Interface]
[0:45:22.070] data/creaturescripts/scripts/expvouncher.lua:onLogin
[0:45:22.070] Description:
[0:45:22.070] data/creaturescripts/scripts/expvouncher.lua:2: attempt to compare number with string
[0:45:22.070] stack traceback:
[0:45:22.070]     data/creaturescripts/scripts/expvouncher.lua:2: in function <data/creaturescripts/scripts/expvouncher.lua:1>

[0:45:22.119] Axe has logged out.

Code:
function onLogin(cid)
    if getCreatureStorage(cid, 3024776) > 1 and getCreatureStorage(cid, 3024776) < os.time() and getCreatureStorage(cid, 3024777) > 0 then
        doPlayerSetExperienceRate(cid, math.abs(getPlayerRates(cid)[8] - getCreatureStorage(cid, 3024777)))
    --[[add math abs because idk if you have extreme low rates but that could cause a negative exp rate and that wouldn't be cool xd ]]
        doCreatureSetStorage(cid, 3024776, -1)
        doCreatureSetStorage(cid, 3024777, -1)
    end
    return true
end

Why players with expboost in my server can't login?
 
Solution
Code:
function onLogin(cid)
    local bonus = tonumber(getCreatureStorage(cid, 3024777))
    if bonus and getCreatureStorage(cid, 3024776) > 1 and getCreatureStorage(cid, 3024776) < os.time() and bonus > 0 then
        doPlayerSetExperienceRate(cid, math.abs(getPlayerRates(cid)[8] - bonus))
    --[[add math abs because idk if you have extreme low rates but that could cause a negative exp rate and that wouldn't be cool xd ]]
        doCreatureSetStorage(cid, 3024776, -1)
        doCreatureSetStorage(cid, 3024777, -1)
    end
    return true
end
You can't have fp inside storage natively because it's expecting string or integers so if you want to have float/double inside storage you need to convert it from string to number using "tonumber".
Code:
[0:45:22.070] data/creaturescripts/scripts/expvouncher.lua:2: attempt to compare number with string

Lua:
if getCreatureStorage(cid, 3024776) > 1 and getCreatureStorage(cid, 3024776) < os.time() and getCreatureStorage(cid, 3024777) > 0 then

My guess would be that one of those storage values is actually a string and it is being compared with a number, which is not possible.
 
Code:
[0:45:22.070] data/creaturescripts/scripts/expvouncher.lua:2: attempt to compare number with string

Lua:
if getCreatureStorage(cid, 3024776) > 1 and getCreatureStorage(cid, 3024776) < os.time() and getCreatureStorage(cid, 3024777) > 0 then

My guess would be that one of those storage values is actually a string and it is being compared with a number, which is not possible.

There is something wrong on NPC who add the expvouncher?

Code:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)     
NpcSystem.parseParameters(npcHandler)

local talkState = {}

function ExpBackNormal_EndVoucher(cid, bonus)
    local rates = math.abs(getPlayerRates(cid)[8] - bonus)
    doPlayerSetExperienceRate(cid, rates)
    doCreatureSetStorage(cid, 3024776, -1)
    doCreatureSetStorage(cid, 3024777, -1)
    return true
end

function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
    return false    
end

local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local price = 0

if msgcontains(msg:lower(), "basic exp booster") then
    price = getPlayerLevel(cid) * 350
    selfSay("Do you want the basic exp booster (15% bonus, 2 hours) for ".. price .." gold coins?", cid)
    talkState[talkUser] = 1
elseif msgcontains(msg:lower(), "strong exp booster") then
    price = 5
    selfSay("Do you want the strong exp booster (30% bonus, 2 hours) for ".. price .." donate coins?", cid)
    talkState[talkUser] = 3
elseif msgcontains(msg:lower(), "great exp booster") then
    price = 15
    selfSay("Do you want the great exp booster (50% bonus, 2 hours) for ".. price .." donate coins?", cid)
    talkState[talkUser] = 4






elseif msgcontains(msg:lower(), "yes") then
    -- gps
    if talkState[talkUser] == 1 then
        if(doPlayerRemoveMoney(cid, price)) then
            local exhaustedvoucher = 3024775
            local time = 3024776
            local bonusMultiplier = 3024777
            if(os.time() < getCreatureStorage(cid, exhaustedvoucher)) then
                selfSay("You can only use it once every 20 hours! You will be able to use this item again on: " .. os.date("%B", getPlayerStorageValue(cid, exhaustedvoucher)) .. "-" .. os.date("%d", getPlayerStorageValue(cid, exhaustedvoucher)) .. "-" .. os.date("%Y", getPlayerStorageValue(cid, exhaustedvoucher)) .. "  " .. os.date("%X", getPlayerStorageValue(cid, exhaustedvoucher)) .. ".")
                return true
            end
            local bonus = 0.15
            local rates = getPlayerRates(cid)[8] + bonus
            doPlayerSetExperienceRate(cid, rates)
            addEvent(ExpBackNormal_EndVoucher, 7200000, cid, bonus) -- 2 hours
            doCreatureSetStorage(cid, exhaustedvoucher, os.time() + (20*60*60*1000)) -- 24 hours
            doCreatureSetStorage(cid, time, os.time() + 7200000)
            doCreatureSetStorage(cid, bonusMultiplier, bonus)
            doSendMagicEffect(getCreaturePosition(cid), 14)
            selfSay("Here you are... 2 hours of 15% exp bonus!", cid)
            talkState[talkUser] = 0
        else
            selfSay("You dont have ".. price .." coins", cid)
            talkState[talkUser] = 0
        end
    -- tokens
    elseif talkState[talkUser] > 1 then
           local tokenid = 6527
           local ItemID = 0
           if(Topic[cid] == 3) then -- strong exp booster
            price = 5
            ItemID = 11401
           elseif(Topic[cid] == 4) then -- great exp booster
            price = 15
            ItemID = 11402
        end
        if getPlayerItemCount(cid, tokenid) < price then
            selfSay('Sorry, you don\'t have enough tokens.', cid)
            return 1
        end
        doPlayerRemoveItem(cid, tokenid, price)
        doPlayerAddItem(cid, ItemID, 1)
        selfSay('Here you are.', cid)
        talkState[talkUser] = 0
    end
end

end  -- fim function
         

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
 
Can you try breaking the line before using and ? in order to figure out which expression is causing the error.
Lua:
if getCreatureStorage(cid, 3024776) > 1
and getCreatureStorage(cid, 3024776) < os.time()
and getCreatureStorage(cid, 3024777) > 0 then
 
Code:
function onLogin(cid)
    local bonus = tonumber(getCreatureStorage(cid, 3024777))
    if bonus and getCreatureStorage(cid, 3024776) > 1 and getCreatureStorage(cid, 3024776) < os.time() and bonus > 0 then
        doPlayerSetExperienceRate(cid, math.abs(getPlayerRates(cid)[8] - bonus))
    --[[add math abs because idk if you have extreme low rates but that could cause a negative exp rate and that wouldn't be cool xd ]]
        doCreatureSetStorage(cid, 3024776, -1)
        doCreatureSetStorage(cid, 3024777, -1)
    end
    return true
end
You can't have fp inside storage natively because it's expecting string or integers so if you want to have float/double inside storage you need to convert it from string to number using "tonumber".
 
Solution
Back
Top