Jump to content

[Help]Dayz fix veh


dex.

Recommended Posts

So. I wanna do script if i type /fixveh he fix the vehicle+Adds all parts in car(tires,engine, etc...). How i should do it? 

 

    for i,veh in ipairs(MesaSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(500,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{500,x,y,z})
        setElementData(vehCol,"fuel",10)
    end

I put here how vehicles are made

Link to comment
4 minutes ago, Dimos7 said:

addCommandHandler("fixveh", function(player), false, false 
    if isPedInVehicle(player) then
      local veh = getPedOccupiedVehicle(player) 
      fixVehicle(veh) 
      end
   end) 

 

I know how to make this fixing script. But i need script to add tires, engine and tank part in also. :)

Link to comment
17 minutes ago, Dimos7 said:

What do you mean add like upgrade? 

Like. Cars don't have tires and stuff like that. but i if i type /fixveh i need to add tires in to car.  

Edited by dex.
Link to comment
local tires = getElementData(vehicle, "needtires")
local engines = getElementData(vehicle, "needengines")
local rotaries = getElementData(vehicle, "needrotary")
local parts = getElementData(vehicle, "needparts")

local col = getElementData(vehicle, "parent")
setElementData(col, "Tire_inVehicle", tires)
setElementData(col, "Engine_inVehicle", engines)
setElementData(col, "Rotary_inVehicle", rotaries)
setElementData(col, "Parts_inVehicle", parts)

-- Should work but untested.
-- Based on latest version of the gamemode. https://github.com/NullSystemWorks/mtadayz/blob/master/DayZ/handlers/vehicles/server/actions_vehicles.lua#L16-L40

 

Link to comment
23 minutes ago, MrTasty said:

local tires = getElementData(vehicle, "needtires")
local engines = getElementData(vehicle, "needengines")
local rotaries = getElementData(vehicle, "needrotary")
local parts = getElementData(vehicle, "needparts")

local col = getElementData(vehicle, "parent")
setElementData(col, "Tire_inVehicle", tires)
setElementData(col, "Engine_inVehicle", engines)
setElementData(col, "Rotary_inVehicle", rotaries)
setElementData(col, "Parts_inVehicle", parts)

-- Should work but untested.
-- Based on latest version of the gamemode. https://github.com/NullSystemWorks/mtadayz/blob/master/DayZ/handlers/vehicles/server/actions_vehicles.lua#L16-L40

 

Not working, im using 0.5.5a. That oldschool one :) I put here my whole script

MesaSpawns = gameplayVariables["Mesaspawns"]

RancherSpawns = gameplayVariables["Rancherspawns"]

ReginaSpawns = gameplayVariables["Reginaspawns"]

MoonbeamSpawns = gameplayVariables["Moonbeamspawns"]

BulletSpwans = gameplayVariables["Bulletspwans"]

TrashmasterSpawns = gameplayVariables["Trashmasterspawns"]

WashingtonSpawns = gameplayVariables["Washingtonspawns"]

Hunter1Spawns = gameplayVariables["Hunter1spawns"]

CabbieSpawns = gameplayVariables["Cabbiespawns"]

PackerSpawns = gameplayVariables["Packerspawns"]

AdmiralSpawns = gameplayVariables["Admiralspawns"]

SeasparrowSpawns = gameplayVariables["Seasparrowspawns"]

LandstalkerSpawns = gameplayVariables["Landstalkerspawns"]

BravuraSpawns = gameplayVariables["Bravuraspawns"]

SultanSpawns = gameplayVariables["Sultanspawns"]

CometSpawns = gameplayVariables["Cometspawns"]

HotringSpawns = gameplayVariables["Hotringspawns"]

BuffaloSpawns = gameplayVariables["Buffalospawns"]

LinerunnerSpawns = gameplayVariables["Linerunnerspawns"]

PerennielSpawns = gameplayVariables["Perennielspawns"]

SentinelSpawns = gameplayVariables["Sentinelspawns"]

DumperSpawns = gameplayVariables["Dumperspawns"]

MananaSpawns = gameplayVariables["Mananaspawns"]

InfernusSpawns = gameplayVariables["Infernusspawns"]

MuleSpawns = gameplayVariables["Mulespawns"]

AmbulanceSpawns = gameplayVariables["Ambulancespawns"]

LeviathanSpawns = gameplayVariables["Leviathanspawns"]

TaxiSpawns = gameplayVariables["Taxispawns"]

PremierSpawns = gameplayVariables["Premierspawns"]

EnforcerSpawns = gameplayVariables["Enforcerspawns"]

TurismoSpawns = gameplayVariables["Turismospawns"]

PCJSpawns = gameplayVariables["PCJspawns"]

FreewaySpawns = gameplayVariables["Freewayspawns"]

QuadSpawns = gameplayVariables["Quadspawns"]

DinghySpawns = gameplayVariables["Dinghyspawns"]

WaltonSpawns = gameplayVariables["Waltonspawns"]

BurritoSpawns = gameplayVariables["Burritospawns"]

CamperSpawns = gameplayVariables["Camperspawns"]

NewsMaverickSpawns = gameplayVariables["NewsMaverickspawns"]

FBIRanchersSpawns = gameplayVariables["FBIRancherspawns"]

SandkingSpawns = gameplayVariables["Sandkingspawns"]

BloodringBangerSpawns = gameplayVariables["BloodringBangerspawns"]

SuperGTSpawns = gameplayVariables["SuperGTspawns"]

ShamalSpawns = gameplayVariables["Shamalspawns"]

HPV1000Spawns = gameplayVariables["HPV1000spawns"]

NRGSpawns = gameplayVariables["NRGspawns"]

