• How to return value into callback mysqloo
    2 replies, posted
Hello ! I have a problem I can't solve. I would like to check if a player is new on my server. So, i've created this function : function player:isFirstJoin() return db:RunQuery("SELECT steamID FROM players WHERE steamID = '".. self:SteamID().."'", function(query, status, result) if(noResult(result)) then return true else return false end end) end But if I do that, this function return nothing. This isn't the first time I've had this. When I try to return a value into mysqloo callback, it doesn't work and I don't know why... and if I create a variable before query and I try to modify this variable into the callback, the variable is not redefined. Can you help me please ? Thanks
Give this post a read, gmsv_mysqloo v9. For a short recap of why you're methods aren't working. Method 1 doesn't work because returning from a nested function returns to whatever invoked that function, not the function it was defined in. Method 2 doesn't work because MySQLOO queries are asynchronous, which means your callback isn't called until after your base function has returned. You can make queries synchronous by using `query:wait()`, however this will cause you're server to halt based on the ping to your MySQL server.
Thank you ! I don't know how but I didn't see that it was a nested function ! I will work differently !
Sorry, you need to Log In to post a reply to this thread.