Screen Resoultion Hook?

Is there any hook or other way to tell if a player has changed their screen resolution in game? I’m trying to make a HUD and I want to make it so it works even if you change your resolution. I could just put the variables in the HUD hook, but I would prefer a more efficient one.

you want it to adjust to screen resolutions?

Ya, basically. I just want this code here to run every time the screen resolution has changed:



HUD[1] = {}
	HUD[1].BPosX = 0
	HUD[1].BPosY = 0
	HUD[1].CPosX = 13
	HUD[1].CPosY = 11
HUD[2] = {}
	HUD[2].BPosX = ScrW() - BSzX
	HUD[2].BPosY = 0
	HUD[2].CPosX = 262
	HUD[2].CPosY = 11
HUD[3] = {}
	HUD[3].BPosX = 0
	HUD[3].BPosY = ScrH() - BSzY
	HUD[3].CPosX = 13
	HUD[3].CPosY = 28
HUD[4] = {}
	HUD[4].BPosX = ScrW() - BSzX
	HUD[4].BPosY = ScrH() - BSzY
	HUD[4].CPosX = 262
	HUD[4].CPosY = 28


Why wouldn’t you just make one size, and make it based off of ScrW() and ScrH()?

These are x,y coordinates, not sizes and the ScrW() and ScrH() only run once when you call them so the HUD would always be stuck at the resolution used when you called them.

I was just thinking about putting the ScrW() and ScrH() stuff within the HUD hook and keeping the static numbers outside of it instead.

Edit: Actually that works out alright, just thought there might be an actual hook for this.

You can make your own hook using ScrW and ScrH like c-unit said, just put them in a save their values in a think hook and then in the next think check if the new values differ. If they do, call the hook and set the new values.

Anyways, what you’re doing now will also work.

this is a pretty good Idea actually. So I decided to make it for OP :v:

[lua]
local scrw = ScrW();
local scrh = ScrH();
local bool = true

hook.Add(“Think”, “CallUpdateScreenHook”, function()
if( ScrW() != scrw && bool) then
hook.Call(“ScreenSizeUpdate”, GAMEMODE)
bool = false;
scrw = ScrW();
scrh = ScrH();
end

if( ScrW() == scrw ) then
	bool = true;
end

end)

hook.Add(“ScreenSizeUpdate”, “ChangeHUDSize”, function()
print(“Yo Nigga your screen size has changed!”)
end)
[/lua]

http://www.zimg.eu/i/479203518

Just hook into ‘ScreenSizeUpdate’ and go from there