• Returning from server side to client side
    6 replies, posted
Hey there, Basically, I have a quest/mission system that I've made, and I'm stuck on on thing - I made a global cooldown timer for each quest, before the player can take the mission again. I'm using the net library for my quest/mission system. The problem is that when the players open the gui, it needs to check if the timer still on cooldown, and return a boolean(or any other method, doesn't matter), the timer is on serverside, so is there a way to use the net library to return variables? or any alternate way to do it to call it from clientside and return it back to clientside? Any help will be appreciated. Thanks for reading.
You'll need to send those values/booleans using net when player opens the menu. Make serverside concommand to open the menu which will send a net message, on client in net.Receive open your panel and process data.
That's how I had it Server-side [CODE] function KQNPCS.ReturnTimer(id, ply) net.Start(Tag.."_ReturnTimer" ) local exists if timer.Exists("Quest_"..id) then print("Exists") exists = 1 else print("Doesn't Exists") exists = 0 end net.WriteFloat(exists) net.Send(ply) end net.Receive(Tag.."_FindTimer", function(Len, Client) local ply = Client local id = net.ReadFloat() KQNPCS.ReturnTimer(id, Client) end) [/CODE] Client-Side: [CODE] net.Start(Tag.."_FindTimer") net.WriteFloat( Tbl.id) net.SendToServer() local Avaliable net.Receive( Tag.. "_ReturnTimer", function() Avaliable = net.ReadFloat() end) print(Avaliable) [/CODE] However, if I print the 'Avaliable' within the net.Receive, it prints 0 or 1, if I print it outside of the net.Receive, it prints nil. Any ideas? Am I doing something wrong?
The way I would do it is, console command from client to server "quest_check_cooldown", then server to client via the umsg library.
[QUOTE=thegrb93;41558270]The way I would do it is, console command from client to server "quest_check_cooldown", then server to client via the umsg library.[/QUOTE] Wont work
Bump
What I do for my things is something like this (lua/autorun) [lua] local name = "a name" if SERVER then net.Receive(name, function(len, ply) ply:SendLua("function GetMyBool() return "..tostring(boolean that needs to be sent).." end") end) end if CLIENT then function GetMyBool() return false end function ObtainUpdatedBool() net.Start(name) net.SendToServer() end end [/lua] and for the shtuff [lua] ObtainUpdatedBool() timer.Simple(0.5, function() local bool = GetMyBool() end) [/lua]
Sorry, you need to Log In to post a reply to this thread.