MySQLOO - Attempt to index local query 1


//----------------------------------------------------------
//                  ChargeBackBan (CBB)
//  DO NOT EDIT the other files in the addon unless you
//  know what you are doing, and you are willing to open up
//  your server to the banned players we block.
//
//               Otherwise, enjoy modding!
//
------------------------------------------------------------\\
include("cbb/functions.lua")
include("cbb/config.lua")
if(cbb_letsgo) then
    require ("mysqloo")
    function cbb_connectDB()
        databaseObject = mysqloo.connect("-snip-", "-snip-", "-snip-", "-snip-", -snip-)
        databaseObject.onConnected = function() cbb_print("[CHARGEBACKBAN] Connected to the database!") end
        databaseObject.onConnectionFailed = function() cbb_print("[CHARGEBACKBAN] Failed to connect to the database.") end
        databaseObject:connect()
    end
    function cbb_isBanned( ply, steamid, uniqueid )
        local query1 = databaseObject:query("SELECT * FROM cbb_banned WHERE steamid = '" .. steamid .. "'")
        query1.onSuccess = function(q)
            if cbb_isBannedChecker(q) then
                if(cbb_echobans) then
                    cbb_tellAdmins("We just banned " .. ply:Nick() .. " for having having a ChargebackBan")
                end
                ply:cbb_banPlayer()
            end
        end
        query1.onError = function(q,e) cbb_tellAdmins("[CHARGEBACKBAN] We failed to check if " .. ply:Nick() .." should be banned!") end
        query1:start()
    end
    function cbb_isBannedTest( steamid )
        local query1 = databaseObject:query("SELECT * FROM cbb_banned WHERE steamid = '" .. steamid .. "'")
        query1.onSuccess = function(q)
            if cbb_isBannedChecker(q) then
                if(steamid == "STEAM_0:1:102608846")then
                    cbb_print("[CHARGEBACKBAN] Our Testing SteamID (STEAM_0:1:102608846) was banned on our system!")
                    cbb_print("[CHARGEBACKBAN] Hurray! That means we can automatically ban the chargeback minges.")
                    return true
                end
                cbb_print("[CHARGEBACKBAN] " .. steamid .. " is globally banned on our system.")
                return true
            else
                return false
            end
        end
        query1.onError = function(q,e) cbb_tellAdmins("[CHARGEBACKBAN] We failed to check if " .. steamid .." should be banned!") end
        query1:start()    
    end
    cbb_connectDB()
    if(cbb_isBannedTest("STEAM_0:1:102608846")) then
        hook.Add("PlayerAuthed", "IsPlayerBanned", cbb_IsBanned)
    else
        cbb_print("[CHARGEBACKBAN] There was a problem checking if we can ban chargeback minges.")
        cbb_print("[CHARGEBACKBAN] Hook not initialized!")
    end
else
    cbb_print("[CHARGEBACKBAN] You haven't enabled the addon in the config file!")
end

What is wrong with this?

I’m being told that there is a problem on line 47, about query1 being a nil value.

[editline]14th February 2015[/editline]

Oh, and yes. Those credentials do work for my MySQL Server.

Try them if you want.

You run the query before the database has had time to start afaik, delay it to the onConnected callback.

Thanks

Remove the code, you just told everyone reading your mysql information .

I suggest you change it!

Couldn’t care less - I’m going to release it at one point anyway.

-snip-