SQLite not saving

Hello all,

As you can see I’m trying to make a custom rank with sqlite saving. The table is created already, so that’s not the problem. I get the notifications when I ran the command but it’s not saving to sqlite. Can someone help me? (DB.Begin() DB.Query() DB.Commit() are darkrp functions)

Thank you.

[lua]
function rankControl(ply, cmd, args)
local id = args[1]
local val = args[2]
if not ValidEntity(ply) or not ply:GetUserGroup() == “root” or not id or not (val == “vip”) then return end
DB.Query([[SELECT rank FROM projrprank WHERE steam=]]…sql.SQLStr(id)…[[;]], function(arg)
if arg then
DB.Query([[UPDATE projrprank SET rank=]]…val…[[ WHERE steam=]]…sql.SQLStr(id)…[[;]])
else
DB.Begin()
DB.Query([[INSERT INTO projrprank VALUES(]]…sql.SQLStr(id)…[[, ]]…val…[[);]])
DB.Commit()
end
for k, v in pairs(player.GetAll()) do
if id == v:SteamID() then
v.rank = val
umsg.Start(“sendrank”, v)
umsg.String(val)
umsg.End()
GAMEMODE:Notify(v, 2, 4, “Congratulations with your new status!”) timer.Simple(1, function() GAMEMODE:Notify(v, 2, 4, “Thank you for supporting us - Darkline Crew”) end)
GAMEMODE:Notify(ply, 1, 4, “Set status to “…val…” for “…v:Nick()…” (”…v:SteamID()…")!")
else
GAMEMODE:Notify(ply, 1, 4, “Set status to “…val…” for “…v:SteamID()…”!”)
end
end
end)
end
concommand.Add(“rankSet”, rankControl)
[/lua]

[editline]27th July 2012[/editline]

No server/clientside errors

Updated script;

[lua]
function rankCheckLoad(ply)
DB.Query(“SELECT rank FROM projrprank WHERE steam=”…sql.SQLStr(ply:SteamID())…";", function(arg)
if arg then
ply.rank = arg
umsg.Start(“sendrank”, ply)
umsg.String(arg)
umsg.End()
end
end)
end
hook.Add(“PlayerInitialSpawn”, “PlayerrankCheckLoad”, rankCheckLoad)

function rankControl(ply, cmd, args)
local id = tostring(args[1])
local val = args[2]
if not ValidEntity(ply) or not (ply:GetUserGroup() == “root”) or not id or not val == “vip” then return end
DB.Query(“SELECT rank FROM projrprank WHERE steam=”…sql.SQLStr(id)…";", function(arg)
if arg then
DB.Query(“UPDATE projrprank SET rank=”…val…" WHERE steam="…sql.SQLStr(id)…";")
else
DB.Query(“INSERT INTO projrprank VALUES(”…sql.SQLStr(id)…", “…val…”);")
end
end)
for k, v in pairs(player.GetAll()) do
if id == v:SteamID() then
v.rank = val
print(val)
umsg.Start(“sendrank”, v)
umsg.String(val)
umsg.End()
GAMEMODE:Notify(v, 2, 4, “Congratulations with your new status!”) timer.Simple(1, function() GAMEMODE:Notify(v, 2, 4, “Thank you for supporting us - Darkline Crew”) end)
GAMEMODE:Notify(ply, 1, 4, “Set status to “…val…” for “…v:Nick()…” (”…v:SteamID()…")!")
else
GAMEMODE:Notify(ply, 1, 4, “Set status to “…val…” for “…v:SteamID()…”!”)
end
end
end
concommand.Add(“rankSet”, rankControl)
[/lua]