Argom Posted November 30, 2020 Share Posted November 30, 2020 Hi, I found a resource on how to put a text in a ped, but I can't find a way to move the text, so that it is not on the waist but on the head. The code is the following: ]]-- --[[CONFIGURACIONES DEL PED]]-- local ped_id = 285 -- La ID del skin [http://adf.ly/hMF9l] local px, py, pz = 2492.12598, -1669.97876, 13.33595 -- 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
Lergen Posted November 30, 2020 Share Posted November 30, 2020 (edited) The text is drawn by finding where the ped is on your screen: local pedX,pedY,pedZ = getElementPosition(NPC) local sx,sy = getScreenFromWorldPosition (pedX,pedY,pedZ) local cameraX,cameraY,cameraZ = getCameraMatrix() Then drawing the text on that spot: 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) So if you want to modify the position of the text, you can just add or subtract from those positions. For example: dxDrawText(texto,sx - 80,sy - 80,screenWidth, screenHeight,tocolor ( R, G, B, Text_Opacidad ), size,fuente) PS there's an option to add code when you're making a post instead of just pasting the raw-text (it's easier to make sense of). Edited November 30, 2020 by Lergen Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now