No refreshing of HUDPaint

Hello,
I have a problem with the hook HUDPaint. I’m trying to draw a rounded box with a value in a datafile. But when the value in the data file is changed, the rounded box is not updated. Isn’t HUDPaint supposed to be reloaded every frames ?
this is a fake code that represent my problem :


hook.Add("HUDPaint","HUDaLightSaber_EmpireRebellion", function()
    local value = file.Read("directoryfile/filewhereisthevalue.txt","DATA")
    tonumber(value,10)
    draw.RoundedBox(0, ScrW() * 0.5, ScrH() * 0.5 ,value,ScrH()* 0.5, Color(0, 0,0))
end)

(in lua/autorun/client)
Thank you for all help possible,
I’m sure it’s simple answer but i an’t find it :slight_smile:

I guess you can use InitPostEntity to load it, that’s what I use to load images via a website.

To read through a website you need a 3 second timer, dunno if that applies to a file.Read too, try fiddling around with it

Is this hook reload every frame ?

InitPostEntity is ran once and that’s when the player is initializing and entities have been initialized

You shouldn’t be reading a file every frame

But the value could be changed at all times so how to do ?

First consider if you really need to do it this way, then you could just put it in a 5 second timer or something. I don’t think you can watch files for changes from lua

I’m trying to do it with GetGlobalint and setglobal int