Jump to content

ID Invisível para Staff


Recommended Posts

Olá pessoal

Eu gostaria de saber se tem possibilidade de quando o staff ficar invisível, o ID que fica em cima da cabeça dele desapareça no sistema que eu uso, eu vi um tópico aqui solucionado porém é para um sistema diferente do que uso.

Sistema: Script_ID_System - Danilin

Vou deixar o código abaixo

Agradecerei muito quem puder me ajudar

 

--[[
/\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\/
										            Curta a Minha Página <3									        
 									     	https://www.facebook.com/danilinmtascr/		
								   
                        :::::::::      :::     ::::    ::: ::::::::::: :::        ::::::::::: ::::    ::: 
                        :+:    :+:   :+: :+:   :+:+:   :+:     :+:     :+:            :+:     :+:+:   :+: 
                        +:+    +:+  +:+   +:+  :+:+:+  +:+     +:+     +:+            +:+     :+:+:+  +:+ 
                        +#+    +:+ +#++:++#++: +#+ +:+ +#+     +#+     +#+            +#+     +#+ +:+ +#+ 
                        +#+    +#+ +#+     +#+ +#+  +#+#+#     +#+     +#+            +#+     +#+  +#+#+# 
                        #+#    #+# #+#     #+# #+#   #+#+#     #+#     #+#            #+#     #+#   #+#+# 
                        #########  ###     ### ###    #### ########### ########## ########### ###    #### 
                                        						
/\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\/
--]]
function Start_Id ( _, acc )
	if eventName == "onPlayerLogin" then
		setElementData ( source, "ID", getAccountID(acc) or "0" )
		--outputChatBox ( "#1E90FF▶ #ffffffEntrou #1E90FF◄➺ #ffffffIdentidade: #1E90FF ( ".. getPlayerName(source) .." #1E90FF) #ffffffID: #1E90FF( "..(getAccountID(acc) or "0") .." )", root, 255,255,255,true)
	elseif eventName == "onPlayerLogout" then
		removeElementData( source, "ID" )
		--outputChatBox ( "#FF0000▶ #ffffffSaiu #FF0000◄➺ #ffffffIdentidade: #FF0000 ( ".. getPlayerName(source) .." #00ff00) #ffffffDeslogou.", root, 255,255,255,true)
	elseif eventName == "onResourceStart" then
		for _, player in pairs(getElementsByType("player")) do
			local acc = getPlayerAccount(player)
			if not isGuestAccount(acc) then
				setElementData( source, "ID", getAccountID(acc) or "0" )
			end
		end
	end
end
addEventHandler("onResourceStart", resourceRoot, Start_Id)
addEventHandler("onPlayerLogout", root, Start_Id)
addEventHandler("onPlayerLogin", root, Start_Id)

function getPlayerID(id)
	v = false
	for i, player in ipairs (getElementsByType("player")) do
		if getElementData(player, "ID") == id then
			v = player
			break
		end
	end
	return v
end
--============================================================================================================================--
                                   --=============================--
                                   ----------- ID PLAYER ------------
                                   --=============================--
function getnick(player, command, id, ...)
    if(id) then
        local playerID = tonumber(id)
		if(playerID) then
			local Player2 = getPlayerID(playerID)
			if(Player2) then	
				outputChatBox ( "#00ff00✘ #ffffffINFO #00ff00✘➺ #ffffff Nome do Jogador #00ff00" .. getPlayerName(Player2) .."", player, 255,255,255,true)
			else
				outputChatBox ( "#FF0000✘ #ffffffERRO #FF0000✘➺ #ffffff O Jogador(a) de ID: #FF0000( " .. id .. " ) #ffffffNão Foi Encontrado!", player, 255,255,255,true)
			end 
		else
			outputChatBox ( "#FF0000✘ #ffffffERRO #FF0000✘➺ #ffffff ID: #FF0000( " .. id .. " ) #ffffffInválido!", player, 255,255,255,true)
		end
	else
		outputChatBox ( "#FF0000✘ #ffffffERRO #FF0000✘➺ #ffffffUse /id #FF0000[#ffffffID#FF0000]", player, 255,255,255,true)
	end
end
addCommandHandler("id", getnick)

 

Link to comment
6 hours ago, Lord Henry said:

O script que você mostrou não tem a parte de mostrar o ID em cima da cabeça do jogador.

Falta a parte client-side.

Desculpa, acabei mandando um antigo, vou mandar o atual

Server Side

function Start_Id()
	for _, player in pairs(getElementsByType("player")) do
		local acc = getPlayerAccount(player)
		if not isGuestAccount(acc) then
			setElementData(player, "ID", getAccountID(acc) or "N/A")
		end
	end
