Jump to content

Ped con DxDrawText


iSmokee

Recommended Posts

Afortunadamente 'getPedBonePosition' trae ejemplos perfectos:

addEventHandler( "onClientRender",root, 
   function( ) 
      local px, py, pz, tx, ty, tz, dist 
      px, py, pz = getCameraMatrix( ) 
      for _, v in ipairs( getElementsByType 'player' ) do 
         tx, ty, tz = getElementPosition( v ) 
         dist = math.sqrt( ( px - tx ) ^ 2 + ( py - ty ) ^ 2 + ( pz - tz ) ^ 2 ) 
         if dist < 30.0 then 
            if isLineOfSightClear( px, py, pz, tx, ty, tz, true, false, false, true, false, false, false,localPlayer ) then 
               local sx, sy, sz = getPedBonePosition( v, 5 ) 
               local x,y = getScreenFromWorldPosition( sx, sy, sz + 0.3 ) 
               if x then -- getScreenFromWorldPosition returns false if the point isn't on screen 
                dxDrawText( getPlayerName( v ), x, y, x, y, tocolor(150, 50, 0), 0.85 + ( 15 - dist ) * 0.02, "bankgothic" ) 
               end 
            end 
         end 
      end 
   end 
) 

Link to comment

este es un video de como hacerlo.

el codigo fuente del script:

ocal ped_id = 0                     -- La ID del skin [http://adf.ly/hMF9l] 
local px, py, pz = 0, 0, 0              -- La posicion y rotacion [http://adf.ly/hMFFZ] 
local ped_rotation = 0                  -- La posicion y rotacion [http://adf.ly/hMFFZ] 
--[[CONFIGURACIONES DEL TEXTO -> PED]]-- 
local texto = "Texto del ped"           -- El texto que tendra el ped 
local texto_alcanze =  25               -- Distancia de donde se vera el texto 
local R, G, B = 255, 255, 255           -- Color del texto [http://adf.ly/hMFT8] esta en blanco. 
local Text_Opacidad = 255               -- (DEFAULT: 255    [min: 0 - max: 255]) Es la opacidad osea lo trasparente 
local fuente = "sans"                   -- El tipo de lectra esta: "default", ["default-bold", "clear", "arial", "sans", "pricedown", "bankgothic", "diploma", "beckett"] 
local size = 2                          -- El tamaño del texto [DEFAULT: 2] 
---------------------------------------------------------------------------- 
---------------------NO EDITAR DE AQUI PARA ABAJO--------------------------- 
---------------------------------------------------------------------------- 
local rootElement = getRootElement()  
local NPC = createPed(ped_id, px, py, pz, ped_rotation) 
local screenWidth, screenHeight = guiGetScreenSize() 
  
function NPCnametag() 
    local pedX,pedY,pedZ = getElementPosition(NPC) 
    local sx,sy = getScreenFromWorldPosition (pedX,pedY,pedZ) 
    local cameraX,cameraY,cameraZ = getCameraMatrix() 
    if sx then  
        if getDistanceBetweenPoints3D(cameraX,cameraY,cameraZ,pedX,pedY,pedZ) <= texto_alcanze then  
            dxDrawText(texto,sx,sy,screenWidth, screenHeight,tocolor ( R, G, B, Text_Opacidad ), size,fuente) 
        end 
    end 
end 
  
function HandleTheRendering() 
    addEventHandler("onClientRender",rootElement, NPCnametag) 
end 
addEventHandler("onClientResourceStart",rootElement, HandleTheRendering) 
  

Link to comment
  • Recently Browsing   0 members

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