Jump to content

Please help me


1LoL1

Recommended Posts

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:

-___________________________-.png

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
And this he enters a car..

FFFFF.png

setElementData(vehCol,"Parts_inVehicle",math.random(0,parts)) 

And yet this writing me when I write /svp

svpp.png

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
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 :(

ERRoR.png

And here is the error:

ERRRooRS.png

ToString :( everywhere I put everything I have done according Engine.

Link to comment
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
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

F,T,E,T.png

ErrrrroSrS.png

Line: 1282

if engine == needengine then 

Line: 672

if ((setElementData(col,"Tire_inVehicle"), math.random (0, tonumber(tires)) then 

Link to comment
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.. :

HMMEHM.png

And here's the error.. :

First_ErroR.png

Link to comment
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.. :

HMMEHM.png

And here's the error.. :

First_ErroR.png

maybe an end is missing, send me the function in pm.

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