Jump to content

Ajuda de como fazer isso quando estiver digitando some o cargo admin


Recommended Posts

spacer.png

Spoiler
local font = dxCreateFont("gfx/font.ttf",7,true)
local dxCromus = dxCreateFont("gfx/font.ttf",10,true)
local normalDrawDistance = 50.0
local drawDistance = normalDrawDistance
local eventDrawDistance = 50.0

local tick = getTickCount()
local cText = ''
local index = 0
local speed = 500

function onClientResourceStart(resource)
	visibleTick = getTickCount()
	counter = 0
	customHealthbar = false
	for k, player in pairs(getElementsByType("player")) do
		setPlayerNametagShowing(player, false)
	end	
end
addEventHandler("onClientResourceStart", resourceRoot, onClientResourceStart )

function onClientResourceStop(resource)
	for k, player in pairs(getElementsByType("player")) do
		setPlayerNametagShowing(player, false)
	end	
end
addEventHandler( "onClientResourceStop", resourceRoot, onClientResourceStop)


function onClientPlayerJoin()
	setPlayerNametagShowing(source, false)
end
addEventHandler("onClientPlayerJoin", root, onClientPlayerJoin)

function drawHPBar( x, y, v, d)
	if(v < 0.0) then
		v = 0.0
	elseif(v > 100.0) then
		v = 100.0
	end
	 dxDrawRectangle(x - 21, y, 42, 5, tocolor(0, 0, 0, 250 - d))
  dxDrawRectangle(x - 20, y + 1, v / 2.5, 3, tocolor((100 - v) * 1.0, v * 255, 0, 255 - d))
end

function drawArmourBar( x, y, v, d)
	if(v < 0.0) then
		v = 0.0
	elseif(v > 100.0) then
		v = 100.0
	end
	dxDrawRectangle(x - 21, y, 42, 5, tocolor(0, 0, 0, 250 - d))
  dxDrawRectangle(x - 20, y + 1, v / 2.5, 3, tocolor(255, 255, 255, 255 - d))
end

sx,sy = guiGetScreenSize()
px,py = 1920,1080
SX,SY =  (sx/px), (sy/py)

function chatCheckPulse()
    local chatting = isChatBoxInputActive() or isConsoleActive()
	if(chatting ~= g_oldChatting) then
		setElementData(localPlayer, "chatting", chatting)
		g_oldChatting = chatting
	end 
end
setTimer(chatCheckPulse, 500, 0)

function drawPlayerTags()
	local cx, cy, cz, lx, ly, lz = getCameraMatrix()
	if(getElementData(localPlayer, "special.event")) then
		drawDistance = eventDrawDistance
	else
		drawDistance = normalDrawDistance
	end
	local target = getPedTarget(localPlayer)
	for k, player in pairs(getElementsByType("player", root, true)) do
		if(player ~= localPlayer) then
			local vx, vy, vz = getPedBonePosition(player, 8)
			local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz )
			if dist < drawDistance or player == target then
				if( isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false) ) then
					local x, y = getScreenFromWorldPosition (vx, vy, vz + 0.3)
					if(x and y) then
						--local tag = getElementData(player, "gang.tag") or ""
						-- local name = tag .. getPlayerName(player) .. "(" .. (getElementData(player, "id") or "?") .. ")"
						-- local nameU = tag .. string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "") .. "(" .. (getElementData(player, "id") or "?") .. ")"
						local name = getPlayerName(player)
						local nameU = string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "")
						local scale = SY*1
						local w = dxGetTextWidth(nameU, scale, dxCromus)
						local h = dxGetFontHeight(scale, dxCromus)
						local color = tocolor(getPlayerNametagColor(player))

						if dist < 5 then
							size = 1.1 - (dist/drawDistance) ---- tamanho da fonte do name 
						else
							--size = 1.5
						end
						
						dxDrawText(name, x - w / 2.1,y - h - 15, 0, 0, color, size, "default-bold", "left", "top", false, false, false, true, false)
						
						if(getElementData(player, "chatting")) then
						
						if (index >= 4) then
                        tick = getTickCount() + speed
                        index = 0
                        cText = ''
                        end
							dxDrawBorderedText('Digitando' .. (cText or ''), x - 1  - w / 2.1,y - 1 - h - 46, 0, 0, tocolor(255, 255, 255), 1.0, "default-bold")
							
							if (getTickCount() > tick and index <= 4) then
                            tick = getTickCount() + speed
                            index = index + 1
                            cText = utf8.sub('...', 1, index)
                            end
						end
	
						local health = getElementHealth ( player )
						local armour = getPedArmor ( player )

						if(health > 0.0) then
						local rate =   math.ceil(500/(getPedStat(player,24)))
						drawHPBar(x, y-2.0, health*rate, dist)
							if(armour > 0.0) then
							drawArmourBar(x, y-10.0, armour, dist)
							end
							local cargo = getElementData(player, "cargo")
							if(cargo) then
							w = dxGetTextWidth(cargo, 1.2, font )
							dxDrawBorderedText(cargo, x - 1  - w / 2.6,y - 1 - h - 30, 0, 0, tocolor(255,255,255), 1.0, "default-bold")			
							end					
						end
					end
				end
			end
		end
	end
