Jump to content

Delete Post.


Recommended Posts

Para que hacerlo desde 0 si en el mismo race lo puede editar, solo basta con buscar donde imprime el nametag y editarlo.

Cuando lo encuentres lo mas lógico es que el argumento que muestre en pantalla sea getPlayerName(theplayer), o algo similar, lo que tienes que hacer es editarlo asi, rank(theplayer).."\n"..getPlayerName(theplayer), suponiendo que tienes una función que busca el rank del player que por cierto se llamaría rank. Lo que indica el "\n" es simular un enter (espaciado vertical), para seguir escribiendo una linea mas abajo.

Link to comment
  
nametag = {} 
local nametags = {} 
local g_screenX,g_screenY = guiGetScreenSize() 
local bHideNametags = false 
  
local NAMETAG_SCALE = 0.40 --Overall adjustment of the nametag, use this to resize but constrain proportions 
local NAMETAG_ALPHA_DISTANCE = 100 --Distance to start fading out 
local NAMETAG_DISTANCE = 100 --Distance until we're gone 
local NAMETAG_ALPHA = 120 --The overall alpha level of the nametag 
--The following arent actual pixel measurements, they're just proportional constraints 
local NAMETAG_TEXT_BAR_SPACE = 2 
local NAMETAG_WIDTH = 40 
local NAMETAG_HEIGHT = 4 
local NAMETAG_TEXTSIZE = 0.3 
local NAMETAG_OUTLINE_THICKNESS = 1.2 
-- 
local NAMETAG_ALPHA_DIFF = NAMETAG_DISTANCE - NAMETAG_ALPHA_DISTANCE 
NAMETAG_SCALE = 1/NAMETAG_SCALE * 800 / g_screenY 
  
-- Ensure the name tag doesn't get too big 
local maxScaleCurve = { {0, 0}, {3, 3}, {13, 5} } 
-- Ensure the text doesn't get too small/unreadable 
local textScaleCurve = { {0, 0.8}, {0.8, 1.2}, {99, 99} } 
-- Make the text a bit brighter and fade more gradually 
local textAlphaCurve = { {0, 0}, {25, 100}, {120, 190}, {255, 190} } 
  
function nametag.create ( player ) 
    nametags[player] = true 
end 
  
function nametag.destroy ( player ) 
    nametags[player] = nil 
end 
  
---------------THE FOLLOWING IS THE MANAGEMENT OF NAMETAGS----------------- 
addEventHandler('onClientResourceStart', g_ResRoot, 
    function() 
        for i,player in ipairs(getElementsByType"player") do 
            if player ~= g_Me then 
                nametag.create ( player ) 
            end 
        end 
    end 
) 
  
addEventHandler ( "onClientPlayerJoin", g_Root, 
    function() 
        if source == g_Me then return end 
        setPlayerNametagShowing ( source, false ) 
        nametag.create ( source ) 
    end 
) 
  
addEventHandler ( "onClientPlayerQuit", g_Root, 
    function() 
        nametag.destroy ( source ) 
    end 
) 
  
  
addEvent ( "onClientScreenFadedOut", true ) 
addEventHandler ( "onClientScreenFadedOut", g_Root, 
    function() 
        bHideNametags = true 
    end 
) 
  
addEvent ( "onClientScreenFadedIn", true ) 
addEventHandler ( "onClientScreenFadedIn", g_Root, 
    function() 
        bHideNametags = false 
    end 
) 
  
  
  
