Diablomta Posted January 20, 2017 Share Posted January 20, 2017 Necesito saber que un vehiculo cuando se suba muestre un text que diga ejemplo Cambio: 4 ayuda Link to comment
aka Blue Posted January 20, 2017 Share Posted January 20, 2017 Usa la función GetVehicleCurrentGear dentro de un dxDrawText utilizando el evento onClientRender Link to comment
Diablomta Posted January 20, 2017 Author Share Posted January 20, 2017 me puedes ayudar un poco mas lo ise y no me resulto un poco mas detallado PD: que eso lo muestre en un solo vehiculo el 602 Alpha Link to comment
#Dv^ Posted January 20, 2017 Share Posted January 20, 2017 Posteá lo que hiciste y te ayudaremos con tu error Link to comment
Diablomta Posted January 21, 2017 Author Share Posted January 21, 2017 (edited) al final solo quiero hacer una especie de resource de cambio del auto que con un bindkey suba el cambio y con otro bindkey lo baje tengo este pero no me funciona al 100&, solo quiero que sea para un vehiculo estos cambios pero no puedo editarlo para un vehiculo a de mas no me resulta muy bien, este sale con una imagen pero yo quiero que salga un dxDrawText que diga Cambio: (AQUI EL CURRENTGEAR) osea cambio actual que lleva . local playerGear = 0 local playerVehicleSeat = 0 function setPlayerGear( key ) if key == "num_add" then if playerGear < 5 then playerGear = playerGear + 1 playSoundFrontEnd( 4 ) end elseif key == "num_sub" then if playerGear > -1 then playerGear = playerGear - 1 playSoundFrontEnd( 4 ) end end end function setPlayerGearByCmd( command ) if command == "gearu" then setPlayerGear( "num_add" ) elseif command == "geard" then setPlayerGear( "num_sub" ) end end function createImage() gearbox = guiCreateStaticImage(0.8232,0.5508,0.1172,0.1563,"gearbox.png",true) marker = guiCreateStaticImage(0.4667,0.4667,0.0833,0.0833,"marker.png",true,gearbox) end function manual() local vehicle = getPedOccupiedVehicle( getLocalPlayer() ) if vehicle and playerVehicleSeat == 0 then local vehicleGear = getVehicleCurrentGear( vehicle ) local velX, velY, velZ = getElementVelocity( vehicle ) local vType = getVehicleType( vehicle ) local velX2 = math.abs( velX ) local velY2 = math.abs( velY ) local velZ2 = math.abs( velZ ) local visible local dvel if playerGear == 1 then dvel = 1.055 elseif playerGear == 2 then dvel = 1.012 elseif playerGear == 3 then dvel = 1.005 elseif playerGear == 4 then dvel = 1.0025 end if vType ~= "Plane" and vType ~= "Helicopter" and vType ~= "Boat" and vType ~= "Trailer" and vType ~= "Train" and vType ~= "BMX" then visible = true if playerGear > 0 then toggleControl( "accelerate", true ) toggleControl( "brake_reverse", false ) if playerGear < vehicleGear then if math.max( velX2, velY2, velZ2 ) ~= velZ2 then local x, y = velX / dvel, velY / dvel setElementVelocity ( vehicle, x, y, velZ ) end end elseif playerGear == 0 then toggleControl( "accelerate", false ) toggleControl( "brake_reverse", false ) elseif playerGear == -1 then toggleControl( "accelerate", false ) toggleControl( "brake_reverse", true ) local state = false local keys = getBoundKeys( "accelerate" ) for key,_ in pairs(keys) do if getKeyState( key ) then state = true end end local keys2 = getBoundKeys( "brake_reverse" ) for key,_ in pairs(keys2) do if getKeyState( key ) then state = true end end if state then setControlState( "accelerate", false ) setControlState( "brake_reverse", true ) else setControlState( "accelerate", false ) setControlState( "brake_reverse", false ) end end if vehicleGear < playerGear then if math.max( velX2, velY2, velZ2 ) ~= velZ2 then local s = ( ( ( playerGear - vehicleGear ) / 100 ) + 1 ) s = s * ( ( ( playerGear - vehicleGear ) / 120 ) + 1 ) local x, y = velX / s, velY / s setElementVelocity ( vehicle, x, y, velZ ) end end else visible = false toggleControl( "accelerate", true ) toggleControl( "brake_reverse", true ) end if visible then guiSetVisible( gearbox, true ) if playerGear == -1 then guiSetPosition( marker, 0.1583, 0.275, true ) elseif playerGear == 0 then guiSetPosition( marker, 0.4667, 0.4667, true ) elseif playerGear == 1 then guiSetPosition( marker, 0.3583, 0.275, true ) elseif playerGear == 2 then guiSetPosition( marker, 0.3583, 0.6417, true ) elseif playerGear == 3 then guiSetPosition( marker, 0.5583, 0.275, true ) elseif playerGear == 4 then guiSetPosition( marker, 0.5583, 0.6417, true ) elseif playerGear == 5 then guiSetPosition( marker, 0.7583, 0.275, true ) end else guiSetVisible( gearbox, false ) end else playerGear = 0 guiSetVisible( gearbox, false ) end end function seat( player, seat ) playerVehicleSeat = seat end bindKey( "num_add", "up", setPlayerGear ) bindKey( "num_sub", "up", setPlayerGear ) addEventHandler( "onClientResourceStart", getResourceRootElement(getThisResource()), createImage ) addEventHandler( "onClientRender", getRootElement(), manual ) addEventHandler( "onClientVehicleEnter", getRootElement(), seat ) addCommandHandler( "gearu", setPlayerGearByCmd ) addCommandHandler( "geard", setPlayerGearByCmd ) Edited January 21, 2017 by Diablomta Link to comment
#Dv^ Posted January 21, 2017 Share Posted January 21, 2017 addEventHandler("onClientRender", root, function() local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle then dxDrawText("Cambio: "..getVehicleCurrentGear(vehicle), 20, 20, 0, 0, tocolor(255, 255, 255, 255), 2, "default-bold") end end ) Link to comment
Diablomta Posted January 22, 2017 Author Share Posted January 22, 2017 (edited) y esto como lo modifico para que sea para un solo vehiculo? Edited January 22, 2017 by Diablomta Link to comment
Sensacion Posted January 22, 2017 Share Posted January 22, 2017 Por casualidad no será para un Lamborghini? Link to comment
Diablomta Posted January 22, 2017 Author Share Posted January 22, 2017 nel es para un tractor :v Link to comment
#Dv^ Posted January 22, 2017 Share Posted January 22, 2017 8 hours ago, Diablomta said: y esto como lo modifico para que sea para un solo vehiculo? Usa getElementModel para comprobar si es el vehículo que pides Link to comment
Diablomta Posted January 22, 2017 Author Share Posted January 22, 2017 (edited) no me funciona asi :v help addEventHandler("onClientRender", root, function() local vehicle = getPedOccupiedVehicle(localPlayer) local id = getElementModel (vehicle) if id == 519 or id == 577 then if vehicle then dxDrawText("Cambio: "..getVehicleCurrentGear(vehicle), 1320, 703, 0, 100, tocolor(255, 255, 255, 255), 1, "default-bold") end end ) addEventHandler ( "onPlayerVehicleEnter", root, planeEnter ) Edited January 22, 2017 by Diablomta Link to comment
Diablomta Posted January 22, 2017 Author Share Posted January 22, 2017 le puedo colocar un dxDrawRectangle ? al dxDrawText? Link to comment
#Dv^ Posted January 22, 2017 Share Posted January 22, 2017 Eso sería una función aparte Link to comment
aka Blue Posted January 22, 2017 Share Posted January 22, 2017 Si. Pero ten en cuenta que para que no quede el rectangulo dibujado encima del texto, debes ponerlo encima del dxDrawText Link to comment
Diablomta Posted January 22, 2017 Author Share Posted January 22, 2017 Puedo cambiarle el tipo de letra al dxDrawText? y como lo hago? Link to comment
#Dv^ Posted January 22, 2017 Share Posted January 22, 2017 (edited) Quote "default": Tahoma "default-bold": Tahoma Bold "clear": Verdana "arial": Arial "sans": Microsoft Sans Serif "pricedown": Pricedown (GTA's theme text) "bankgothic": Bank Gothic Medium "diploma": Diploma Regular "beckett": Beckett Regular Estas son algunos de las fuentes predeterminadas de MTA En 'font' reemplazas por algunas de esas dxDrawText("Cambio: "..getVehicleCurrentGear(vehicle), 20, 20, 0, 0, tocolor(255, 255, 255, 255), 2, font) Si quieres usar una distinta que no esté en esa lista, deberás usar dxCreateFont Edited January 22, 2017 by #Dv^ Link to comment
Diablomta Posted January 23, 2017 Author Share Posted January 23, 2017 (edited) me sale un error en la consola o debugscript este es http://imgur.com/a/6NVXs ese error lo da cuando estas fuera del vehiculo, entras y se arregla :v ayuda :V Edited January 23, 2017 by Diablomta Link to comment
Rose Posted January 23, 2017 Share Posted January 23, 2017 addEventHandler("onClientRender", root, function() local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle then local id = getElementModel (vehicle) if id == 519 or id == 577 then dxDrawText("Cambio: "..getVehicleCurrentGear(vehicle), 1320, 703, 0, 100, tocolor(255, 255, 255, 255), 1, "default-bold") end end end ) Te da error porque aunque no estés en el auto se ejecutará tu código(no existe 'vehicle'), y como onClientRender se "actualiza" por cada frame, te dará error. Link to comment
#Dv^ Posted January 23, 2017 Share Posted January 23, 2017 (edited) @Diablomta posteá tu código Edited January 23, 2017 by #Dv^ Link to comment
Diablomta Posted January 23, 2017 Author Share Posted January 23, 2017 (edited) addEventHandler("onClientRender", root, function() local vehicle = getPedOccupiedVehicle(localPlayer) local id = getElementModel (vehicle) if vehicle then if id == 411 or id == 522 then dxDrawText("Cambio: "..getVehicleCurrentGear(vehicle), 1285, 657.100, 0, 100, tocolor(255, 255, 255, 255), 1.1, "default") end end end ) Edited January 23, 2017 by Diablomta Link to comment
#Dv^ Posted January 23, 2017 Share Posted January 23, 2017 El error era que posicionaste mal la variable "id" addEventHandler("onClientRender", root, function() local vehicle = getPedOccupiedVehicle(localPlayer) if vehicle then local id = getElementModel (vehicle) if id == 411 or id == 522 then dxDrawText("LG: "..getVehicleCurrentGear(vehicle), 1285, 657.100, 0, 100, tocolor(255, 255, 255, 255), 1.1, "default") end end end ) Link to comment
Recommended Posts