Jump to content

DayZ - code to car spawn


wgnsy123

Recommended Posts

Hello guys, i have a problem...

I have code to spawn SWAT car in server DayZ - Ok, car is spawning, but at the top of the screen does not text "Fuel x/60"

And i have second problem - i cant put Engine/Tank Parts/Tires to my added car...

Help please ;/

Code of "vehicle_spawns.lua" - my lua file

spawnyPojazdow={ 
      {601, 122.98459625244,2066.1225585938,16.934089660645, 2, 0, 50}, 
} 
for i,v in ipairs(spawnyPojazdow) do 
        veh = createVehicle(v[1], v[2], v[3], v[4]) 
        vehCol = createColSphere(v[2], v[3], v[4], 1.5) 
        attachElements (vehCol, veh, 0, 0, 0 ) 
        setElementData(vehCol,"parent",veh) 
        setElementData(veh,"parent",vehCol) 
        setElementData(vehCol,"vehicle",true) 
        setElementData(vehCol,"MAX_Slots",80) 
        --Engine + Tires 
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh)) 
        setElementData(vehCol,"Tire_inVehicle",math.random(v[5],tires)) 
        setElementData(vehCol,"Engine_inVehicle",math.random(v[6],engine)) 
        setElementData(vehCol,"Parts_inVehicle",math.random(v[7],parts)) 
        --vehicle_indentifikation 
        setElementData(vehCol,"spawn",{v[1], v[2], v[3], v[4]}) 
        --others 
        setElementData(vehCol, "fuel",60) 
    end 

Link to comment
  
spawnyPojazdow={ 
      {601, 122.98459625244,2066.1225585938,16.934089660645, 2, 0, 50}, 
} 
for i,v in ipairs(spawnyPojazdow) do 
        veh = createVehicle(v[1], v[2], v[3], v[4]) 
        vehCol = createColSphere(v[2], v[3], v[4], 1.5) 
        attachElements (vehCol, veh, 0, 0, 0 ) 
        setElementData(vehCol,"parent",veh) 
        setElementData(veh,"parent",vehCol) 
        setElementData(vehCol,"vehicle",true) 
        setElementData(vehCol,"MAX_Slots",80) 
        --Engine + Tires 
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh)) 
        setElementData(veh,"Tire_inVehicle",math.random(v[5],tires)) 
        setElementData(veh,"Engine_inVehicle",math.random(v[6],engine)) 
        setElementData(veh,"Parts_inVehicle",math.random(v[7],parts)) 
        --vehicle_indentifikation 
        setElementData(veh,"spawn",{v[1], v[2], v[3], v[4]}) 
        --others 
        setElementData(veh, "fuel",60) 
    end 
  
  
  
  

try it

Link to comment
  • 2 weeks later...

I create new lua file - name: "vehicles_spawn.lua"

And i write this in the file:

