GAMEMODE function overriding doesn't work on initial game load
5 replies, posted
I'm writing a script to override the gamemode's HUDPaint (DarkRP for instance), using the line of code
[CODE]function GAMEMODE:HUDPaint()
end[/CODE]
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
[code]timer.Simple( 1, function()
function GAMEMODE:HUDPaint()
-- stuff
end
end )[/code]
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
[CODE]hook.Add( "HUDPaint", "HUDPaint", function()
function GAMEMODE:HUDPaint()
end
end )[/CODE]
Sorry, you need to Log In to post a reply to this thread.