HUD
Functions

GM: CD can Render Info

Origin is HUDPaint hook. Called before we render each car dealers info text (above head). This can be used to override the data per car dealer with custom visual styles.

Used in: VCMod Main addon.

Client GM:VC_CD_canRenderInfo(Entity ent, String text)

Arguments

1. Entity ent; Car Dealer NPC
The NPC of which we want to render info about.

2. String text; Text
The text above the head.

Returns

1. Boolean Return false if you want the original VCMod above head info to not draw.

Example

hook.Add("VC_CD_canRenderInfo", "createCustomVCModCarDealerText", function(ent, text)
	// This code snippet is a stripped down version of the currently used VCMod car dealer above head info drawing

	// A lot of code is removed for demonstration purposes, keep that in mind

	// Create a pixel visibility entity
	if !ent.VC_PVsb then ent.VC_Color = VC.Color.White ent.VC_PVsb = util.GetPixelVisibleHandle() end

	// Get positions and visibility
	local BInd = ent:LookupBone("ValveBiped.Bip01_Head1")
	local pos = Vector(0,0,0) if BInd then local BonePos , BoneAng = ent:GetBonePosition(ent:LookupBone("ValveBiped.Bip01_Head1")) pos = BonePos+Vector(0,0,8) else pos=ent:GetPos()+Vector(0,0,65) end
	local Vis = util.PixelVisible(pos+Vector(0,0,5), 1, ent.VC_PVsb) local Dist = nil
	pos = pos:ToScreen()

	// A lot of code is removed for demonstration purposes, keep that in mind
	local VisM = 1
	surface.SetFont("VC_Name") local tz = surface.GetTextSize(text)
	local Sx = math.Round(pos.x+(VisM-1)*50) local Sy = math.Round(pos.y-25) local PSx, PSy = tz, 50

	// Drawing background
	local clr = table.Copy(VC.Color.Main) clr.a=clr.a*VisM draw.RoundedBox(0, math.Round(Sx-PSx/2)+1, Sy, PSx, PSy, clr)

	// Drawing text
	local tclr = table.Copy(VC.Color.White) tclr.a=tclr.a*VisM draw.SimpleText(text, "VC_Name", Sx, Sy+25, tclr, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)

	return false // This will force the original VCMod code render code to not function
end)
Page modified:
...2018-12-14 19:43:51