TowtruckSpawns = gameplayVariables["Towtruckspawns"]

TractorSpawns = gameplayVariables["Tractorspawns"]

hunterSpawns = gameplayVariables["hunterspawns"]

pickupSpawns = gameplayVariables["pickupspawns"]

patriotSpawns = gameplayVariables["patriotspawns"]

sanchezSpanws = gameplayVariables["sanchezspawns"]

barracksSpawns = gameplayVariables["barracksspawns"]

coachSpawns = gameplayVariables["coachspawns"]

fisherBootSpawns = gameplayVariables["fisherboatspawns"]

bikeSpawns = gameplayVariables["bikespawns"]

maverikSpawns = gameplayVariables["maverickspawns"]

tentSpawns = gameplayVariables["tentsspawns"]

heliCrashSites = gameplayVariables["helicrashsides"]

hospitalPacks = {

{315.29998779297,484.79998779297,1},
{319.89999389648,494.79998779297,1},
{-2670.87890625,636.8984375,14.453125},
{-2637.0556640625,635.03125,14.453125},
{-1515.669921875,2519.166015625,56.0703125},
{-1513.888671875,2519.5908203125,56.064819335938},
{-1528.8955078125,2516.724609375,55.986171722412},
{2022.1650390625,-1402.6806640625,17.18045425415},
{2042.7001953125,-1409.4775390625,17.1640625},
{-316.5478515625,1051.6494140625,20.340259552002},
{-337.9541015625,1049.490234375,19.739168167114},
{-331.5849609375,1046.037109375,26.012474060059},
{-307.0419921875,1045.27734375,26.012474060059},
{1171.490234375,-1310.560546875,13.986573219299},
{1171.609375,-1306.556640625,13.996350288391},
{1158.5048828125,-1326.333984375,31.503561019897},
{1159.80078125,-1323.9013671875,31.498970031738},
{1238.7119140625,328.2431640625,19.7555103302},
{1229.365234375,311.1435546875,24.7578125},
{-2204.07421875,-2309.58203125,31.375},
{1615.939453125,1818.0537109375,10.8203125},
{1601.9443359375,1816.736328125,10.8203125},
{1590.0166015625,1792.0234375,30.46875},
{1607.3232421875,1776.7412109375,37.3125},
{2107.7626953125,926.16015625,10.8203125},
{2116.12890625,925.7705078125,10.9609375},
{2122.1865234375,925.3193359375,10.8203125},
}

patrolPoints = {

{-1603.2197265625,-2712.736328125,48.9453125},
{319.39999389648,518.40002441406,0.60000002384186},
{321,513.29998779297,0.60000002384186},
{317.29998779297,523,0.60000002384186},
{315.79998779297,528,0.60000002384186},
{2465.748046875,-2215.55859375,13.546875},
{2473.439453125,-2215.56640625,13.546875},
{2480.0732421875,-2216.140625,13.546875},
{2487.24609375,-2215.5966796875,13.546875},
{2494.1005859375,-2215.5859375,13.546875},
{-1686.6728515625,408.9970703125,7.3984375},
{-1682.34375,412.9384765625,7.3984375},
{-1680.0263671875,402.3642578125,7.3984375},
{-1675.84375,406.4677734375,7.3984375},
{-1670.5615234375,411.8359375,7.3984375},
{-1666.2392578125,416.2509765625,7.3984375},
{-1672.7939453125,422.81640625,7.3984375},
{-1677.20703125,418.46484375,7.3984375},
{-2410.7021484375,969.9091796875,45.4609375},
{-2410.744140625,975.220703125,45.4609375},
{-2410.837890625,980.5302734375,45.4609375},
{-1329.3046875,2668.5126953125,50.46875},
{-1328.7314453125,2673.90625,50.0625},
{-1327.0185546875,2679.3876953125,50.46875},
{-1327.3798828125,2684.62890625,50.0625},
{1940.7099609375,-1778.5244140625,13.390598297119},
{1940.6552734375,-1774.908203125,13.390598297119},
{1940.630859375,-1771.728515625,13.390598297119},
{1940.7080078125,-1767.3837890625,13.390598297119},
{-1477.921875,1868.138671875,32.639846801758},
{-1466.1552734375,1869.0048828125,32.6328125},
{-1464.5224609375,1861.3828125,32.639846801758},
{-1477.4599609375,1860.5205078125,32.6328125},
{-735.9208984375,2744.0087890625,47.2265625},
{-739.0439453125,2744.2421875,47.165451049805},
{377.6953125,2601.1083984375,16.484375},
{624.5263671875,1676.25390625,6.9921875},
{620.2958984375,1681.2431640625,6.9921875},
{616.248046875,1686.4169921875,7.1875},
{612.783203125,1691.1650390625,7.1875},
{609.2060546875,1696.201171875,7.1875},
{605.8505859375,1700.978515625,7.1875},
{602.27734375,1706.3603515625,7.1875},
{2141.037109375,2742.734375,10.960174560547},
{2142.3115234375,2752.6982421875,10.96019744873},
{2147.9521484375,2752.3203125,10.8203125},
{2152.60546875,2751.953125,10.8203125},
{2152.984375,2743.85546875,10.8203125},
{2147.75,2743.7392578125,10.8203125},
{-97.6298828125,-1175.0283203125,2.4990689754486},
{-90.74609375,-1177.853515625,2.2021217346191},
{-84.75390625,-1163.853515625,2.3359375},
{-91.5771484375,-1160.5732421875,2.4453125},
{-1606.525390625,-2717.2138671875,48.9453125},
{-1609.7109375,-2721.544921875,48.9453125},
{-1599.83203125,-2708.302734375,48.9453125},
{-2246.314453125,-2558.8212890625,32.0703125},
{-2241.3125,-2561.3662109375,32.0703125},
{-1132.2880859375,-135.0986328125,14.14396572113},
{-1153.529296875,-156.373046875,14.1484375},
{-1142.826171875,-145.67578125,14.14396572113},
{655.611328125,-557.9912109375,16.501491546631},
{655.6572265625,-572.1728515625,16.501491546631},
{1601.791015625,2203.90625,11.060997009277},
{1596.806640625,2203.4345703125,10.8203125},
{1590.197265625,2203.4853515625,10.8203125},
{1589.4775390625,2195.43359375,10.8203125},
{1596.125,2194.294921875,10.8203125},
{1601.6591796875,2194.3369140625,10.8203125},
{2206.8466796875,2470.47265625,10.8203125},
{2206.94140625,2474.75,10.8203125},
{2206.9267578125,2478.86328125,10.8203125},
{2198.06640625,2480.6953125,10.8203125},
{2197.541015625,2475.791015625,10.995170593262},
{2197.609375,2471.9169921875,10.995170593262},
{2120.8251953125,915.4833984375,10.8203125},
{2115.1181640625,915.44140625,10.8203125},
{2109.076171875,915.4228515625,10.8203125},
{2109.22265625,924.8779296875,10.9609375},
{2114.9404296875,924.8857421875,10.9609375},
{2119.5126953125,925.2861328125,10.9609375},
{2645.7197265625,1112.7802734375,10.8203125},
{2639.984375,1112.56640625,10.8203125},
{2634.828125,1112.3466796875,10.9609375},
{2634.1826171875,1101.9482421875,10.8203125},
{2636.7509765625,1101.6748046875,10.8203125},
{2643.5126953125,1101.81640625,10.8203125},
{2209.576171875,2469.8251953125,10.8203125},
{2208.8310546875,2475.09375,10.8203125},
{1005.078125,-901.7490234375,42.216625213623},
{993.025390625,-902.474609375,42.222496032715},
}

