[LUA] GM:HUDPaint()

Not sure about this method of hooking.

[lua] hook.Add( ‘HUDPaint’, ‘name’, function() code end ) [/lua]


Remember that it has to be clientside


This is for if you were trying to override the gamemodes actual HUDPaint:
function GAMEMODE:HUDPaint()


Also, HUDPaint is clientside. You should also put scripts in the lua/autorun directory since it will automatically load them and autorefresh them if you save them. I am assuming you’re using windows.

He’s actually correct by using GM:HUDPaint( ). The only reason that the GM error would be given is if he were to include that file way AFTER the game-mode has loaded or refreshed. The file needs to be includes / AddCSLuaFiled right away.

You can’t use GM:HudPaint() via lua scripts, it’s a gamemode hook. Do this instead.

function HudPaint()
hook.Add("HUDPaint", "PaintsHUD", HudPaint)


You rated somebody else dumb for making the same mistake as you - good job!

That’s quite strange. I am using function GM:HUDPaint( ) in my game-mode with absolutely no issues.

Here’s how I include my files:
[lua]MAP_SCALE = 1;
function LoadGameMode( )
local _sharedCount = LoadLuaDirectory( “gamemode/shared/”, { recurse = true, client = true } );
local _clientCount = LoadLuaDirectory( “gamemode/client/”, { recurse = true, client_only = true } );
local _serverCount = LoadLuaDirectory( “gamemode/server/”, { recurse = true } );
local _addonCount = LoadLuaDirectory( “gamemode/addons/”, { recurse = true, client = true } ); // Addons are “shared” by default.

local _contentCount = LoadLuaDirectory( "gamemode/content/", { recurse = true, client = true } );
( GM or GAMEMODE ):SortVehicleTable( );
MsgC( COLOR_GREEN, "GameMode loaded " .. ( _clientCount + _sharedCount + _serverCount + _addonCount + _contentCount ) .. " files!

" )

local _loOutput = fileio:New( );
_loOutput:Write( "file_structure", "Shared_Files", toprint( FILE_LOADER_SHARED_LUA_FILES ) );
_loOutput:Write( "file_structure", "Client_Files", toprint( FILE_LOADER_CLIENT_LUA_FILES ) );
_loOutput:Write( "file_structure", "Server_Files", toprint( FILE_LOADER_SERVER_LUA_FILES ) );
_loOutput:Write( "file_structure", "File_Load_Order", toprint( FILE_LOADER_EXACT_LOAD_ORDER ) );

– RunBenchmark( LoadGameMode );
LoadGameMode( );[/lua]


You’re using improper load-sequencing. My LoadLuaDirectory is fully recursive and handles permissions properly. I use GM:HUDPaint( ) in the addon segment in development in one of the debug files.

I’m not trying to argue, but fact is fact…

[lua]function GM:HUDPaint( )
// Corner - even, xStart, yStart, Width, Height, Color
draw.RoundedBox( 0, 0, 0, ScrW( ), ScrH( ), Color( 0, 0, 0, 225 ) )

// Gutter
draw.RoundedBox( 0, 0, 0, ScrW( ) * 0.20 - 50, ScrH( ), Color( 50, 50, 50, 225 ) )
draw.RoundedBox( 0, ScrW( ) * 0.20 - 50, 0, 1, ScrH( ), Color( 150, 150, 150, 225 ) )


works perfectly. If you can’t get it to work, go back to the Lua 101 drawing boards. To the OP, if you add me on steam, I’ll be more than happy to assist you in adding this function by ensuring your load order is proper.

This is how the BASE gamemode does it; if there was an error with it then why did Garry use this?
Name: gamemode:HUDPaint( )
Desc: Use this section to paint your HUD
function GM:HUDPaint()

hook.Run( "HUDDrawTargetID" )
hook.Run( "HUDDrawPickupHistory" )
hook.Run( "DrawDeathNotice", 0.85, 0.04 )


Name: gamemode:HUDPaintBackground( )
Desc: Same as HUDPaint except drawn before
function GM:HUDPaintBackground()

Maybe because it’s not Garry, it’s not me, it’s you that are doing it incorrectly. Rate me dumb all you want; it makes you look dumb for your inability to be open-minded enough to understand when you’ve made a mistake.

If you look at his console, you’ll notice he’s not running a gamemode script - he’s using running clientside scripts… So trying to prove me wrong makes you look like you’re incapable of reading and / or you’re ignorant. So I appreciate your attitude and enthusiasm, but maybe you should learn to read before you write.

GM table doesn’t exist outside of gamemode folder, that’s why he gets the error. He tried to lua_openscript the file on server.

My post was 100% accurate.

We still have not heard from the OP if this is what he is in fact doing though. You can put scripts in the lua directory and execute them on launch. Addons can do this too and GM WILL EXIST for those files.

The OP needs to specify.

Fuck me if I’m wrong but Acecool, aren’t you the guy on WAYWO who was trying to prove that your algorithm for getting true randomization was correct?
Maybe you should calm down and put ice on that ego; you’re really making a fool of yourself.

I know that he’s not using this code inside a gamemode, that’s why I said to use GAMEMODE instead of GM if he wants to override the gamemodes HUDPaint.