spawnyPojazdow={ 
      {601, 122.98459625244,2066.1225585938,16.934089660645, 2, 0, 50}, 
} 
for i,v in ipairs(spawnyPojazdow) do 
        veh = createVehicle(v[1], v[2], v[3], v[4]) 
        vehCol = createColSphere(v[2], v[3], v[4], 1.5) 
        attachElements (vehCol, veh, 0, 0, 0 ) 
        setElementData(vehCol,"parent",veh) 
        setElementData(veh,"parent",vehCol) 
        setElementData(vehCol,"vehicle",true) 
        setElementData(vehCol,"MAX_Slots",80) 
        --Engine + Tires 
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh)) 
        setElementData(veh,"Tire_inVehicle",math.random(v[5],tires)) 
        setElementData(veh,"Engine_inVehicle",math.random(v[6],engine)) 
        setElementData(veh,"Parts_inVehicle",math.random(v[7],parts)) 
        --vehicle_indentifikation 
        setElementData(veh,"spawn",{v[1], v[2], v[3], v[4]}) 
        --others 
        setElementData(veh, "fuel",60) 
  end 
  local tires, engine, parts = getVehicleAddonInfos(id) 
  setVehicleEngineState(veh, false) 
  setElementData(veh, "maxfuel", getVehicleMaxFuel(col)) 
  setElementData(veh, "needtires", tires) 
  setElementData(veh, "needengines", engine) 
  setElementData(veh, "needparts", parts) 
  if (getElementData(col, "Tire_inVehicle") or 0) < tonumber(tires) then 
    setVehicleEngineState(veh, false) 
    return 
  end 
  if (getElementData(col, "Engine_inVehicle") or 0) < tonumber(engine) then 
    setVehicleEngineState(veh, false) 
    return 
  end 
  if not getElementData(col, "Parts_inVehicle") then 
    setElementData(col, "Parts_inVehicle", math.random(0, parts)) 
  end 
  if 1 >= (getElementData(col, "fuel") or 0) and not getElementModel(veh) == 509 then 
    triggerClientEvent(source, "displayClientInfo", source, "Vehicle", "No tank left in this vehicle!", 22, 255, 0) 
    setVehicleEngineState(veh, false) 
    return 
  end 
  setVehicleEngineState(veh, true) 
  bindKey(source, "k", "down", setEngineStateByPlayer) 
  outputChatBox("Press 'K' to turn the engine on/off!", source) 
end 

And i put code to meta.xml :

Link to comment

add this to your code

vehicleAddonsInfo = { 
  { 601,4,1, 1}, --Change this as you like 
} 
function getVehicleAddonInfos(id) 
  for i, veh in ipairs(vehicleAddonsInfo) do 
    if veh[1] == id then 
      return veh[2], veh[3], veh[4] 
    end 
  end 
end 
  
vehicleFuelInfo = { 
  {601, 0.25},--Change this as you like 
} 
function getVehicleAddonInfos(id) 
  for i, veh in ipairs(vehicleAddonsInfo) do 
    if veh[1] == id then 
      return veh[2], veh[3], veh[4] 
    end 
  end 
end 
vehicleFuelTable = { 
    {601, 100},--Change this as you like 
  
} 

Link to comment
Not working.

Show code with changes

Edit:

spawnyPojazdow={ 
      {601, 122.98459625244,2066.1225585938,16.934089660645, 2, 0, 50}, 
} 
for i,v in ipairs(spawnyPojazdow) do 
        veh = createVehicle(v[1], v[2], v[3], v[4]) 
        vehCol = createColSphere(v[2], v[3], v[4], 1.5) 
        attachElements (vehCol, veh, 0, 0, 0 ) 
        setElementData(vehCol,"parent",veh) 
        setElementData(veh,"parent",vehCol) 
        setElementData(vehCol,"vehicle",true) 
        setElementData(vehCol,"MAX_Slots",80) 
        --Engine + Tires 
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh)) 
        setElementData(veh,"Tire_inVehicle",math.random(v[5],tires)) 
        setElementData(veh,"Engine_inVehicle",math.random(v[6],engine)) 
        setElementData(veh,"Parts_inVehicle",math.random(v[7],parts)) 
        --vehicle_indentifikation 
        setElementData(veh,"spawn",{v[1], v[2], v[3], v[4]}) 
        --others 
        setElementData(veh, "fuel",60) 
  end 
  
vehicleAddonsInfo = { 
  { 
  601, 
    0, 
    1, 
    1 
  } 
} 
function getVehicleAddonInfos(id) 
  for i, veh in ipairs(vehicleAddonsInfo) do 
    if veh[1] == id then 
      return veh[2], veh[3], veh[4] 
    end 
  end 
end 
vehicleFuelInfo = { 
  {601, 0.1} 
} 
function getVehicleAddonInfos(id) 
  for i, veh in ipairs(vehicleAddonsInfo) do 
    if veh[1] == id then 
      return veh[2], veh[3], veh[4] 
    end 
  end 
