Sergioks Posted January 22, 2014 Share Posted January 22, 2014 ¡Hola! Tengo un Problema Referente al script "ac_vehicles". El Script en si funciona, yo quiero añadirle un DxDrawText al marker. que diga "Vehiculos". Asi quedo el client-side despues de modificarlo: local markers = { } local typeOfMarker = 0 local rotation = 0 for i,marker in ipairs(vehMarkers) do local r,g,b = 50, 50, 50 --- STAFFs if marker[5] == 2 then r,g,b = 255, 255, 255 --- Gratis elseif marker[5] == 3 then r,g,b = 50, 50, 50 --- STAFFs Aviones elseif marker[5] == 4 then r,g,b = 50, 50, 50 --- STAFFs Botes elseif marker[5] == 5 then r,g,b = 0, 144, 217 --- Clan#1 elseif marker[5] == 6 then r,g,b = 0, 0, 200 --- Clan#2 end markers[i] = createMarker( marker[1], marker[2], marker[3], 'cylinder', 1.8, r, g, b, 100 ) setElementData( markers[i], "rot", marker[4] ) setElementData( markers[i], "type", marker[5] ) end addEventHandler( "onClientResourceStart", getResourceRootElement( ), function ( startedRes ) for i,marker in ipairs(vehMarkers) do addEventHandler( "onClientMarkerHit", markers[i], check ) addEventHandler("onClientMarkerLeave", markers[i], closeWin ) end end ) --- Adicion DxDrawText: local gMaxDistance = 25 addEventHandler("onClientRender", getRootElement(), function() --- Camera Matrix -- local Cx, Cy, Cz = getCameraMatrix() -------------------- --- Marker --- local Mx, My, Mz = getElementPosition ( markers[i] ) --- Linea 51 -------------- --- Distancia --- local Distancia = getDistanceBetweenPoints3D ( Cx, Cy, Cz, Mx, My, Mz ) --- Linea 54 ------------------ --- getScreenFromWorldPosition --- local x,y = getScreenFromWorldPosition( Mx, My, Mz + 0.95, 0.06 ) ---------------------------------- --- getElementPosition ( getLocalPlayer () ) --- local posX,posY,posZ = getElementPosition(getLocalPlayer()) ------------------------------------------------ if Distancia <= gMaxDistance then if x and y then if isLineOfSightClear (posX ,posY ,posZ ,Mx, My, Mz, true, true, false, true) then dxDrawText("Vehiculos", x, y, x, y, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "top", false, false, false, false, true, true) end end end end ) --- Final de Adicion --- Codigo de Error: WARNING: ac_vehicles\vehicle_client.lua:51: Bad argument @ 'getElementPosition' WARNING ac_vehicles\vehicle_client.lua:54: Bad argument @ 'getDistanceBetweenPoints3D' Es Raro este error Porque, En Otros Markers que hice funciono este codigo, y lo hice de manera que solo deba modificar la linea: --- Marker --- local Mx, My, Mz = getElementPosition ( markers[i] ) --- Linea 51 -------------- Ya Trate Cambiar el Nombre del Marker: ... VehicleSpawn = createMarker( marker[1], marker[2], marker[3], 'cylinder', 1.8, r, g, b, 100 ) setElementData( VehicleSpawn, "rot", marker[4] ) setElementData( VehicleSpawn, "type", marker[5] ) end addEventHandler( "onClientResourceStart", getResourceRootElement( ), function ( startedRes ) for i,marker in ipairs(vehMarkers) do addEventHandler( "onClientMarkerHit", VehicleSpawn, check ) addEventHandler("onClientMarkerLeave", VehicleSpawn, closeWin ) end end ) local gMaxDistance = 25 addEventHandler("onClientRender", getRootElement(), function() --- Camera Matrix -- local Cx, Cy, Cz = getCameraMatrix() -------------------- --- Marker --- local Mx, My, Mz = getElementPosition ( VehicleSpawn ) -------------- --- Distancia --- local Distancia = getDistanceBetweenPoints3D ( Cx, Cy, Cz, Mx, My, Mz ) ------------------ --- getScreenFromWorldPosition --- local x,y = getScreenFromWorldPosition( Mx, My, Mz + 0.95, 0.06 ) ---------------------------------- --- getElementPosition ( getLocalPlayer () ) --- local posX,posY,posZ = getElementPosition(getLocalPlayer()) ------------------------------------------------ if Distancia <= gMaxDistance then if x and y then if isLineOfSightClear (posX ,posY ,posZ ,Mx, My, Mz, true, true, false, true) then dxDrawText("Vehiculos", x, y, x, y, tocolor(255, 0, 0, 255), 1.00, "bankgothic", "center", "top", false, false, false, false, true, true) end end end end ) y Cuando lo ejecuto dice: ERROR: ac_vehicle\vehicle_client.lua:38: 'onMarkerHit'. With This Function is already handled ERROR: ac_vehicle\vehicle_client.lua:39: 'onMarkerLeave'. With This Function is already handled ¿Que Hago? ¡AYUDA! Salu2! Edit: Ultimo Mensaje DebugScript De Error Corregido. escribí mal unas palabras Link to comment
JesusAliso Posted January 23, 2014 Share Posted January 23, 2014 Que error es el que te da ahora? Link to comment
PhantomDamn Posted January 23, 2014 Share Posted January 23, 2014 agrega este escript al client side.. y le modificas el texto, te aparecera a cierta distancia del marker. --\\\\\\\\\\\\\\\\\\\\\\\\\\ --// 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( 2104.6, -1787.8, 12.6, 'Cylinder', 1.5, 255, 255, 0, 0 ); addEventHandler ( 'onClientRender', root, function ( ) -- local x, y, z = getCameraMatrix(); local x1, y1, z1 = getElementPosition ( marker ); 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 ); local textscale = math.evalCurve( gTextScaleCurve, scale ); local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); -- dxDrawText( "Agregar palabra o frase aqui", x1_, y1_, x1_, y1_, tocolor ( 255, 0, 0, textalpha ), textscale * gTextSize, "Bankgothic", "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
Sergioks Posted January 26, 2014 Author Share Posted January 26, 2014 agrega este escript al client side.. y le modificas el texto, te aparecera a cierta distancia del marker. --\\\\\\\\\\\\\\\\\\\\\\\\\\ --// 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( 2104.6, -1787.8, 12.6, 'Cylinder', 1.5, 255, 255, 0, 0 ); addEventHandler ( 'onClientRender', root, function ( ) -- local x, y, z = getCameraMatrix(); local x1, y1, z1 = getElementPosition ( marker ); 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 ); local textscale = math.evalCurve( gTextScaleCurve, scale ); local textalpha = math.evalCurve( gTextAlphaCurve, alpha ); -- dxDrawText( "Agregar palabra o frase aqui", x1_, y1_, x1_, y1_, tocolor ( 255, 0, 0, textalpha ), textscale * gTextSize, "Bankgothic", "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 Gracias Link to comment
PhantomDamn Posted January 26, 2014 Share Posted January 26, 2014 De nada, un placer ayudarte Link to comment
Recommended Posts