Hey again,
I'm trying to update a value from a command (shared) to the HUD (client) however the value doesn't update on the client? Here's my code (edited to remove copies etc)
local threatLevel = "MODERATE"
--SetGlobalString("threatLevel", "MODERATE")
hook.Add( "PlayerSay", "commands", function( ply, text, public )
local darkRPName = ply:Nick();
if(string.lower(commandInput[1]) == "!threat") then
local
if(commandInput[2] == "1") then
SetGlobalString("threatLevel", "LOW")
end
end
end )
hook.Run("commands")
And the client side:
local threatLevel = GetGlobalString("threatLevel")
draw.DrawText(threatLevel, "DermaDefaultBold21Outline", ScrW() - 53, ScrH() - 25 + 1, Color(255,255,255,255), 1)
Thanks!
Whats the code where you are setting the value of commandInput? Also you say it doesnt update on the client, is it updated on the server?
"commandInput" is just reading the text of the "PlayerSay" and splitting it by spaces - there's no errors there. And yes it's updated on the server however I use a different method for that (just a standard variable).
Where is the draw.DrawText() being run?
It should be executed in a HUDPaint hook.
Yup it is, the text appears. But just doesn't update to the new "Threat" level once the certain command has been used.
I assume you are also declaring "threatLevel" inside the paint hook?
The code looks fine to me, are you getting any errors in the console?
Nope I wasn't lol. Silly mistake. Thanks!
Sorry, you need to Log In to post a reply to this thread.