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

Dance.lua problem

Exactly

New Member
Joined
Jul 14, 2014
Messages
117
Reaction score
4
Error console:

[Error - CreatureScript Interface]
data/creaturescripts/scripts/dance.lua:eek:nDirection
Description:
data/creaturescripts/scripts/dance.lua:19: bad argument #3 to 'max' (number expected, got nil)
stack traceback:
[C]: in function 'max'
data/creaturescripts/scripts/dance.lua:19: in function <data/creaturescripts/scripts/dance.lua:9>

Dance.lua

Lua:
--- Edit by Collo~ gg: 7284838 (c)----

local exhaust = {
    storage = 2153,
    seconds = 10
}
local storage = 45658
function onDirection(cid, old, current)
    if isPlayer(cid) then
        if current ~= old and exhaustion.check(cid, exhaust.storage) then
            doPlayerSendCancel(cid, 'Don\'t saturate the server making flood.')
            return false
        else
            if getCreatureStorage(cid, storage) == 6 then           
                exhaustion.set(cid, exhaust.storage, exhaust.seconds)
                doCreatureSetStorage(cid, storage, 0)
            else
                doCreatureSetStorage(cid, storage, math.max(0, getCreatureStorage(cid, storage)) + 1)
            end
        end
    end
    return true
end


Thanks for help !
 
What distro are you using?
It seems to be because
Code:
getCreatureStorage(cid, storage)) + 1
is returning nil instead of a number which is what math.max wants, that suggests that the players storage is not evaluated yet.
To avoid that, put
Code:
setCreatureStorage(cid, 45658,1)
in login.lua
 
Back
Top