#Ivan7 Posted June 17, 2014 Share Posted June 17, 2014 Ok so im trying to add a dxDrawText to my taxi marker but nothing shows... the marker does but not the text 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 markertaxi = createMarker( -2479.9282226563, -197.41656494141, 24.623662948608, 'Cylinder', 1.5, 255, 0, 255, 170 ); addEventHandler ( 'onClientRender', root, function ( ) -- local x, y, z = getCameraMatrix(); local x1, y1, z1 = getElementPosition ( markertaxi ); local distance_1 = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ); -- -- 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 ); end local textscale = math.evalCurve( gTextScaleCurve, scale ); local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); end -- dxDrawText( "Taxi Job", x1_, y1_, x1_, y1_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); end ); 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 GUIEditor = { memo = {}, button = {}, window = {}, } GUIEditor.window[1] = guiCreateWindow(0.4, 0.16, 0.35, 0.45, "Gta-Ar Taxi Job", true) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) bAccept = guiCreateButton(0.10, 0.90, 0.41, 0.80, "Accept", true, GUIEditor.window[1]) guiSetProperty(bAccept, "NormalTextColour", "FFAAAAAA") bClose = guiCreateButton(0.52, 0.90, 0.41, 0.80, "Decline", true, GUIEditor.window[1]) guiSetProperty(bClose, "NormalTextColour", "FFAAAAAA") GUIEditor.memo[1] = guiCreateMemo(0.10, 0.1, 0.80, 0.75, " Gta-Ar Taxi Job Rules: 1) Go To Player (Blue Blip). 2) Pick up Player by pressing car horn. 3) Drop off Player to Red Blip. Be sure not to die, if you do you will lose your customer. Every dropoff you will earn up to $1000! Made By: [Gta-Ar]#Ivan ", true, GUIEditor.window[1]) createBlipAttachedTo( markertaxi, 42) function showGUIbt(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) and getTeamN(hitElement) ~= "Police" and not isPedInVehicle ( hitElement ) then if getElementData(hitElement,"JobNew") ~= 4 then guiSetVisible(GUIEditor.window[1], true) showCursor( true ) else joinTeam() end end end addEventHandler("onClientMarkerHit", joinBD, showGUIbt) function showGUIbf() if source == bAccept then guiSetVisible (GUIEditor.window[1], false ) showCursor ( false ) joinTeam() elseif source == bClose then guiSetVisible (GUIEditor.window[1], false ) showCursor ( false ) end end addEventHandler("onClientGUIClick", resourceRoot, showGUIbf) Link to comment
#Ivan7 Posted June 17, 2014 Author Share Posted June 17, 2014 also when i hit the marker it says attempting to compare nil with a number.. Link to comment
Moderators IIYAMA Posted June 17, 2014 Moderators Share Posted June 17, 2014 Ok so im trying to add a dxDrawText to my taxi marker but nothing shows... the marker does but not the textlocal 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 markertaxi = createMarker( -2479.9282226563, -197.41656494141, 24.623662948608, 'Cylinder', 1.5, 255, 0, 255, 170 ); addEventHandler ( 'onClientRender', root, function ( ) -- local x, y, z = getCameraMatrix(); local x1, y1, z1 = getElementPosition ( markertaxi ); local distance_1 = getDistanceBetweenPoints3D( x, y, z, x1, y1, z1 ); -- -- 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 ); end local textscale = math.evalCurve( gTextScaleCurve, scale ); local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); end -- dxDrawText( "Taxi Job", x1_, y1_, x1_, y1_, tocolor ( 255, 255, 255, textalpha ), textscale * gTextSize, "arial", "center", "bottom", false, false, false, true ); end ); 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 GUIEditor = { memo = {}, button = {}, window = {}, } GUIEditor.window[1] = guiCreateWindow(0.4, 0.16, 0.35, 0.45, "Gta-Ar Taxi Job", true) guiWindowSetSizable(GUIEditor.window[1], false) guiSetVisible(GUIEditor.window[1], false) bAccept = guiCreateButton(0.10, 0.90, 0.41, 0.80, "Accept", true, GUIEditor.window[1]) guiSetProperty(bAccept, "NormalTextColour", "FFAAAAAA") bClose = guiCreateButton(0.52, 0.90, 0.41, 0.80, "Decline", true, GUIEditor.window[1]) guiSetProperty(bClose, "NormalTextColour", "FFAAAAAA") GUIEditor.memo[1] = guiCreateMemo(0.10, 0.1, 0.80, 0.75, " Gta-Ar Taxi Job Rules: 1) Go To Player (Blue Blip). 2) Pick up Player by pressing car horn. 3) Drop off Player to Red Blip. Be sure not to die, if you do you will lose your customer. Every dropoff you will earn up to $1000! Made By: [Gta-Ar]#Ivan ", true, GUIEditor.window[1]) createBlipAttachedTo( markertaxi, 42) function showGUIbt(hitElement) if getElementType(hitElement) == "player" and (hitElement == localPlayer) and getTeamN(hitElement) ~= "Police" and not isPedInVehicle ( hitElement ) then if getElementData(hitElement,"JobNew") ~= 4 then guiSetVisible(GUIEditor.window[1], true) showCursor( true ) else joinTeam() end end end addEventHandler("onClientMarkerHit", joinBD, showGUIbt) function showGUIbf() if source == bAccept then guiSetVisible (GUIEditor.window[1], false ) showCursor ( false ) joinTeam() elseif source == bClose then guiSetVisible (GUIEditor.window[1], false ) showCursor ( false ) end end addEventHandler("onClientGUIClick", resourceRoot, showGUIbf) I don't believe this is your code because: - You don't use lua tags. (scripters would use it) - You don't show us the exact error. (line number, from this code) - It looks like you don't know what this error means. - And you don't debug your code, which is the worse. Link to comment
#Ivan7 Posted June 17, 2014 Author Share Posted June 17, 2014 I never said it was at first... also im just doing editing like i said im new Link to comment
#Ivan7 Posted June 17, 2014 Author Share Posted June 17, 2014 + i did debug its in another topic and i stated the excat error. Link to comment
Moderators IIYAMA Posted June 17, 2014 Moderators Share Posted June 17, 2014 I never said it was at first... also im just doing editing like i said im new This is exactly the worse thing you can do. So you can just post somebody his code, here on the forum without asking? He(owner) is probably not really happy about it, also the scripters who edited the code, will not be happy when they noticed that they are illegally editing others people their code on a community forum. You should always write down the owner of the code down, so the people will know from who they are editing the code. The best you can do is contact the owner it self and ask him if you have rights for that. You have much to learn about copy right ⓒ. Link to comment
#Ivan7 Posted June 17, 2014 Author Share Posted June 17, 2014 1) the whole script isnt the owners.. 2) i created the GUI, Blips, Marker, Peds etc... 3) Only Problem I am having with is dxDrawText which now I took out because it doesnt seem to 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