end

function drawPedTags()
	local cx, cy, cz, lx, ly, lz = getCameraMatrix()
	local target = getPedTarget(localPlayer)
	for k, ped in pairs(getElementsByType("ped", root, true)) do
		if(getElementData(ped, "nametagShowing")) then
			local vx, vy, vz = getPedBonePosition(ped, 8)
			local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz )
			if dist < drawDistance or ped == target then
				if( isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false) ) then
					local x, y = getScreenFromWorldPosition (vx, vy, vz + 0.3)
					if(x and y) then
						local tag = getElementData(ped, "gang.tag") or ""
						local name = tag .. (getElementData(ped, "pedName") or "")
						local scale = SY*0.9
						local w = dxGetTextWidth(name, scale, font)
						local h = dxGetFontHeight(scale, font)
						
						local color = tocolor(255,255,255)
						
						local pedNametagColor = getElementData(ped, "pedNametagColor")
						
						if(pedNametagColor) then
							local r,g,b = unpack(pedNametagColor)
							color = tocolor(r,g,b)
						end

					    dxDrawText(name, x - 1  - w / 1,y - 1 - h, w, h, tocolor(0,0,0,200), scale, font)
						dxDrawText(name, x - w / 1,y - h, w, h, color, scale, font)

						local health = getElementHealth(ped)
						local armour = getPedArmor(ped)

						if(health > 0.0) then
							local rate =   math.ceil(500/(getPedStat(ped,24)))
							--drawHPBar(x, y-6.0, health*rate, dist)
							if(armour > 0.0) then
								--drawArmourBar(x, y-12.0, armour, dist)
							end				
						end
						if(getElementData(ped, "hologram")) then
							local text = "Desconectado"
							w = dxGetTextWidth(text, 1, "default-bold")
							dxDrawText(text, x - 1  - w / 2,y - 1 - h - 12-18, w, h, tocolor(0,0,0), 1, "default-bold")
							dxDrawText(text, x - w / 2,y - h - 12-18, w, h, tocolor(255,255,255), 1, "default-bold")
						end						
					end
				end
			end
		end
	end
end

function drawCarTags()
	local cx, cy, cz, lx, ly, lz = getCameraMatrix()
	for k, vehicle in pairs(getElementsByType("vehicle", root, true)) do
		local px, py, pz = getElementPosition(vehicle)
		local dist = getDistanceBetweenPoints3D(cx, cy, cz, px, py, pz)
		if dist < 60 then
			if( isLineOfSightClear(cx, cy, cz, px, py, pz, true, false, false) ) then
				local x, y = getScreenFromWorldPosition (px, py, pz + 1)
				if(x and y) then
					local owner = getElementData(vehicle, "owner")
					if isElement(owner) then
						local ownerName = getPlayerName(owner)
						local h = dxGetFontHeight(SY*0.8, fontPlayers)
						local w = dxGetTextWidth(ownerName, SY*0.8, fontPlayers)
						dxDrawText(ownerName, x - w / 2, y + h*-2, w, h, tocolor(getPlayerNametagColor(owner)), SY*0.8, fontPlayers)			
					end
				end
			end
		end
	end
end

function onClientRender()
	drawPlayerTags()
	--drawPedTags()
	--drawCarTags()
end
addEventHandler("onClientRender", root, onClientRender)

enabled = true
function ativarnt()
	enabled = not enabled
	if enabled then
		addEventHandler("onClientRender", root, onClientRender)
	else
		removeEventHandler("onClientRender", root, onClientRender)
	end
end
         

 

 

Edited by Lord Henry
Script muito longo colocado dentro de spoiler.
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...