end
addEventHandler("onResourceStart", resourceRoot, Start_Id)

function Login_Id(_, acc)
	setElementData(source, "ID", getAccountID(acc) or "N/A")
end
addEventHandler("onPlayerLogin", root, Login_Id)

function getNickFromID(player, _, id)
	if tonumber(id) then
		local thePlayer = getPlayerFromID(tonumber(id))
		if thePlayer then	
			outputChatBox ( "#106FE7 #ffffffINFO #106FE7➺ #ffffff Nome do Jogador #106FE7" ..getPlayerName(thePlayer), player, 255, 255, 255, true)
		end
	end
end
addCommandHandler("id", getNickFromID)

function getPlayerFromID(id)
	for _, v in pairs(getElementsByType("player")) do
		if getElementData(v, "ID") == id then
			return v
		end
	end
end

 

Client Side

 

local normalDrawDistance = 50.0

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

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

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

function fRenderNameTag()
	local target = getPedTarget(localPlayer)
	for _, player in pairs(getElementsByType("player", root, true)) do
		if player ~= localPlayer then
			local cx, cy, cz = getCameraMatrix()
			local vx, vy, vz = getPedBonePosition(player, 8)
			local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz)
			if dist < normalDrawDistance or player == target then
				if isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false, true, false, false, false, localPlayer) then
					local x, y = getScreenFromWorldPosition(vx, vy, vz + 0.3)
					if x and y then
						local text = getElementData(player, "ID") or "N/A"
						local w = dxGetTextWidth(text, 1, "default-bold", true)

						local alpha = 255
						if dist >= 10 then
							local leftover = dist - 10
							alpha = math.max(0, alpha - dist * (leftover/5))
						end
						
						dxDrawBorderedText(text, x - w, y - 10, x + w, y, tocolor(255, 255, 255, alpha), alpha, 1, "default-bold", "center", "top", false, false, false, true)	
					end
				end
			end
		end
	end
end
addEventHandler("onClientRender", root, fRenderNameTag)

function dxDrawBorderedText(text, left, top, right, bottom, color, alpha, scale, font, alignX, alignY, clip, wordBreak,postGUI) 
    for oX = -1, 1 do -- Border size is 1 
        for oY = -1, 1 do -- Border size is 1 
            dxDrawText(text, left + oX, top + oY, right + oX, bottom + oY, tocolor(0, 0, 0, alpha), scale, font, alignX, alignY, clip, wordBreak,postGUI) 
        end 
    end 
    dxDrawText(text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI) 
end

 

Pronto

Link to comment
  • Other Languages Moderators

Faça essas alterações:

server-side

function Start_Id()
    for _, player in pairs(getElementsByType("player")) do
        local acc = getPlayerAccount(player)
        if not isGuestAccount(acc) then
            setElementData(player, "ID", getAccountID(acc) or "N/A")
            if hasObjectPermissionTo(player, "command.mute", false) then -- Se o jogador é Staff, então:
                setElementData(player, "isStaff", true)
            else -- Caso o jogador tinha essa data antes, mas trocou de conta enquanto este resource estava desligado e agora não está como Staff:
                removeElementData(player, "isStaff")
            end
        end
    end
end
addEventHandler("onResourceStart", resourceRoot, Start_Id)

function Login_Id(_, acc)
    setElementData(source, "ID", getAccountID(acc) or "N/A")
    if hasObjectPermissionTo(source, "command.mute", false) then -- Se o jogador é Staff, então:
        setElementData(source, "isStaff", true)
    end
end
addEventHandler("onPlayerLogin", root, Login_Id)

addEventHandler("onPlayerLogout", root, function(acc)
    removeElementData(source, "isStaff") -- Deslogou, não está mais logado na conta de Staff.
end)

client-side

function fRenderNameTag()
    local target = getPedTarget(localPlayer)
    for _, player in pairs(getElementsByType("player", root, true)) do
        if player ~= localPlayer then
            local cx, cy, cz = getCameraMatrix()
            local vx, vy, vz = getPedBonePosition(player, 8)
            local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz)
            if dist < normalDrawDistance or player == target then
                if isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false, true, false, false, false, localPlayer) then
                    local x, y = getScreenFromWorldPosition(vx, vy, vz + 0.3)
                    if x and y then
                        local text = getElementData(player, "ID") or "N/A"
                        local w = dxGetTextWidth(text, 1, "default-bold", true)

                        local alpha = 255
                        if dist >= 10 then
                            local leftover = dist - 10
                            alpha = math.max(0, alpha - dist * (leftover/5))
                        end
                        if not getElementData(player, "isStaff") then -- Se o alvo NÃO É staff, então:
                            dxDrawBorderedText(text, x - w, y - 10, x + w, y, tocolor(255, 255, 255, alpha), alpha, 1, "default-bold", "center", "top", false, false, false, true)
                        end
                    end
                end
            end
        end
    end
