Login to ZARP
Username: Password: Remember me
  • Page:
  • 1
  • 2

TOPIC: Learning LUA -- Challenges?

Learning LUA -- Challenges? 6 years 1 month 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 Golden Blue Badge
  • Posts: 18666
  • Thanks received: 8623
  • Karma: -378
Last Edit: 6 years 1 month ago by Nafe.
Login or register to post a reply.

Learning LUA -- Challenges? 6 years 1 month 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 Golden Blue Badge
  • Foos yer doos?
  • Posts: 6007
  • Thanks received: 2443
  • Karma: 123
Login or register to post a reply.
The following user(s) said Thank You: Nafe

Learning LUA -- Challenges? 6 years 1 month 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 Golden Blue Badge
  • "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 1 month 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 Golden Blue Badge
  • Foos yer doos?
  • Posts: 6007
  • Thanks received: 2443
  • Karma: 123
Login or register to post a reply.
The following user(s) said Thank You: Nafe, TheXnator, House

Learning LUA -- Challenges? 6 years 1 month ago #1033448



Just an update for my HP and Armor HUD
  • Nafe
  • Nafe's Avatar
  • Offline
  • Former Community Manager
  • ZARP VIP Golden Blue Badge
  • Posts: 18666
  • Thanks received: 8623
  • Karma: -378
Login or register to post a reply.

Learning LUA -- Challenges? 6 years 1 month 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: 7197
  • Thanks received: 1544
  • Karma: -45
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 1 month 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
Time to create page: 1.403 seconds

144 PLAYERS ONLINE

Connect to server View Gametracker DarkRP 1
4/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
1/32
online
Connect to server View Gametracker Surf
0/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
139/913
online
Top