addEventHandler ( "onClientRender", g_Root, 
    function() 
        -- Hideous quick fix -- 
        for i,player in ipairs(g_Players) do 
            if player ~= g_Me then 
                setPlayerNametagShowing ( player, false ) 
                if not nametags[player] then 
                    nametag.create ( player ) 
                end 
            end 
        end 
        if bHideNametags then 
            return 
        end 
        local x,y,z = getCameraMatrix() 
        for player in pairs(nametags) do 
            while true do 
                if not isPedInVehicle(player) or isPlayerDead(player) then break end 
                local vehicle = getPedOccupiedVehicle(player) 
                local px,py,pz = getElementPosition ( vehicle ) 
                local pdistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz ) 
                if pdistance <= NAMETAG_DISTANCE then 
                    --Get screenposition 
                    local sx,sy = getScreenFromWorldPosition ( px, py, pz+0.95, 0.06 ) 
                    if not sx or not sy then break end 
                    --Calculate our components 
                    local scale = 1/(NAMETAG_SCALE * (pdistance / NAMETAG_DISTANCE)) 
                    local alpha = ((pdistance - NAMETAG_ALPHA_DISTANCE) / NAMETAG_ALPHA_DIFF) 
                    alpha = (alpha < 0) and NAMETAG_ALPHA or NAMETAG_ALPHA-(alpha*NAMETAG_ALPHA) 
                    scale = math.evalCurve(maxScaleCurve,scale) 
                    local textscale = math.evalCurve(textScaleCurve,scale) 
                    local textalpha = math.evalCurve(textAlphaCurve,alpha) 
                    local outlineThickness = NAMETAG_OUTLINE_THICKNESS*(scale) 
                    --Draw our text 
                    local r,g,b = 255,255,255 
                    local team = getPlayerTeam(player) 
                    if team then 
                        r,g,b = getTeamColor(team) 
                    end 
                    local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2 
                    --dxDrawText ( getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, "default", "center", "bottom", false, false, false ) 
                    dxDrawText ( getPlayerName(player), sx + 1, sy - offset + 1, sx + 1, sy - offset + 1, tocolor(0,0,0,255), textscale*NAMETAG_TEXTSIZE, "bankgothic", "center", "bottom", false, false, false ) 
                    dxDrawColorText( getPlayerNametagText(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, 'bankgothic', 'center', 'bottom' ) 
                    --We draw three parts to make the healthbar.  First the outline/background 
                    local drawX = sx - NAMETAG_WIDTH*scale/2 
                    drawY = sy + offset 
                    local width,height =  NAMETAG_WIDTH*scale, NAMETAG_HEIGHT*scale 
                    dxDrawRectangle ( drawX, drawY, width, height, tocolor(0,0,0,alpha) ) 
                    --Next the inner background 
                    local health = getElementHealth(vehicle) 
                    health = math.max(health - 250, 0)/750 
                    local p = -510*(health^2) 
                    --local r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0) 
                    
          dxDrawRectangle (     drawX + outlineThickness, 
                                        drawY + outlineThickness, 
                                        width - outlineThickness*2, 
                                        height - outlineThickness*2, 
                                        tocolor(178,178,178,0.4*alpha) 
                                    ) 
                    --Finally, the actual health 
          
                    dxDrawRectangle (   drawX + outlineThickness, 
                                        drawY + outlineThickness, 
                                        health*(width - outlineThickness*2), 
                                        height - outlineThickness*2, 
                                        tocolor(r,g,b,alpha) 
                                    )           
                end 
                break 
            end 
        end 
    end 
) 
  
function dxDrawColorText(str, ax, ay, bx, by, color, scale, font, alignX, alignY) 
  if alignX then 
    if alignX == "center" then 
      local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) 
      ax = ax + (bx-ax)/2 - w/2 
    elseif alignX == "right" then 
      local w = dxGetTextWidth(str:gsub("#%x%x%x%x%x%x",""), scale, font) 
      ax = bx - w 
    end 
  end 
  
  if alignY then 
    if alignY == "center" then 
      local h = dxGetFontHeight(scale, font) 
      ay = ay + (by-ay)/2 - h/2 
    elseif alignY == "bottom" then 
      local h = dxGetFontHeight(scale, font) 
      ay = by - h 
    end 
  end 
  
  local pat = "(.-)#(%x%x%x%x%x%x)" 
  local s, e, cap, col = str:find(pat, 1) 
  local last = 1 
  while s do 
    if cap == "" and col then color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) end 
    if s ~= 1 or cap ~= "" then 
      local w = dxGetTextWidth(cap, scale, font) 
      dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) 
      ax = ax + w 
      color = tocolor(tonumber("0x"..col:sub(1, 2)), tonumber("0x"..col:sub(3, 4)), tonumber("0x"..col:sub(5, 6)), 255) 
    end 
    last = e + 1 
    s, e, cap, col = str:find(pat, last) 
  end 
  if last <= #str then 
    cap = str:sub(last) 
    local w = dxGetTextWidth(cap, scale, font) 
    dxDrawText(cap, ax, ay, ax + w, by, color, scale, font) 
  end 
end 
  

Este es el nametags del race.zip.

Link to comment

Juraría haber leído rank en alguna parte xD, bueno ahora tienes que crear un script para obtener el rango, pero como esta es una función solo de server, tendrás que hacer un script a parte, a mi se me ocurre usar onPlayerLogin y onResourceStart como eventos que desencadenan la función, dentro de esa funcion podrías usar setElementData para guardar el rango de los jugadores. Lo otro que podrías hacer en vez de setAccountData, seria hacer un trigger, pero al menos a mi gusto no seria lo mas efectivo.

Link to comment