end 
vehicleFuelTable = { 
  {601, 60} 
} 
function getVehicleMaxFuel(loot) 
  local modelID = getElementModel(getElementData(loot, "parent")) 
  for i, vehicle in ipairs(vehicleFuelTable) do 
    if modelID == vehicle[1] then 
      return vehicle[2] 
    end 
  end 
  return false 
end 
function onPlayerEnterDayzVehicle(veh, seat) 
  local col = getElementData(dayZVeh, "parent") 
  local id = getElementModel(dayZVeh) 
  if not seat == 1 then 
    return 
  end 
  local tires, engine, parts = getVehicleAddonInfos(id) 
  setVehicleEngineState(dayZVeh, false) 
  setElementData(dayZVeh, "maxfuel", getVehicleMaxFuel(col)) 
  setElementData(dayZVeh, "needtires", tires) 
  setElementData(dayZVeh, "needengines", engine) 
  setElementData(dayZVeh, "needparts", parts) 
  if getElementData(col, "Tire_inVehicle") or 0 < tonumber(tires) then 
    setVehicleEngineState(dayZVeh, false) 
    return 
  end 
  if getElementData(col, "Engine_inVehicle") or 0 < tonumber(engine) then 
    setVehicleEngineState(dayZVeh, false) 
    return 
  end 
  if not getElementData(col, "Parts_inVehicle") then 
    setElementData(col, "Parts_inVehicle", math.random(0, parts)) 
  end 
  if getElementData(col, "fuel") or 1 >= 0 and not getElementModel(dayZVehBob) == 509 then 
    triggerClientEvent(source, "displayClientInfo", source, "Vehicle", "No tank left in this vehicle!", 22, 255, 0) 
    setVehicleEngineState(dayZVehBob, false) 
    return 
  end 
end 

Link to comment
Not working.

well, when you cant add engine,tire, or tank parts, it's not vehicle_spawn problem, it's your inventory problem, double check your inventory

This is the fix :

spawnyPojazdow={ 
      {601, 122.98459625244,2066.1225585938,16.934089660645, 2, 0, 50}, 
} 
for i,v in ipairs(spawnyPojazdow) do 
        veh = createVehicle(v[1], v[2], v[3], v[4]) 
        vehCol = createColSphere(v[2], v[3], v[4], 1.5) 
        attachElements (vehCol, veh, 0, 0, 0 ) 
        setElementData(vehCol,"parent",veh) 
        setElementData(veh,"parent",vehCol) 
        setElementData(vehCol,"vehicle",true) 
        setElementData(vehCol,"MAX_Slots",80) 
        --Engine + Tires 
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh)) 
        setElementData(veh,"Tire_inVehicle",math.random(v[5],tires)) 
        setElementData(veh,"Engine_inVehicle",math.random(v[6],engine)) 
        setElementData(veh,"Parts_inVehicle",math.random(v[7],parts)) 
        --vehicle_indentifikation 
        setElementData(veh,"spawn",{v[1], v[2], v[3], v[4]}) 
        --others 
        setElementData(veh, "fuel",60) 
  end 
  
vehicleAddonsInfo = { 
  { 
  601, 
    0, 
    1, 
    1 
  } 
} 
function getVehicleAddonInfos(id) 
  for i, veh in ipairs(vehicleAddonsInfo) do 
    if veh[1] == id then 
      return veh[2], veh[3], veh[4] 
    end 
  end 
end 
vehicleFuelInfo = { 
  {601, 0.1} 
} 
function getVehicleAddonInfos(id) 
  for i, veh in ipairs(vehicleAddonsInfo) do 
    if veh[1] == id then 
      return veh[2], veh[3], veh[4] 
    end 
  end 
end 
vehicleFuelTable = { 
  {601, 60} 
} 
function getVehicleMaxFuel(loot) 
  local modelID = getElementModel(getElementData(loot, "parent")) 
  for i, vehicle in ipairs(vehicleFuelTable) do 
    if modelID == vehicle[1] then 
      return vehicle[2] 
    end 
  end 
  return false 