end
addEventHandler("onClientRender", root, fRenderNameTag)

 

Edited by Lord Henry
  • Thanks 1
Link to comment

Colocando exatamente dessa forma que tu mandou, fica conforme essa imagem https://prnt.sc/EnAfwvAqXzbe

porém no cliente side se eu acrescentar essas linhas acima da parte que tu mencionou, o ID some para todo mundo, o que será que pode ser?

 

local normalDrawDistance = 50.0

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

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

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

 

Link to comment

Então, desculpe minha falta de conhecimento rsrs mas eu também fiz da forma que tu mencionou, vou deixar aqui como eu fiz

 

cliente-side

 

local normalDrawDistance = 50.0

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

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

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

function fRenderNameTag()
    local target = getPedTarget(localPlayer)
    for _, player in pairs(getElementsByType("player", root, true)) do
        if player ~= localPlayer then
            local cx, cy, cz = getCameraMatrix()
            local vx, vy, vz = getPedBonePosition(player, 8)
            local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz)
            if dist < normalDrawDistance or player == target then
                if isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false, true, false, false, false, localPlayer) then
                    local x, y = getScreenFromWorldPosition(vx, vy, vz + 0.3)
                    if x and y then
                        local text = getElementData(player, "ID") or "N/A"
                        local w = dxGetTextWidth(text, 1, "default-bold", true)

                        local alpha = 255
                        if dist >= 10 then
                            local leftover = dist - 10
                            alpha = math.max(0, alpha - dist * (leftover/5))
                        end
                        if not getElementData(player, "isStaff") then -- Se o alvo NÃO É staff, então:
                            dxDrawBorderedText(text, x - w, y - 10, x + w, y, tocolor(255, 255, 255, alpha), alpha, 1, "default-bold", "center", "top", false, false, false, true)
                        end
                    end
                end
            end
        end
    end
end
addEventHandler("onClientRender", root, fRenderNameTag)

function dxDrawBorderedText(text, left, top, right, bottom, color, alpha, scale, font, alignX, alignY, clip, wordBreak,postGUI) 
    for oX = -1, 1 do -- Border size is 1 
        for oY = -1, 1 do -- Border size is 1 
            dxDrawText(text, left + oX, top + oY, right + oX, bottom + oY, tocolor(0, 0, 0, alpha), scale, font, alignX, alignY, clip, wordBreak,postGUI) 
        end 
    end 
    dxDrawText(text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI) 
end

 

server-side

 

function Start_Id()
    for _, player in pairs(getElementsByType("player")) do
        local acc = getPlayerAccount(player)
        if not isGuestAccount(acc) then
            setElementData(player, "ID", getAccountID(acc) or "N/A")
            if hasObjectPermissionTo(player, "command.mute", false) then -- Se o jogador é Staff, então:
                setElementData(player, "isStaff", true)
            else -- Caso o jogador tinha essa data antes, mas trocou de conta enquanto este resource estava desligado e agora não está como Staff:
                removeElementData(player, "isStaff")
            end
        end
    end
end
addEventHandler("onResourceStart", resourceRoot, Start_Id)



function Login_Id(_, acc)
    setElementData(source, "ID", getAccountID(acc) or "N/A")
    if hasObjectPermissionTo(source, "command.mute", false) then -- Se o jogador é Staff, então:
        setElementData(source, "isStaff", true)
    end
end
addEventHandler("onPlayerLogin", root, Login_Id)

