Hello,
I was just wondering if someone could help me here! I would like to change the place of this "hud/vehicle_health", I would like it in the bottom, center of the screen if thats possible (for no cost) thank you.
Code is below
[code]
hook.Add("HUDPaint", "DrawVehicleHealth", function()
local pos = LocalPlayer():GetShootPos()
local ang = LocalPlayer():GetAimVector()
local tracedata = {}
tracedata.start = pos
tracedata.endpos = pos + (ang * 100)
tracedata.filter = LocalPlayer()
local trace = util.TraceLine(tracedata)
local ent = trace.Entity
if(LocalPlayer():InVehicle() && ent:IsVehicle() && ent:Health() > 0) then
draw.RoundedBox( 16, 0, 595, 1005, 40, Color( 0, 0, 0, 200 ) )
draw.RoundedBox( 16, 5, 600, ent:Health() * 5, 30, Color( 255, 0, 0, 200 ) )
draw.DrawText( "Vehicle Health: " .. ent:Health(), "TargetID", ScrW() * 0.5, 605, Color( 255,255,255,255 ), TEXT_ALIGN_CENTER )
elseif LocalPlayer():InVehicle() then
draw.RoundedBox( 16, 0, 595, 1005, 40, Color( 0, 0, 0, 200 ) )
draw.RoundedBox( 16, 5, 600, 200 * 5, 30, Color( 255, 0, 0, 200 ) )
draw.DrawText( "Vehicle Health: NOT REGISTERED", "TargetID", ScrW() * 0.5, 605, Color( 255,255,255,255 ), TEXT_ALIGN_CENTER )
end
end)
[/code]
Do something like this, basically you want your X position to be half the screen's width and then minus half the width of your box and then your Y to be the top of the screen minus the height of your shape.
[code]
local width = 100
local height = 50
local x, y = ScrW()/2 - width/2, ScrH() - height
[/code]
I got no idea what that means.... you think you could re-code it or somthing to fit next to the hud which is useually on bottom left of screen. here is an image of where i want it [URL="http://gyazo.com/ebb5ac92a5360bc83139d0a8f7dc5c69"]image[/URL]To the right side of the HUD
I'm not going to spoon feed it to you...
You can move it yourself with the code I gave and by looking on the wiki to make sure you change thr right variables [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/draw/RoundedBox]draw.RoundedBox[/url]
Sorry, you need to Log In to post a reply to this thread.