BieHDC Posted August 14, 2013 Share Posted August 14, 2013 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 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 Link to comment
bandi94 Posted August 14, 2013 Share Posted August 14, 2013 --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 Link to comment
BieHDC Posted August 14, 2013 Author Share Posted August 14, 2013 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 ) ) Link to comment
bandi94 Posted August 14, 2013 Share Posted August 14, 2013 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. Link to comment
BieHDC Posted August 14, 2013 Author Share Posted August 14, 2013 On own car because this will be for a dd and a dm server the problem is the speedo dont get sucessfully "built" if no nitro is added Link to comment
BieHDC Posted August 14, 2013 Author Share Posted August 14, 2013 Screenshotz http://www.bilder-upload.eu/show.php?file=3faf69-1376501762.png http://www.bilder-upload.eu/show.php?file=7df431-1376501784.png Link to comment
BieHDC Posted August 14, 2013 Author Share Posted August 14, 2013 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 Link to comment
bandi94 Posted August 14, 2013 Share Posted August 14, 2013 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 Link to comment
BieHDC Posted August 14, 2013 Author Share Posted August 14, 2013 yeah thx man if somebody want my and your speedo version of this ask me pm^ Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now