Hi,
I have a sv side script with a variable in it.... I want to get the value of it in a hud. So I did a hud in a cl side script, and I included my sv side script. But I get the error that my variable is a nil value when I call it in the cl side script. How should I do ?
Thanks !
You should use networking (net.*)
Although you don't get values from clients to server for perform, because people would spoon feed those, but in case for hud do you mean interface, you should still opt by saving those variables locally
But if you want to share any data (Although i still say there's no need to send variables from cl to sv), you can use net library for that
[QUOTE=gonzalolog;51265886]You should use networking (net.*)
Although you don't get values from clients to server for perform, because people would spoon feed those, but in case for hud do you mean interface, you should still opt by saving those variables locally
But if you want to share any data (Although i still say there's no need to send variables from cl to sv), you can use net library for that[/QUOTE]
I have a timer on serverside, that gives me a value (the time left), and I would like to put that value in a hud. Hud are clientside... what should I do ?
OH, And it was not from cl to sv but from sv to cl ^^', sorry if I'm bad to explain.
In that case, you have 2 options, the first one it's to set a global variable as when you start the timer, like
[lua]
SetGlobalInt("TimerRunning",CurTime()+30)
timer.Simple(30,function() doTimerEnt() end
[/lua]
Then inside your hud check if TimerRunning is a number, otherwise don't draw the timer in client
[lua]
if(GetGlobalInt("TimerRunning",0) - CurTime() > 0) then
draw.SimpleText(GetGlobalInt("TimerRunning",0) - CurTime())
end
[/lua]
Or just send a net message when you start the timer, and do all maths in clientside
[QUOTE=gonzalolog;51265997]In that case, you have 2 options, the first one it's to set a global variable as when you start the timer, like
[lua]
SetGlobalInt("TimerRunning",CurTime()+30)
timer.Simple(30,function() doTimerEnt() end
[/lua]
Then inside your hud check if TimerRunning is a number, otherwise don't draw the timer in client
[lua]
if(GetGlobalInt("TimerRunning",0) - CurTime() > 0) then
draw.SimpleText(GetGlobalInt("TimerRunning",0) - CurTime())
end
[/lua]
Or just send a net message when you start the timer, and do all maths in clientside[/QUOTE]
Thank you very much ! c:
Sorry, you need to Log In to post a reply to this thread.