En la comunidad en ingles me dieron algo asi, pero tiene un error, me muestra mi propio rango sobre el nick de todos los players, y asi mismo, si otro player tiene un rango, le muestra solo el suyo.& no funciona cuando lo estas "specteando"

Client.lua

  
  
addEventHandler ( "onClientRender", getRootElement ( ), 
function ( ) 
    local PlayerX, PlayerY, PlayerZ = getElementPosition ( getLocalPlayer ( ) ) 
    for i, v in ipairs ( getElementsByType("player") ) do 
    if v == getLocalPlayer() then else 
    local PedX, PedY, PedZ = getElementPosition ( v ) 
    local dist = getDistanceBetweenPoints3D ( PlayerX, PlayerY, PlayerZ, PedX, PedY, PedZ ) 
    local PX, PY, PZ = getElementPosition ( getLocalPlayer ( ) ) 
    local PeX, PeY, PeZ = getElementPosition(v) 
    local Rot = findRotation(PeX, PeY, PX, PY) 
    if dist <= 40 then 
            local scx, scy = getScreenFromWorldPosition ( PedX, PedY, PedZ + 1.2, -50, true ) 
            if isLineOfSightClear ( PlayerX, PlayerY, PlayerZ, PedX, PedY, PedZ, true, false, false, false ) and scx and scy then 
                    
            local alpha   = 200 
            local r       = 0 
            local g       = 150 
                    local b       = 200 
                    local scale   = 2 
                    local scale3d = true 
                    local font    = "default-bold" 
  
                    
                    local text = getElementData(localPlayer, "ACL") or "" 
  
                    
                    dxDrawText ( text, scx, scy, scx, scy, tocolor ( r, g, b, alpha ), scale, font, "center", "center",true,true,true,true) 
                
                    local rem, asd, asd2 = getTimerDetails(InterTimer) 
                    local p = rem / 500 
                    if not val1 or not val2 then 
                    return 
                    end 
                    local v1,v2,v3 = interpolateBetween(val1, 0,0, val2, 0,0, p, "Linear") 
                    local MyScale = ( ( v1 / 100 ) * 1.3 ) /( ( 1360 / x ) * ( 768 / y ) ) 
                    if dist <= 10 then 
                    if not getKeyBoundToFunction(ChallengePlayer) then 
                    bindKey("H", "down", ChallengePlayer, v) 
                    end 
                    local scx2, scy2 = getScreenFromWorldPosition ( PedX, PedY, PedZ + 1, -50, true ) 
                    local alpha2 = 255 
                    dxDrawText ( "#66ffaaPress #ffffffH #66ffaaTo Challenge", scx2, scy2, scx2, scy2, tocolor ( r, g, b, alpha2 ), MyScale * 1.5, font, "center", "center",false,false,false,true ) 
                    else 
                    if getKeyBoundToFunction(ChallengePlayer) then 
                    unbindKey("H","down",ChallengePlayer) 
                    end 
                    end     
                else alpha = 0 
                end 
  

Server.lua

  
  
addEventHandler( 'onPlayerLogin', root, 
    function ( ) 
        local account = getPlayerAccount( source ) 
        if account and not isGuestAccount( account ) then 
            local accountName = getAccountName( account ); 
            if isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Owner" ) ) then 
                setElementData(source, "ACL", "Owner") 
            elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "ClanMananger" ) ) then 
                setElementData(source, "ACL", "Clan-Mananger") 
            elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Admin" ) ) then 
                setElementData(source, "ACL", "Admin") 
            elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "SuperModerador" ) ) then 
                setElementData(source, "ACL", "SuperModerador") 
            elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Moderador" ) ) then 
                setElementData(source, "ACL", "Moderador")      
            elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Miembro" ) ) then 
                setElementData(source, "ACL", "Miembro")                
            elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "MiembroTrial" ) ) then 
                setElementData(source, "ACL", "MiembroTrial") 
            end 
       end 
    end 
) 
  
addEventHandler( 'onPlayerLogout', root, 
function ( ) 
local acl = getElementData(source, "ACL") 
    if acl then 
        removeElementData(source,"ACL") 
    end 
end) 
  

Link to comment
  • 3 weeks later...