end 
function onPlayerEnterDayzVehicle(veh, seat) 
  local col = getElementData(dayZVeh, "parent") 
  local id = getElementModel(dayZVeh) 
  if not seat == 1 then 
    return 
  end 
  local tires, engine, parts = getVehicleAddonInfos(id) 
  setVehicleEngineState(dayZVeh, false) 
  setElementData(dayZVeh, "maxfuel", getVehicleMaxFuel(col)) 
  setElementData(dayZVeh, "needtires", tires) 
  setElementData(dayZVeh, "needengines", engine) 
  setElementData(dayZVeh, "needparts", parts) 
  if getElementData(col, "Tire_inVehicle") or 0 < tonumber(tires) then 
    setVehicleEngineState(dayZVeh, false) 
    return 
  end 
  if getElementData(col, "Engine_inVehicle") or 0 < tonumber(engine) then 
    setVehicleEngineState(dayZVeh, false) 
    return 
  end 
  if not getElementData(col, "Parts_inVehicle") then 
    setElementData(col, "Parts_inVehicle", math.random(0, parts)) 
  end 
  if getElementData(col, "fuel") or 1 >= 0 and not getElementModel(dayZVehBob) == 509 then 
    triggerClientEvent(source, "displayClientInfo", source, "Vehicle", "No tank left in this vehicle!", 22, 255, 0) 
    setVehicleEngineState(dayZVehBob, false) 
    return 
  end 
end 

Link to comment

Its your code:

spawnyPojazdow={ 
      {601, 122.98459625244,2066.1225585938,16.934089660645, 2, 0, 50}, 
} 
for i,v in ipairs(spawnyPojazdow) do 
        veh = createVehicle(v[1], v[2], v[3], v[4]) 
        vehCol = createColSphere(v[2], v[3], v[4], 1.5) 
        attachElements (vehCol, veh, 0, 0, 0 ) 
        setElementData(vehCol,"parent",veh) 
        setElementData(veh,"parent",vehCol) 
        setElementData(vehCol,"vehicle",true) 
        setElementData(vehCol,"MAX_Slots",80) 
        --Engine + Tires 
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh)) 
        setElementData(veh,"Tire_inVehicle",math.random(v[5],tires)) 
        setElementData(veh,"Engine_inVehicle",math.random(v[6],engine)) 
        setElementData(veh,"Parts_inVehicle",math.random(v[7],parts)) 
        --vehicle_indentifikation 
        setElementData(veh,"spawn",{v[1], v[2], v[3], v[4]}) 
        --others 
        setElementData(veh, "fuel",60) 
  end 
  
vehicleAddonsInfo = { 
  { 
  601, 
    0, 
    1, 
    1 
  } 
} 
function getVehicleAddonInfos(id) 
  for i, veh in ipairs(vehicleAddonsInfo) do 
    if veh[1] == id then 
      return veh[2], veh[3], veh[4] 
    end 
  end 
end 
vehicleFuelInfo = { 
  {601, 0.1} 
} 
function getVehicleAddonInfos(id) 
  for i, veh in ipairs(vehicleAddonsInfo) do 
    if veh[1] == id then 
      return veh[2], veh[3], veh[4] 
    end 
  end 
end 
vehicleFuelTable = { 
  {601, 60} 
} 
function getVehicleMaxFuel(loot) 
  local modelID = getElementModel(getElementData(loot, "parent")) 
  for i, vehicle in ipairs(vehicleFuelTable) do 
    if modelID == vehicle[1] then 
      return vehicle[2] 
    end 
  end 
  return false 
