Hello, Facepunch.
The problem I have encountered is returning data from a function when using the tmysql module.
My current code is:
[code]
function DB.GetVip(ply)
if not ValidEntity(ply) then return end
if not ply:IRPValidated() then return end
tmysql.query("SELECT vip FROM irp_accounts WHERE id = " .. math.floor(ply:IRPID()), function(res, status, error)
return res[1][1]
end)
end
[/code]
Although this doesn't return the data in the DB.GetVip function, it only returns it for the tmysql callback.
I really need a solution to this, in order to release a crucial update for my gamemode.
Thank you to all that can help.
Shouldn't it be
[code]if not ValidEntity == ply then return end[/code]
[QUOTE=Eusion;21366936]Hello, Facepunch.
The problem I have encountered is returning data from a function when using the tmysql module.
My current code is:
[code]
function DB.GetVip(ply)
if not ValidEntity(ply) then return end
if not ply:IRPValidated() then return end
tmysql.query("SELECT vip FROM irp_accounts WHERE id = " .. math.floor(ply:IRPID()), function(res, status, error)
return res[1][1]
end)
end
[/code]Although this doesn't return the data in the DB.GetVip function, it only returns it for the tmysql callback.
I really need a solution to this, in order to release a crucial update for my gamemode.
Thank you to all that can help.[/QUOTE]
You cant,
make this on the player's Inital spawn, and save it as like: ply.VIP = res[1][1]
on that way, you can use DB.GetVip(ply) and just return the ply.VIP
[QUOTE=Busymonkey;21367370]Shouldn't it be
[code]if not ValidEntity == ply then return end[/code][/QUOTE]
Not realy.
A: ent:IsValid()
B: ValidEntity(ent)
Thank you everyone for your suggestions.
I have found a solution, it was due to the function I was using this in requesting the answer instantly.
As it is threaded. It doesn't return the query table instantly.
My friend, Scorpius has devised a solution for this,
but again, thank you for your suggestions.
~Eusion.
[QUOTE=bromvlieg;21367378]
A: ent:IsValid()
B: ValidEntity(ent)[/QUOTE]
Ah, I see.
I'm not much of an advanced coder, but I figured I'd give my contribution :)
Sorry, you need to Log In to post a reply to this thread.