• My HUD is not loaded except if I put the code in cl_hudreplacement.lua
    6 replies, posted
Hi, I might have missunderstand how custom module work but here is my problem : I finished my F4 menu and it's working fine, i was able to modify it & save to see the result with lua autorefresh. Now i'm aiming to create a custom HUD but i can't make the basic to work : I got a folder named 'ricky_hud' into /ricky_rp/addons/darkrpmodification-master_gmchosting/lua/darkrp_modules and a cl_rhud.lua into /ricky_rp/addons/darkrpmodification-master_gmchosting/lua/darkrp_modules/ricky_hud/lua/rhud/client But the code is not loaded i have reloaded the server & restarted it but nothing working : cl_rhud.lua local testmat = Material("materials/rhud/heart32.png") function DrawHUD()   surface.SetMaterial( testmat ) surface.SetDrawColor( Color( 255, 150, 0, 255 ) ) surface.DrawTexturedRect( ScrW() - 5 - 16, ScrH() - 5 - 16, 16, 16 )   print("ricky hud") end hook.Add("HUDPaint", "RHUD", DrawHUD) Here is the test code, it's not printing anything... But if i place it into cl_hudreplacement.lua into the hudreplacement folder it's working and it's reloading fine with lua refresh... I really don't understand what is going on ! Please halp ! Thanks in advance
I have no idea if DrawHud() works as I normally use hook.Add("HUDPaint", "ygwdhu", function(). This tutorial might help you: https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index1064.html . BTW, does your function stay the same on both you f4 menu and this? As I think your DrawHud function is being over-writed.
As i said if i place my hook in hud_replacement.lua it works...
Put a print in the file to test if it's being loaded initially.
I did it it's not loaded :/ I tried restarting server etc... If i create a folder and put the .lua in it it's loaded tho... :/
Just do that then. I'm not sure of DarkRP's module file structure but do whatever works, I guess.
Darkrp requires you to to have cl sh or sv in the name to load the file which is why cl_hudreplacement works See here Creating modules Also darkrp modules do not use the lua folder or any folders, you just throw them into the module section for example: darkrpmodification/lua/darkrp_modules/my_coolhud/cl_hudfile.lua
Sorry, you need to Log In to post a reply to this thread.