I have a darkrp module hud that works but I need to run it manually. Here is the code:
if not LocalPlayer():IsValid() then return end
local lp = LocalPlayer()
local armor = lp:Armor() or 0
local health = lp:Health() or 0
if health > 100 then health = 100 end
if health < 0 then health = 0 end
if(IsValid(lp) and IsValid(lp:GetActiveWeapon())) then
local ammo = 0 local clip = 0 if IsValid( weapon ) then
clip = weapon:Clip1()
ammo = lp:GetAmmoCount(weapon:GetPrimaryAmmoType())
end
end
hook.Add( "HUDPaint", "DrawHud", function()
local Texture1 = Material("hud/hud2.png")
surface.SetMaterial(Texture1)
surface.SetDrawColor(Color(255, 255, 255, 255))
surface.DrawTexturedRect(0, 35, ScrW()/1, ScrH()/1.04, Color(255, 255, 255, 255))
draw.DrawText(health, "CloseCaption_Normal", 180, 1015, Color(255, 255, 255, 255))
draw.DrawText(armor, "CloseCaption_Normal", 500, 1015, Color(255, 255, 255, 255))
draw.DrawText(DarkRP.getPhrase("wallet", DarkRP.formatMoney(lp:getDarkRPVar("money")), ""), "CloseCaption_Normal", 1660, 115, Color(255, 255, 255, 255))
draw.DrawText(clip or 0, "CloseCaption_Normal", 1500, 995, Color(255, 255, 255, 255))
draw.DrawText(ammo or 0, "CloseCaption_Normal", 1720, 995, Color(255, 255, 255, 255))
end)
Is there anything I can do?
Best guess it that you do this at the top of the code, assuming this code gets run instantly the localplayer is not ready, this is preventing it from loading. By running it manually you have already loaded into the game thus the code can make it past the if statement.
I literally never saw you here..well, old posts. But not new. Welcome back alive i guess?
Your the only source i used to learn lua. and it was the best
Sorry, you need to Log In to post a reply to this thread.