Sqlite Boolean Value

[lua]
if (!sql.TableExists(“TRP_Missions”)) then
query = “CREATE TABLE TRP_Missions ( steamid varchar(225), level varchar(225) )”
dolevels = sql.Query(query)
if (sql.TableExists(“TRP_Missions”)) then
print(“TrueRP: Mission System Successfully Installed”)
else
print( sql.LastError( dolevels ) )
end

	end

[/lua]

[lua]
function NewPlayer(ply)

sql.Query("INSERT INTO TRP_Missions (`steamid`, `level`)VALUES ('"..ply:SteamID().."', '1')")

end
[/lua]

[lua]
function MyLevel(ply)

query = "SELECT level FROM TRP_Missions WHERE steamid = '".. ply:SteamID() .."'"
theLevel = sql.QueryValue(query)
print("You are level " .. theLevel .. ".")

end
concommand.Add(“MyLevel”, MyLevel)
[/lua]

When I type MyLevel in console I get the following error.



attempt to concatenate global 'theLevel' (a boolean value)


Any clue why this is happening?

Sorry, I really don’t know anything about programming, but a boolean value can only be ‘true’ or ‘false’ afaik?

Yeah. But I do not know what could be causing that.

QueryValue is probably returning false, so when you try to concatenate the result with a string, it will throw that error. Either cast the result with tostring() or use print(“string”, result).

I was just looking through my console and found this if it helps…




Hook 'Initialize' Failed: gamemodes	ruerp\gamemode\init.lua:10: attempt to perform arithmetic on a boolean value



Not unless you tell us what your line 10 of init.lua is.

[lua]if (sql.TableExists(“TRP_Money”) & sql.TableExists(“TRP_Missions”)) then[/lua]

Sorry.

It’s && not &.

Thanx this worked!