1LoL1 Posted September 9, 2014 Share Posted September 9, 2014 Please anyone knows what is wrong? 360 - setElementData(vehCol,"fuel",10) Link to comment
Castillo Posted September 9, 2014 Share Posted September 9, 2014 That line is not the one giving the error, as it has no loop at all. Link to comment
1LoL1 Posted September 9, 2014 Author Share Posted September 9, 2014 That line is not the one giving the error, as it has no loop at all. When I write /svp so I wrote this Link to comment
Castillo Posted September 9, 2014 Share Posted September 9, 2014 Post the entire function code. Link to comment
1LoL1 Posted September 9, 2014 Author Share Posted September 9, 2014 I have this problem as here Url: https://forum.multitheftauto.com/viewtopic.php?f=91&t=70730&p=658173&hilit=tank+parts#p658173 And I wrote this Screen: Script: local veh = getPedOccupiedVehicle(getLocalPlayer()) if veh then local maxfuel = getElementData(veh, "maxfuel") local fuel = getElementData(getElementData(veh, "parent"), "fuel") local needengine = getElementData(veh, "needengines") 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 w = dxGetTextWidth(engine .. "/" .. needengine .. " Engine", 1.02, "default-bold") if engine == needengine then r, g, b = 0, 255, 0 else r, g, b = 255, 0, 0 end dxDrawText(engine .. "/" .. needengine .. " Engine", screenWidth * 0.5 - w / 2, screenHeight * 0, screenWidth * 0.5 - w / 2, screenHeight * 0, tocolor(r, g, b, 220), 1.02, "default-bold") local w = dxGetTextWidth(tires .. "/" .. needtires .. " Tires", 1.02, "default-bold") if tires == needtires then r, g, b = 0, 255, 0 else r, g, b = 255, 0, 0 end dxDrawText(tires .. "/" .. needtires .. " Tires", screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, tocolor(r, g, b, 220), 1.02, "default-bold") local w = dxGetTextWidth(tostring(parts).."/"..tostring(needparts).." Tank Parts",1.02,"default-bold") if parts == needparts then r, g, b = 0, 255, 0 else r, g, b = 255, 0, 0 end dxDrawText(tostring(parts).."/"..tostring(needparts).." Tank Parts", screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, tocolor(r, g, b, 220), 1.02, "default-bold") local w = dxGetTextWidth("Fuel:" .. math.floor(fuel) .. "/" .. maxfuel, 1.02, "default-bold") if fuel == maxfuel then r,g,b = 0,255,0 elseif fuel < maxfuel/10 then r,g,b = 255,0,0 elseif fuel < maxfuel/4 then r,g,b = 255,50,0 elseif fuel < maxfuel/3 then r,g,b = 200,100,0 elseif fuel < maxfuel/2 then r,g,b = 125,200,0 elseif fuel < maxfuel/1.5 then r,g,b = 50,200,0 end dxDrawText ("Fuel:"..math.floor(fuel).."/"..maxfuel,screenWidth*0.5-w/2 , screenHeight*0+offset*2,screenWidth*0.5-w/2 , screenHeight*0+offset*2,tocolor ( r,g,b, 220 ), 1.02, "default-bold" ) end And here I wrote a mistake .. if engine == needengine then Link to comment
1LoL1 Posted September 9, 2014 Author Share Posted September 9, 2014 And this he enters a car.. setElementData(vehCol,"Parts_inVehicle",math.random(0,parts)) And yet this writing me when I write /svp if ((getElementData(col,"Parts_inVehicle") or 0) < tonumber(parts)) then Please help someone Link to comment
Anubhav Posted September 9, 2014 Share Posted September 9, 2014 And this he enters a car.. setElementData(vehCol,"Parts_inVehicle",math.random(0,parts)) And yet this writing me when I write /svp if ((getElementData(col,"Parts_inVehicle") or 0) < tonumber(parts)) then Please help someone 1. setElementData(vehCol, "Parts_inVehicle", math.random(0, tonumber(parts)) 2. The element data wasn't set so yes. It will be set if my codes work. Link to comment
1LoL1 Posted September 10, 2014 Author Share Posted September 10, 2014 local veh = getPedOccupiedVehicle(getLocalPlayer()) if veh then local maxfuel = getElementData(veh, "maxfuel") local fuel = getElementData(getElementData(veh, "parent"), "fuel") local needengine = getElementData(veh, "needengines") 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 w = dxGetTextWidth(tostring(engine) .. "/" .. tostring(needengine) .. " Engine", 1.02, "default-bold") if engine == needengine then r, g, b = 0, 255, 0 else r, g, b = 255, 0, 0 end dxDrawText(tostring(engine) .. "/" .. tostring(needengine) .. " Engine", screenWidth * 0.5 - w / 2, screenHeight * 0, screenWidth * 0.5 - w / 2, screenHeight * 0, tocolor(r, g, b, 220), 1.02, "default-bold") local w = dxGetTextWidth(tostring(tires) .. "/" .. tostring(needtires) .. " Tires", 1.02, "default-bold") if tires == needtires then r, g, b = 0, 255, 0 else r, g, b = 255, 0, 0 end dxDrawText(tostring(tires) .. "/" .. tostring(needtires) .. " Tires", screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, tocolor(r, g, b, 220), 1.02, "default-bold") local w = dxGetTextWidth(tostring(parts) .. "/" .. tostring(needparts) .. " Tank Parts", 1.02, "default-bold") if parts == needparts then r, g, b = 0, 255, 0 else r, g, b = 255, 0, 0 end dxDrawText(tostring(parts).."/"..tostring(needparts).." Tank Parts", screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, tocolor(r, g, b, 220), 1.02, "default-bold") local w = dxGetTextWidth("Fuel:" .. math.floor(fuel) .. "/" .. maxfuel, 1.02, "default-bold") if fuel == maxfuel then r,g,b = 0,255,0 elseif fuel < maxfuel/10 then r,g,b = 255,0,0 elseif fuel < maxfuel/4 then r,g,b = 255,50,0 elseif fuel < maxfuel/3 then r,g,b = 200,100,0 elseif fuel < maxfuel/2 then r,g,b = 125,200,0 elseif fuel < maxfuel/1.5 then r,g,b = 50,200,0 end dxDrawText ("Fuel:"..math.floor(fuel).."/"..maxfuel,screenWidth*0.5-w/2 , screenHeight*0+offset*2,screenWidth*0.5-w/2 , screenHeight*0+offset*2,tocolor ( r,g,b, 220 ), 1.02, "default-bold" ) end so to me it shows And here is the error: ToString everywhere I put everything I have done according Engine. Link to comment
1LoL1 Posted September 10, 2014 Author Share Posted September 10, 2014 Please help me Link to comment
1LoL1 Posted September 10, 2014 Author Share Posted September 10, 2014 Please help me I want to add only tank parts Link to comment
Anubhav Posted September 11, 2014 Share Posted September 11, 2014 That means you never had set the value. Link to comment
1LoL1 Posted September 11, 2014 Author Share Posted September 11, 2014 That means you never had set the value. And you know to fix it? Link to comment
Anubhav Posted September 11, 2014 Share Posted September 11, 2014 Please check if you have set the value to vehicle. Link to comment
1LoL1 Posted September 12, 2014 Author Share Posted September 12, 2014 Please check if you have set the value to vehicle. Where? line? Link to comment
Anubhav Posted September 12, 2014 Share Posted September 12, 2014 Wherever you set the value. Link to comment
1LoL1 Posted September 15, 2014 Author Share Posted September 15, 2014 Someone please help? Link to comment
Castillo Posted September 15, 2014 Share Posted September 15, 2014 local veh = getPedOccupiedVehicle(getLocalPlayer()) if veh then local maxfuel = getElementData(veh, "maxfuel") or 0 local fuel = getElementData(getElementData(veh, "parent"), "fuel") or 0 local needengine = getElementData(veh, "needengines") 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 w = dxGetTextWidth(tostring(engine) .. "/" .. tostring(needengine) .. " Engine", 1.02, "default-bold") if engine == needengine then r, g, b = 0, 255, 0 else r, g, b = 255, 0, 0 end dxDrawText(tostring(engine) .. "/" .. tostring(needengine) .. " Engine", screenWidth * 0.5 - w / 2, screenHeight * 0, screenWidth * 0.5 - w / 2, screenHeight * 0, tocolor(r, g, b, 220), 1.02, "default-bold") local w = dxGetTextWidth(tostring(tires) .. "/" .. tostring(needtires) .. " Tires", 1.02, "default-bold") if tires == needtires then r, g, b = 0, 255, 0 else r, g, b = 255, 0, 0 end dxDrawText(tostring(tires) .. "/" .. tostring(needtires) .. " Tires", screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, tocolor(r, g, b, 220), 1.02, "default-bold") local w = dxGetTextWidth(tostring(parts) .. "/" .. tostring(needparts) .. " Tank Parts", 1.02, "default-bold") if parts == needparts then r, g, b = 0, 255, 0 else r, g, b = 255, 0, 0 end dxDrawText(tostring(parts).."/"..tostring(needparts).." Tank Parts", screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, tocolor(r, g, b, 220), 1.02, "default-bold") local w = dxGetTextWidth("Fuel:" .. math.floor(fuel) .. "/" .. maxfuel, 1.02, "default-bold") if fuel == maxfuel then r,g,b = 0,255,0 elseif fuel < maxfuel/10 then r,g,b = 255,0,0 elseif fuel < maxfuel/4 then r,g,b = 255,50,0 elseif fuel < maxfuel/3 then r,g,b = 200,100,0 elseif fuel < maxfuel/2 then r,g,b = 125,200,0 elseif fuel < maxfuel/1.5 then r,g,b = 50,200,0 end dxDrawText ("Fuel:"..math.floor(fuel).."/"..maxfuel,screenWidth*0.5-w/2 , screenHeight*0+offset*2,screenWidth*0.5-w/2 , screenHeight*0+offset*2,tocolor ( r,g,b, 220 ), 1.02, "default-bold" ) end Link to comment
1LoL1 Posted September 16, 2014 Author Share Posted September 16, 2014 local veh = getPedOccupiedVehicle(getLocalPlayer()) if veh then local maxfuel = getElementData(veh, "maxfuel") or 0 local fuel = getElementData(getElementData(veh, "parent"), "fuel") or 0 local needengine = getElementData(veh, "needengines") 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 w = dxGetTextWidth(tostring(engine) .. "/" .. tostring(needengine) .. " Engine", 1.02, "default-bold") if engine == needengine then r, g, b = 0, 255, 0 else r, g, b = 255, 0, 0 end dxDrawText(tostring(engine) .. "/" .. tostring(needengine) .. " Engine", screenWidth * 0.5 - w / 2, screenHeight * 0, screenWidth * 0.5 - w / 2, screenHeight * 0, tocolor(r, g, b, 220), 1.02, "default-bold") local w = dxGetTextWidth(tostring(tires) .. "/" .. tostring(needtires) .. " Tires", 1.02, "default-bold") if tires == needtires then r, g, b = 0, 255, 0 else r, g, b = 255, 0, 0 end dxDrawText(tostring(tires) .. "/" .. tostring(needtires) .. " Tires", screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, tocolor(r, g, b, 220), 1.02, "default-bold") local w = dxGetTextWidth(tostring(parts) .. "/" .. tostring(needparts) .. " Tank Parts", 1.02, "default-bold") if parts == needparts then r, g, b = 0, 255, 0 else r, g, b = 255, 0, 0 end dxDrawText(tostring(parts).."/"..tostring(needparts).." Tank Parts", screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, screenWidth * 0.5 - w / 2, screenHeight * 0 + offset, tocolor(r, g, b, 220), 1.02, "default-bold") local w = dxGetTextWidth("Fuel:" .. math.floor(fuel) .. "/" .. maxfuel, 1.02, "default-bold") if fuel == maxfuel then r,g,b = 0,255,0 elseif fuel < maxfuel/10 then r,g,b = 255,0,0 elseif fuel < maxfuel/4 then r,g,b = 255,50,0 elseif fuel < maxfuel/3 then r,g,b = 200,100,0 elseif fuel < maxfuel/2 then r,g,b = 125,200,0 elseif fuel < maxfuel/1.5 then r,g,b = 50,200,0 end dxDrawText ("Fuel:"..math.floor(fuel).."/"..maxfuel,screenWidth*0.5-w/2 , screenHeight*0+offset*2,screenWidth*0.5-w/2 , screenHeight*0+offset*2,tocolor ( r,g,b, 220 ), 1.02, "default-bold" ) end Already it looks a little better all the time but it's not Line: 1282 if engine == needengine then Line: 672 if ((setElementData(col,"Tire_inVehicle"), math.random (0, tonumber(tires)) then Link to comment
Saml1er Posted September 16, 2014 Share Posted September 16, 2014 if ((setElementData(col,"Tire_inVehicle"), math.random (0, tonumber(tires)) then to local num = tonumber(tires) if num and setElementData(col,"Tire_inVehicle", math.random (0, num) ) then Link to comment
1LoL1 Posted September 16, 2014 Author Share Posted September 16, 2014 if ((setElementData(col,"Tire_inVehicle"), math.random (0, tonumber(tires)) then to local num = tonumber(tires) if num and setElementData(col,"Tire_inVehicle", math.random (0, num) ) then Tire, Engine already works but not tank parts and is even higher.. : And here's the error.. : Link to comment
Saml1er Posted September 16, 2014 Share Posted September 16, 2014 if ((setElementData(col,"Tire_inVehicle"), math.random (0, tonumber(tires)) then to local num = tonumber(tires) if num and setElementData(col,"Tire_inVehicle", math.random (0, num) ) then Tire, Engine already works but not tank parts and is even higher.. : And here's the error.. : maybe an end is missing, send me the function in pm. Link to comment
Castillo Posted September 23, 2014 Share Posted September 23, 2014 Did you do what Saml1er said? Link to comment
1LoL1 Posted September 29, 2014 Author Share Posted September 29, 2014 Did you do what Saml1er said? I sent it to him but he can not 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