[Release] Custom head labels

name
playername
id
hlabel

#1

Hello, I am here today to release a modified name over head script, initially created by @MrDaGree, you can find the initial release here: [Release] Changed Player Name Tags & Distance Names and yes, I did get permission from him to release this.
So, you may be asking what is changed in the release. Well, first I have changed the overall look of the tag. Adding on to this when people talk it displays under their head “Talking…”, you can find screenshots below.


Installation
  1. Navigate to your servers ‘resources’ folder, then drag the hlabels folders from the rar into your ‘resources’ folder.
  2. Go to your ‘server.cfg’ and add under your resources: ‘start hlabels’.
  3. Join your server and enjoy!
Download | EssentialMode

es-hlabels.rar (1.9 KB)
s_hlabel.lua

-- Range Close
TriggerEvent('es:addGroupCommand', 'hlrangec', "mod", function(source, name, message)
	TriggerClientEvent('DisCLS', source)
	TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Your headlabel range has been set to: [ CLOSE ]")
	end, function(source, args, user)
	TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!")
end)


-- Range Medium
TriggerEvent('es:addGroupCommand', 'hlrangem', "mod", function(source, name, message)
	TriggerClientEvent('DisMDM', source)
	TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Your headlabel range has been set to: [ MEDIUM ]")
	end, function(source, args, user)
	TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!")
end)

-- Range Far
TriggerEvent('es:addGroupCommand', 'hlrangef', "mod", function(source, name, message)
	TriggerClientEvent('DisFAR', source)
	TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Your headlabel range has been set to: [ FAR ]")
	end, function(source, args, user)
	TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!")
end)

-- Labels OFF Client
TriggerEvent('es:addGroupCommand', 'hloff', "user", function(source, name, message)
	TriggerClientEvent('hlDIS', source)
	TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "^1Headlabels have been disabled.")
	end, function(source, args, user)
	TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!")
end)

-- Labels ON Client
TriggerEvent('es:addGroupCommand', 'hlon', "user", function(source, name, message)
	TriggerClientEvent('hlEN', source)
	TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "^1Headlabels have been enabled.")
	end, function(source, args, user)
	TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient permissions!")
end)

c_hlabel.lua

--[[
---------------------------------------------------
HEAD LABELS(C_HLABEL.LUA) by MrDaGree | Edited by Jack
---------------------------------------------------
Last revision: APR 13 2018
---------------------------------------------------
NOTES 
	x Scale stays the same regarless of distance.
	x Working on a /hlset args command. 
	
---------------------------------------------------
	
]]
local showPlayerBlips = false
local ignorePlayerNameDistance = false
local disPlayerNames = 15
local playerSource = 0

RegisterNetEvent('hlDIS')
AddEventHandler('hlDIS', function()
	disPlayerNames = 0
end)

RegisterNetEvent('hlEN')
AddEventHandler('hlEN', function()
	disPlayerNames = 15
end)

RegisterNetEvent('DisCLS')
AddEventHandler('DisCLS', function()
	disPlayerNames = 15
end)

RegisterNetEvent('DisMDM')
AddEventHandler('DisMDM', function()
	disPlayerNames = 200
end)

RegisterNetEvent('DisFAR')
AddEventHandler('DisFAR', function()
	disPlayerNames = 9999
end)

function DrawText3D(x,y,z, text) -- some useful function, use it if you want!
	local onScreen,_x,_y=World3dToScreen2d(x,y,z)
	local px,py,pz=table.unpack(GetGameplayCamCoords())
	local dist = GetDistanceBetweenCoords(px,py,pz, x,y,z, 1)
	local ped_l = GetPlayerPed(-1)
	local offs_z = 1.25
	local mult_a = 1.00
	local mult_s = 1.00
		if IsPedInAnyVehicle(ped_i, true) then
			local veh = GetVehiclePedIsUsing(ped_i)
			if getPedVehSeat(ped_i, veh) > -1 then
				offs_z = 1.10
				mult_a = 0.4
				mult_s = 0.3
			else
				offs_z = 1.30
			end
		end

	local scale = (4.00001/dist)*0.3
	if scale > 0.2 then
		scale = 0.2
	elseif scale < 0.15 then
		scale = 0.15
	end

	local fov = (1/GetGameplayCamFov())*100
	local scale = scale*fov

	if onScreen then
		SetTextFont(4)
		SetTextScale(scale, scale)
		SetTextProportional(true)
		SetTextColour(255, 255, 255, 255)
		SetTextCentre(true)
		SetTextDropshadow(0, 0, 0, 0, 0)
		SetTextOutline()
		SetTextEntry("STRING")
		AddTextComponentString(text)
		DrawText(_x,_y - 0.025)
	end
