GAMEMODE function overriding doesn't work on initial game load

I’m writing a script to override the gamemode’s HUDPaint (DarkRP for instance), using the line of code


function GAMEMODE:HUDPaint()
end

Only returning nil when the gamemode and map is loading. When I auto-refresh the file, it works and overrides the gamemode’s HUD. Why doesn’t it work first time, and how can I fix it?
The file is ran through an addon folder; lua/autorun/client/cl_hud.lua

I would try using:
[LUA]hook.Add(“HUDPaint”, “hudding”, function()
end)[/LUA]

I’m trying to overwrite the current gamemode’s HUD (DarkRP for instance, again) as it uses the GM:HUDPaint, and GAMEMODE:HUDPaint overwrites it fine, but it seems it returns nil because it runs earlier than the gamemode loading. I’m trying not to touch the gamemode for ease of updating.

You can put it in a timer


timer.Simple( 1, function()
	function GAMEMODE:HUDPaint()
		-- stuff
	end
end )

It’s a hack, but it will work… I think the proper way to do it is to use a hook.

But, doing that is the whole point of the hook system.

[editline]13th July 2013[/editline]

If you want the hook to overwrite, you’d need to return something. But, this could cause issues with other hooks.

Had some help and created a very hacky hook that I would’ve never thought worked


hook.Add( "HUDPaint", "HUDPaint", function() 
	function GAMEMODE:HUDPaint()

	end
end )