addEventHandler("onPlayerLogout", root, function(acc)
    removeElementData(source, "isStaff") -- Deslogou, não está mais logado na conta de Staff.
end

function getNickFromID(player, _, id)
	if tonumber(id) then
		local thePlayer = getPlayerFromID(tonumber(id))
		if thePlayer then	
			outputChatBox ( "#106FE7 #ffffffINFO #106FE7➺ #ffffff Nome do Jogador #106FE7" ..getPlayerName(thePlayer), player, 255, 255, 255, true)
		end
	end
end
addCommandHandler("id", getNickFromID)

function getPlayerFromID(id)
	for _, v in pairs(getElementsByType("player")) do
		if getElementData(v, "ID") == id then
			return v
		end
	end
end

 

mesmo dessa forma não deu :(

Link to comment
  • Other Languages Moderators
On 27/04/2023 at 21:08, Joabe said:
addEventHandler("onPlayerLogout", root, function(acc)
    removeElementData(source, "isStaff") -- Deslogou, não está mais logado na conta de Staff.
end

 

Faltou você fechar o parênteses depois do end.

Edited by Lord Henry
Link to comment
  • Other Languages Moderators

Client-side:

local normalDrawDistance = 50.0

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

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

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

addEventHandler("onClientRender", root, function ()
    local target = getPedTarget(localPlayer)
    for _, player in pairs(getElementsByType("player", root, true)) do
        if player ~= localPlayer then
            local cx, cy, cz = getCameraMatrix()
            local vx, vy, vz = getPedBonePosition(player, 8)
            local dist = getDistanceBetweenPoints3D(cx, cy, cz, vx, vy, vz)
            if dist < normalDrawDistance or player == target then
                if isLineOfSightClear(cx, cy, cz, vx, vy, vz, true, false, false, true, false, false, false, localPlayer) then
                    local x, y = getScreenFromWorldPosition(vx, vy, vz + 0.3)
                    if x and y then
                        local text = getElementData(player, "ID") or "N/A"
                        local w = dxGetTextWidth(text, 1, "default-bold", true)

                        local alpha = 255
                        if dist >= 10 then
                            local leftover = dist - 10
                            alpha = math.max(0, alpha - dist * (leftover/5))
                        end
                        if not getElementData(player, "isStaff") then -- Se o alvo NÃO É staff, então:
                            dxDrawBorderedText(text, x - w, y - 10, x + w, y, tocolor(255, 255, 255, alpha), alpha, 1, "default-bold", "center", "top", false, false, false, true)
                        end
                    end
                end
            end
        end
    end
end)

function dxDrawBorderedText(text, left, top, right, bottom, color, alpha, scale, font, alignX, alignY, clip, wordBreak,postGUI) 
    for oX = -1, 1 do -- Border size is 1 
        for oY = -1, 1 do -- Border size is 1 
            dxDrawText(text, left + oX, top + oY, right + oX, bottom + oY, tocolor(0, 0, 0, alpha), scale, font, alignX, alignY, clip, wordBreak,postGUI) 
        end 
    end 
    dxDrawText(text, left, top, right, bottom, color, scale, font, alignX, alignY, clip, wordBreak, postGUI) 
end

Server-side:

addEventHandler("onResourceStart", resourceRoot, function ()
    for _, player in pairs(getElementsByType("player")) do
        local acc = getPlayerAccount(player)
        if not isGuestAccount(acc) then
            local id = getAccountID(acc) -- Obtém o ID da conta do jogador.
            if id then -- Se existe o ID, então:
                setElementData(player, "ID", id)
            end
            if hasObjectPermissionTo(player, "command.mute", false) then -- Se o jogador é Staff, então:
                setElementData(player, "isStaff", true)
            else -- Caso o jogador tinha essa data antes, mas trocou de conta enquanto este resource estava desligado e agora não está como Staff:
                removeElementData(player, "isStaff")
            end
        else -- Caso o jogador tinha essa data antes, mas deslogou enquanto este resource estava desligado e agora não está logado:
            removeElementData(player, "ID")
        end
    end
end)

addEventHandler("onPlayerLogin", root, function (_, acc)
    local id = getAccountID(acc) -- Obtém o ID da conta do jogador.
    if id then -- Se existe o ID, então:
        setElementData(source, "ID", id)
    end
    if hasObjectPermissionTo(source, "command.mute", false) then -- Se o jogador é Staff, então:
        setElementData(source, "isStaff", true)
    end
end)

addEventHandler("onPlayerLogout", root, function(acc)
    removeElementData(source, "isStaff") -- Deslogou, não está mais logado na conta de Staff.
    removeElementData(source, "ID") -- Não está mais logado numa conta para ter um ID.
end)

addCommandHandler("id", function (player, _, id)
    if tonumber(id) then
        local thePlayer = getPlayerFromID(tonumber(id))
        if thePlayer then    
            outputChatBox ( "INFO #106FE7➺ #ffffff Nome do Jogador #106FE7" ..getPlayerName(thePlayer), player, 255, 255, 255, true)
        end
    end
end)

function getPlayerFromID(id)
    for _, v in pairs(getElementsByType("player")) do
        local data = getElementData(v, "ID")
        if data then -- Evita dar erro caso o jogador não tenha essa data.
            if data == id then
                return v
            end
        end
    end
end

 

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...