end

Citizen.CreateThread(function()
	while true do
		for i=0,99 do
		N_0x31698aa80e0223f8(i)
	end
	for id = 0, 31 do
	if NetworkIsPlayerActive(id) and GetPlayerPed(id) ~= GetPlayerPed(-1) then
		ped = GetPlayerPed(id)
		x1, y1, z1 = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
		x2, y2, z2 = table.unpack(GetEntityCoords(GetPlayerPed(id), true))
		distance = math.floor(GetDistanceBetweenCoords(x1,  y1,  z1,  x2,  y2,  z2,  true))
				if distance < disPlayerNames then
					if not ignorePlayerNameDistance then
						if NetworkIsPlayerTalking(id) then
							DrawText3D(x2, y2, z2+1, "~c~" .. GetPlayerServerId(id) .. "  |  " .. string.sub(GetPlayerName(id), 1, 44) .. "~n~~g~Talking...")
						else
							DrawText3D(x2, y2, z2+1, "~c~" .. GetPlayerServerId(id) .. "  |  " .. string.sub(GetPlayerName(id), 1, 44) .. "")
						end
					end
				end
			end
		end
		Citizen.Wait(0)
	end
end)
Download | Non-EssentialMode

hlabels.rar (1.4 KB)
c_hlabel.lua

---------------------------------------------------
HEAD LABELS(C_HLABELS.LUA) by MrDaGree | Edited by Jack
---------------------------------------------------
Last revision: APR 13 2018
---------------------------------------------------
NOTES 
	x Scale stays the same regarless of distance.
	x Working on a /hlset args command. 
	
---------------------------------------------------
	
]]
local showPlayerBlips = false
local ignorePlayerNameDistance = false
local disPlayerNames = 15
local playerSource = 0

RegisterCommand('hloff', function()
	disPlayerNames = 0
end)

RegisterCommand('hlon', function()
	disPlayerNames = 15
end)

RegisterCommand('hlrangec', function()
	disPlayerNames = 15
end)

RegisterCommand('hlrangem', function()
	disPlayerNames = 200
end)

RegisterCommand('hlrangef', function()
	disPlayerNames = 9999
end)

function DrawText3D(x,y,z, text) -- some useful function, use it if you want!
	local onScreen,_x,_y=World3dToScreen2d(x,y,z)
	local px,py,pz=table.unpack(GetGameplayCamCoords())
	local dist = GetDistanceBetweenCoords(px,py,pz, x,y,z, 1)
	local ped_l = GetPlayerPed(-1)
	local offs_z = 1.25
	local mult_a = 1.00
	local mult_s = 1.00
		if IsPedInAnyVehicle(ped_i, true) then
			local veh = GetVehiclePedIsUsing(ped_i)
			if getPedVehSeat(ped_i, veh) > -1 then
				offs_z = 1.10
				mult_a = 0.4
				mult_s = 0.3
			else
				offs_z = 1.30
			end
		end

	local scale = (4.00001/dist)*0.3
	if scale > 0.2 then
		scale = 0.2
	elseif scale < 0.15 then
		scale = 0.15
	end

	local fov = (1/GetGameplayCamFov())*100
	local scale = scale*fov

	if onScreen then
		SetTextFont(4)
		SetTextScale(scale, scale)
		SetTextProportional(true)
		SetTextColour(255, 255, 255, 255)
		SetTextCentre(true)
		SetTextDropshadow(0, 0, 0, 0, 0)
		SetTextOutline()
		SetTextEntry("STRING")
		AddTextComponentString(text)
		DrawText(_x,_y - 0.025)
	end
end

