Login to ZARP





  • Page:
  • 1
  • 2

TOPIC: Learning LUA -- Challenges?

Learning LUA -- Challenges? 6 years 9 months ago #1033435

I am in the middle of trying to make a working HUD which shows just armor and health and the current minute but this is what I have got so far.


surface.CreateFont( "Font1", {
	font = "Arial", -- Use the font-name which is shown to you by your operatorating system.
	size = 100,
	weight = 500,
	blursize = 0,
	scanlines = 0,
	antialias = true,
	underline = false,
	italic = false,
	strikeout = false,
	symbol = false,
	rotary = false,
	shadow = false,
	additive = false,
	outline = false,		
} )


hook.Add("HUDPaint" , "DrawMyHud" , function()

	local Health = LocalPlayer():Health()
	local Armor = LocalPlayer():Armor()

	draw.RoundedBox(0,1570,970,400,200,Color(80,80,80))
	draw.RoundedBox(0,1580,980,400,100,Color(40,40,40))
	draw.RoundedBox(0,1600,1000,Health * 3,30,Color(225,120,120))
	draw.RoundedBox(0,1600,1040,Armor * 3,30,Color(120,120,225))

	end)
  • Nafe
  • Nafe's Avatar
  • Offline
  • Former Community Manager
  • ZARP VIP
  • Posts: 18886
  • Thanks received: 8725
  • Karma: -380
Last Edit: 6 years 9 months ago by Nafe.
Login or register to post a reply.

Learning LUA -- Challenges? 6 years 9 months ago #1033445

One thing to watch out for with HUDs is how they scale on lower resolutions. Put your resolution down to the lowest and it'll take up 80% of your display lol.

Using ScrW() and ScrH() gets you the current screen width and height respectively which you can use as a multiplier to make a good scale for all resolutions.
  • .uzi
  • .uzi's Avatar
  • Offline
  • Former Community Manager
  • ZARP VIP
  • Foos yer doos?
  • Posts: 6010
  • Thanks received: 2445
  • Karma: 123
Login or register to post a reply.
The following user(s) said Thank You: Nafe

Learning LUA -- Challenges? 6 years 9 months ago #1033446

.uzi wrote:
One thing to watch out for with HUDs is how they scale on lower resolutions. Put your resolution down to the lowest and it'll take up 80% of your display lol.

Using ScrW() and ScrH() gets you the current screen width and height respectively which you can use as a multiplier to make a good scale for all resolutions.
local function Scale(s, h)
	local devw = 1080 --Development width
	local devh = 1920 --Development height
	
	return s * (h and (ScrH() / devw) or (ScrW() / devh))
end
  • TheXnator
  • TheXnator's Avatar
  • Offline
  • Former Owner
  • ZARP VIP
  • "Save the tears for when we win!"
  • Posts: 8122
  • Thanks received: 4292
  • Karma: -2024

Discord: thexnator

Former Community Owner: 2020-2022
Login or register to post a reply.
The following user(s) said Thank You: Nafe, .uzi, House

Learning LUA -- Challenges? 6 years 9 months ago #1033447

TheXnator wrote:
.uzi wrote:
One thing to watch out for with HUDs is how they scale on lower resolutions. Put your resolution down to the lowest and it'll take up 80% of your display lol.

Using ScrW() and ScrH() gets you the current screen width and height respectively which you can use as a multiplier to make a good scale for all resolutions.
local function Scale(s, h)
	local devw = 1080 --Development width
	local devh = 1920 --Development height
	
	return s * (h and (ScrH() / devw) or (ScrW() / devh))
end

Yeah what nerd over here put
  • .uzi
  • .uzi's Avatar
  • Offline
  • Former Community Manager
  • ZARP VIP
  • Foos yer doos?
  • Posts: 6010
  • Thanks received: 2445
  • Karma: 123
Login or register to post a reply.
The following user(s) said Thank You: Nafe, TheXnator, House

Learning LUA -- Challenges? 6 years 9 months ago #1033448



Just an update for my HP and Armor HUD
  • Nafe
  • Nafe's Avatar
  • Offline
  • Former Community Manager
  • ZARP VIP
  • Posts: 18886
  • Thanks received: 8725
  • Karma: -380
Login or register to post a reply.

Learning LUA -- Challenges? 6 years 9 months ago #1033924

Nafe wrote:


Just an update for my HP and Armor HUD

consider usinglerp to make it more smooth, mostly for the sake of using it
  • catboy sven ツ
  • catboy sven ツ's Avatar
  • Offline
  • Adept Boarder
  • ZARP VIP
  • Respected Zarp Contributor
  • Posts: 7199
  • Thanks received: 1545
  • Karma: -44

ex-minecraft owner, zarp legend (Was there during the infancy of Zarp), ex-ssrp admin, ex-teamspeak emblem (For SSRP admin & minecraft owner)








Login or register to post a reply.
The following user(s) said Thank You: Nafe, TheXnator

Learning LUA -- Challenges? 6 years 9 months ago #1033928

Nafe wrote:


Just an update for my HP and Armor HUD

Looks good from an amateur! ;)
  • Katje
  • Katje's Avatar
  • Offline
  • User is blocked
  • ZARP VIP
  • Posts: 5286
  • Thanks received: 844
  • Karma: -73
Login or register to post a reply.
  • Page:
  • 1
  • 2
Moderators: Clarky

Time to create page: 0.135 seconds

210 PLAYERS ONLINE

Connect to server View Gametracker DarkRP
12/127
Online
Connect to server View Gametracker Deathrun
0/40
Online
Connect to server View Gametracker TTT
0/47
Online
Connect to server View Gametracker Bhop
0/32
Online
Connect to server View Gametracker Surf
3/32
Online
Connect to server View Gametracker Prop Hunt
0/42
Online
Connect to server View Gametracker Sandbox
0/42
Online
Connect to server Discord
195/974
Online
Top