lootItems = {
["helicrashsides"] = {
{"Night Vision Goggles",368,1,90,10},
{"M136 Rocket Launcher",359,1,90,0},
{"Heat-Seeking RPG",360,1,90,0},
{"Box of Matches",328,0.4,90,2},
{"M1911",346,1,90,10},
{"M9 SD",347,1,90,7},
{"Winchester 1866",349,1,90,6},
{"PDW",352,1,90,5.5},
{"Hunting Knife",335,1,90,4},
{"Hatchet",339,1,90,3},
{"Pizza",1582,1,0,2},
{"Soda Bottle",2647,1,0,2},
{"Empty Gas Canister",1650,1,0,2},
{"Roadflare",324,1,90,2},
{"Milk",2856,1,0,1},
{"Painkiller",2709,0.5,0,4},
{"Empty Soda Cans",2673,0.5,0,2},
{"Scruffy Burgers",2675,0.5,0,3},
{"Grenade",342,1,0,4},
{"Parachute",342,1,0,80},
{"Sawn-Off Shotgun",350,1,90,5},
{"SPAZ-12 Combat Shotgun",351,1,90,4},
{"MP5A5",353,1,90,6},
{"Watch",2710,1,0,4},
{"Heat Pack",1576,1,0,3},
{"Wire Fence",933,0.25,0,1},
{"Lee Enfield",357,1,90,6},
{"Alice Pack",3026,1,0,4},
{"Night Vision Goggles",368,1,90,1.5},
{"Tire",1073,1,0,2},
{"Morphine",1579,1,0,4},
{"Camouflage Clothing",1577,1,0,4.5},
{"Civilian Clothing",1577,1,0,3},
--{"TEC-9",372,1,90,4},
{"AK-47",355,1,90,7},
{"GPS",2976,0.15,0,3},
{"Map",1277,0.8,90,7},
{"Toolbox",2969,0.5,0,1},
{"Engine",929,0.3,0,2},
{"Tent",1279,1,0,4.5},
{"Ghillie Suit",1577,1,0,0.5},
{"M4",356,1,90,1},
{"CZ 550",358,1,90,1.5},
{"Infrared Goggles",369,1,90,3},
{"Assault Pack (ACU)",3026,0.5,0,5},
{"Coyote Backpack",3026,1.3,0,2},
--{"Thermal GPS",2976,0.2,0,3},
--{"GPS Jammer",2976,0.2,0,4},
},
["hospital"] = {
{"Medic Kit",2891,0.7,0},
{"Heat Pack",1576,1,0},
{"Bandage",1578,0.5,0},
{"Blood Bag",1580,1,0},
{"Morphine",1579,1,0},
{"Blood Bag",1580,1,0},
{"Medic Kit",2891,0.7,0},
{"Blood Bag",1580,1,0},
{"Painkiller",1580,1,0},
},
}

