Jump to content

[Help] Difference between Nitro Count and Level


BieHDC

Recommended Posts

Posted

Hello,

i have found an awesome Speedometer (https://community.multitheftauto.com/in ... ls&id=6951)

which is showing if nitro is intalled, but i wanna make it like the car health in the same resource.

The car icon in green when full live and red when low, but nitro not, so i searched for nitro functions and found this(https://wiki.multitheftauto.com/wiki/Ge ... NitroCount) and this(https://wiki.multitheftauto.com/wiki/Ge ... NitroLevel)

now i dont know what one is the right one :S

Here is the car and nitro part:

--car health 
function getCarStateColor() 
    local health = getElementHealth(vehicle) 
         
    if (health) then 
        local g = (255/1000) * health 
        local r = 255 - g 
        local b = 0 
      
        return r, g, b 
    else 
        return 0, 255, 0 
    end 
end 

--nitro part 
function getNitroStateColor()    
    local nitro = getVehicleUpgradeOnSlot(vehicle, 8 ) --added an space for shown right here in forum between 8 and ) 
      
    if (nitro > 0) then 
        return 0, 255, 0 
    else 
        return 75, 75, 75 
    end 
end 

Posted
--nitro part 
function getNitroStateColor()   
    local nitro = getVehicleUpgradeOnSlot(vehicle, 8 ) --added an space for shown right here in forum between 8 and ) 
  
      if nitro then 
  
 local level = getVehicleNitroLevel(vehicle)*100    -- *100 bk nitro level is returned as  0-1 
  
  if level > 25 then     -- green until nitro level is bigger that 25% 
        return 0, 255, 0 
    else 
        return 75, 75, 75 
    end 
end 
 end 

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

Posted

Error on line 7. here: attpemt to perform arithmetic on a boolean value

edit: stops if i add nitro to car

the biggest problem is now that the speedo is only correctly shown with nitro

(and i removed the space between 8 and ) )

Posted

it should work if you are in vehicle , space is not a problem (is ignored) , you can put 20 space's between 8 and ) and still work's

And that error has no seens , false is returned when the vehicle has no Nitro but he passed by the "getVehicleUpgradeOnSlot(vehicle, 8 )" so the vehicle must have Nitro.

Are you trying to get the nitroLevel of you own car(in witch you are in) or other car ?

Edit: that's wierd , "getVehicleUpgradeOnSlot(vehicle, 8 )" should stop the function when the care has no Nitro.

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

Posted

This code with colours is working, but if no nitro still error

isnt there somethig that if nil return something settet before? (tried but i dont gotta it work)

    --nitro part 
function getNitroStateColor()   
    local nitro = getVehicleUpgradeOnSlot(vehicle, 8 ) --added an space for shown right here in forum between 8 and ) 
      
      if nitro then 
        local level = getVehicleNitroLevel(vehicle)*100    -- *100 bk nitro level is returned as  0-1 
       
        if level == 100 then 
            return 0, 255, 0 
        elseif level < 100 and level > 75 then 
            return 128, 150, 0 
        elseif level < 75 and level > 50 then 
            return 255, 255, 0 
        elseif level < 50 and level > 25 then 
            return 255, 128, 0 
        elseif level < 25 and level > 5 then 
            return 255, 0, 0 
        elseif level < 5 then 
            return 75, 75, 75 
        end 
    end 
end 

Posted

Now sould work

    --nitro part 
function getNitroStateColor()   
  
      if getVehicleUpgradeOnSlot(vehicle, 8 ) then 
  
        local level = ( getVehicleNitroLevel(vehicle) or 0 )*100   
       
        if level == 100 then 
            return 0, 255, 0 
        elseif level < 100 and level > 75 then 
            return 128, 150, 0 
        elseif level < 75 and level > 50 then 
            return 255, 255, 0 
        elseif level < 50 and level > 25 then 
            return 255, 128, 0 
        elseif level < 25 and level > 5 then 
            return 255, 0, 0 
        elseif level < 5 then 
            return 75, 75, 75 
        end 
    end 
end 

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

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...