Si usas el tag de race aslo de esta forma en la linea 119 creo

               
local rank = getElementData(player, (aca el dato de tus rangos qe no se cual es  ) ) 
             dxDrawText (rank.." \n"..getPlayerName(player), sx + 1, sy - offset + 1, sx + 1, sy - offset + 1, tocolor(0,0,0,255), textscale*NAMETAG_TEXTSIZE, "bankgothic", "center", "bottom", false, false, false ) 
                    dxDrawColorText( getPlayerNametagText(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, 'bankgothic', 'center', 'bottom' ) 

Link to comment

Miren esto Diganme que tal?

Pienso meterlo con el race.zip Agregandolo al meta.xml

Lo renombre de nategas.lua a nametags_c.lua

nametag = {} 
local nametags = {} 
local g_screenX,g_screenY = guiGetScreenSize() 
local bHideNametags = false 
  
local NAMETAG_SCALE = 0.3 --Overall adjustment of the nametag, use this to resize but constrain proportions 
local NAMETAG_ALPHA_DISTANCE = 50 --Distance to start fading out 
local NAMETAG_DISTANCE = 120 --Distance until we're gone 
local NAMETAG_ALPHA = 120 --The overall alpha level of the nametag 
--The following arent actual pixel measurements, they're just proportional constraints 
local NAMETAG_TEXT_BAR_SPACE = 2 
local NAMETAG_WIDTH = 50 
local NAMETAG_HEIGHT = 5 
local NAMETAG_TEXTSIZE = 0.3 
local NAMETAG_OUTLINE_THICKNESS = 1.2 
-- 
local NAMETAG_ALPHA_DIFF = NAMETAG_DISTANCE - NAMETAG_ALPHA_DISTANCE 
NAMETAG_SCALE = 1/NAMETAG_SCALE * 800 / g_screenY  
  
-- Ensure the name tag doesn't get too big 
local maxScaleCurve = { {0, 0}, {3, 3}, {13, 5} } 
-- Ensure the text doesn't get too small/unreadable 
local textScaleCurve = { {0, 0.8}, {0.8, 1.2}, {99, 99} } 
-- Make the text a bit brighter and fade more gradually 
local textAlphaCurve = { {0, 0}, {25, 100}, {120, 190}, {255, 190} } 
  
function nametag.create ( player ) 
    nametags[player] = true 
end 
  
function nametag.destroy ( player ) 
    nametags[player] = nil 
end 
  
  
function renderNametagsForPlayers() 
        -- Hideous quick fix -- 
        for i,player in ipairs(g_Players) do 
            if player ~= g_Me then 
                setPlayerNametagShowing ( player, false ) 
                if not nametags[player] then 
                    nametag.create ( player ) 
                end 
            end 
        end 
        if bHideNametags then 
            return 
        end 
        local x,y,z = getCameraMatrix() 
        if getElementData(localPlayer,"loginState") then return end 
        for player in pairs(nametags) do  
            while true do 
                if not isPedInVehicle(player) or isPlayerDead(player) then break end 
                local vehicle = getPedOccupiedVehicle(player) 
                local px,py,pz = getElementPosition ( vehicle ) 
                local pdistance = getDistanceBetweenPoints3D ( x,y,z,px,py,pz ) 
                if pdistance <= NAMETAG_DISTANCE then 
                    --Get screenposition 
                    local sx,sy = getScreenFromWorldPosition ( px, py, pz+0.95, 0.06 ) 
                    if not sx or not sy then break end 
                    --Calculate our components 
                    local scale = 1/(NAMETAG_SCALE * (pdistance / NAMETAG_DISTANCE)) 
                    local alpha = ((pdistance - NAMETAG_ALPHA_DISTANCE) / NAMETAG_ALPHA_DIFF) 
                    alpha = (alpha < 0) and NAMETAG_ALPHA or NAMETAG_ALPHA-(alpha*NAMETAG_ALPHA) 
                    scale = math.evalCurve(maxScaleCurve,scale) 
                    local textscale = math.evalCurve(textScaleCurve,scale) 
                    local textalpha = math.evalCurve(textAlphaCurve,alpha) 
                    local outlineThickness = NAMETAG_OUTLINE_THICKNESS*(scale) 
                    --Draw our text 
                    local r,g,b = 255,255,255 
                    local team = getPlayerTeam(player) 
                    if team then 
                        r,g,b = getTeamColor(team) 
                    end 
                    local offset = (scale) * NAMETAG_TEXT_BAR_SPACE/2 
                    local rank = getElementData(localPlayer, "ACL") or "" 
                    dxDrawText (rank.." \n"..getPlayerName(player), sx, sy - offset, sx, sy - offset, tocolor(r,g,b,textalpha), textscale*NAMETAG_TEXTSIZE, raceInterface.font, "center", "bottom", false, false, false, true ) 
                    --We draw three parts to make the healthbar.  First the outline/background 
                    local drawX = sx - NAMETAG_WIDTH*scale/2 
                    drawY = sy + offset 
                    local width,height =  NAMETAG_WIDTH*scale, NAMETAG_HEIGHT*scale 
                    --dxDrawRectangle ( drawX, drawY, width, height, tocolor(0,0,0,alpha) ) 
                    --Next the inner background  
                    local health = getElementHealth(vehicle) 
                    health = math.max(health - 250, 0)/750 
                    local p = -510*(health^2) 
                    local r,g = math.max(math.min(p + 255*health + 255, 255), 0), math.max(math.min(p + 765*health, 255), 0) 
                    --[[dxDrawRectangle (   drawX + outlineThickness,  
                                        drawY + outlineThickness,  
                                        width - outlineThickness*2,  
                                        height - outlineThickness*2,  
                                        tocolor(r,g,0,0.4*alpha)  
                                    ) 
                    --Finally, the actual health 
                    --dxDrawRectangle (     drawX + outlineThickness,  
                                        drawY + outlineThickness,  
                                        health*(width - outlineThickness*2),  
                                        height - outlineThickness*2,  
                                        tocolor(r,g,0,alpha)  
                                    )   ]]       
                end 
                break 
            end 
        end 
end 
  
  
---------------THE FOLLOWING IS THE MANAGEMENT OF NAMETAGS----------------- 
addEventHandler('onClientResourceStart', g_ResRoot, 
    function() 
        for i,player in ipairs(getElementsByType"player") do 
            if player ~= g_Me then 
                nametag.create ( player ) 
            end 
        end 
    end 
) 
  
addEventHandler ( "onClientPlayerJoin", g_Root, 
    function() 
        if source == g_Me then return end 
        setPlayerNametagShowing ( source, false ) 
        nametag.create ( source ) 
    end 
) 
  
addEventHandler ( "onClientPlayerQuit", g_Root, 
    function() 
        nametag.destroy ( source ) 
    end 
) 
  
  
addEvent ( "onClientScreenFadedOut", true ) 
addEventHandler ( "onClientScreenFadedOut", g_Root, 
    function() 
        bHideNametags = true 
    end 
) 
  
addEvent ( "onClientScreenFadedIn", true ) 
addEventHandler ( "onClientScreenFadedIn", g_Root, 
    function() 
        bHideNametags = false 
    end 
) 
  
  

Este es un archivo que use como base para obeter el rango nametags_s.lua

  
addEventHandler( 'onPlayerLogin', root, 
    function ( ) 
        local account = getPlayerAccount( source ) 
        if account and not isGuestAccount( account ) then 
            local accountName = getAccountName( account ); 
            if isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Owner" ) ) then 
                setElementData(source, "ACL", "Owner") 
            elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "ClanMananger" ) ) then 
                setElementData(source, "ACL", "Clan-Mananger") 
            elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Admin" ) ) then 
                setElementData(source, "ACL", "Admin") 
            elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "SuperModerador" ) ) then 
                setElementData(source, "ACL", "SuperModerador") 
            elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Moderador" ) ) then 
                setElementData(source, "ACL", "Moderador")      
            elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "Miembro" ) ) then 
                setElementData(source, "ACL", "Miembro")                
            elseif isObjectInACLGroup ( "user." .. accountName, aclGetGroup ( "MiembroTrial" ) ) then 
                setElementData(source, "ACL", "MiembroTrial") 
            end 
       end 
    end 
) 
  
addEventHandler( 'onPlayerLogout', root, 
function ( ) 
local acl = getElementData(source, "ACL") 
    if acl then 
        removeElementData(source,"ACL") 
    end 
end) 
  

Link to comment
@alex

Te faltó definir textscale, textalpha,r,g,b,offset,sy,sx xD

no se me olvido solo puse esa parte del script

@XeroxMTA

cambia esto

  local rank = getElementData(localPlayer, "ACL") or "" 

por esto

  local rank = getElementData(player, "ACL") or "" 

Link to comment

Oye hay un error, Aparece y todo, pero mira...

e5kbhs.jpg

nvb7de.jpg

El script lo que esta haciendo es mostrarme mi rango arriga de todos los players, exeptuando los del acl "everyone" por que no estan en el server-side, pero, aque se debe igualmente a los demas admins y mods que tengo les muestra lo mismo, su propio rango arriba de todos. que hago?

Link to comment

yo utilizo el mismo nametag y tube el mismo problema y la forma de como lo ise fue asi

y me funciono bien

local lvl = getElementData(player, "level") 

en este caso lo ise con el level system tu remplazalo por tu rangos

deberia ser asi

local rank = getElementData(player, "ACL") or "" 

Link to comment
  • Recently Browsing   0 members

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