• Seeking advice with my custom hud.
    4 replies, posted
Well, heres a piece thats been worked on on and off for a year now. My first project (clearly yanked straight out of FPtje's source code and altered to my liking), since grown from there. Not advertising shit here, just asking for advice. What should I do with this piece of... shall we say... Junk... to start getting it to look better? To feel better? To actually not drop the framerate of a decent pc from 80 to 30... Shit, forgot the code [CODE]/*----------------------------------------------------------------------------------- Rainbow Dash's DarkRP HUD Version 1.3 Date last modified: 29/07/2013 Special thanks to: FPtje (aka Falco) for the original DarkRP HUD, from which this is derived from. Lixquid for your work with the ammo section. Much appreciated. The guys at MLSRP for accepting my first attempt at LUA coding for testing. Whoever made that tutorial for making huds. This is derived from that too. Shendow for creating the VGUI for changing the HUD. Should stop people from getting pissy now. Known Bugs: Ammo will not display for any weapon that is not a SWEP. I will not fix this because why would you use HL2 weapons in DarkRP? Ammo may display for some SWEPS that should not have it, including the Spiderman's SWEP. Yeah, this is just how the calculations work. No biggie. Dependencies: Rank display REQUIRES ULX. It's not too hard to modify it to use FAdmin, but I use ULX, and FAdmin is really horrible anyway. If it causes bugs, install ULX or remove the parts about rank. To-Do List: - Clean up code. - Change the rank system to use that networked string stuff Rejax was talking to me about the other night. IsUserGroup and GetUserGroup is only for ULX. The NWString should work for all admin mods he says. Please report any bugs to admin@friendshipisgaming.net ------------------------------------------------------------------------------------- Use common sense with this. Don't resell this, and dont buy once for 20 odd people. If there is a problem you can fix, or you need someone to fix it, go right ahead. Please also note: There is a bit of code here taken straight from the default HUD. This is simply compatibility, as these features are NOT capable of being called from this script, unless they are in this script. The list of items taken straight from the default HUD are: - ConVars loop - Agenda (slightly modified) - Voice Chat Icon Most of these will be rewritten at a later date. */ /*-------------------------- Over-rides. ---------------------------- These bits disable incomplete or potentially buggy code. The code CAN work, but its disabled because it will not work without prerequisits. Each one is explained anyway. Set each variable to true to disable the sad safety mechanisms i coded in. We also need these to run first. I left ammo on by default because I like it. However, set it off and the default one will draw. */ CreateClientConVar( "customhud_disabled", "0", true, false ) local dorank = true -- Do we draw the ULX based ranks? local forcetotop = true -- Force the name and job to be drawn on the top? local doammo = true -- Do we want to draw ammo? /*-------------------------- Hook ---------------------------- This hook is important. Its what tells DarkRP to not draw its disgusting hud. Then we add our version of the file. */ /*-------------------------- Variables n shit ---------------------------- This section defines a lot of the variables. With it, we can speed up shit a lot. A lot of this is just copy-paste from the original file, but I am doing this because I don't see a better way */ local ConVars = {} local Defaults = {} local HUDWidth local HUDHeight local Color = Color local cvars = cvars local draw = draw local GetConVar = GetConVar local Lerp = Lerp local localplayer local pairs = pairs local SortedPairs = SortedPairs local string = string local surface = surface local table = table local tostring = tostring CreateClientConVar("weaponhud", 1, true, false) surface.CreateFont("TrebRlyBig", {font = "Trebuchet24", size = 28, weight = 1000}) surface.CreateFont("TrebMed", {font = "Trebuchet24", size = 24, weight = 600}) surface.CreateFont("TrebMed2", {font = "Trebuchet24", size = 16, weight = 600}) surface.CreateFont("TrebSmall", {font = "Trebuchet24", size = 16, weight = 650}) surface.CreateFont( "RUND_TEXT", {font = "Arial",size = 15,weight = 500} ) /*-------------------------------------------------------- Hud Colors ---------------------------------------------------------- This is where you can define the colors for the hud. Each color is named appropriately. I KINDA stole this idea from Falco, but it makes it much easier to modify. This also provides support for making a hud color modification menu. I dont provide this, However, be my guest to make such a menu for this. */ local function ReloadConVars() ConVars = { background1 = {0,142,230,200}, -- Background of all the windows outline = {0,27,179,200}, -- Outline of all the windows walletlabel = {255,255,255,255}, -- Label for your wallet walletlabeloutline = {0,0,0,255}, -- Outline for your wallet label wallet2 = {0,65,0,255}, -- Actual wallet color wallet2outline = {0,0,0,255}, -- Actual wallet color outline salarylabel = {255,255,255,255}, -- Label for your salary salarylabeloutline = {0,0,0,255}, -- Outline for your salary label salary = {0,65,0,255}, -- Actual salary color salaryoutline = {0,0,0,255}, -- Actual salary color outline salaryunemployed = {255,0,0,255}, --Color of salary if the person is unemployed IE no salary. healthlabel = {240,0,4,255}, -- Label for health healthlabeloutline = {0,0,0,255}, -- Outline for health label armorlabel = {217,224,0,255}, -- Label for Armor armorlabeloutline = {0,0,0,255}, -- Outline for Armor Label ammolabel = {217,224,0,255}, -- Label for ammo ranklabel = {0,27,179,255}, -- Label for rank ranklabeloutline = {0,0,0,255}, -- Outline for rank label name = {255,255,255,255}, -- the color of your name nameoutline = {0,0,0,255}, -- the color of your name job = {255,255,255,255}, -- the color of your job joboutline = {0,0,0,255}, -- the color of your job healthbar = {255,0,0,255}, -- the color of the health bar healthbarbg = {0,27,179,200}, -- the background of the health bar and its outline healthbaroutline = {0,0,0,255}, -- the background of the health bar and its outline healthbartext = {255,255,255,255}, -- the color of the health bar text healthbardeadtext = {255,0,0,255}, -- the color of the health bar text when you are dead. armorbar = {0,0,255,255}, -- the color of the armor bar armorbarbg = {0,142,230,200}, -- the background of the armor bar. I set this to be the same as Background only darker normally armorbaroutline = {0,27,179,200}, -- the outline of the armor bar armorbartext = {255,255,255,255}, -- the text of the armor bar armorbartextoutline = {255,255,255,255}, -- the text of the armor bar armorbarnonetext = {255,0,0,255}, -- the text when you have no armor ammobar = {167,174,0,255}, -- the ammo bar. ammobarbg = {0,27,179,200}, -- its background ammobartext = {200,220,255,255}, -- its text. Currently we don't define it when empty. ammobartextoutline = {255,255,255,255}, -- the text of the armor bar ammobartextshad = {0,0,0,255}, -- its shaddow. Make this black (255,255,255,255) if you have a light color as ammobartext nameandjobdivider = {25,25,25,200}, -- the color of that divider between your name and job. agendabg = {0,27,179,155}, --Background and outline of agenda agendabody = {0,142,230,100}, -- the main body of agenda agendatextoutlin
Instead of making a fake shadow, you can use a modified font. And I don't think your code will get any better because you are using draw functions atleast 250 times.
Yeah, its a real piece of work isnt it. But a modified font, I'm liking this idea. Litterally taking out 4/5 of the simpletext shit. I was also thinking of using an image for the background, but i need to have one that can be tiled over a space, not sure if it can be done.
[lua]surface.CreateFont( "TheDefaultSettings", { font = "Arial", size = 13, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = true, --Why background image? additive = false, outline = false, } )[/lua]
[QUOTE=Netheous;43664550][lua]surface.CreateFont( "TheDefaultSettings", { font = "Arial", size = 13, weight = 500, blursize = 0, scanlines = 0, antialias = true, underline = false, italic = false, strikeout = false, symbol = false, rotary = false, shadow = true, --Why background image? additive = false, outline = false, } )[/lua][/QUOTE] Background because A hud looks dirty if its nothing but text.
Sorry, you need to Log In to post a reply to this thread.