bencskrisz Posted December 19, 2019 Share Posted December 19, 2019 local rootElement = getRootElement() local NPC = createPed(124,0,0,5) local screenWidth, screenHeight = guiGetScreenSize() function NPCnametag() local sx,sy = getScreenFromWorldPosition (getElementPosition(NPC)) if sx then dxDrawText("Bob",sx,sy,screenWidth, screenHeight,tocolor ( 255, 255, 0, 255 ), 2,"sans") end end function HandleTheRendering() addEventHandler("onClientRender",rootElement, NPCnametag) end addEventHandler("onClientResourceStart",rootElement, HandleTheRendering) Link to comment
Motar2k Posted December 19, 2019 Share Posted December 19, 2019 Try this local NPC = createPed(124,0,0,5) local screenWidth, screenHeight = guiGetScreenSize() function NPCnametag() local x,y,z = getPedBonePosition(NPC,6) local sx,sy = getScreenFromWorldPosition(x,y,z) if sx then dxDrawText("Bob",sx,sy,sx,sy,tocolor ( 255, 255, 0, 255 ), 2,"sans") end end function HandleTheRendering() addEventHandler("onClientRender",getRootElement(), NPCnametag) end addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering) Link to comment
bencskrisz Posted December 19, 2019 Author Share Posted December 19, 2019 Thank you so much! Now it appears but.. once I get close to it and then leave from the ped, the nametag wont disappear, its gonna be visible no matter how far im going away from the ped.. can you resolve this? I guess we should need a kinda maxrange or idk.... Link to comment
Motar2k Posted December 19, 2019 Share Posted December 19, 2019 local NPC = createPed(124,0,0,5) local screenWidth, screenHeight = guiGetScreenSize() local range = 15 function NPCnametag() local x,y,z = getPedBonePosition(NPC,6) local px,py,pz = getElementPosition(localPlayer) if getDistanceBetweenPoints3D(x,y,z,px,py,pz) <= range then local sx,sy = getScreenFromWorldPosition(x,y,z) if sx then dxDrawText("Bob",sx,sy,sx,sy,tocolor ( 255, 255, 0, 255 ), 2,"sans") end end end function HandleTheRendering() addEventHandler("onClientRender",getRootElement(), NPCnametag) end addEventHandler("onClientResourceStart",resourceRoot, HandleTheRendering) Link to comment
bencskrisz Posted December 19, 2019 Author Share Posted December 19, 2019 Thank you so much!! It still needs a lot of work to make it perfect but I can do that now. God bless you brother! Link to comment
bencskrisz Posted December 19, 2019 Author Share Posted December 19, 2019 One more question: why does the created ped spawns a bit far from the scripted coordinates? There wasn't any problem with the positioning with the first script what u sent me and now the nametag works perfectly but it does not spawn accurately according to the written coordinates. It spawns a few meters away. What value affected it?? Its strange Nothing nothing, I solved it! Link to comment
Motar2k Posted December 19, 2019 Share Posted December 19, 2019 I imagine it was because the ped was falling Link to comment
bencskrisz Posted December 20, 2019 Author Share Posted December 20, 2019 A bit off-topic (if you're still here) Can you check this for me out? -> It is the script what you solved for me, I just tried to add rotation but it does not rotate.. Can you check this too? I have no idea what is the wrong.. 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