Hey guys, I want to have derma have a 'timer' or a time progress bar, that the server keeps track of. As derma is clientside, I didn't want to spam the server with time requests, but I want an accurate progress bar. Could I simply update the timer every few seconds, and have the clientside have it's own timer? This would correct any mistakes...
Should I just have the clientside have it's own timer, and check to see if it is correct by requesting from server when the timer is done?
I know I did a terrible job of explaining, but tell me if you need any more information.
Also, say I wanted to update the Derma Menu, say I have a grid menu and drag one element in one grid square to another, and it communicates that movement with the server, how would I have the derma menu update to reflect this, and show the element in the next slot? Should I just close and recreate the Derma Menu, but save the coordinates? Thanks.
[1] Just make two identical timers, one on the server and one on the clients.
[2] Check [URL="http://wiki.garrysmod.com/page/Drag_and_Drop_for_VGUI"]this[/URL] out and the [URL="http://wiki.garrysmod.com/page/Grid-Based_Inventory_System"]inventory guide[/URL] on the wiki as well.
You can use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/CurTime]CurTime[/url] instead of a timer if you want since this is for derma. Just set a variable when the server timer is created, and use that to calculate the time left. For example:
[CODE]
-- SERVERSIDE:
util.AddNetworkString( "TimerStarted" ) -- send this to a client to start a 500 second timer
-- CLIENTSIDE:
local timer = 0 -- create a timer variable to use later
net.Receive( "TimerStarted", function()
timer = CurTime() + 500 -- this makes a timer with 500 seconds on it
end )
-- HOW TO USE THIS WITH DERMA STUFF:
function somepanel:Paint()
local timeleft = timer - CurTime()
-- draw stuff
end
[/CODE]
You could even send CurTime from the server so the times are perfectly in sync.
Sorry, you need to Log In to post a reply to this thread.