Jump to content

Help


Flipi

Recommended Posts

hi, how do i fix this problem? (nitro)

how to change the word false? and how do I remove the decimals? (nitro)

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

screen2: 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
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 = "#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".. ( type ( fNitroLevel ) == "number" and fNitroLevel .."#0080FF%" or "No 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

you will need to do some maths, the percentage goes over 100, the car colours over 255. (since you got the variable already you will only need to do the car colour.)

probably:

//EDIT:

  
setTimer(function() 
local r, g, b = ( fNitroLevel*2.5, fNitroLevel/2.5, [fNitroLevel*3]/4 ) 
setVehicleColor( car, r, g, b ) 
 end, 500, 0) 
  

Edited by Guest
Link to comment
That's not what he wants, he wants to change the color of the text.

he got a local on that already so..

  
    dxDrawText ( "#0080FFNitro:  [size=6][b]..hColor..[/b][/size]".. ( type ( fNitroLevel ) == "number" and fNitroLevel .."#0080FF%" or "No nitro" ), (rx - 199 ), ( ry - 29), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1, "default-bold", "left", "top", false, false, true, true, false ) 
  

Link to comment
That's not what he wants, he wants to change the color of the text.

he got a local on that already so..

  
    dxDrawText ( "#0080FFNitro:  [size=6][b]..hColor..[/b][/size]".. ( type ( fNitroLevel ) == "number" and fNitroLevel .."#0080FF%" or "No nitro" ), (rx - 199 ), ( ry - 29), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1, "default-bold", "left", "top", false, false, true, true, false ) 
  

I tried, but the problem is that the vehicle stats appears when you activate the nitro and disappears the vehicle stats when disable the nitro.

Link to comment
That's not what he wants, he wants to change the color of the text.

he got a local on that already so..

  
    dxDrawText ( "#0080FFNitro:  [size=6][b]..hColor..[/b][/size]".. ( type ( fNitroLevel ) == "number" and fNitroLevel .."#0080FF%" or "No nitro" ), (rx - 199 ), ( ry - 29), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1, "default-bold", "left", "top", false, false, true, true, false ) 
  

Yeah, but that'll use the same color as the health bar, it won't matter if the nitro goes down, it'll use the health value to set the color.

Link to comment
That's not what he wants, he wants to change the color of the text.

he got a local on that already so..

  
    dxDrawText ( "#0080FFNitro:  [size=6][b]..hColor..[/b][/size]".. ( type ( fNitroLevel ) == "number" and fNitroLevel .."#0080FF%" or "No nitro" ), (rx - 199 ), ( ry - 29), 1280, 887, tocolor ( 255, 255, 255, 255 ), 1, "default-bold", "left", "top", false, false, true, true, false ) 
  

Yeah, but that'll use the same color as the health bar, it won't matter if the nitro goes down, it'll use the health value to set the color.

I tried the same thing, but the problem is that the vehicle stats only appears when activating the nitro

Link to comment
Post the new script code.

modified script:

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 ) 

Link to comment
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 ) ) 
        -- 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 
    else 
        nColor = "#ff0000" 
    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 
       
    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 ) 

Link to comment
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 ) ) 
        -- 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 
    else 
        nColor = "#ff0000" 
    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 
       
    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 ) 

the text does not change color :/

Link to comment

That's because you are overwritting the variable 'nColor'.

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 = "#40FF00" 
    local kColor = "#40FF00" 
    local mColor = "#40FF00" 
    local nColor = "#40FF00" 
    if ( type ( fNitroLevel ) == "number" ) then 
        fNitroLevel = math.floor ( ( fNitroLevel * 100 ) ) 
        -- 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 
    else 
        nColor = "#ff0000" 
    end 
  
    -- 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 ) 
    outputChatBox ( nColor ) 
    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 ) 

This one works ( tested ).

Link to comment
That's because you are overwritting the variable 'nColor'.
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 = "#40FF00" 
    local kColor = "#40FF00" 
    local mColor = "#40FF00" 
    local nColor = "#40FF00" 
    if ( type ( fNitroLevel ) == "number" ) then 
        fNitroLevel = math.floor ( ( fNitroLevel * 100 ) ) 
        -- 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 
    else 
        nColor = "#ff0000" 
    end 
  
    -- 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 ) 
    outputChatBox ( nColor ) 
    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 ) 

This one works ( tested ).

Wow thanks is working! :)

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

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