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

Solved 1.3 local variable returning nil, not sure why.

Oneda

Aspiring Spriter
Joined
Dec 3, 2013
Messages
159
Solutions
2
Reaction score
104
Location
Brazil
So, I'm trying to parse a var in a getItemCount, but its returning nil, not really sure what I'm doing wrong here.

if I replace
Lua:
player:getItemCount(aucItem)
with
Lua:
player:getItemCount(2160)
for example, the script runs well. Pretty confused why the var itself is returning nil.


Lua:
function onSay(player, words, param)
    local aucItem = param
 
    if not tonumber(aucItem) then
        player:sendPrivateMessage(player, "Invalid item ID.")
        print (''..aucItem..'[1]')
    elseif player:getItemCount(aucItem) <= 0 then
        print (''..aucItem..'[2]')
        player:sendPrivateMessage(player, "You don't have any items with that ID.")
    else
        print (''..aucItem..'[3]')      
    end
end


Edit: nevermind, I actually just re-read the post and found the obvious mistake.

The solution if anyone else ever make this mistake:

Lua:
    local aucItem = tonumber(param)
and
Lua:
    if not tonumber(param) then

(Yeah, just converting the var back into a number.)
 
Last edited:
Back
Top