Player info

Hello readers,

I want a player information above someones head for my server. I want a roundedbox that displays the players health and underneath it the playersname.

Ive been searching on google but could not find any usefull information.

In cl_hudreplacement, you want to set [“DarkRP_EntityDisplay”] = true. This will disable it from drawing the original information above players heads.

Then you want to use the link provided and put it in darkrp_modules (if you don’t know how to do this, then you can easily do this by creating a folder in darkrp_modules, choose a name, e.g. informationhud, and then you will need to put a file in it called cl_hud.lua). The link will show you the default entity display use by DarkRP, but, nevertheless, you can still use this to help you.

The yellow highlighted area might not provide what you want, but, the whole file should be enough to achieve what you want.

Your question is not really specific enough, do you know how to make a HUD? Do you not understand how to do the positioning above someone’s head? In that case I use this bit of code to get the location on screen.



local tracedEntity = ply:GetEyeTrace().Entity
if IsValid( tracedEntity ) and tracedEntity:isKeysOwnable() and ply:GetEyeTrace().Fraction < 0.005 then
	tracedEntity:drawOwnableInfo()
elseif tracedEntity:IsPlayer() and not GAMEMODE.Config.globalshow and ply:GetEyeTrace().Fraction < 0.01 then
	local pl = tracedEntity
	local pPos = pl:EyePos()
	local zOffset = ply:GetEyeTrace().Fraction * 2500
	pPos.z = pPos.z + 15 + zOffset
	pPos = pPos:ToScreen()

	-- The drawing of your HUD goes here, refer to the positions to draw on as pPos.x and pPos.y
        -- This code also keeps in mind that in DarkRP you want to draw info on doors and vehicles and such
	-- As a heads up (pun intended), this needs to be in a HUDPaint hook. Duh...
end