India Posted February 11, 2021 Share Posted February 11, 2021 I using vehicle hud script but when i get in a car this error given: [ERROR]: attempt to concatenate local 'needengine' (a boolean value) function updateIcons() if getElementData(getLocalPlayer(), "logedin") then if fading >= 0 and fading2 == "up" then fading = fading + 5 elseif fading <= 255 and fading2 == "down" then fading = fading - 5 end if fading == 0 then fading2 = "up" elseif fading == 255 then fading2 = "down" end local veh = getPedOccupiedVehicle (getLocalPlayer()) if veh then local maxfuel = getElementData(veh,"maxfuel") local fuel = getElementData(getElementData(veh,"parent"),"fuel") local needengine = getElementData(veh,"needengine") local needtires = getElementData(veh,"needtires") local needparts = getElementData(veh,"needparts") local engine = getElementData(getElementData(veh,"parent"),"Engine_inVehicle") or 0 local tires = getElementData(getElementData(veh,"parent"),"Tire_inVehicle") or 0 local parts = getElementData(getElementData(veh,"parent"),"Parts_inVehicle") or 0 local offset = dxGetFontHeight(1.02,"default-bold") local healt = getElementHealth(veh)/10 local w = dxGetTextWidth(engine.."/"..needengine.." Motor",1.02,"default-bold") -- HERE IS given ERROR :29: --if needengine,needparts,needmetal,needtires ~= false or nil then if engine == needengine then dxDrawRectangle(60, 214, 60, 13, tocolor(101,188,69, 255)) -- ENG dxDrawText ("Motor:"..engine.."/"..needengine,63,214,5,5,tocolor ( 0,0,0, 231 ), 0.9, "default-bold" ) r,g,b = 209,252,115 else dxDrawRectangle(60, 214, 60, 13, tocolor(255,0,0, fading)) -- ENG dxDrawText ("Motor:"..engine.."/"..needengine,63,214,5,5,tocolor ( 0,0,0, fading ), 0.9, "default-bold" ) r,g,b = 255,0,0 end Link to comment
Tekken Posted February 11, 2021 Share Posted February 11, 2021 Replace needengine with (needengine or 0) 1 Link to comment
India Posted February 11, 2021 Author Share Posted February 11, 2021 1 hour ago, Tekken said: Replace needengine with (needengine or 0) Yea thanks, its fixed and new problem is attempt to perform arithmetic on local 'maxfuel' (a boolean value) line starts: elseif fuel <= maxfuel/10 then if fuel == maxfuel then dxDrawRectangle(16, 214, 10, 115, tocolor(100,252,115, 250), true) --100% elseif getElementData(getElementData(veh,"parent"),"fuel") <= 0 then setVehicleEngineState(veh, false) dxDrawRectangle(16, 315, 10, 14.5, tocolor(255,0,0, 120), true) --20% elseif fuel <= maxfuel/10 then dxDrawRectangle(16, 315, 10, 14.5, tocolor(250,0,0, 140), true) --20% elseif fuel <= maxfuel/4 then dxDrawRectangle(16, 308, 10, 19, tocolor(225,25,0, 160), true) --20% elseif fuel <= maxfuel/3 then dxDrawRectangle(16, 308, 10, 19, tocolor(200,50,0, 180), true) --20% elseif fuel <= maxfuel/2 then dxDrawRectangle(16, 290, 10, 39, tocolor(175,100,0, 200), true) --40% elseif fuel <= maxfuel/1.5 then dxDrawRectangle(16, 251, 10, 76, tocolor(150,150,0, 220), true) --80% elseif fuel <= maxfuel/0 then dxDrawRectangle(16, 233, 10, 95, tocolor(125,200,0, 240), true) --90% end Link to comment
India Posted February 11, 2021 Author Share Posted February 11, 2021 (edited) 1 hour ago, Tekken said: You do the same if i do same, the fuel gauge does not decrease, remains stable, i do this if fuel == maxfuel or 0 then Edited February 11, 2021 by India Link to comment
Tekken Posted February 11, 2021 Share Posted February 11, 2021 That’s because or 0 will return 0 Something is wrong with your getVehicleAddonsInfo function 1 Link to comment
India Posted February 11, 2021 Author Share Posted February 11, 2021 1 hour ago, Tekken said: That’s because or 0 will return 0 Something is wrong with your getVehicleAddonsInfo function Hm, im sorry i forgot to share this local maxfuel = getElementData(veh, "maxfuel") and now its fixed, thanks for your help local maxfuel = getElementData(veh, "maxfuel") or 0 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