Essentially, the gamemode I’m trying to make a hud for has a timer which is server side. It works in the built in “timeleft” command, but i’m having a lot of trouble sending it to the client to use in a hud.
GetRoundsLeft() and GetTimeLeft() are printed from a function in init.lua, so I assume this will work in init.lua
net.Start("RoundsLeft")
net.WriteString(GetRoundsLeft())
net.Broadcast()
net.Start("RoundTimeLeft")
net.WriteString(GetTimeLeft())
net.Broadcast()
in cl_networkstrings.lua I have this, which presumably is fine
net.Receive("RoundsLeft", function(len)
RoundsLeft = net.ReadString()
end)
net.Receive("RoundTimeLeft", function(len)
RoundTimeLeft = net.ReadString()
end)
and in vgui/gamemode_timer.lua (a derma panel thingy) I have this
draw.DrawText("Round " .. RoundNumber .. " of " .. RoundLimit , "font", 149, 74, Color(255, 255, 255, 255),TEXT_ALIGN_CENTER)
draw.DrawText(RoundTimeLeft, "font", 147, 0, Color(255, 255, 255, 255),TEXT_ALIGN_CENTER)
All of this (to me) looks like it should work. I took a string, sent it, recieved it, made it a global variable, and then tried to use it in another file. What’ve I messed up here? Any help it much appreciated