Jump to content

Glr Quando Passo Esse script Pra Host ele da erro


Recommended Posts

Alguem sabe Onde ta o erro, Script de NometagID

tag = {};
strPlayers = {};

--return
tag.NAMETAG_OFFSET = 1.1;
tag.NAMETAG_WIDTH = 100;
tag.NAMETAG_HEIGHT = 20;
tag.NAMETAG_MAX_DISTANCE = 25;
tag.NAMETAG_SCALE = 3.5;
tag.dxDraw = dxDrawText;

tag.dxCreateFont = dxCreateFont;
tag.nametagFont = tag.dxCreateFont("font.ttf", 17);
tag.size = 0.6;
tag.color = 240;
tag.size2 = "center"
tag.nametagsVisible = true
local function removeHexFromString(string)
	return string.gsub(string, "#%x%x%x%x%x%x","")
end


addEventHandler("onClientRender", root, function ()
	if not tag.nametagsVisible then
		return
	end
	--local r, g, b = exports.dpUI:getThemeColor()
	local cx, cy, cz = getCameraMatrix()
	for player, info in pairs(strPlayers) do
		local px, py, pz = getElementPosition(player)		
		local x, y = getScreenFromWorldPosition(px, py, pz + tag.NAMETAG_OFFSET)
		if x then
			tag.distance = getDistanceBetweenPoints3D(cx, cy, cz, px, py, pz)
			if tag.distance < tag.NAMETAG_MAX_DISTANCE then
				local name = info.name or "false"
				local id = info.ids or "false"
				--local famali = info.familia or "false"
				local obsh = name.." ("..id..")"
				local scale = 1 / tag.distance * tag.NAMETAG_SCALE
				local width = tag.NAMETAG_WIDTH * scale
				local height = tag.NAMETAG_HEIGHT * scale
				local nx, ny = x - width / 2, y - height / 2
				--dxDrawNametagText(name, nx, ny, nx + width, ny + height, tocolor(255, 255, 255, 255), scale)
				tag.dxDraw(obsh, nx, ny, nx + width, ny + height, tocolor(tag.color, tag.color, tag.color, tag.color), tag.size,tag.size, tag.nametagFont, tag.size2, tag.size2)
			end
		end
	end
end)

function tag.showPlayer(player)
	if not isElement(player) then
		return false
	end
	setPlayerNametagShowing(player, false)
	if player == localPlayer then
		return
	end
	strPlayers[player] = {name = player.name,ids = getElementData(player,"id") or "false"}
	return true
end

addEventHandler("onClientElementStreamIn", root, function ()
	if source.type == "player" then
		tag.showPlayer(source)
	end
end)

addEventHandler("onClientElementStreamOut", root, function ()
	if source.type == "player" then
		strPlayers[source] = nil
	end
end)

addEventHandler("onClientPlayerQuit", root, function ()
	strPlayers[source] = nil
end)

addEventHandler("onClientPlayerJoin", root, function ()
	if isElementStreamedIn(source) then
		tag.showPlayer(source)
	end
	setPlayerNametagShowing(source, false)
end)

addEventHandler("onClientPlayerSpawn", root, function ()
	if isElementStreamedIn(source) then
		tag.showPlayer(source)
	end
end)

addEventHandler("onClientElementDataChange", root, function(dataName, oldValue)
	
	if dataName == "Passport" then
		tag.showPlayer(source)
	end
end)

addEventHandler("onClientResourceStart", resourceRoot, function ()
	for i, player in ipairs(getElementsByType("player")) do
		if isElementStreamedIn(player) then
			tag.showPlayer(player)
		end
		setPlayerNametagShowing(player, false)
	end

end)

function setVisible(visible)
	tag.nametagsVisible = not not visible
end

 

  • Confused 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...