3B00DG4MER Posted March 19, 2014 Share Posted March 19, 2014 Hello,I want today to Create a 3D Text Appears above the head of a ped i have seen that in SUAR server Thanks. Link to comment
WhoAmI Posted March 19, 2014 Share Posted March 19, 2014 local pedX, pedY, pedZ = 0, 0, 0 local maxDistance = 12 -- the distance showing 3dtext addEventHandler ( "onClientRender", root, function ( ) local pX, pY, pZ = getElementPosition ( localPlayer ) local distance = getDistanceBetweenPoints3D ( pX, pY, pZ, pedX, pedY, pedZ ) if ( distance <= maxDistance ) then local x, y = getScreenFromWorldPosition ( pedX, pedY, pedZ ) if ( x and y ) then dxDrawText( "text", x, y, _, _, tocolor( 255, 255, 255, 2555 ), 2, "default", "center", "center" ) end end end ) It should work, but I'm not sure, couse I was writing it kinda fast. Link to comment
3B00DG4MER Posted March 19, 2014 Author Share Posted March 19, 2014 local pedX, pedY, pedZ = 0, 0, 0 local maxDistance = 12 -- the distance showing 3dtext addEventHandler ( "onClientRender", root, function ( ) local pX, pY, pZ = getElementPosition ( localPlayer ) local distance = getDistanceBetweenPoints3D ( pX, pY, pZ, pedX, pedY, pedZ ) if ( distance <= maxDistance ) then local x, y = getScreenFromWorldPosition ( pedX, pedY, pedZ ) if ( x and y ) then dxDrawText( "text", x, y, _, _, tocolor( 255, 255, 255, 2555 ), 2, "default", "center", "center" ) end end end ) It should work, but I'm not sure, couse I was writing it kinda fast. Don't Work I tried to Attach the Text to a Ped local ped = createPed (21, 2000.6636962891, 1538.318359375, 13.5859375) addEventHandler ( "onClientRender", root, function ( ) local pX, pY, pZ = getElementPosition ( ped ) local distance = getDistanceBetweenPoints3D ( pX, pY, pZ, pedX, pedY, pedZ ) if ( distance <= maxDistance ) then local x, y = getScreenFromWorldPosition ( pX, pY, pZ ) if ( x and y ) then dxDrawText( "Criminal", x, y, _, _, tocolor( 255, 255, 255, 2555 ), 2, "default", "center", "center" ) end end end ) But the same fix it with Ped PLease Link to comment
WhoAmI Posted March 19, 2014 Share Posted March 19, 2014 local ped = createPed (21, 2000.6636962891, 1538.318359375, 13.5859375) addEventHandler ( "onClientRender", root, function ( ) local pX, pY, pZ = getElementPosition ( player ) local pedX, pedY, pedZ = getElementPosition ( ped ) local distance = getDistanceBetweenPoints3D ( pX, pY, pZ, pedX, pedY, pedZ ) if ( distance <= 12 ) then local x, y = getScreenFromWorldPosition ( pedX, pedY, pedZ ) if ( x and y ) then dxDrawText( "Criminal", x, y, _, _, tocolor( 255, 255, 255, 2555 ), 2, "default", "center", "center" ) end end end ) Link to comment
3B00DG4MER Posted March 19, 2014 Author Share Posted March 19, 2014 local ped = createPed (21, 2000.6636962891, 1538.318359375, 13.5859375) addEventHandler ( "onClientRender", root, function ( ) local pX, pY, pZ = getElementPosition ( player ) local pedX, pedY, pedZ = getElementPosition ( ped ) local distance = getDistanceBetweenPoints3D ( pX, pY, pZ, pedX, pedY, pedZ ) if ( distance <= 12 ) then local x, y = getScreenFromWorldPosition ( pedX, pedY, pedZ ) if ( x and y ) then dxDrawText( "Criminal", x, y, _, _, tocolor( 255, 255, 255, 2555 ), 2, "default", "center", "center" ) end end end ) Problem with line "if (distance <= 12) then" Attempt to compare Boolean with number i think you must convert distance to number tonumber(distance) afaik Link to comment
WhoAmI Posted March 19, 2014 Share Posted March 19, 2014 change local pX, pY, pZ = getElementPosition ( player ) to local pX, pY, pZ = getElementPosition ( localPlayer ) Link to comment
Moderators IIYAMA Posted March 19, 2014 Moderators Share Posted March 19, 2014 It is maybe also handy if you check if the ped still does exist. if isElement(ped) then or you may will have trouble when the ped somehow is deleted.(by another script) Link to comment
3B00DG4MER Posted March 19, 2014 Author Share Posted March 19, 2014 change local pX, pY, pZ = getElementPosition ( player ) to local pX, pY, pZ = getElementPosition ( localPlayer ) Thankkkks Can you give a code which change Font (Not GTA sa Fonts,Import One) Link to comment
WhoAmI Posted March 19, 2014 Share Posted March 19, 2014 Use [url=https://wiki.multitheftauto.com/wiki/DxCreateFont]https://wiki.multitheftauto.com/wiki/DxCreateFont[/url] Link to comment
3B00DG4MER Posted March 19, 2014 Author Share Posted March 19, 2014 Thank you for all your work 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