end 
function onPlayerEnterDayzVehicle(veh, seat) 
  local col = getElementData(dayZVeh, "parent") 
  local id = getElementModel(dayZVeh) 
  if not seat == 1 then 
    return 
  end 
  local tires, engine, parts = getVehicleAddonInfos(id) 
  setVehicleEngineState(dayZVeh, false) 
  setElementData(dayZVeh, "maxfuel", getVehicleMaxFuel(col)) 
  setElementData(dayZVeh, "needtires", tires) 
  setElementData(dayZVeh, "needengines", engine) 
  setElementData(dayZVeh, "needparts", parts) 
  if getElementData(col, "Tire_inVehicle") or 0 < tonumber(tires) then 
    setVehicleEngineState(dayZVeh, false) 
    return 
  end 
  if getElementData(col, "Engine_inVehicle") or 0 < tonumber(engine) then 
    setVehicleEngineState(dayZVeh, false) 
    return 
  end 
  if not getElementData(col, "Parts_inVehicle") then 
    setElementData(col, "Parts_inVehicle", math.random(0, parts)) 
  end 
  if getElementData(col, "fuel") or 1 >= 0 and not getElementModel(dayZVehBob) == 509 then 
    triggerClientEvent(source, "displayClientInfo", source, "Vehicle", "No tank left in this vehicle!", 22, 255, 0) 
    setVehicleEngineState(dayZVehBob, false) 
    return 
  end 
end 

Link to comment
Its your code:
spawnyPojazdow={ 
      {601, 122.98459625244,2066.1225585938,16.934089660645, 2, 0, 50}, 
} 
for i,v in ipairs(spawnyPojazdow) do 
        veh = createVehicle(v[1], v[2], v[3], v[4]) 
        vehCol = createColSphere(v[2], v[3], v[4], 1.5) 
        attachElements (vehCol, veh, 0, 0, 0 ) 
        setElementData(vehCol,"parent",veh) 
        setElementData(veh,"parent",vehCol) 
        setElementData(vehCol,"vehicle",true) 
        setElementData(vehCol,"MAX_Slots",80) 
        --Engine + Tires 
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh)) 
        setElementData(veh,"Tire_inVehicle",math.random(v[5],tires)) 
        setElementData(veh,"Engine_inVehicle",math.random(v[6],engine)) 
        setElementData(veh,"Parts_inVehicle",math.random(v[7],parts)) 
        --vehicle_indentifikation 
        setElementData(veh,"spawn",{v[1], v[2], v[3], v[4]}) 
        --others 
        setElementData(veh, "fuel",60) 
  end 
  
vehicleAddonsInfo = { 
  { 
  601, 
    0, 
    1, 
    1 
  } 
} 
function getVehicleAddonInfos(id) 
  for i, veh in ipairs(vehicleAddonsInfo) do 
    if veh[1] == id then 
      return veh[2], veh[3], veh[4] 
    end 
  end 
end 
vehicleFuelInfo = { 
  {601, 0.1} 
} 
function getVehicleAddonInfos(id) 
  for i, veh in ipairs(vehicleAddonsInfo) do 
    if veh[1] == id then 
      return veh[2], veh[3], veh[4] 
    end 
  end 
end 
vehicleFuelTable = { 
  {601, 60} 
} 
function getVehicleMaxFuel(loot) 
  local modelID = getElementModel(getElementData(loot, "parent")) 
  for i, vehicle in ipairs(vehicleFuelTable) do 
    if modelID == vehicle[1] then 
      return vehicle[2] 
    end 
  end 
  return false 
end 
function onPlayerEnterDayzVehicle(veh, seat) 
  local col = getElementData(dayZVeh, "parent") 
  local id = getElementModel(dayZVeh) 
  if not seat == 1 then 
    return 
  end 
  local tires, engine, parts = getVehicleAddonInfos(id) 
  setVehicleEngineState(dayZVeh, false) 
  setElementData(dayZVeh, "maxfuel", getVehicleMaxFuel(col)) 
  setElementData(dayZVeh, "needtires", tires) 
  setElementData(dayZVeh, "needengines", engine) 
  setElementData(dayZVeh, "needparts", parts) 
  if getElementData(col, "Tire_inVehicle") or 0 < tonumber(tires) then 
    setVehicleEngineState(dayZVeh, false) 
    return 
  end 
  if getElementData(col, "Engine_inVehicle") or 0 < tonumber(engine) then 
    setVehicleEngineState(dayZVeh, false) 
    return 
  end 
  if not getElementData(col, "Parts_inVehicle") then 
    setElementData(col, "Parts_inVehicle", math.random(0, parts)) 
  end 
  if getElementData(col, "fuel") or 1 >= 0 and not getElementModel(dayZVehBob) == 509 then 
    triggerClientEvent(source, "displayClientInfo", source, "Vehicle", "No tank left in this vehicle!", 22, 255, 0) 
    setVehicleEngineState(dayZVehBob, false) 
    return 
  end 
