Run sql.Query in clientside script, but modify only server database.

Hello! I need help, i have two functions: GetPlayerClanID() and GetPlayerClan(), i make a clan system.
Table with clans placed in serverside DB.
I need send “SELECT” request using sql.QueryValue from clientside script to server, and get return of sql.Query function, be sure on clientside script.
I tried to do it with basical GMOD Net library, but my function returns before net.Receive will be return in my function.
I tried make it with ent:SetNWString, this is of course silly, this may seem silly but I don’t know how to do otherwise :wavey:
In general: i need a get return of serverside function in clientside script, because hook OnPlayerChat only serverside. And I can only use this hook in my script.
Please help me! Thank!

Make a server side function that returns the results from the database and then have a net message receive catcher that calls the function and sends the contents to your client.
Also, make sure to put restrictions on how often and at what volumes your client will be able to call the function at.

He can also make a thing like in the timers that when you call the function theres an argument with a callback function.
You can make the same when net.Recieve has happened.

Run this code on shared, and you understand my problem.
if SERVER then
net.Receive( “test_tosv”, function( len, ply )
if net.ReadString() != “request is processed” then return 0 end
local needSend = “function is fulfilled as needed”
net.Broadcast() – net.Send(ply)
end )
function GetPlayerClanID()
net.WriteString(“request is processed”)
local text = “Func not filfilled”
net.Receive( “test_tocl”, function( len, ply )
local isProcessed = net.ReadString()
text = isProcessed
end )
return text

[editline]3rd February 2016[/editline]

How to make callback? :smile:

Make an empty table, when the function is called add the callback argument to the table and request the sql thing, and when the net recieve happens go through that table and call all the callbacks and theb empty the table.

Send example, please. I bad understand English, i use translator.

Thank all! I did so:
function PLAYER:SetVarClan(clanid)
if !self:IsValid() then return false end
self:SetNWInt(“clanid”, clanid)
self:SetNWString(“clanname”, GetClanName(clanid))
return 1
And get clan ID or clan name so:
Thank! :smile:
P.S: SetVarClan() called in hook ‘PlayerInitialSpawn’