So I am trying to send a variable I declared in the server to client. Here is the code:
--SERVER--
[CODE]
util.AddNetworkString('SendVarToClient')
healthprogress = 80
hook.Add('Think', 'SendVar', function()
net.Start('SendVarToClient')
net.WriteInt(healthprogress, 8)
net.Broadcast()
end)
[/CODE]
--CLIENT--
[CODE]
net.Receive('SendVarToClient', function()
local net.ReadInt(8) = healthprogress
end)
[/CODE]
Please help
[editline]11th February 2017[/editline]
Anyone?
If you need it constantly update a variable, you should use SetNW* functions and store it to an entity. Could you give more context on what you need this healthprogress variable for?
timer.Create('HealthTimerProgress',.9,0,function() -- Creating a timer so every couple of seconds it adds 1 to the variable healthprogress.
healthprogress = healthprogress + 1
end)
From your other thread, it seems like this is only used in ENT:Use, which is serverside only. Why do you need this shared?
I am trying to send the value of self.healthprogress to client so I can draw it on the entity.
Change healthprogress to be an NWInt instead.
Sorry, you need to Log In to post a reply to this thread.