end 

This is the full vehicles_spawn.lua ?

Edit: Next time cut the image right!

Edited by Guest
Link to comment
spawnyPojazdow={ 
      {601, 122.98459625244,2066.1225585938,16.934089660645, 2, 0, 50}, 
} 
for i,veh in ipairs(spawnyPojazdow) do 
        local x,y,z = veh[1],veh[2],veh[3] 
        veh = createVehicle(601,x,y,z) 
        vehCol = createColSphere(x,y,z,2) 
        attachElements ( vehCol, veh, 0, 0, 0 ) 
        setElementData(vehCol,"parent",veh) 
        setElementData(veh,"parent",vehCol) 
        setElementData(vehCol,"vehicle",true) 
        setElementData(vehCol,"MAX_Slots",0) 
        --Engine + Tires 
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh)) 
        setElementData(vehCol,"Tire_inVehicle",math.random(0,tires)) 
        setElementData(vehCol,"Engine_inVehicle",math.random(0,engine)) 
        setElementData(vehCol,"Parts_inVehicle",math.random(0,parts)) 
        --vehicle_indentifikation 
        setElementData(vehCol,"spawn",{601,x,y,z}) 
        --others 
        setElementData(vehCol,"fuel",0) 
  end 
  
vehicleAddonsInfo = { 
  { 
  601, 
    0, 
    1, 
    1 
  } 
} 
function getVehicleAddonInfos(id) 
  for i, veh in ipairs(vehicleAddonsInfo) do 
    if veh[1] == id then 
      return veh[2], veh[3], veh[4] 
    end 
  end 
end 
vehicleFuelInfo = { 
  {601, 0.1} 
} 
function getVehicleAddonInfos(id) 
  for i, veh in ipairs(vehicleAddonsInfo) do 
    if veh[1] == id then 
      return veh[2], veh[3], veh[4] 
    end 
  end 
end 
vehicleFuelTable = { 
  {601, 60} 
} 
function getVehicleMaxFuel(loot) 
  local modelID = getElementModel(getElementData(loot, "parent")) 
  for i, vehicle in ipairs(vehicleFuelTable) do 
    if modelID == vehicle[1] then 
      return vehicle[2] 
    end 
  end 
  return false 
end 
function onPlayerEnterDayzVehicle(veh, seat) 
  local col = getElementData(dayZVeh, "parent") 
  local id = getElementModel(dayZVeh) 
  if not seat == 1 then 
    return 
  end 
  local tires, engine, parts = getVehicleAddonInfos(id) 
  setVehicleEngineState(dayZVeh, false) 
  setElementData(dayZVeh, "maxfuel", getVehicleMaxFuel(col)) 
  setElementData(dayZVeh, "needtires", tires) 
  setElementData(dayZVeh, "needengines", engine) 
  setElementData(dayZVeh, "needparts", parts) 
  if getElementData(col, "Tire_inVehicle") or 0 < tonumber(tires) then 
    setVehicleEngineState(dayZVeh, false) 
    return 
  end 
  if getElementData(col, "Engine_inVehicle") or 0 < tonumber(engine) then 
    setVehicleEngineState(dayZVeh, false) 
    return 
  end 
  if not getElementData(col, "Parts_inVehicle") then 
    setElementData(col, "Parts_inVehicle", math.random(0, parts)) 
  end 
  if getElementData(col, "fuel") or 1 >= 0 and not getElementModel(dayZVehBob) == 509 then 
    triggerClientEvent(source, "displayClientInfo", source, "Vehicle", "No tank left in this vehicle!", 22, 255, 0) 
    setVehicleEngineState(dayZVehBob, false) 
    return 
  end 
