attempt to perform arithmetic on global 'xp' (a nil value) [DarkRP]

[LUA]function GoodXP(ply, args)
target = FindPlayer(args)
if target then
DB.Begin()
giverID = ply:SteamID()
targetID = target:SteamID()
rpxp = DB.QueryValue(“SELECT level FROM stkrp_lvl WHERE steam = '”…giverID…"’")
inf = rpxp + 50
DB.Query(“UPDATE stkrp_lvl SET level = “…inf…” WHERE steam = '”…targetID…"’")
DB.Commit()
ply:PrintMessage(HUD_PRINTTALK, “You Have Sucessfully Given " … args … " " … (influence) …” RPXP")
target:PrintMessage(HUD_PRINTTALK, “You Have Been Given " … (influence) …” RPXP From “…ply:Nick()…”. You Now Have “…influence…” RPXP")
return “”
else
ply:PrintMessage(HUD_PRINTTALK, “Cannot Find Person”)
return “”
end
end
[/LUA]

I type in /goodrp Bob Dylan (Myself)

[LUA][gamemodes\stkrpv3beta\gamemode\data.lua:71] attempt to call local ‘callback’ (a nil value)(Hook: PlayerSay)
[cpp] Error: hook->PlayerSay returned a non-string!
[/LUA]

Any help? No doubt it’s right there in my face. But I can’t see it.

Database Creation Line:
[LUA]DB.Query(“CREATE TABLE IF NOT EXISTS stkrp_lvl(steam char(20) NOT NULL, level INTEGER NOT NULL, PRIMARY KEY(steam));”)[/LUA]

Show the full code, please.

It’s 774 lines big, and that is really all I have made of it so far.

Isn’t args a table?
Will FindPlayer(args) work? Won’t you need to do args[1], or table.concat(args," ") ?

Having target as a global might not really be a good idea either.

FindPlayer(args) work. If I put /goodrp Blahblah it will print “Cannot Find Player”. If I put in /goodrp Bob Dylan. It works.

Try this code…

[lua]
function GoodXP(ply, args)
target = FindPlayer(args[1])
if target then
giverID = ply:SteamID()
targetID = target:SteamID()
rpxp = DB.QueryValue(“SELECT level FROM stkrp_lvl WHERE steam = '”…giverID…"’")
inf = rpxp + 50
DB.QueryValue(“UPDATE stkrp_lvl SET level = “…inf…” WHERE steam = '”…targetID…"’")
ply:PrintMessage(HUD_PRINTTALK, “You Have Sucessfully Given " … target:Nick() … " " … (inf) …” RPXP")
target:PrintMessage(HUD_PRINTTALK, “You Have Been Given " … (inf) …” RPXP From “…ply:Nick()…”. You Now Have “…inf…” RPXP")
return “”
else
ply:PrintMessage(HUD_PRINTTALK, “Cannot Find Player…”)
return “”
end
end
[/lua]

[lua][gamemodes\stkrpv3beta\gamemode\data.lua:71] attempt to call local ‘callback’ (a nil value)(Hook: PlayerSay)
[cpp] Error: hook->PlayerSay returned a non-string![/lua]

Line 71:

[lua] callback(sql.QueryValue(query))[/lua]

[lua]
sql.QueryValue(query,function(data)
PrintTable(data);
end)
[/lua]