I'm working on a HUD but I'm confused on how to modify these things:
-Weapon selection
-Ammo pickup notification
And for the problems:
-Having 2 DrawPoly's never/sometimes works (pretty much never, which is annoying)
-Getting weapon name (not the class) of a non-Lua weapon
-Getting the ammo of a non-Lua weapon
[editline]7th October 2014[/editline]
Bumping as it's been an hour and I am extremly bored and can't really do/think of anything to do while I wait for some sort of response, I don't need ALL of them answered at once, just whichever ones people can help me with.
I'm not sure you can "modify" the pickup notification... For Weapon Selection, I know for a fact you can't... You'd have to write your own. Take a look at the TTT client file for weapon selection...
This should be a "stand-alone" version of the TTT weapon switcher. I can't recall if I updated everything, or not... But, that's the code from TTT ( old, most likely outdated unless the weapon switcher wasn't updated, but you can still learn a LOT from it... Basically use PlayerBindPress to prevent the main weapon switcher from showing by return true; On invprev/next show if not shown, reset visible time if shown.. On +attack, if shown select weapon and return true, if not visible do not override return. On +attack2 if shown close and return true, if not shown then don't override ).. From that, it is pretty simple to create one. I'll be creating a much lighter weight version of a weapon switcher without a lot of the bloat in a bit and releasing it.
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/cl_ttt_weapon_switcher.lua.html[/url]
To hide the HL2 version take a look at ShouldDrawHUD: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/vgui/proper_hud_creation.lua.html[/url]
Never use a for loop in that hook either, it is called n times per frame, a loop would be n^2 per frame. I did a benchmark, 100 million times using the above code = 0.08 seconds. With a loop ... 15 seconds...
Now, DrawPoly I can help you with.. What is the problem? What doesn't work? If you're drawing a circle, or something like that and you have an issue where the color doesn't work, more specifically the alpha not being properly calculated.. IE 255 shows up as half transparent.. Do this:
[code]draw.NoTexture( );
surface.SetDrawColor( Color( 20, 20, 20, 200 ) );
surface.DrawPoly( _speedo );[/code]
Poly examples:
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/poly/simplified_circles_with_poly.lua.html[/url]
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/poly/tilted_rectangle_poly_as_health_meter.lua.html[/url]
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/poly/another_tilted_health_bar.lua.html[/url]
[url]https://dl.dropboxusercontent.com/u/26074909/tutoring/poly/creating_shapes_using_poly.lua.html[/url]
Additionally, I'd recommend creating the object ONCE ( and updating only when resolution changes ), and drawing it...
Example of a stand-alone hook which calls when the player changes resolution: [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_hooks/acecool_hook_playerchangedresolution/gm_playerchangedresolution.lua[/url]
Usage example ( poly:MakeCircle is almost the same as the above simplified circle, but part of a poly meta-table object I'll be releasing soon... This just covers making it once, rendering it x times, updating it only when necessary... ): [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/_hooks/acecool_hook_playerchangedresolution/example_usage.lua[/url]
Now, non-Lua weapon, you need to have a table of data ( especially ammo, etc.. ): [url]https://dl.dropboxusercontent.com/u/26074909/tutoring/weapons/hl2_weapons_table.lua.html[/url]
As for name, try seeing if PrintTable( Entity( 1 ):GetActiveWeapon( ):GetTable( ) ) works, otherwise you'd need to set it in the table.
-snip-
Adding draw.NoTexture() fixed the DrawPoly issue
Sorry, you need to Log In to post a reply to this thread.