vehicleAddonsInfo = {
{500,4,1,1},
{489,4,1,1},
{479,4,1,1},
{418,4,1,1},
{408,6,1,1},
{421,4,1,1},
{438,4,1,1},
{443,6,1,1},
{445,4,1,1},
{447,0,2,2},
--
{400,4,1,1},
{401,4,1,1},
{402,4,1,1},
{403,6,1,1},
{404,4,1,1},
{405,4,1,1},
{406,4,1,1},
{410,4,1,1},
{411,4,1,1},
{414,4,1,1},
{416,4,1,1},
{417,0,2,1},
{420,4,1,1},
{426,4,1,1},
{427,4,1,1},
{451,4,1,1},
{461,2,1,1},
{463,2,1,1},
{471,4,1,1},
{473,0,1,1},
{478,4,1,1},
{482,4,1,1},
{483,4,1,1},
{488,0,2,1},
{490,4,1,1},
{495,4,1,1},
{504,4,1,1},
{506,4,1,1},
{519,3,2,1},
{523,2,1,1},
{522,2,1,1},
{525,4,1,1},
{531,4,1,1},
{422,4,1,1},
{470,4,1,1},
{468,2,1,1},
{433,6,1,1},
{437,6,1,1},
{509,0,0,0},
{487,0,1,1},
{497,0,1,1},
{453,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
function createHeliCrashSite()
    if cargoCol then
        destroyElement(getElementData(cargoCol,"parent"))
        destroyElement(cargoCol)
    end
        local item_id = math.random(table.size(heliCrashSites))
        local x,y,z = heliCrashSites[item_id][1],heliCrashSites[item_id][2],heliCrashSites[item_id][3]
        cargobob = createVehicle(548,x,y,z,nil,nil,nil)
        setElementHealth(cargobob,0)
        setElementFrozen(cargobob,true)
        cargoCol = createColSphere(x,y,z,3)
        setElementData(cargoCol,"parent",cargobob)
        setElementData(cargoCol,"helicrash",true)
        setElementData(cargoCol,"MAX_Slots",0)
        for i, item in ipairs(lootItems["helicrashsides"]) do
            local value =  math.percentChance (item[5]*3.5,math.random(1,2))
            setElementData(cargoCol,item[1],value)
            --weapon Ammo
            local ammoData,weapID = getWeaponAmmoType (item[1],true)
            if ammoData and value > 0 then
                setElementData(cargoCol,ammoData,math.random(1,2))
            end
        end
        setTimer(createHeliCrashSite,3600000,1)
end
createHeliCrashSite()

function updateHospitals ()
    for i,box in pairs(hospitalCol) do
        for _,items in ipairs(lootItems["hospital"]) do
            setElementData(hospitalCol[i],items[1],math.random(1,5))
        end
    end
    setTimer(updateHospitals,3600000,1)
end

hospitalCol = {}
function createHospitalPacks()
    number1 = 0
    for i,box in ipairs(hospitalPacks) do
        number1 = number1+1
        local x,y,z = box[1],box[2],box[3]
        object = createObject(1558,x,y,z,nil,nil,nil)
        hospitalCol[i] = createColSphere(x,y,z,2)
        setElementData(hospitalCol[i],"parent",object)
        setElementData(hospitalCol[i],"hospitalbox",true)
        setElementData(hospitalCol[i],"MAX_Slots",20)
        for _,items in ipairs(lootItems["hospital"]) do
            local randomNumber = math.random(1,10)
            if randomNumber >= 2 then
                setElementData(hospitalCol[i],items[1],math.random(1,5))
            end
        end 
    end
    setTimer(updateHospitals,3600000,1)
end
createHospitalPacks()

for i,patrol in ipairs(patrolPoints) do
    local x,y,z = patrol[1],patrol[2],patrol[3]
    patrolCol = createColSphere(x,y,z,3)
    setElementData(patrolCol,"patrolstation",true)
end


dayzVehicles = {}
function spawnDayZVehicles()
    if getElementData(getRootElement(),"serverhasloadvehicles") then return end
    for i,veh in ipairs(MesaSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(500,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{500,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(RancherSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(489,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{489,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(ReginaSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(479,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{479,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(MoonbeamSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(418,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{418,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(TrashmasterSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(408,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{408,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(WashingtonSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(421,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{421,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(CabbieSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(438,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{438,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(PackerSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(443,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{443,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(AdmiralSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(445,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{445,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(SeasparrowSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(447,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(0))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{447,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(LandstalkerSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(400,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{400,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(BravuraSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(401,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{401,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(BuffaloSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(402,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{402,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(LinerunnerSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(403,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{403,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(PerennielSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(404,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{404,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(SentinelSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(405,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{405,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(DumperSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(406,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{406,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(MananaSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(410,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{410,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(InfernusSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(411,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{411,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(MuleSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(414,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{414,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(AmbulanceSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(416,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{416,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(LeviathanSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(417,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(0))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{417,x,y,z})
        setElementData(vehCol,"fuel",10)

    end
    for i,veh in ipairs(TaxiSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(420,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{420,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(PremierSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(426,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{426,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(EnforcerSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(427,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{427,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(TurismoSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(451,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{451,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(PCJSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(461,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{461,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(DinghySpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(473,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(0))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{473,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(WaltonSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(478,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{478,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(FreewaySpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(463,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{463,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(BurritoSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(482,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{482,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(CamperSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(483,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{483,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(QuadSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(471,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{471,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(FBIRanchersSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(490,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{490,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(SandkingSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(495,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{495,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(BloodringBangerSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(504,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{504,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(SuperGTSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(506,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{506,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(ShamalSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(519,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(0))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{519,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(HPV1000Spawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(523,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{523,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(NRGSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(522,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{522,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(NewsMaverickSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(488,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(0))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{488,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(SultanSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(560,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",20)
        --Engine + Tires + Parts
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        --vehicle_indentifikation
        setElementData(vehCol,"spawn",{560,x,y,z})
        --others
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(BulletSpwans) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(541,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",20)
        --Engine + Tires + Parts
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        --vehicle_indentifikation
        setElementData(vehCol,"spawn",{541,x,y,z})
        --others
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(HotringSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(494,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",15)
        --Engine + Tires + Parts
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        --vehicle_indentifikation
        setElementData(vehCol,"spawn",{494,x,y,z})
        --others
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(CometSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(480,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",20)
        --Engine + Tires + Parts
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        --vehicle_indentifikation
        setElementData(vehCol,"spawn",{480,x,y,z})
        --others
        setElementData(vehCol,"fuel",10)
    end	
	
    for i,veh in ipairs(TowtruckSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(525,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{525,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(TractorSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(531,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{531,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(pickupSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(422,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",20)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{422,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(patriotSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(470,x,y,z)
        vehCol = createColSphere(x,y,z,2.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",38)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{470,x,y,z})
        setElementData(vehCol,"fuel",10)
        for i,items in ipairs(lootItems["helicrashsides"]) do
            local randomNumber = math.random(1,10)
            if randomNumber == 5 then
                setElementData(vehCol,items[1],1)
            end
        end
    end
    for i,veh in ipairs(sanchezSpanws) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(468,x,y,z)
        vehCol = createColSphere(x,y,z,1.5)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",6)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{468,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(barracksSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(433,x,y,z)
        vehCol = createColSphere(x,y,z,4)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",64)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{433,x,y,z})
        setElementData(vehCol,"fuel",10)
        for i,items in ipairs(lootItems["helicrashsides"]) do
            local randomNumber = math.random(1,10)
            if randomNumber == 5 then
                setElementData(vehCol,items[1],math.random(1,2))
            end
        end
    end
    for i,veh in ipairs(coachSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(437,x,y,z)
        vehCol = createColSphere(x,y,z,4)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",56)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{437,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(fisherBootSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(453,x,y,z)
        vehCol = createColSphere(x,y,z,4)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",30)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{453,x,y,z})
        setElementData(vehCol,"fuel",10)
    end
    for i,veh in ipairs(bikeSpawns) do
        local x,y,z = veh[1],veh[2],veh[3]
        veh = createVehicle(509,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)
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(0))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        setElementData(vehCol,"spawn",{509,x,y,z})
        setElementData(vehCol,"fuel",0)
    end
    for i,tent in ipairs(tentSpawns) do
        local x,y,z = tent[1],tent[2],tent[3]
        tent = createObject(3243,x,y,z-1)
        setObjectScale(tent,0.5)
        tentCol = createColSphere(x,y,z,4)
        attachElements ( tentCol, tent, 0, 0, 0 )
        setElementData(tentCol,"parent",tent)
        setElementData(tent,"parent",tentCol)
        setElementData(tentCol,"tent",true)
        setElementData(tentCol,"vehicle",true)
        setElementData(tentCol,"MAX_Slots",30)
    end
        --Maverik
        local item_id = math.random(table.size(maverikSpawns))
        local x,y,z = maverikSpawns[item_id][1],maverikSpawns[item_id][2],maverikSpawns[item_id][3]
        hunter = createVehicle(487,x,y,z)
        vehCol = createColSphere(x,y,z,4)
        attachElements ( vehCol, hunter, 0, 0, 0 )
        setElementData(vehCol,"parent",hunter)
        setElementData(hunter,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",10)
        --Engine + Tires + Parts
        local tires,engine,parts = getVehicleAddonInfos (487)
        setElementData(vehCol,"Tire_inVehicle",(0))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        --vehicle_indentifikation
        setElementData(vehCol,"spawn",{487,x,y,z})
        --others
        setElementData(vehCol,"fuel",10)
    
        --Police Maverik
        local item_id = math.random(table.size(hunterSpawns))
        local x,y,z = hunterSpawns[item_id][1],hunterSpawns[item_id][2],hunterSpawns[item_id][3]
        hunter = createVehicle(497,x,y,z)
        vehCol = createColSphere(x,y,z,4)
        attachElements ( vehCol, hunter, 0, 0, 0 )
        setElementData(vehCol,"parent",hunter)
        setElementData(hunter,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",10)
        --Engine + Tires + Parts
        local tires,engine,parts = getVehicleAddonInfos (497)
        setElementData(vehCol,"Tire_inVehicle",(0))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        --vehicle_indentifikation
        setElementData(vehCol,"spawn",{497,x,y,z})
        --others
        setElementData(vehCol,"fuel",10)
end
--spawnDayZVehicles()
function spawnVehiclePack (ps,cmd)
    if getElementData(ps,"admin") then
        spawnDayZVehicles()
        outputChatBox("Vehicles have been respawned!",ps,255,0,0,true)
    end
end
addCommandHandler("svp",spawnVehiclePack)

function notifyAboutExplosion()
    local col = getElementData(source,"parent")
    local x1,y1,z1 = getElementPosition(source)
    id,x,y,z  = getElementData(col,"spawn")[1],getElementData(col,"spawn")[2],getElementData(col,"spawn")[3],getElementData(col,"spawn")[4]
    setTimer(respawnDayZVehicle,1800000,1,id,x,y,z,source,col,getElementData(col,"MAX_Slots"))
    setElementData(col,"deadVehicle",true)
    setElementData(source,"isExploded",true)
    createExplosion (x1+4,y1+1,z1,4)
    createExplosion (x1+2,y1-4,z1,4)
    createExplosion (x1-1,y1+5,z1,4)
    createExplosion (x1-4,y1,z1-2,4)
end
addEventHandler("onVehicleExplode", getRootElement(), notifyAboutExplosion)

function respawnVehiclesInWater (vehiclesInWater)
    for i,veh in ipairs(vehiclesInWater) do
        if getElementModel(veh) == 453 then break end
        local col = getElementData(veh,"parent")
        id,x,y,z  = getElementData(col,"spawn")[1],getElementData(col,"spawn")[2],getElementData(col,"spawn")[3],getElementData(col,"spawn")[4]
        respawnDayZVehicle(id,x,y,z,veh,col,getElementData(col,"MAX_Slots"))
    end
end
addEvent("respawnVehiclesInWater",true)
addEventHandler("respawnVehiclesInWater",getRootElement(),respawnVehiclesInWater)

function checkVehicleInWater ()
    local randomPlayer = getRandomPlayer()
    triggerClientEvent(randomPlayer,"checkVehicleInWaterClient",randomPlayer)
end
setTimer(checkVehicleInWater,1800000,0)
--1800000

function respawnDayZVehicle(id,x,y,z,veh,col,max_slots)
    if id == 497 then
        local item_id = math.random(table.size(hunterSpawns))
        x,y,z = hunterSpawns[item_id][1],hunterSpawns[item_id][2],hunterSpawns[item_id][3]
    end
    if id == 487 then
        local item_id = math.random(table.size(maverikSpawns))
        x,y,z = maverikSpawns[item_id][1],maverikSpawns[item_id][2],maverikSpawns[item_id][3]
    end
        destroyElement(veh)
        destroyElement(col)
        veh = createVehicle(id,x,y,z+1)
        vehCol = createColSphere(x,y,z,4)
        attachElements ( vehCol, veh, 0, 0, 0 )
        setElementData(vehCol,"parent",veh)
        setElementData(veh,"parent",vehCol)
        setElementData(vehCol,"vehicle",true)
        setElementData(vehCol,"MAX_Slots",max_slots)
        --Engine + Tires + Parts
        local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
        setElementData(vehCol,"Tire_inVehicle",(1))
        setElementData(vehCol,"Engine_inVehicle",(0))
        setElementData(vehCol,"Parts_inVehicle",(0))
        --vehicle_indentifikation
        setElementData(vehCol,"spawn",{id,x,y,z})
        --others
        setElementData(vehCol,"fuel",10)
        
        if id == 433 then
            for i,items in ipairs(lootItems["helicrashsides"]) do
                local randomNumber = math.random(1,10)
                if randomNumber == 5 then
                    setElementData(vehCol,items[1],math.random(1,2))
                end
            end
        elseif id == 470 then
            for i,items in ipairs(lootItems["helicrashsides"]) do
                local randomNumber = math.random(1,10)
                if randomNumber == 5 then
                    setElementData(vehCol,items[1],math.random(1,2))
                end
            end 
        end
end

vehicleAddonsInfo = {
{500,4,1,1},
{489,4,1,1},
{479,4,1,1},
{418,4,1,1},
{408,6,1,1},
{421,4,1,1},
{438,4,1,1},
{443,6,1,1},
{445,4,1,1},
{447,0,2,2},
{400,4,1,1},
{401,4,1,1},
{402,4,1,1},
{403,6,1,1},
{404,4,1,1},
{405,4,1,1},
{406,4,1,1},
{410,4,1,1},
{411,4,1,1},
{414,4,1,1},
{416,4,1,1},
{417,0,2,1},
{420,4,1,1},
{426,4,1,1},
{427,4,1,1},
{451,4,1,1},
{461,2,1,1},
{463,2,1,1},
{471,4,1,1},
{473,0,1,1},
{478,4,1,1},
{482,4,1,1},
{483,4,1,1},
{488,0,2,1},
{490,4,1,1},
{495,4,1,1},
{504,4,1,1},
{506,4,1,1},
{519,3,2,1},
{523,2,1,1},
{522,2,1,1},
{525,4,1,1},
{531,4,1,1},
{422,4,1,1},
{470,4,1,1},
{468,2,1,1},
{433,6,1,1},
{437,6,1,1},
{509,0,0,1},
{487,0,1,1},
{497,0,1,1},
{453,0,1,1},
{494,4,1,1},
{541,4,1,1},
{560,4,1,1},
{480,4,1,1},
}

vehicleFuelInfo = {
{500,0.25},
{489,0.25},
{479,0.25},
{418,0.25},
{408,0.25},
{421,0.25},
{438,0.25},
{443,0.25},
{445,0.25},
{447,0.25},
{400,0.25},
{401,0.25},
{402,0.25},
{403,0.25},
{404,0.25},
{405,0.25},
{406,0.25},
{410,0.25},
{411,0.25},
{414,0.25},
{416,0.25},
{417,0.25},
{420,0.25},
{426,0.25},
{427,0.25},
{451,0.25},
{461,0.25},
{463,0.25},
{471,0.25},
{473,0.25},
{478,0.25},
{482,0.25},
{483,0.25},
{488,0.25},
{490,0.25},
{495,0.25},
{504,0.25},
{506,0.25},
{519,0.25},
{523,0.25},
{522,0.25},
{525,0.25},
{531,0.25},
{422,0.25},
{470,0.1},
{468,0.1},
{433,0.5},
{437,0.5},
{509,0},
{487,0.25},
{497,0.25},
{453,0.1},
{494,0.25},
{541,0.25},
{560,0.25},
{480,0.25},
}

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

function onPlayerEnterDayzVehicle(veh,seat)
local col = getElementData(veh,"parent")
local id = getElementModel(veh)
if not seat == 1 then return 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 ((getElementData(col,"Parts_inVehicle") or 0) < tonumber(parts)) then
    setVehicleEngineState ( veh, true )
    return
end
if (getElementData(col,"fuel") or 0) <= 1 then
    if not getElementModel(veh) == 509 then
    triggerClientEvent (source, "displayClientInfo", source,"Vehicle","Sem gasolina!",22,255,0)
        setVehicleEngineState ( veh, false )
        return
    end
end
setVehicleEngineState ( veh, true )
bindKey(source,"k","down",setEngineStateByPlayer)
outputChatBox("Press 'K' to turn the engine on/off!",source)

end
addEventHandler ( "onPlayerVehicleEnter", getRootElement(), onPlayerEnterDayzVehicle )

function onPlayerExitDayzVehicle(veh,seat)
    if seat == 1 then
        setVehicleEngineState ( veh, false )
        unbindKey(source,"k","down",setEngineStateByPlayer)
    end 
end
addEventHandler ( "onPlayerVehicleExit", getRootElement(), onPlayerExitDayzVehicle )

function getVehicleFuelRemove (id)
    for i,veh in ipairs(vehicleFuelInfo) do
        if veh[1] == id then
        return veh[2],veh[4]
        end
    end
end

function setVehiclesFuelPerMinute ()
    for i,veh in ipairs(getElementsByType("vehicle")) do
        if getVehicleEngineState(veh) == true then
            if getElementData(getElementData(veh,"parent"),"fuel") >= 0 then
                setElementData(getElementData(veh,"parent"),"fuel",getElementData(getElementData(veh,"parent"),"fuel")-getVehicleFuelRemove(getElementModel(veh)))
            else
                setVehicleEngineState ( veh, false )
            end
        end
    end
end
setTimer(setVehiclesFuelPerMinute,20000,0)

function isVehicleReadyToStart2 (veh)
        if getElementData(getElementData(veh,"parent"),"fuel") >= 1 then
            local tires,engine = getVehicleAddonInfos (getElementModel(veh))
            if (getElementData(getElementData(veh,"parent"),"Tire_inVehicle") or 0) > tonumber(tires) and (getElementData(getElementData(veh,"parent"),"Engine_inVehicle") or 0) > tonumber(engine) then 
                setVehicleEngineState ( veh, true )
            end
        end
        setTimer(isVehicleReadyToStart2,1000,1,veh)
end

repairTimer = {}
function repairVehicle (veh)
if repairTimer[veh] then triggerClientEvent (source, "displayClientInfo", source,"Vehicle",getVehicleName(veh).." is currently being repaired!",255,22,0) return end
local health = math.floor(getElementHealth(veh))
repairTimer[veh] = setTimer(fixVehicleDayZ,(1000-health)*120,1,veh,source)
setElementFrozen (veh,true)
setElementData(veh,"repairer",source)
setElementData(source,"repairingvehicle",veh)
setPedAnimation (source,"SCRATCHING","sclng_r",nil,true,false)
triggerClientEvent (source, "displayClientInfo", source,"Vehicle","You started to repair "..getVehicleName(veh),22,255,0)
end
addEvent("repairVehicle",true)
addEventHandler("repairVehicle",getRootElement(),repairVehicle)

function fixVehicleDayZ(veh,player)
setElementHealth(veh,1000)
fixVehicle (veh)
setPedAnimation(player,false)
setElementFrozen (veh,false)
repairTimer[veh] = nil
setElementData(veh,"repairer",nil)
setElementData(player,"repairingvehicle",nil)
triggerClientEvent (player, "displayClientInfo", player,"Vehicle","You finished repairing "..getVehicleName(veh),22,255,0)
end

function stopFixxingWhileMoving()
local veh = getElementData(source,"repairingvehicle")
setPedAnimation(source)
setElementFrozen (veh,false)
setElementData(veh,"repairer",nil)
setElementData(source,"repairingvehicle",nil)
triggerClientEvent (source, "displayClientInfo", source,"Vehicle","You stopped repairing "..getVehicleName(veh),255,22,0)
killTimer(repairTimer[veh])
repairTimer[veh] = nil
end
addEvent("onClientMovesWhileAnimation",true)
addEventHandler("onClientMovesWhileAnimation",getRootElement(),stopFixxingWhileMoving)

function debugFixxing()
for i,veh in ipairs(getElementsByType("vehicle")) do
    if getElementData(veh,"repairer") == source then
        outputDebugString("Vehicle repairer disconnected - destroyed tables")
        killTimer(repairTimer[veh])
        setElementFrozen (veh,false)
        repairTimer[veh] = nil
        setElementData(veh,"repairer",nil)
    end 
end
end
addEventHandler("onPlayerQuit",getRootElement(),debugFixxing)


function setEngineStateByPlayer (playersource)
    local veh = getPedOccupiedVehicle (playersource)
    setVehicleEngineState (veh, not getVehicleEngineState(veh))
    if getElementData(getElementData(veh,"parent"),"fuel") <= 0 then return end
    if getVehicleEngineState(veh) == true then
        triggerClientEvent (playersource, "displayClientInfo", playersource,"Vehicle","Engine started!",22,255,0)
    else
        triggerClientEvent (playersource, "displayClientInfo", playersource,"Vehicle","Engine stopped!",255,22,0)
    end
end

 

Link to comment

You're gonna have to use getVehicleAddonInfos in that situation. If your script is in an external resource, add

<export function="getVehicleAddonInfos" type="server"/>

 to DayZ/meta.xml (if its not already there) and try the following code

local tires,engine,parts = exports.DayZ:getVehicleAddonInfos(getElementModel(vehicle)) -- remove "exports.DayZ:" if your script will be inside the DayZ resource
local col = getElementData(vehicle, "parent")
setElementData(col,"Tire_inVehicle", tires)
setElementData(col,"Engine_inVehicle", engine)
setElementData(col,"Parts_inVehicle", parts)

 

Link to comment
12 minutes ago, MrTasty said:

You're gonna have to use getVehicleAddonInfos in that situation. If your script is in an external resource, add


<export function="getVehicleAddonInfos" type="server"/>

 to DayZ/meta.xml (if its not already there) and try the following code


local tires,engine,parts = exports.DayZ:getVehicleAddonInfos(getElementModel(vehicle)) -- remove "exports.DayZ:" if your script will be inside the DayZ resourcelocal col = getElementData(vehicle, "parent")setElementData(col,"Tire_inVehicle", tires)setElementData(col,"Engine_inVehicle", engine)setElementData(col,"Parts_inVehicle", parts)

 

Thank you. One more question. i have error in my duty script 

local onDuty = {}

addCommandHandler('duty',function (player,cmd, spawnVeh, RaceVehicle)
	local accName = getAccountName(getPlayerAccount(player))
	if isObjectInACLGroup('user.'..accName,aclGetGroup('Admin')) then
		if not onDuty[player] or onDuty[player] == false then
			onDuty[player] = true
			outputChatBox("#F10404[ADMINISTRATOR] #FF8B00 "..getPlayerName(player)..' #04F42Cis now on duty!', getRootElement(), 255, 255, 255, true)
			triggerClientEvent(player,"onDuty",getRootElement()) 
			timer1 = setTimer(function()
				setElementAlpha(player, 0)
				setElementData(player,'food',100)
				setElementData(player,'thirst',50)
				setElementData(player,'temperature',36.5)
				setElementData(player,'blood', 12000)
				setElementData(player,'pain',false)
				setElementData(player,'brokenbone',false)
				setElementData(player,'bleeding',0)
				setElementData(player,'cold',false)
				setElementData(player, 'playerOnDuty', true)
				if theVehicle and getVehicleController ( theVehicle ) == player then  
				fixVehicle (spawnVeh)
				end
			end,50,0)
		else
			onDuty[player] = false
			setElementAlpha(player, 255)
			setElementData(player, 'playerOnDuty', false)
			destroyElement (player, RaceVehicle)
			outputChatBox("#F10404[ADMINISTRATOR] #FF8B00 "..getPlayerName(player)..' #3600FF is now off duty!', getRootElement(), 255, 255, 255, true)
			if isTimer(timer1) then
				killTimer(timer1)
			end
		end
	end
end)

addCommandHandler('duty',function (player,cmd, spawnVeh, RaceVehicle)
	local accName = getAccountName(getPlayerAccount(player))
	if isObjectInACLGroup('user.'..accName,aclGetGroup('SuperModerator')) then
		if not onDuty[player] or onDuty[player] == false then
			onDuty[player] = true
			outputChatBox("#F10404[SuperModerator] #FF8B00 "..getPlayerName(player)..' #04F42Cis now on duty!', getRootElement(), 255, 255, 255, true)
			triggerClientEvent(player,"onDuty",getRootElement()) 
			timer1 = setTimer(function()
				setElementAlpha(player, 0)
				setElementData(player,'food',100)
				setElementData(player,'thirst',25)
				setElementData(player,'temperature',36.5)
				setElementData(player,'blood', 12000)
				setElementData(player,'pain',false)
				setElementData(player,'brokenbone',false)
				setElementData(player,'bleeding',0)
				setElementData(player,'cold',false)
				setElementData(player, 'playerOnDuty', true)
				if theVehicle and getVehicleController ( theVehicle ) == player then  
				fixVehicle (spawnVeh)
				end
			end,50,0)
		else
			onDuty[player] = false
			setElementAlpha(player, 255)
			setElementData(player, 'playerOnDuty', false)
			destroyElement (player, RaceVehicle)
			outputChatBox("#F10404[SuperModerator] #FF8B00 "..getPlayerName(player)..' #3600FF is now off duty!', getRootElement(), 255, 255, 255, true)
			if isTimer(timer1) then
				killTimer(timer1)
			end
		end
	end
end)

addCommandHandler('duty',function (player,cmd, spawnVeh, RaceVehicle)
	local accName = getAccountName(getPlayerAccount(player))
	if isObjectInACLGroup('user.'..accName,aclGetGroup('Moderator')) then
		if not onDuty[player] or onDuty[player] == false then
			onDuty[player] = true
			outputChatBox("#F10404[Moderator] #FF8B00 "..getPlayerName(player)..' #04F42Cis now on duty!', getRootElement(), 255, 255, 255, true)
			triggerClientEvent(player,"onDuty",getRootElement()) 
			timer1 = setTimer(function()
				setElementAlpha(player, 0)
				setElementData(player,'food',100)
				setElementData(player,'thirst',25)
				setElementData(player,'temperature',36.5)
				setElementData(player,'blood', 12000)
				setElementData(player,'pain',false)
				setElementData(player,'brokenbone',false)
				setElementData(player,'bleeding',0)
				setElementData(player,'cold',false)
				setElementData(player, 'playerOnDuty', true)
				if theVehicle and getVehicleController ( theVehicle ) == player then  
				fixVehicle (spawnVeh)
				end
			end,50,0)
		else
			onDuty[player] = false
			setElementAlpha(player, 255)
			setElementData(player, 'playerOnDuty', false)
			outputChatBox("#F10404[Moderator] #FF8B00 "..getPlayerName(player)..' #3600FF is now off duty!', getRootElement(), 255, 255, 255, true)
			if isTimer(timer1) then
				killTimer(timer1)
			end
		end
	end
end)

Line 12-20.. But why?

And if i run your script i got thoose errors: http://prntscr.com/j6xmam

Link to comment

Try passing the player element as an argument to the setTimer callback.

			timer1 = setTimer(function(plr)
				setElementAlpha(plr, 0)
				setElementData(plr,'food',100)
				setElementData(plr,'thirst',50)
				setElementData(plr,'temperature',36.5)
				setElementData(plr,'blood', 12000)
				setElementData(plr,'pain',false)
				setElementData(plr,'brokenbone',false)
				setElementData(plr,'bleeding',0)
				setElementData(plr,'cold',false)
				setElementData(plr, 'playerOnDuty', true)
				if theVehicle and getVehicleController ( theVehicle ) == plr then  
				fixVehicle (spawnVeh)
				end
			end,50,0,player)
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...