-misterX- Posted January 16, 2013 Share Posted January 16, 2013 what's wrong? hte console doesn't reort anything! local marker = createMarker( 1552.4996337891, -1677.3264160156, 15.1953125, "Cylinder", 1.5, 0, 0, 255, 150) local marker1 = createMarker( -1604.5458984375, 712.25848388672, 12.8671875, "Cylinder", 1.5, 0, 0, 255, 150) local marker2 = createMarker( 2340.9245605469, 2456.0463867188, 13.96875, "Cylinder", 1.5, 0, 0, 255, 150) dxDrawText("police job", 1552.4996337891, -1677.3264160156, 15.1953125, tocolor(0, 0, 0, 200), 2-(distance/20), "arial", "center", "center") dxDrawText("police job", -1604.5458984375, 712.25848388672, 12.8671875, tocolor(0, 0, 0, 200), 2-(distance/20), "arial", "center", "center") dxDrawText("police job", 2340.9245605469, 2456.0463867188, 13.96875, tocolor(0, 0, 0, 200), 2-(distance/20), "arial", "center", "center") Link to comment
novo Posted January 16, 2013 Share Posted January 16, 2013 hte console /debugscript 3 Link to comment
-misterX- Posted January 16, 2013 Author Share Posted January 16, 2013 DOESNT REPORT ANYTHING! Link to comment
csiguusz Posted January 16, 2013 Share Posted January 16, 2013 dxDrawText just read the wiki about it. You can't use the same coordinates for this, what you used to create a marker. Link to comment
-misterX- Posted January 16, 2013 Author Share Posted January 16, 2013 still not working local marker = createMarker( 1552.4996337891, -1677.3264160156, 15.1953125, "Cylinder", 1.5, 0, 0, 255, 150) local marker1 = createMarker( -1604.5458984375, 712.25848388672, 12.8671875, "Cylinder", 1.5, 0, 0, 255, 150) local marker2 = createMarker( 2340.9245605469, 2456.0463867188, 13.96875, "Cylinder", 1.5, 0, 0, 255, 150) local x1,y1,z1 = getElementPosition ( marker ) local x2,y2,z2 = getElementPosition ( marker1 ) local x3,y3,z3 = getElementPosition ( maker2 ) dxDrawText("police job", x1 + 2, y1 + 2, z1 + 2, tocolor(0, 0, 0, 200), 2-(distance/20), "arial", "center", "center") dxDrawText("police job", x2 + 2, y2 + 2, z2 + 2, tocolor(0, 0, 0, 200), 2-(distance/20), "arial", "center", "center") dxDrawText("police job", x3 + 2, y3 + 2, z3 + 2, tocolor(0, 0, 0, 200), 2-(distance/20), "arial", "center", "center") Link to comment
novo Posted January 16, 2013 Share Posted January 16, 2013 local X,Y,Z = 0, 0, 0 -- MARKER'S X,Y,Z -- Marker local XX,YY,ZZ = 2486.4111328125, -1646.0546875, 13.5 local WorldKor1, WorldKor2 = getScreenFromWorldPosition(X,Y,Z) dxDrawText("police job", WorldKor1, WorldKor2 , WorldKor1, WorldKor2, tocolor(0, 0, 0, 200), 2-(distance/20), "arial", "center", "center") Link to comment
-misterX- Posted January 16, 2013 Author Share Posted January 16, 2013 now debug report attempt ot perform arithmetical on global distance Link to comment
novo Posted January 16, 2013 Share Posted January 16, 2013 Did you edit values for your Marker's X, Y, Z? You can use getElementPosition() like below. local X,Y,Z = getElementPosition(marker) --getElementPosition() will return X, Y, Z of the element called "marker" Link to comment
-misterX- Posted January 16, 2013 Author Share Posted January 16, 2013 why not work? local marker = createMarker( 1552.4996337891, -1677.3264160156, 15.1953125, "Cylinder", 1.5, 0, 0, 255, 150) local marker1 = createMarker( -1604.5458984375, 712.25848388672, 12.8671875, "Cylinder", 1.5, 0, 0, 255, 150) local marker2 = createMarker( 2340.9245605469, 2456.0463867188, 13.96875, "Cylinder", 1.5, 0, 0, 255, 150) local x1,y1,z1 = getElementPosition ( marker ) local x2,y2,z2 = getElementPosition ( marker1 ) local x3,y3,z3 = getElementPosition ( marker2 ) dxDrawText("police job", x1 + 2, y1 + 2, z1 + 2, tocolor ( 0, 0, 0, 255 ) ) dxDrawText("police job", x2 + 2, y2 + 2, z2 + 2, tocolor ( 0, 0, 0, 255 ) ) dxDrawText("police job", x3 + 2, y3 + 2, z3 + 2, tocolor ( 0, 0, 0, 255 ) ) Link to comment
novo Posted January 16, 2013 Share Posted January 16, 2013 I told you to apply this code.. local X,Y,Z = 0, 0, 0 -- MARKER'S X,Y,Z -- Marker local XX,YY,ZZ = 2486.4111328125, -1646.0546875, 13.5 local WorldKor1, WorldKor2 = getScreenFromWorldPosition(X,Y,Z) dxDrawText("police job", WorldKor1, WorldKor2 , WorldKor1, WorldKor2, tocolor(0, 0, 0, 200), 2-(distance/20), "arial", "center", "center") Link to comment
-misterX- Posted January 16, 2013 Author Share Posted January 16, 2013 no give errors in debug but nothing local x1,y1,z1 = getElementPosition ( marker ) local x2,y2,z2 = getElementPosition ( marker1 ) local x3,y3,z3 = getElementPosition ( marker2 ) local screenWidth, screenHeight = guiGetScreenSize ( ) dxDrawText("police job", x1 + 2, y1 + 2,screenWidth,screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "pricedown" ) dxDrawText("police job", x2 + 2, y2 + 2,screenWidth,screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "pricedown" ) dxDrawText("police job", x3 + 2, y3 + 2,screenWidth,screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "pricedown" ) Link to comment
csiguusz Posted January 16, 2013 Share Posted January 16, 2013 I think novo meant something like this: local x1,y1,z1 = getElementPosition ( marker ) local x2,y2,z2 = getElementPosition ( marker1 ) local x3,y3,z3 = getElementPosition ( marker2 ) local screenWidth, screenHeight = guiGetScreenSize ( ) local x1_, y1_, dis = getScreenFromWorldPosition( x1, y1, z1 ) local x2_, y2_, dis = getScreenFromWorldPosition( x2, y2, z2 ) local x3_, y3_, dis = getScreenFromWorldPosition( x3, y3, z3 ) dxDrawText("police job", x1_ + 2, y1_ + 2,screenWidth,screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "pricedown" ) dxDrawText("police job", x2_ + 2, y2_ + 2,screenWidth,screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "pricedown" ) dxDrawText("police job", x3_ + 2, y3_ + 2,screenWidth,screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "pricedown" ) Link to comment
Castillo Posted January 16, 2013 Share Posted January 16, 2013 You need to use onClientRender to draw it. addEventHandler ( "onClientRender", root, function ( ) local x1,y1,z1 = getElementPosition ( marker ) local x2,y2,z2 = getElementPosition ( marker1 ) local x3,y3,z3 = getElementPosition ( marker2 ) local screenWidth, screenHeight = guiGetScreenSize ( ) local x1_, y1_, dis = getScreenFromWorldPosition( x1, y1, z1 ) local x2_, y2_, dis = getScreenFromWorldPosition( x2, y2, z2 ) local x3_, y3_, dis = getScreenFromWorldPosition( x3, y3, z3 ) dxDrawText("police job", x1_ + 2, y1_ + 2,screenWidth,screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "pricedown" ) dxDrawText("police job", x2_ + 2, y2_ + 2,screenWidth,screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "pricedown" ) dxDrawText("police job", x3_ + 2, y3_ + 2,screenWidth,screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "pricedown" ) end ) Link to comment
-misterX- Posted January 16, 2013 Author Share Posted January 16, 2013 doesn't even spawn the markers ( Link to comment
-misterX- Posted January 17, 2013 Author Share Posted January 17, 2013 sorry my bad, it works fine! sorry, two more questions, first is it possible to put the text over the marker? cause it uder it and on one of the sides second i cans see all the thext from evreywhere, can i render them when i'm closer? Link to comment
-misterX- Posted January 19, 2013 Author Share Posted January 19, 2013 local marker = createMarker( 1552.4996337891, -1677.3264160156, 15.1953125, "Cylinder", 1.5, 0, 0, 255, 150) local marker1 = createMarker( -1604.5458984375, 712.25848388672, 12.8671875, "Cylinder", 1.5, 0, 0, 255, 150) local marker2 = createMarker( 2340.9245605469, 2456.0463867188, 13.96875, "Cylinder", 1.5, 0, 0, 255, 150) addEventHandler ( "onClientRender", root, function ( ) local x1,y1,z1 = getElementPosition ( marker ) local x2,y2,z2 = getElementPosition ( marker1 ) local x3,y3,z3 = getElementPosition ( marker2 ) local screenWidth, screenHeight = guiGetScreenSize ( ) local x1_, y1_, dis = getScreenFromWorldPosition( x1, y1, z1 ) local x2_, y2_, dis = getScreenFromWorldPosition( x2, y2, z2 ) local x3_, y3_, dis = getScreenFromWorldPosition( x3, y3, z3 ) dxDrawText("police job", x1_, y1_,screenWidth,screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "arial" ) dxDrawText("police job", x2_, y2_,screenWidth,screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "arial" ) dxDrawText("police job", x3_, y3_,screenWidth,screenHeight, tocolor ( 0, 0, 0, 255 ), 1, "arial" ) end ) Link to comment
-misterX- Posted January 19, 2013 Author Share Posted January 19, 2013 so how can i fix it? Link to comment
-misterX- Posted January 20, 2013 Author Share Posted January 20, 2013 i can see hte text from everywhere, is it possible to render the text when i'm close to them? Link to comment
Blaawee Posted January 20, 2013 Share Posted January 20, 2013 --\\\\\\\\\\\\\\\\\\\\\\\\\\ --// Setting local g_screenX, g_screenY = guiGetScreenSize(); local gScale = 0.3; local gAlphaDistance = 25; local gMaxDistance = 50; -- Max Distance local gTextAlpha = 120; local gTextSize = 1; local gAlphaDiff = gMaxDistance - gAlphaDistance; gScale = 1 / gScale * 800 / g_screenY; local gMaxScaleCurve = { { 0, 0 }, { 3, 3 }, { 13, 5 } }; local gTextScaleCurve = { { 0, 0.8 }, { 0.8, 1.2 }, { 99, 99 } }; local gTextAlphaCurve = { { 0, 0 }, { 25, 100 }, { 120, 190 }, { 255, 190 } }; local marker = createMarker( 1552.4996337891, -1677.3264160156, 15.1953125, 'Cylinder', 1.5, 0, 0, 255, 150 ); local marker1 = createMarker( -1604.5458984375, 712.25848388672, 12.8671875, 'Cylinder', 1.5, 0, 0, 255, 150 ); local marker2 = createMarker( 2340.9245605469, 2456.0463867188, 13.96875, 'Cylinder', 1.5, 0, 0, 255, 150 ); addEventHandler ( 'onClientRender', root, function ( ) -- local x, y, z = getCameraMatrix(); local x1, y1, z1 = getElementPosition ( marker ); local x2, y2, z2 = getElementPosition ( marker1 ); local x3, y3, z3 = getElementPosition ( marker2 ); local distance_1 = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ); local distance_2 = getDistanceBetweenPoints3D( x, y, z, x2, y2, z2 ); local distance_3 = getDistanceBetweenPoints3D( x, y, z, x3, y3, z3 ); -- -- Marker #1 if distance_1 <= gMaxDistance then local x1_, y1_ = getScreenFromWorldPosition( x1, y1, z1 + 0.95, 0.06 ); if x1_ and y1_ then -- local scale = 1 / ( gScale * ( distance_1 / gMaxDistance ) ); local alpha = ( ( distance_1 - gAlphaDistance ) / gAlphaDiff ); alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); scale = math.evalCurve( gMaxScaleCurve, scale ); local textscale = math.evalCurve( gTextScaleCurve, scale ); local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); -- dxDrawText( "police job", x1_, y1_, x1_, y1_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); end -- Marker #2 elseif distance_2 <= gMaxDistance then local x2_, y2_ = getScreenFromWorldPosition( x2, y2, z2 + 0.95, 0.06 ); if x2_ and y2_ then -- local scale = 1 / ( gScale * ( distance_2 / gMaxDistance ) ); local alpha = ( ( distance_2 - gAlphaDistance ) / gAlphaDiff ); alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); scale = math.evalCurve( gMaxScaleCurve, scale ); local textscale = math.evalCurve( gTextScaleCurve, scale ); local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); -- dxDrawText( "police job", x2_, y2_, x2_, y2_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); end -- Marker #3 elseif distance_3 <= gMaxDistance then local x3_, y3_ = getScreenFromWorldPosition( x3, y3, z3 + 0.95, 0.06 ); if x3_ and y3_ then -- local scale = 1 / ( gScale * ( distance_3 / gMaxDistance ) ); local alpha = ( ( distance_3 - gAlphaDistance ) / gAlphaDiff ); alpha = ( alpha < 0 ) and gTextAlpha or gTextAlpha - ( alpha * gTextAlpha ); scale = math.evalCurve( gMaxScaleCurve, scale ); local textscale = math.evalCurve( gTextScaleCurve, scale ); local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); -- dxDrawText( "police job", x3_, y3_, x3_, y3_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); end end end ); -- ////////////////////////////////// -- // MATH FUNCTIONS // -- ////////////////////////////////// function math.evalCurve( curve, input ) if input < curve[ 1 ][ 1 ] then return curve[ 1 ][ 2 ]; end for idx = 2, #curve do if input < curve[ idx ][ 1 ] then local x1 = curve[ idx - 1 ][ 1 ]; local y1 = curve[ idx - 1 ][ 2 ]; local x2 = curve[ idx ][ 1 ]; local y2 = curve[ idx ][ 2 ]; local alpha = ( input - x1 ) / ( x2 - x1 ); return math.lerp( y1, y2, alpha ); end end return curve[ #curve ][ 2 ]; end function math.lerp( from, to, alpha ) return from + ( to-from ) * alpha; end Link to comment
-misterX- Posted January 20, 2013 Author Share Posted January 20, 2013 thanks it works! 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