Citizen.CreateThread(function()
	while true do
		for i=0,99 do
		N_0x31698aa80e0223f8(i)
	end
	for id = 0, 31 do
	if NetworkIsPlayerActive(id) and GetPlayerPed(id) ~= GetPlayerPed(-1) then
		ped = GetPlayerPed(id)
		x1, y1, z1 = table.unpack(GetEntityCoords(GetPlayerPed(-1), true))
		x2, y2, z2 = table.unpack(GetEntityCoords(GetPlayerPed(id), true))
		distance = math.floor(GetDistanceBetweenCoords(x1,  y1,  z1,  x2,  y2,  z2,  true))
				if distance < disPlayerNames then
					if not ignorePlayerNameDistance then
						if NetworkIsPlayerTalking(id) then
							DrawText3D(x2, y2, z2+1, "~c~" .. GetPlayerServerId(id) .. "  |  " .. string.sub(GetPlayerName(id), 1, 44) .. "~n~~g~Talking...")
						else
							DrawText3D(x2, y2, z2+1, "~c~" .. GetPlayerServerId(id) .. "  |  " .. string.sub(GetPlayerName(id), 1, 44) .. "")
						end
					end
				end
			end
		end
		Citizen.Wait(0)
	end
end)
Screenshots

Not talking.


Talking.

Features
  • Commands which can be found in s_hlabel.lua in the EssentialMode version, these commands are also permission based. In the non-EssentialMode version they can be found in the c_hlabel.lua. These commands are:
    /hlrangec - This sets the range of the headlabels to 15
    /hlrangem - This sets the range of the headlabels to 200
    /hlrangef - This sets the range of the headlabels so you can see every player.
    /hlon - This turns headlabels on for yourself.
    /hloff - This turns headlabels off for yourself.
    These commands are permission based except from /hlon and /hloff.
  • Displays when players are talking.
  • Scale of the headlabels stay the same regardless of range.

I hope you guys enjoy this script and suggestions are always welcomed. Any questions just reply to this topic.

#2

Could you also add typing?


#3

I have tried doing this in the past but had no luck but if somebody with a little more experience wants to contribute to this then that would be the only way.


#4

Post updated.

- Added Features.

#5

Why is /hlon and /hloff not permission based?


#6

As it is only for yourself, not other players. It wouldn’t make sense to have the ability to disable/enable them for people with x permission.


#7

I see so anyone can enable that?


#8

Yes, anybody can enable it. But if you want you can change it.


#9

I’m also going to make a separate link for non-essentialmode.


#10

Got it so i can just set user to superadmin? for enable and disable head labels?


#11

Yup.

TriggerEvent('es:addGroupCommand', 'hlon', "user", function(source, name, message)

to

TriggerEvent('es:addGroupCommand', 'hlon', "superadmin", function(source, name, message)

#12

Great release!
possible to change them to the real names? within esx


#13

Thanks! Not too familiar with ESX so if you’re wanting that you’ll probably have to do a bit of coding yourself.


#14

You could use esx_rpchat as an example for setting a character name overhead rather than a player name.


#15

I’ll have a look at it. Do you have a link to it? Can’t seem to find it.


#16

Where can I change the “talking…” position been looking though with no luck.


#17
DrawText3D(x2, y2, z2+1, "~c~" .. GetPlayerServerId(id) .. "  |  " .. string.sub(GetPlayerName(id), 1, 44) .. "~n~~g~Talking...")

this line, just change (x2, y2, z2+1, that should do it.


#18

ahhh I was hoping to move just the talking oh well.


#19

I see this as more of an Admin script? Shouldn’t this be permission-based;

Alright, essentialmode is shit and I’m not even looking at it. However, why don’t you just make the commands permission based via ace permission? :man_facepalming:

 RegisterCommand('hlon', function()
	disPlayerNames = 15
end)

Toooo…

 RegisterCommand('hlon', function()
	disPlayerNames = 15
end, true)

Add this to the server.cfg:

add_ace group.groupName command.hlon allow

idk, just seems better with permission rather than anyone using it?

EDIT: Also, wouldn’t this be classed as a re-release? As all you basically did was add “Talking…” under the players name? I mean, I wouldn’t call it a whole new resource just for that? Just a thought. It’s a good idea though.


#20

If you want to do that then you do that, people may not just use it for arrpee purposes. It might just be a small iteration for a freeroam, or sandbox server.