Jump to content

Ayuda resource


Flipi

Recommended Posts

Hola, quiero editar este resource para que en la parte del nitro me de la cantidad de nitro que tiene el vehiculo, pero nose como hacerlo

local rx, ry = guiGetScreenSize ( ) 
  
function vehiclestatus ( ) 
    if ( isPedInVehicle ( localPlayer ) == false ) then return false end 
    local x, y, z = getElementPosition( localPlayer ) 
    local car = getPedOccupiedVehicle ( localPlayer ) 
    local sx, sy, sz = getElementVelocity ( car ) 
    local kphSpeed = math.ceil( ( ( sx^2 + sy^2 + sz^2 ) ^ ( 0.5 ) ) * 161 ) 
    local mphSpeed = math.ceil( ( ( ( sx^2 + sy^2 + sz^2 ) ^ ( 0.5 ) ) * 161 ) / 1.61 ) 
    local health = getElementHealth ( car ) 
    local name = getVehicleName ( car ) 
    local currenthealth = math.floor( health/10 ) 
    local nos = 0; 
    local hColor = "#00ff00" 
    -- Health Colors -- 
    if ( currenthealth < 20 ) then hColor = "#ff0000" 
    elseif ( currenthealth < 40 ) then hColor = "#FF6400" 
    elseif ( currenthealth < 60 ) then hColor = "#C86400" 
    elseif ( currenthealth < 70 ) then hColor = "#C89600" 
    elseif ( currenthealth < 80 ) then hColor = "#329600" 
    elseif ( currenthealth < 90 ) then hColor = "#00ff00" end 
    -- Nitro Colors -- 
    if ( nos < 20 ) then hColor = "#ff0000" 
    elseif ( nos < 40 ) then hColor = "#FF6400" 
    elseif ( nos < 60 ) then hColor = "#C86400" 
    elseif ( nos < 70 ) then hColor = "#C89600" 
    elseif ( nos < 80 ) then hColor = "#329600" 
    elseif ( nos < 90 ) then hColor = "#00ff00" end 
    dxDrawRectangle( ( rx-205 ), ( ry-78 ), 199, 17, tocolor(0, 0, 0, 180), true) 
    dxDrawRectangle( ( rx-205 ), ( ry-54 ), 199, 17, tocolor(0, 0, 0, 180), true) 
    dxDrawRectangle( ( rx-205 ), ( ry-30 ), 199, 17, tocolor(0, 0, 0, 180), true) 
    dxDrawText ( "#0080FFVelocidad: #FFFFFF"..tostring(kphSpeed).." #FF8000Kmh #0080FF/ #FFFFFF"..tostring(mphSpeed).." #FF8000Mph", ( rx - 199 ), ( ry - 77 ), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1,"default-bold", "left", "top", false, false, true, true, false ) 
    dxDrawText ( "#0080FFVehiculo: #FFFFFF".. hColor ..""..tostring(currenthealth).."#0080FF% #FF8000| #0080FF"..tostring(name).."", ( rx - 199 ), ( ry - 53 ), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1,"default-bold", "left", "top", false, false, true, true, false ) 
    dxDrawText ( "#0080FFNitro: #FFFFFF".. hColor ..""..tostring(nos).."  
end 
addEventHandler ( "onClientRender", root, vehiclestatus ) 
  
  
 

Link to comment
  • MTA Team

El ejemplo de la Wiki:

  
function displayNitroLevel(pPlayer) 
    if pPlayer == localPlayer then 
        if getVehicleUpgradeOnSlot(source, -- s8) --> then -- Check if the vehicle has nitro installed 
            local fNitroLevel = getVehicleNitroLevel(source) 
            outputChatBox("The nitro level of this " .. getVehicleName(source) .. " is " .. fNitroLevel .. ".", 255, 180, 20, false) 
        end 
    end 
end 
addEventHandler("onClientVehicleEnter", root, displayNitroLevel) 
  
  

Link to comment
El ejemplo de la Wiki:
  
function displayNitroLevel(pPlayer) 
    if pPlayer == localPlayer then 
        if getVehicleUpgradeOnSlot(source, -- s8) --> then -- Check if the vehicle has nitro installed 
            local fNitroLevel = getVehicleNitroLevel(source) 
            outputChatBox("The nitro level of this " .. getVehicleName(source) .. " is " .. fNitroLevel .. ".", 255, 180, 20, false) 
        end 
    end 
end 
addEventHandler("onClientVehicleEnter", root, displayNitroLevel) 
  
  

Aca lo agrege, pero el problema es que cuando activo el nitro, el porcentaje de agotamiento da muchos decimales, y como puedo poner que en vez de false diga "no nitro"

IMG: http://imageshack.us/a/img837/4341/szid.png

IMG2: http://imageshack.us/a/img14/4149/8xog.png

local rx, ry = guiGetScreenSize ( ) 
  
function vehiclestatus ( ) 
    if ( isPedInVehicle ( localPlayer ) == false ) then return false end 
    local x, y, z = getElementPosition( localPlayer ) 
    local car = getPedOccupiedVehicle ( localPlayer ) 
    local sx, sy, sz = getElementVelocity ( car ) 
    local kphSpeed = math.ceil( ( ( sx^2 + sy^2 + sz^2 ) ^ ( 0.5 ) ) * 161 ) 
    local mphSpeed = math.ceil( ( ( ( sx^2 + sy^2 + sz^2 ) ^ ( 0.5 ) ) * 161 ) / 1.61 ) 
    local health = getElementHealth ( car ) 
    local name = getVehicleName ( car ) 
    local currenthealth = math.floor( health/10 ) 
    local fNitroLevel = getVehicleNitroLevel( car ) 
    local hColor = "#00ff00" 
    -- Health Colors -- 
    if ( currenthealth < 20 ) then hColor = "#ff0000" 
    elseif ( currenthealth < 40 ) then hColor = "#FF6400" 
    elseif ( currenthealth < 60 ) then hColor = "#C86400" 
    elseif ( currenthealth < 70 ) then hColor = "#C89600" 
    elseif ( currenthealth < 80 ) then hColor = "#329600" 
    elseif ( currenthealth < 90 ) then hColor = "#00ff00" end 
    dxDrawRectangle( ( rx-205 ), ( ry-78 ), 199, 17, tocolor(0, 0, 0, 180), true) 
    dxDrawRectangle( ( rx-205 ), ( ry-54 ), 199, 17, tocolor(0, 0, 0, 180), true) 
    dxDrawRectangle( ( rx-205 ), ( ry-30 ), 199, 17, tocolor(0, 0, 0, 180), true) 
    dxDrawText ( "#0080FFVelocidad: #FFFFFF"..tostring(kphSpeed).." #FF8000Kmh #0080FF/ #FFFFFF"..tostring(mphSpeed).." #FF8000Mph", ( rx - 199 ), ( ry - 77 ), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1,"default-bold", "left", "top", false, false, true, true, false ) 
    dxDrawText ( "#0080FFVehiculo: #FFFFFF".. hColor ..""..tostring(currenthealth).."#0080FF% #FF8000| #0080FF"..tostring(name).."", ( rx - 199 ), ( ry - 53 ), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1,"default-bold", "left", "top", false, false, true, true, false ) 
    dxDrawText ( "#0080FFNitro: #FF8000"..tostring(fNitroLevel).."#0080FF%", (rx - 199 ), ( ry - 29), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1, "default-bold", "left", "top", false, false, true, true, false ) 
end 
addEventHandler ( "onClientRender", root, vehiclestatus ) 

Link to comment
Prueba cambiando:
local fNitroLevel = getVehicleNitroLevel( car ) 

por esto:

local fNitroLevel = getVehicleNitroLevel( car ) or 0 
local fNitroLevel = math.floor( fNitroLevel*100 ) 
if fNitroLevel == 0 then fNitroLevel = "no nitro" end 

mira hice esto y funciona, pero lo que quiero ahora es como poner que la cantidad de nitro (el porcentaje) cambie de color cuando va disminuyendo al igual que la vida del vehiculo. intenté hacer lo mismo que con lo del "-- Kph Colors --, -- Mph Colors --, -- Health Colors --" y agregar "local nColor" a la parte del dxDrawText del nitro.

local rx, ry = guiGetScreenSize ( ) 
  
function vehiclestatus ( ) 
    if ( isPedInVehicle ( localPlayer ) == false ) then return false end 
    local x, y, z = getElementPosition( localPlayer ) 
    local car = getPedOccupiedVehicle ( localPlayer ) 
    local sx, sy, sz = getElementVelocity ( car ) 
    local kphSpeed = math.ceil( ( ( sx^2 + sy^2 + sz^2 ) ^ ( 0.5 ) ) * 161 ) 
    local mphSpeed = math.ceil( ( ( ( sx^2 + sy^2 + sz^2 ) ^ ( 0.5 ) ) * 161 ) / 1.61 ) 
    local health = getElementHealth ( car ) 
    local name = getVehicleName ( car ) 
    local currenthealth = math.floor( health/10 ) 
    local fNitroLevel = getVehicleNitroLevel ( car ) 
    if ( type ( fNitroLevel ) == "number" ) then 
        fNitroLevel = math.floor ( ( fNitroLevel * 100 ) ) 
    end 
    local hColor = "#40FF00" 
    local kColor = "#40FF00" 
    local mColor = "#40FF00" 
  
    -- Kph Colors -- 
    if ( kphSpeed < 20 ) then kColor = "#D8F6CE" 
    elseif ( kphSpeed < 40 ) then kColor = "#BCF5A9" 
    elseif ( kphSpeed < 60 ) then kColor = "#9FF781" 
    elseif ( kphSpeed < 70 ) then kColor = "#82FA58" 
    elseif ( kphSpeed < 80 ) then kColor = "#64FE2E" 
    elseif ( kphSpeed < 90 ) then kColor = "#40FF00" end 
     
    -- Mph Colors -- 
    if ( mphSpeed < 20 ) then mColor = "#D8F6CE" 
    elseif ( mphSpeed < 40 ) then mColor = "#BCF5A9" 
    elseif ( mphSpeed < 60 ) then mColor = "#9FF781" 
    elseif ( mphSpeed < 70 ) then mColor = "#82FA58" 
    elseif ( mphSpeed < 80 ) then mColor = "#64FE2E" 
    elseif ( mphSpeed < 90 ) then mColor = "#40FF00" end 
     
    -- Health Colors -- 
    if ( currenthealth < 20 ) then hColor = "#ff0000" 
    elseif ( currenthealth < 40 ) then hColor = "#FF6400" 
    elseif ( currenthealth < 60 ) then hColor = "#C86400" 
    elseif ( currenthealth < 70 ) then hColor = "#C89600" 
    elseif ( currenthealth < 80 ) then hColor = "#329600" 
    elseif ( currenthealth < 90 ) then hColor = "#40FF00" end 
     
    dxDrawRectangle( ( rx-205 ), ( ry-78 ), 199, 17, tocolor(0, 0, 0, 180), true) 
    dxDrawRectangle( ( rx-205 ), ( ry-54 ), 199, 17, tocolor(0, 0, 0, 180), true) 
    dxDrawRectangle( ( rx-205 ), ( ry-30 ), 199, 17, tocolor(0, 0, 0, 180), true) 
    dxDrawText ( "#0080FFVelocidad: #FFFFFF"..kColor..""..tostring(kphSpeed).." #FF8000Kmh #0080FF/ "..mColor..""..tostring(mphSpeed).." #FF8000Mph", ( rx - 199 ), ( ry - 77 ), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1,"default-bold", "left", "top", false, false, true, true, false ) 
    dxDrawText ( "#0080FFVehiculo: #FFFFFF".. hColor ..""..tostring(currenthealth).."#0080FF% #FF8000| #0080FF"..tostring(name).."", ( rx - 199 ), ( ry - 53 ), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1,"default-bold", "left", "top", false, false, true, true, false ) 
    dxDrawText ( "#0080FFNitro: #40FF00".. ( type ( fNitroLevel ) == "number" and fNitroLevel .."#0080FF%" or "#FF8000Sin nitro" ), (rx - 199 ), ( ry - 29), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1, "default-bold", "left", "top", false, false, true, true, false ) 
end 
addEventHandler ( "onClientRender", root, vehiclestatus ) 

Link to comment

Prueba asi :D

local rx, ry = guiGetScreenSize ( ) 
  
function vehiclestatus ( ) 
    if ( isPedInVehicle ( localPlayer ) == false ) then return false end 
    local x, y, z = getElementPosition( localPlayer ) 
    local car = getPedOccupiedVehicle ( localPlayer ) 
    local sx, sy, sz = getElementVelocity ( car ) 
    local kphSpeed = math.ceil( ( ( sx^2 + sy^2 + sz^2 ) ^ ( 0.5 ) ) * 161 ) 
    local mphSpeed = math.ceil( ( ( ( sx^2 + sy^2 + sz^2 ) ^ ( 0.5 ) ) * 161 ) / 1.61 ) 
    local health = getElementHealth ( car ) 
    local name = getVehicleName ( car ) 
    local currenthealth = math.floor( health/10 ) 
    local fNitroLevel = getVehicleNitroLevel ( car ) 
    if ( type ( fNitroLevel ) == "number" ) then 
        fNitroLevel = math.floor ( ( fNitroLevel * 100 ) ) 
    end 
    local hColor = "#40FF00" 
    local kColor = "#40FF00" 
    local mColor = "#40FF00" 
    local nColor = "#40FF00" 
  
    -- Kph Colors -- 
    if ( kphSpeed < 20 ) then kColor = "#D8F6CE" 
    elseif ( kphSpeed < 40 ) then kColor = "#BCF5A9" 
    elseif ( kphSpeed < 60 ) then kColor = "#9FF781" 
    elseif ( kphSpeed < 70 ) then kColor = "#82FA58" 
    elseif ( kphSpeed < 80 ) then kColor = "#64FE2E" 
    elseif ( kphSpeed < 90 ) then kColor = "#40FF00" end 
    
    -- Mph Colors -- 
    if ( mphSpeed < 20 ) then mColor = "#D8F6CE" 
    elseif ( mphSpeed < 40 ) then mColor = "#BCF5A9" 
    elseif ( mphSpeed < 60 ) then mColor = "#9FF781" 
    elseif ( mphSpeed < 70 ) then mColor = "#82FA58" 
    elseif ( mphSpeed < 80 ) then mColor = "#64FE2E" 
    elseif ( mphSpeed < 90 ) then mColor = "#40FF00" end 
    
    -- Health Colors -- 
    if ( currenthealth < 20 ) then hColor = "#ff0000" 
    elseif ( currenthealth < 40 ) then hColor = "#FF6400" 
    elseif ( currenthealth < 60 ) then hColor = "#C86400" 
    elseif ( currenthealth < 70 ) then hColor = "#C89600" 
    elseif ( currenthealth < 80 ) then hColor = "#329600" 
    elseif ( currenthealth < 90 ) then hColor = "#40FF00" end 
     
        -- Nitro Colors -- 
    if ( fNitroLevel < 20 ) then nColor = "#ff0000" 
    elseif ( fNitroLevel < 40 ) then nColor = "#FF6400" 
    elseif ( fNitroLevel < 60 ) then nColor = "#C86400" 
    elseif ( fNitroLevel < 70 ) then nColor = "#C89600" 
    elseif ( fNitroLevel < 80 ) then nColor = "#329600" 
    elseif ( fNitroLevel < 90 ) then nColor = "#40FF00" end 
    
    dxDrawRectangle( ( rx-205 ), ( ry-78 ), 199, 17, tocolor(0, 0, 0, 180), true) 
    dxDrawRectangle( ( rx-205 ), ( ry-54 ), 199, 17, tocolor(0, 0, 0, 180), true) 
    dxDrawRectangle( ( rx-205 ), ( ry-30 ), 199, 17, tocolor(0, 0, 0, 180), true) 
    dxDrawText ( "#0080FFVelocidad: #FFFFFF"..kColor..""..tostring(kphSpeed).." #FF8000Kmh #0080FF/ "..mColor..""..tostring(mphSpeed).." #FF8000Mph", ( rx - 199 ), ( ry - 77 ), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1,"default-bold", "left", "top", false, false, true, true, false ) 
    dxDrawText ( "#0080FFVehiculo: #FFFFFF".. hColor ..""..tostring(currenthealth).."#0080FF% #FF8000| #0080FF"..tostring(name).."", ( rx - 199 ), ( ry - 53 ), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1,"default-bold", "left", "top", false, false, true, true, false ) 
    dxDrawText ( "#0080FFNitro: #40FF00".. nColor ..""..( type ( fNitroLevel ) == "number" and fNitroLevel .."#0080FF%" or "#FF8000Sin nitro" ), (rx - 199 ), ( ry - 29), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1, "default-bold", "left", "top", false, false, true, true, false ) 
end 
addEventHandler ( "onClientRender", root, vehiclestatus ) 

*Edit: Creo que esta mal o le falta algo :c

Link to comment
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...