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

Lua bad argument #1 to 'ipairs' (table expected, got boolean)

Wezza

lua nOOb
Joined
May 31, 2008
Messages
2,278
Reaction score
31
console error;

Code:
/data/lib/cs_functions.lua:494: bad argument #1 to 'ipairs' (table expected, got boolean)
stack traceback:
[C]: in function 'ipairs'
./data/lib/cs_functions.lua:494: in function <./data/lib/cs_functions.lua:490>

cs_functions;


Code:
function closeCs()
    local players = getCsPlayers()
    doBroadcastMessage("Counter-Strike is over! Total score: Terror: " .. getGlobalStorageValue(887786) .. ", Counter: " .. getGlobalStorageValue(887787) .. ". Next Counter-Strike: 22.00 CET tomorrow.", 22)
    setGlobalStorageValue(888888, 0)
    for _, cid in ipairs(players) do
        leaveCs(cid)
    end
end

line 494;
for _, cid in ipairs(players) do
leaveCs(cid)
 
console error;

Code:
/data/lib/cs_functions.lua:494: bad argument #1 to 'ipairs' (table expected, got boolean)
stack traceback:
[C]: in function 'ipairs'
./data/lib/cs_functions.lua:494: in function <./data/lib/cs_functions.lua:490>

cs_functions;


Code:
function closeCs()
    local players = getCsPlayers()
    doBroadcastMessage("Counter-Strike is over! Total score: Terror: " .. getGlobalStorageValue(887786) .. ", Counter: " .. getGlobalStorageValue(887787) .. ". Next Counter-Strike: 22.00 CET tomorrow.", 22)
    setGlobalStorageValue(888888, 0)
    for _, cid in ipairs(players) do
        leaveCs(cid)
    end
end

line 494;
for _, cid in ipairs(players) do
leaveCs(cid)

I'm not sure, but it do expect a table? If so we gonna need to see the getCsPlayers() functions cuz you assigned the ipairs with it.
 
In this function, getCsPlayers() should return a table.
Do you have the function getCsPlayers and is this function above function closeCs()?
If you have the function getCsPlayers and it's on the right place, post the function.
 
The function i posted above is the getCsPlayers

however here is the rest of it;

Code:
function getCsPlayers()
    local result = db.getResult("SELECT `player_id` FROM `cs`")

    if result:getID() ~= LUA_ERROR then
        local players = {}
        repeat
            local player_id = result:getDataInt "player_id"
            if player_id ~= nil then
                local cid = getPlayerByName(getPlayerNameByGUID(player_id))
                if isPlayer(cid) == TRUE then
                    table.insert(players, cid)
                else
                    db.executeQuery("DELETE FROM `cs` WHERE `player_id` = " .. player_id .. ";")
                end
            end
        until not result:next()
       
        result:free()
        return players
    end   
    return LUA_ERROR
end
 
What does it show in your console if you add this under local players = getCsPlayers()?
Code:
print(#players)
 
Back
Top