end 

Link to comment
spawnyPojazdow={ 
      {601, 122.98459625244,2066.1225585938,16.934089660645, 2, 0, 50}, 
} 
function respawn() 
for i,veh in ipairs(spawnyPojazdow) do 
        local x,y,z = veh[1],veh[2],veh[3] 
        veh = createVehicle(601,x,y,z) 
        vehCol = createColSphere(x,y,z,2) 
        attachElements ( vehCol, veh, 0, 0, 0 ) 
        setElementData(vehCol,"parent",veh) 
        setElementData(veh,"parent",vehCol) 
        setElementData(vehCol,"vehicle",true) 
        setElementData(vehCol,"MAX_Slots",0) 
        --Engine + Tires 
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh)) 
        setElementData(vehCol,"Tire_inVehicle",math.random(0,tires)) 
        setElementData(vehCol,"Engine_inVehicle",math.random(0,engine)) 
        setElementData(vehCol,"Parts_inVehicle",math.random(0,parts)) 
        --vehicle_indentifikation 
        setElementData(vehCol,"spawn",{601,x,y,z}) 
        --others 
        setElementData(vehCol,"fuel",0) 
  end 
end 
addCommandHandler("spawn",respawn) --Use spawn to spanwn car  
  
vehicleAddonsInfo = { 
  { 
  601, 
    0, 
    1, 
    1 
  } 
} 
function getVehicleAddonInfos(id) 
  for i, veh in ipairs(vehicleAddonsInfo) do 
    if veh[1] == id then 
      return veh[2], veh[3], veh[4] 
    end 
  end 
end 
vehicleFuelInfo = { 
  {601, 0.1} 
} 
function getVehicleAddonInfos(id) 
  for i, veh in ipairs(vehicleAddonsInfo) do 
    if veh[1] == id then 
      return veh[2], veh[3], veh[4] 
    end 
  end 
end 
vehicleFuelTable = { 
  {601, 60} 
} 
function getVehicleMaxFuel(loot) 
  local modelID = getElementModel(getElementData(loot, "parent")) 
  for i, vehicle in ipairs(vehicleFuelTable) do 
    if modelID == vehicle[1] then 
      return vehicle[2] 
    end 
  end 
  return false 
end 
function onPlayerEnterDayzVehicle(veh, seat) 
  local col = getElementData(dayZVeh, "parent") 
  local id = getElementModel(dayZVeh) 
  if not seat == 1 then 
    return 
  end 
  local tires, engine, parts = getVehicleAddonInfos(id) 
  setVehicleEngineState(dayZVeh, false) 
  setElementData(dayZVeh, "maxfuel", getVehicleMaxFuel(col)) 
  setElementData(dayZVeh, "needtires", tires) 
  setElementData(dayZVeh, "needengines", engine) 
  setElementData(dayZVeh, "needparts", parts) 
  if getElementData(col, "Tire_inVehicle") or 0 < tonumber(tires) then 
    setVehicleEngineState(dayZVeh, false) 
    return 
  end 
  if getElementData(col, "Engine_inVehicle") or 0 < tonumber(engine) then 
    setVehicleEngineState(dayZVeh, false) 
    return 
  end 
  if not getElementData(col, "Parts_inVehicle") then 
    setElementData(col, "Parts_inVehicle", math.random(0, parts)) 
  end 
  if getElementData(col, "fuel") or 1 >= 0 and not getElementModel(dayZVehBob) == 509 then 
    triggerClientEvent(source, "displayClientInfo", source, "Vehicle", "No tank left in this vehicle!", 22, 255, 0) 
    setVehicleEngineState(dayZVehBob, false) 
    return 
  end 
end 

Use: /spawn

Edited by Guest
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...