Jump to content

Ajuda com sistema de backup


Recommended Posts

Boa noite rapaziada, seguinte, estou aqui com um sistema de backup de veículos por database, e o que acontece, o servidor spawna o veículo, e ao explodir, ele volta no local que ele spawnou, até ai ok, porém o sistema de backup faz o seguinte, ele salva onde o veículo está, e caso ocorra um desligamento do servidor, ao reiniciar, se explodir o veículo novamente, ele spawna na onde o sistema de backup salvou ele, ou seja, se ele spawna na area 51, e o sistema de backup salvou ele la em ls, ao invez dele spawnar na area 51 que é seu local correto, ele vai spawnar em LS pois foi la que o sistema salvou ele.

eu pensei em usar um setElementData e depois um getElementData para poder obter as coordenadas do local de spawn original, mas n faço a minima ideia por onde comecar, se alguem puder me ajudar, obrigado !!

 

parte do servidor onde tem os dados do spawn dos veículos

hospitalPacks = {
{-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},
{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},
{275.30685424805,1889.0017089844,17.671506881714}, ----- Tenda Medica 51 -------
{275.29724121094,1894.240234375,17.669857025146}, ----- Tenda Medica 51 -------
{246.54913330078,2114.4567871094,17.671398162842}, ----- Tenda Medica 51 -------
{240.98666381836,2114.3959960938,17.670330047607}, ----- Tenda Medica 51 -------
{1389.0604248047,1772.0107421875,10.868975639343}, ----- Tenda Medica Aero LV ------
{-2667.3984375,612.50695800781,14.570329666138}, ------- Tenda Medica HP SF -------
{-2662.3532714844,612.74169921875,14.572191238403}, ------- Tenda Medica HP SF --------
{1612.0623779297,1848.4633789063,10.870816230774}, -------- Tenda Medica HP LV --------
{1605.9671630859,1848.6759033203,10.878125190735}, -------- Tenda Medica HP LV --------
{-1247.9757080078,22.812610626221,14.171301841736}, ------- Tenda Medica Aero SF -------
{-296.43521118164,1084.3815917969,19.771415710449}, ------- Tenda Medica HP FC -----------
{-300.16088867188,1047.8997802734,20.170841217041}, ------- HP FC --------
{-315.2180480957,1046.5977783203,20.207050323486}, -------- HP FC --------
{-325.88632202148,1048.3531494141,20.199048995972}, ------- HP FC --------
{-332.0661315918,1050.5997314453,20.18150138855}, --------- HP FC --------
{3682.95,1787.1583,35.472111}, -- ILHA LV
{3684.6257,1777.33,35.507122},
{3684.6077,1773.4244,35.51075},
{3682.7141,1765.6033,35.498505},
{3479.2446,1762.9865,35.371639},
{3449.7549,1762.7432,35.371094}, -- ILHA LV
}

patrolPoints = {
{-1603.2197265625,-2712.736328125,48.9453125},
{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},
{-6062.0649414063,50.474006652832,32.802623748779},
}

lootItems = {
  helicrashsides = {
	{"Compass",1851,1,0,2},
	{"Scrap Metal",1577,1,0,3},
	{"Stinger",2899,0.3,0,3},
	{"Tire Repair Kit",2015,0.5,0,4},
	{"Hose",1880,0.5,0,6},
	{"Syringe",2000,1,0,6},
	{"Night Vision Goggles",368,1,90,10},
	{"Box of Matches",328,0.4,90,2},
	{"Hunting Knife",335,1,90,4},
	{"Chainsaw",341,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},
	{"Grenade",342,1,0,2},
	{"Parachute",342,1,0,2},
	{"Watch",2710,1,0,4},
	{"Crossbow",357,1,90,6},
	{"Night Vision Goggles",368,1,90,1.5},
	{"Tire",1073,1,0,2},
	{"GPS",2976,0.15,0,3},
	{"Map",1277,0.8,90,7},
	{"Toolbox",2969,0.5,0,1},
	{"Engine",929,0.3,0,2},
	{"Main Rotor Assembly",929,0.3,0,2},
	{"Tent",1279,1,0,3.5},
	{"Infrared Goggles",369,1,90,3},
  },
  hospital = {
	{"Syringe",2000,1,0},
	{"Antibiotics",1919,2.1,0},
	{"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}
  }
}

for i,bpData in pairs(BackpacksTable)do
  table.insert(lootItems.helicrashsides,{bpData[1],bpData[3],1,0,bpData[4][5]})
end

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)
	setObjectScale(object,1)
	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 >= 5 then
		setElementData(hospitalCol[i],items[1],math.random(1,5))
	  end
	end
  end
  setTimer(updateHospitals,3600000,1)
end
createHospitalPacks()

patrolCol = {}
for num,patrol in ipairs(patrolPoints) do
  local x,y,z = patrol[1],patrol[2],patrol[3]
  patrolCol[num] = createColSphere(x,y,z,3)
  setElementData(patrolCol[num],"patrolstation",true)
  local rand = math.random(1,15)
  if rand == 1 then
	lts = 100
  elseif rand == 2 or rand == 3 then
	lts = 80
  elseif rand >= 4 or rand <= 6 then
	lts = 60
  elseif rand >= 7 or rand <= 10 then
	lts = 40
  else
	lts = 20
  end
  setElementData(patrolCol[num],"patrollts",lts)
end

function updatepatrol()
  for i,box in pairs(patrolCol) do
	local rand = math.random(1,15)
	if rand == 1 then
	  lts = 100
	elseif rand == 2 or rand == 3 then
	  lts = 80
	elseif rand >= 4 or rand <= 6 then
	  lts = 60
	elseif rand >= 7 or rand <= 10 then
	  lts = 40
	else
	  lts = 20
	end
	setElementData(patrolCol[i],"patrollts",lts)
  end
end
setTimer(updatepatrol,10800000,0)

function spawnDayZVehicles()
	for _, data in ipairs(vehicleSpawns) do
		veh = createVehicle(data[1],data[2],data[3],data[4])
		vehCol = createColSphere(data[2],data[3],data[4],2.5)
		attachElements(vehCol,veh,0,0,0)
		setElementData(vehCol,"parent",veh)
		setElementData(veh,"parent",vehCol)
		setElementData(vehCol,"vehicle",true)
		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))
		
		setElementData(vehCol,"Tire_inVehicle_HP",400)
		setElementData(vehCol,"Engine_inVehicle_HP",400)
		setElementData(vehCol,"Parts_inVehicle_HP",400)
		setElementData(vehCol,"armorPointsMax",1000)
		setElementData(vehCol,"armorPoints",0)
		setElementData(vehCol,"vehicle:station",0)
		setElementData(vehCol,"receiver",0)
		
		setVehicleHeadLightColor(veh,math.random(0,255),math.random(0,255),math.random(0,255))
		
		setElementData(vehCol,"fuel",10)
		setElementData(vehCol,"MAX_Slots",data[5])
		setElementData(vehCol,"spawn",{data[1],data[2],data[3],data[4]})
	end
end

function spawnVehiclePack(ps,cmd)
	if getElementData(ps,"admin") then
		spawnDayZVehicles()
		outputChatBox("SVP Sucess!",ps,8, 193, 207,true)
	end	
end
addCommandHandler("svp",spawnVehiclePack)

function notifyAboutExplosion()
  occupants = getVehicleOccupants(source) or {}
  for _,peds in pairs(occupants)do
	removePedFromVehicle(peds)
  end
  local col = getElementData(source,"parent")
--  if col and getElementData(col,"helicrash") then return end
  id,x,y,z = getElementData(col,"spawn")[1],getElementData(col,"spawn")[2],getElementData(col,"spawn")[3],getElementData(col,"spawn")[4]
  setTimer(respawnDayZVehicle,15000,1,id,x,y,z,source,col,getElementData(col,"MAX_Slots"))
  setElementData(col,"deadVehicle",true)
  setElementData(source,"isExploded",true)
  x1,y1,z1 = getElementPosition(source)
  createExplosion(x1+1,y1+1,z1,4)
  createExplosion(x1-1,y1-1,z1,4)
  createExplosion(x1+1,y1-1,z1,4)
  createExplosion(x1-1,y1+1,z1,4)
end
addEventHandler("onVehicleExplode",getRootElement(),notifyAboutExplosion)

function respawnVehiclesInWater(vehiclesInWater)
  for i,veh in ipairs(getElementsByType("vehicle"))do
	if isElementInWater(veh) and getVehicleType(veh) ~= "Boat" then
	  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)
	  respawnDayZVehicle(id,x,y,z,veh,col,getElementData(col,"MAX_Slots"))
	end
  end
end
setTimer(respawnVehiclesInWater,1800000,0)

function respawnDayZVehicle(id,x,y,z,veh,col,max_slots)
	local armorMax = getElementData(col,"armorPointsMax")
	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
	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))
	
	setElementData(vehCol,"Tire_inVehicle_HP",400)
	setElementData(vehCol,"Engine_inVehicle_HP",400)
	setElementData(vehCol,"Parts_inVehicle_HP",400)
	setElementData(vehCol,"armorPointsMax",armorMax)
	setElementData(vehCol,"armorPoints",0)
	
	setVehicleHeadLightColor(veh,math.random(0,255),math.random(0,255),math.random(0,255))
	
	setElementData(vehCol,"receiver",0)
	setElementData(vehCol,"vehicle:station",0)
	--vehicle_indentifikation
	setElementData(vehCol,"spawn",{id,x,y,z})
	--others
	setElementData(vehCol,"fuel",10)
end

function onPlayerEnterDayzVehicle(veh,seat)
	local col = getElementData(veh,"parent")
	local id = getElementModel(veh)
	local tires,engine,parts = getVehicleAddonInfos (id)
	setElementData(veh,"maxfuel",getVehicleMaxFuel(col))
	setElementData(veh,"needtires",tires)
	setElementData(veh,"needengine",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,false)
		return
	end
	if (getElementData(col,"fuel") or 0) <= 1 then
		if not getElementModel(veh) == 510 then
			setVehicleEngineState(veh,false)
			return
		end
	end
	bindKey(source,"k","down",setEngineStateByPlayer)
	triggerClientEvent (source, "displayClientInfo", source,"Vehicle","Pressione a tecla *K* para ligar/desligar o veículo",200,200,22)
end
addEventHandler("onPlayerVehicleEnter",getRootElement(),onPlayerEnterDayzVehicle)

function setEngineState(player,key,keyState)
	local theVehicle = getPedOccupiedVehicle(player)
    if theVehicle and getVehicleController(theVehicle) == player then
		if checkVehicleMovable(theVehicle) then
			setVehicleEngineState(theVehicle, not getVehicleEngineState(theVehicle))
		end	
    end	
end

function checkVehicleMovable(veh)
	if isElement(veh) then
		local parent = getElementData(veh,"parent") 
		if parent then
			if ((getElementData(parent,"Tire_inVehicle") or 0) ~= getElementData(veh,"needtires")) then
				setVehicleEngineState(veh,false)
				return false
			end
			if ((getElementData(parent,"Engine_inVehicle") or 0) ~= getElementData(veh,"needengine")) then
				setVehicleEngineState(veh,false)
				return false
			end
			if ((getElementData(parent,"Parts_inVehicle") or 0) ~= getElementData(veh,"needparts")) then 
				setVehicleEngineState (veh,false) 
				return false
			end
			return true
		end	
	end	
end

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

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),getElementData(veh,"parent")))
			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,parts,metal = 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) and (getElementData(getElementData(veh,"parent"),"Parts_inVehicle") or 0) > tonumber(parts) 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"," is currently being repaired!",255,22,0) return end
	local health = math.floor(getElementHealth(veh))
	repairTimer[veh] = setTimer(fixVehicleDayZ, 25000, 1, veh, source)
	setElementFrozen (veh,true)
	setElementData(veh,"repairer",source)
	setElementData(source,"repairingvehicle",veh)
	setPedAnimation (source,"SCRATCHING","sclng_r",nil,false,false)
	triggerClientEvent (source, "displayClientInfo", source,"Vehicle","Você começou a reparar o veículo, aguarde...",255,0,0)
end
addEvent("repairVehicle",true)
addEventHandler("repairVehicle",getRootElement(),repairVehicle)

function fixVehicleDayZ(veh,player)
	setElementHealth(veh,1000)
	fixVehicle (veh)
	setPedAnimation(player,false)
	setElementFrozen (veh,false)
	setVehicleDamageProof (veh,false)
	repairTimer[veh] = nil
	setElementData(veh,"repairer",nil)
	setElementData(player,"repairingvehicle",nil)
	triggerClientEvent (player, "displayClientInfo", player,"Vehicle","Você terminou de reparar o veículo.",22,255,0)
end

function stopFixxingWhileMoving()
	local veh = getElementData(source,"repairingvehicle")
	setPedAnimation(source)
	setElementFrozen (veh,false)
	setVehicleDamageProof (veh,false)
	setElementData(veh,"repairer",nil)
	setElementData(source,"repairingvehicle",nil)
	setElementData(source,"Repairing",false)
	triggerClientEvent (source, "displayClientInfo", source,"Vehicle","Você parou de reparar o veículo.",22,255,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
			setVehicleDamageProof (veh,false)
			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)
	local seat = getPedOccupiedVehicleSeat ( playersource )
	if seat == 0 then
		if getElementData(getElementData(veh,"parent"),"fuel") <= 0 then return end
		local tires,engine,parts = getVehicleAddonInfos (getElementModel(veh))
		local col = getElementData ( veh, "parent" )
		if col then
			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, false )
				return
			end	
		end
		setVehicleEngineState (veh, not getVehicleEngineState(veh))
		if getVehicleEngineState(veh) == true then
			triggerClientEvent (playersource, "displayClientInfo", playersource,"Vehicle","Motor Ligado!",22,255,0)
		else
			triggerClientEvent (playersource, "displayClientInfo", playersource,"Vehicle","Motor Desligado!",255,22,0)
		end
	end
end

sistema de backup

--## Copyright (c) 2015 Grosu `PoWeR` Mihaita.

local dbType = "SQLite";  --Here set your db type, "MySQL" or "SQLite" <!>
local dbName = "";        --Your database name <!>
local dbHost = "";		  --Your hostname/IP <!>
local dbUser = "";		  --Username for database <!>
local dbPass = "";		  --Password for database <!>
local dbPort = 1234; 	  --This is an port exemple CHANGE IT <!>

local last_veh_id = 0;	  --Don't edit here <!>
local last_tent_id = 0;   --Don't edit here <!>

local itemsDataTable = { -- If your server have different items be sure you imported your item table here!
	{"M4A1"},
{"M4A1 CCO"},
{"M4A1 CCO SD"},
{"Sa-58P"},
{"Sa-58P CCO"},
{"M4A3 CCO"},
{"M16A4 ACOG"},
{"G36C (Camo)"},
{"M16A2"},
{"FN FAL"},
{"AKS-74U"},
{"AKS (Gold)"},
{"MG36"},
{"Bizon PP-19 SD"},
{"AK-107"},
{"AK-107 GL"},
{"AK-74"},
{"G36C"},
{"Gorro Noel"},
{"G36C SD"},
{"AKS-74 Kobra"},
{"AKM"},
{"RPK"},
{"CZ 550"},
{"SVD CAMO"},
{"M40A3"},
{"DMR"},
{"M24"},
{"M107"},
{"AS50"},
{"KSVK"},
{"Cheytac M200"},
{"M249 SAW"},
{"Mk 48 Mod 0"},
{"M240"},
{"PKM"},
{"PKP"},
{"Double-Barreled Shotgun"},
{"M1014"},
{"Remington 870"},
{"Winchester 1866"},
{"Sawn-Off Shotgun"},
{"PDW"},
{"MP5A5"},
{"MP5SD6"},
{"Machete"},
{"Hatchet"},
{"Crowbar"},
{"Shovel"},
{"Makarov PM"},
{"Makarov SD"},
{"G17"},
{"M1911"},
{"M9"},
{"M9 SD"},
{"Revolver"},
{"Balanced Vest"},
{"Press Vest"},
{"Police Vest"},
{"Light Tactical Vest"},
{"Balistic Vest"},
{"UK Assalt Vest DPM Camo"},
{"UK Assalt Vest DPM Black"},
{"Balistic Plus Vest"},
{"Helmet"},
{"Mossy Helmet"},
{"UN Helmet"},
{"Gorro Noel"},
{"Aviator Helmet"},
{"Gas Mask 1"},
{"Gas Mask 2"},
{"Motorbike Helmet 1"},
{"Motorbike Helmet 2"},
{"Motorbike Helmet 3"},
{"Motorbike Helmet 4"},
{"Skate Helmet"},
{"Tanker Helmet"},
{"Welding Helmet 1"},
{"Welding Helmet 2"},
{"Smersh Backpack"},
{"Courier Bag"},
{"Child Briefcase"},
{"Improvised Backpack"},
{"Assault Pack (ACU)"},
{"Alice Pack"},
{"British Assault Pack"},
{"Taloon Backpack"},
{"Omega Backpack"},
{"Alfa Backpack"},
{"Hunting Backpack"},
{"Camping Backpack"},
{"Drybag Backpack"},
{"Mountain Backpack"},
{"Czech Backpack"},
{"Camping Tactical Backpack"},
{"Coyote Backpack"},
{"Coyote Backpack (Desert)"},
{"Coyote Backpack (Mossy)"},
{"Tactical Backpack"},
{"Eskimo Backpack"},
{"Tiger Backpack"},
{"Noel Backpack"},
{"Canned Spaghetti (Fechado)"},
{"Canned Spaghetti (Aberto)"},
{"Canned Baked Beans (Fechado)"},
{"Canned Baked Beans (Aberto)"},
{"Canned Sardines (Fechado)"},
{"Canned Sardines (Aberto)"},
{"Can of Tactical Bacon (Fechado)"},
{"Can of Tactical Bacon (Aberto)"},
{"Water Bottle"},
{"Burger"},
{"Pizza"},
{"Soda Bottle"},
{"Milk"},
{"Cooked Meat"},
{"Raw Meat"},
{"Antibiotics"},
{"Bandage"},
{"Medic Kit"},
{"Heat Pack"},
{"Painkiller"},
{"Blood Bag"},
{"Morphine"},
{"Engine"},
{"Tire"},
{"Tank Parts"},
{"Scrap Metal"},
{"Steel Sheet"},
{"Empty Gas Canister"},
{"Full Gas Canister"},
{"Stinger"},
{"Wood Pile"},
{"Roadflare"},
{"Wire Fence"},
{"Tent"},
{"Empty Water Bottle"},
{"Empty Soda Cans"},
{"Night Vision Goggles"},
{"Infrared Goggles"},
{"Map"},
{"Box of Matches"},
{"Watch"},
{"GPS"},
{"Toolbox"},
{"Radio Device"},
{"Syringe"},
{"Opener"},
{"Hose"},
{"Tire Repair Kit"},
{"Compass"},
-------
{"30Rnd. STANAG"},
{"FN FAL Mag."},
{"G36 Mag"},
{"30Rnd. AK"},
{"CZ 550 Mag."},
{"SVD Mag."},
{"M24 Mag."},
{"DMR Mag."},
{"10Rnd. M107"},
{"5Rnd. KSVK"},
{"5Rnd. Cheytac M200"},
{"100Rnd. M249 SAW"},
{"100Rnd. M240."},
{"PKM Mag."},
{"2Rnd. Slug"},
{"Bizon Mag"},
{"MG36 Mag."},
{"M1014 Slug"},
{"1866 Slug"},
{"PDW Mag"},
{"AKM Mag."},
{"5Rnd 12.7x99mm NATO"},
{"Sa-58 Mag."},
{"MP5 Mag"},
{"Grenade"},
{"Tear Gas"},
{"Binoculars"},
{"Parachute"},
{"Makarov Mag"},
{"G17 Mag"},
{"M1911 Mag"},
{"M9 Mag"},
{".45 ACP"}
};

function noteAdmins(theAlert)
	for _,v in ipairs(getElementsByType("player")) do
		if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(v)), aclGetGroup("Admin"))) then
			outputChatBox("#FF0000[Backup]: #FFFFFF"..tostring(theAlert), v, 255, 255, 255,  true);
		end
	end
end

if (dbType == "MySQL") then
	db = dbConnect("mysql", "dbname="..dbName..";host="..dbHost..";port="..dbPort, dbUser, dbPass, "share=1");
	dbExec(db, "CREATE TABLE IF NOT EXISTS vehicles(model, x, y, z, rX, rY, rZ, slots, fuel, receiver, armorPoints, armorPointsMax, engines, moving, parts, items, id)");
	dbExec(db, "CREATE TABLE IF NOT EXISTS tents(model, x, y, z, rX, rY, rZ, slots, scale, items, id)");
	noteAdmins("Database connected to MySQL!");
elseif (dbType == "SQLite") then
	db = dbConnect("sqlite", "database.db");
	dbExec(db, "CREATE TABLE IF NOT EXISTS vehicles(model, x, y, z, rX, rY, rZ, slots, fuel, receiver, armorPoints, armorPointsMax, engines, moving, parts, items, id)");
	dbExec(db, "CREATE TABLE IF NOT EXISTS tents(model, x, y, z, rX, rY, rZ, slots, scale, items, id)");
	noteAdmins("Database connected to SQLite!");
else
	noteAdmins("Error: `dbType` wrong attribute!");
	return false;
end

function backup_vehs()
	dbExec(db, "DELETE FROM vehicles");
	local vehicleCounter = 0;
	for _,veh in ipairs(getElementsByType("vehicle")) do
		if (not getElementData(veh, "helicrash") and not getElementData(veh, "deadVehicle")) then
			local col = getElementData(veh, "parent");
			if (col and getElementType(col) == "colshape") then
				local model = getElementModel(veh);
				local x, y, z = getElementPosition(veh);
				local rX, rY, rZ = getElementRotation(veh);
				local slots = getElementData(col, "MAX_Slots") or 20;
				local fuel = getElementData(col, "fuel") or 0;
				
				local moving = getElementData(col, "Tire_inVehicle") or 0;
				local engines = getElementData(col, "Engine_inVehicle") or 0;
				local parts = getElementData(col, "Parts_inVehicle") or 0;
				
				local siren = getElementData(col, "Sirene_inVehicle") or 0;
				local receiver = getElementData(col, "receiver") or 0;
				local armorPointsMax = getElementData(col, "armorPointsMax") or 0;
				local armorPoints = getElementData(col, "armorPoints") or 0;
				
				local items = {};
				vehicleCounter = vehicleCounter + 1;
				for _,v in ipairs(itemsDataTable) do
					local quantity = getElementData(col, v[1]) or 0;
					if (quantity > 0) then
						table.insert(items, {v[1], quantity});
					end
				end
				dbExec(db, "INSERT INTO vehicles(model, x, y, z, rX, rY, rZ, slots, fuel, engines, receiver, armorPoints, armorPointsMax, moving, parts, items, id) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", model, x, y, z, rX, rY, rZ, slots, fuel, engines, receiver, armorPoints, armorPointsMax, moving, parts, toJSON(items), vehicleCounter)
			end
		end
	end
	noteAdmins("Veículos Salvos ["..vehicleCounter.."]");
end
addEventHandler("onResourceStop",getResourceRootElement(),backup_vehs)
setTimer(backup_vehs,3600000,0)

function backup_tents()
	dbExec(db, "DELETE FROM tents");
	local tentsCounter = 0;
	for _,col in ipairs(getElementsByType("colshape")) do
		if (getElementData(col, "tent")) then
			local tent = getElementData(col, "parent");
			local x, y, z = getElementPosition(tent);
			local rX, rY, rZ = getElementRotation(tent);
			local model = getElementModel(tent);
			local slots = getElementData(col, "MAX_Slots") or 300;
			local scale = getObjectScale(tent);
			local items = {};
			tentsCounter = tentsCounter + 1;
			for _,v in ipairs(itemsDataTable) do
				local quantity = getElementData(col, v[1]) or 0;
				if (quantity > 0) then
					table.insert(items, {v[1], quantity});
				end
			end
			dbExec(db, "INSERT INTO tents(model, x, y, z, rX, rY, rZ, slots, scale, items, id) VALUES(?,?,?,?,?,?,?,?,?,?,?)", model, x, y, z, rX, rY, rZ, slots, scale, toJSON(items), tentsCounter)
		end
	end
	noteAdmins("Tendas Salvas ["..tentsCounter.."]");
end
addEventHandler("onResourceStop",getResourceRootElement(),backup_tents)
setTimer(backup_tents,3600000,0)

function create_veh(model, x, y, z, rX, rY, rZ, slots, fuel, receiver, armorPoints, armorPointsMax, engines, moving, parts, items, id)
	local veh = createVehicle(model, x, y, z);
	local vehCol = createColSphere(x, y, z, 4);
	setElementRotation(veh, rX, rY, rZ);
	attachElements(vehCol, veh, 0, 0, 0);
	setElementData(vehCol, "parent", veh);
	setElementData(veh, "parent", vehCol);
	setElementData(vehCol, "vehicle", true);
	setElementData(vehCol, "MAX_Slots", tonumber(slots));
	setElementData(vehCol, "Tire_inVehicle", tonumber(moving));
	setElementData(vehCol, "Engine_inVehicle", tonumber(engines));
	setElementData(vehCol, "Parts_inVehicle", tonumber(parts));
	setElementData(vehCol, "spawn", {model, x, y, z});
	setElementData(vehCol, "fuel", tonumber(fuel));
	setElementData(vehCol, "receiver", tonumber(receiver));
	setElementData(vehCol, "armorPointsMax", tonumber(armorPointsMax));
	setElementData(vehCol, "armorPoints", tonumber(armorPoints));
	
	
	for _,v in ipairs(fromJSON(items)) do
		setElementData(vehCol, v[1], v[2]);
	end
end

function create_tent(model, x, y, z, rX, rY, rZ, slots, scale, items, id)
	local tent = createObject(model, x, y, z);
	local tentCol = createColSphere(x, y, z,  4);
	setElementRotation(tent, rX, rY, rZ);
	setObjectScale(tent, scale);
	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", slots);
	setElementData(tentCol,"visible",true)
	for _,v in ipairs(fromJSON(items)) do
		setElementData(tentCol, v[1], v[2]);
	end
end

function load_vehs(q)
	if (q) then
		local p = dbPoll(q, 0);
		if (#p > 0) then
			for _,d in pairs(p) do
				last_veh_id = d["id"];
				create_veh(d["model"], d["x"], d["y"], d["z"], d["rX"], d["rY"], d["rZ"], d["slots"], d["fuel"],d["receiver"], d["armorPoints"], d["armorPointsMax"], d["engines"], d["moving"], d["parts"], d["items"], d["id"]);
			end
		end
	end
	noteAdmins("Veiculos Carregados!");
end

function load_tents(q)
	if (q) then
		local p = dbPoll(q, 0);
		if (#p > 0) then
			for _,d in pairs(p) do
				last_tent_id = d["id"];
				create_tent(d["model"], d["x"], d["y"], d["z"], d["rX"], d["rY"], d["rZ"], d["slots"], d["scale"], d["items"], d["id"]);
			end
		end
	end 
	noteAdmins("Tendas Carregadas!");
end

function  start_resource ()
   dbQuery(load_tents, {}, db, "SELECT * FROM `tents`")
   dbQuery(load_vehs, {}, db, "SELECT * FROM `vehicles`")
end
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), start_resource) 

addEventHandler("onPlayerCommand", root, function(cmd)
	if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin"))) then
		if (cmd == "loadtent") then --carregar tendas
			dbQuery(load_tents, {}, db, "SELECT * FROM `tents`");
		elseif (cmd == "loadcar") then --carregar veiculos
			dbQuery(load_vehs, {}, db, "SELECT * FROM `vehicles`");
		elseif (cmd == "savecar") then --salvar veiculos
			backup_vehs();
		elseif (cmd == "savetent") then -- salvar tendas
			backup_tents();
		elseif (cmd == "backup") then --start stop backup  a cada 30 minutos
			if (isTimer(vehbkTimer) and isTimer(tentbkTimer)) then
				killTimer(vehbkTimer);
				killTimer(tentbkTimer);
				noteAdmins(getPlayerName(source).."#FFFFFF Backup Automatico Parado!");
			else
				vehbkTimer = setTimer(backup_vehs, 30*60000, 0);
				tentbkTimer = setTimer(backup_tents, 30*60000, 0);
				noteAdmins(getPlayerName(source).."#FFFFFF Backup Automatico Iniciado!");
			end
		end
	end
end);

 

Link to post

tentei umas modificações porém não obtive sucesso, se alguém puder me dizer oque estou fazendo de errado eu agradeço

 

--## Copyright (c) 2015 Grosu `PoWeR` Mihaita.
--## MTA:DayZ Backup System v1.5.

local dbType = "SQLite";  --Here set your db type, "MySQL" or "SQLite" <!>
local dbName = "";        --Your database name <!>
local dbHost = "";		  --Your hostname/IP <!>
local dbUser = "";		  --Username for database <!>
local dbPass = "";		  --Password for database <!>
local dbPort = 1234; 	  --This is an port exemple CHANGE IT <!>

local last_veh_id = 0;	  --Don't edit here <!>
local last_tent_id = 0;   --Don't edit here <!>

local itemsDataTable = { -- If your server have different items be sure you imported your item table here!
	{"M4A1"},
{"M4A1 CCO"},
{"M4A1 CCO SD"},
{"Sa-58P"},
{"Sa-58P CCO"},
{"M4A3 CCO"},
{"M16A4 ACOG"},
{"G36C (Camo)"},
{"M16A2"},
{"FN FAL"},
{"AKS-74U"},
{"AKS (Gold)"},
{"MG36"},
{"Bizon PP-19 SD"},
{"AK-107"},
{"AK-107 GL"},
{"AK-74"},
{"G36C"},
{"Gorro Noel"},
{"G36C SD"},
{"AKS-74 Kobra"},
{"AKM"},
{"RPK"},
{"CZ 550"},
{"SVD CAMO"},
{"M40A3"},
{"DMR"},
{"M24"},
{"M107"},
{"AS50"},
{"KSVK"},
{"Cheytac M200"},
{"M249 SAW"},
{"Mk 48 Mod 0"},
{"M240"},
{"PKM"},
{"PKP"},
{"Double-Barreled Shotgun"},
{"M1014"},
{"Remington 870"},
{"Winchester 1866"},
{"Sawn-Off Shotgun"},
{"PDW"},
{"MP5A5"},
{"MP5SD6"},
{"Machete"},
{"Hatchet"},
{"Crowbar"},
{"Shovel"},
{"Makarov PM"},
{"Makarov SD"},
{"G17"},
{"M1911"},
{"M9"},
{"M9 SD"},
{"Revolver"},
{"Balanced Vest"},
{"Press Vest"},
{"Police Vest"},
{"Light Tactical Vest"},
{"Balistic Vest"},
{"UK Assalt Vest DPM Camo"},
{"UK Assalt Vest DPM Black"},
{"Balistic Plus Vest"},
{"Helmet"},
{"Mossy Helmet"},
{"UN Helmet"},
{"Gorro Noel"},
{"Aviator Helmet"},
{"Gas Mask 1"},
{"Gas Mask 2"},
{"Motorbike Helmet 1"},
{"Motorbike Helmet 2"},
{"Motorbike Helmet 3"},
{"Motorbike Helmet 4"},
{"Skate Helmet"},
{"Tanker Helmet"},
{"Welding Helmet 1"},
{"Welding Helmet 2"},
{"Smersh Backpack"},
{"Courier Bag"},
{"Child Briefcase"},
{"Improvised Backpack"},
{"Assault Pack (ACU)"},
{"Alice Pack"},
{"British Assault Pack"},
{"Taloon Backpack"},
{"Omega Backpack"},
{"Alfa Backpack"},
{"Hunting Backpack"},
{"Camping Backpack"},
{"Drybag Backpack"},
{"Mountain Backpack"},
{"Czech Backpack"},
{"Camping Tactical Backpack"},
{"Coyote Backpack"},
{"Coyote Backpack (Desert)"},
{"Coyote Backpack (Mossy)"},
{"Tactical Backpack"},
{"Eskimo Backpack"},
{"Tiger Backpack"},
{"Noel Backpack"},
{"Canned Spaghetti (Fechado)"},
{"Canned Spaghetti (Aberto)"},
{"Canned Baked Beans (Fechado)"},
{"Canned Baked Beans (Aberto)"},
{"Canned Sardines (Fechado)"},
{"Canned Sardines (Aberto)"},
{"Can of Tactical Bacon (Fechado)"},
{"Can of Tactical Bacon (Aberto)"},
{"Water Bottle"},
{"Burger"},
{"Pizza"},
{"Soda Bottle"},
{"Milk"},
{"Cooked Meat"},
{"Raw Meat"},
{"Antibiotics"},
{"Bandage"},
{"Medic Kit"},
{"Heat Pack"},
{"Painkiller"},
{"Blood Bag"},
{"Morphine"},
{"Engine"},
{"Tire"},
{"Tank Parts"},
{"Scrap Metal"},
{"Steel Sheet"},
{"Empty Gas Canister"},
{"Full Gas Canister"},
{"Stinger"},
{"Wood Pile"},
{"Roadflare"},
{"Wire Fence"},
{"Tent"},
{"Empty Water Bottle"},
{"Empty Soda Cans"},
{"Night Vision Goggles"},
{"Infrared Goggles"},
{"Map"},
{"Box of Matches"},
{"Watch"},
{"GPS"},
{"Toolbox"},
{"Radio Device"},
{"Syringe"},
{"Opener"},
{"Hose"},
{"Tire Repair Kit"},
{"Compass"},
-------
{"30Rnd. STANAG"},
{"FN FAL Mag."},
{"G36 Mag"},
{"30Rnd. AK"},
{"CZ 550 Mag."},
{"SVD Mag."},
{"M24 Mag."},
{"DMR Mag."},
{"10Rnd. M107"},
{"5Rnd. KSVK"},
{"5Rnd. Cheytac M200"},
{"100Rnd. M249 SAW"},
{"100Rnd. M240."},
{"PKM Mag."},
{"2Rnd. Slug"},
{"Bizon Mag"},
{"MG36 Mag."},
{"M1014 Slug"},
{"1866 Slug"},
{"PDW Mag"},
{"AKM Mag."},
{"5Rnd 12.7x99mm NATO"},
{"Sa-58 Mag."},
{"MP5 Mag"},
{"Grenade"},
{"Tear Gas"},
{"Binoculars"},
{"Parachute"},
{"Makarov Mag"},
{"G17 Mag"},
{"M1911 Mag"},
{"M9 Mag"},
{".45 ACP"}
};

function noteAdmins(theAlert)
	for _,v in ipairs(getElementsByType("player")) do
		if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(v)), aclGetGroup("Admin"))) then
			outputChatBox("#FF0000[Backup]: #FFFFFF"..tostring(theAlert), v, 255, 255, 255,  true);
		end
	end
end

if (dbType == "MySQL") then
	db = dbConnect("mysql", "dbname="..dbName..";host="..dbHost..";port="..dbPort, dbUser, dbPass, "share=1");
	dbExec(db, "CREATE TABLE IF NOT EXISTS vehicles(model, x, y, z, rX, rY, rZ, slots, fuel, receiver, armorPoints, armorPointsMax, engines, moving, parts, items, id)");
	dbExec(db, "CREATE TABLE IF NOT EXISTS tents(model, x, y, z, rX, rY, rZ, slots, scale, items, id)");
	noteAdmins("Database connected to MySQL!");
elseif (dbType == "SQLite") then
	db = dbConnect("sqlite", "database.db");
	dbExec(db, "CREATE TABLE IF NOT EXISTS vehicles(model, x, y, z, rX, rY, rZ, slots, fuel, receiver, armorPoints, armorPointsMax, engines, moving, parts, items, id)");
	dbExec(db, "CREATE TABLE IF NOT EXISTS tents(model, x, y, z, rX, rY, rZ, slots, scale, items, id)");
	noteAdmins("Database connected to SQLite!");
else
	noteAdmins("Error: `dbType` wrong attribute!");
	return false;
end

function backup_vehs()
	dbExec(db, "DELETE FROM vehicles");
	local vehicleCounter = 0;
	for _,veh in ipairs(getElementsByType("vehicle")) do
		if (not getElementData(veh, "helicrash") and not getElementData(veh, "deadVehicle")) then
			local col = getElementData(veh, "parent");
			if (col and getElementType(col) == "colshape") then
				local model = getElementModel(veh);
				local x, y, z = getElementPosition(veh);
				local SpawnVehXYZ = getElementData(vehCol,"spawn"); -- Linha adicionada
				local rX, rY, rZ = getElementRotation(veh);
				local slots = getElementData(col, "MAX_Slots") or 20;
				local fuel = getElementData(col, "fuel") or 0;
				
				local moving = getElementData(col, "Tire_inVehicle") or 0;
				local engines = getElementData(col, "Engine_inVehicle") or 0;
				local parts = getElementData(col, "Parts_inVehicle") or 0;
				
				local siren = getElementData(col, "Sirene_inVehicle") or 0;
				local receiver = getElementData(col, "receiver") or 0;
				local armorPointsMax = getElementData(col, "armorPointsMax") or 0;
				local armorPoints = getElementData(col, "armorPoints") or 0;
				
				local Spawn_X = getElementData(vehCol,"Spawn_X",SpawnVehXYZ[2]); -- Linha adicionada
				local Spawn_Y = getElementData(vehCol,"Spawn_Y",SpawnVehXYZ[3]); -- Linha adicionada 
				local Spawn_Z = getElementData(vehCol,"Spawn_Z",SpawnVehXYZ[4]); -- Linha adicionada
				
				local items = {};
				vehicleCounter = vehicleCounter + 1;
				for _,v in ipairs(itemsDataTable) do
					local quantity = getElementData(col, v[1]) or 0;
					if (quantity > 0) then
						table.insert(items, {v[1], quantity});
					end
				end
				dbExec(db, "INSERT INTO vehicles(model, x, y, z, rX, rY, rZ, SpawnVehXYZ, slots, fuel, engines, receiver, armorPoints, armorPointsMax, moving, parts, items, id) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", model, x, y, z, rX, rY, rZ, SpawnVehXYZ, slots, fuel, engines, receiver, armorPoints, armorPointsMax, moving, parts, toJSON(items), vehicleCounter) -- Alterado
			end
		end
	end
	noteAdmins("Veículos Salvos ["..vehicleCounter.."]");
end
addEventHandler("onResourceStop",getResourceRootElement(),backup_vehs)
setTimer(backup_vehs,3600000,0)

function backup_tents()
	dbExec(db, "DELETE FROM tents");
	local tentsCounter = 0;
	for _,col in ipairs(getElementsByType("colshape")) do
		if (getElementData(col, "tent")) then
			local tent = getElementData(col, "parent");
			local x, y, z = getElementPosition(tent);
			local rX, rY, rZ = getElementRotation(tent);
			local model = getElementModel(tent);
			local slots = getElementData(col, "MAX_Slots") or 300;
			local scale = getObjectScale(tent);
			local items = {};
			tentsCounter = tentsCounter + 1;
			for _,v in ipairs(itemsDataTable) do
				local quantity = getElementData(col, v[1]) or 0;
				if (quantity > 0) then
					table.insert(items, {v[1], quantity});
				end
			end
			dbExec(db, "INSERT INTO tents(model, x, y, z, rX, rY, rZ, slots, scale, items, id) VALUES(?,?,?,?,?,?,?,?,?,?,?)", model, x, y, z, rX, rY, rZ, slots, scale, toJSON(items), tentsCounter)
		end
	end
	noteAdmins("Tendas Salvas ["..tentsCounter.."]");
end
addEventHandler("onResourceStop",getResourceRootElement(),backup_tents)
setTimer(backup_tents,3600000,0)

function create_veh(model, x, y, z, rX, rY, rZ,SpawnVx,SpawnVy,SpawnVz, slots, fuel, receiver, armorPoints, armorPointsMax, engines, moving, parts, items, id) -- Linha alterada
	local veh = createVehicle(model, x, y, z);
	local vehCol = createColSphere(x, y, z, 4);
	setElementRotation(veh, rX, rY, rZ);
	attachElements(vehCol, veh, 0, 0, 0);
	setElementData(vehCol, "parent", veh);
	setElementData(veh, "parent", vehCol);
	setElementData(vehCol, "vehicle", true);
	setElementData(vehCol, "MAX_Slots", tonumber(slots));
	setElementData(vehCol, "Tire_inVehicle", tonumber(moving));
	setElementData(vehCol, "Engine_inVehicle", tonumber(engines));
	setElementData(vehCol, "Parts_inVehicle", tonumber(parts));
	setElementData(vehCol, "spawn", {model, SpawnVx,SpawnVy,SpawnVz}); -- Linha alterada
	setElementData(vehCol, "SpawnVx",Spawn_X); -- Linha alterada
	setElementData(vehCol, "SpawnVy",Spawn_Y); -- Linha alterada
	setElementData(vehCol, "SpawnVz",Spawn_Z); -- Linha alterada
	setElementData(vehCol, "fuel", tonumber(fuel));
	setElementData(vehCol, "receiver", tonumber(receiver));
	setElementData(vehCol, "armorPointsMax", tonumber(armorPointsMax));
	setElementData(vehCol, "armorPoints", tonumber(armorPoints));
	
	
	for _,v in ipairs(fromJSON(items)) do
		setElementData(vehCol, v[1], v[2]);
	end
end

function create_tent(model, x, y, z, rX, rY, rZ, slots, scale, items, id)
	local tent = createObject(model, x, y, z);
	local tentCol = createColSphere(x, y, z,  4);
	setElementRotation(tent, rX, rY, rZ);
	setObjectScale(tent, scale);
	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", slots);
	setElementData(tentCol,"visible",true)
	for _,v in ipairs(fromJSON(items)) do
		setElementData(tentCol, v[1], v[2]);
	end
end

function load_vehs(q)
	if (q) then
		local p = dbPoll(q, 0);
		if (#p > 0) then
			for _,d in pairs(p) do
				last_veh_id = d["id"];
				create_veh(d["model"], d["x"], d["y"], d["z"], d["rX"], d["rY"], d["rZ"], d["slots"], d["fuel"],d["receiver"], d["armorPoints"], d["armorPointsMax"], d["engines"], d["moving"], d["parts"], d["items"], d["id"]);
			end
		end
	end
	noteAdmins("Veiculos Carregados!");
end

function load_tents(q)
	if (q) then
		local p = dbPoll(q, 0);
		if (#p > 0) then
			for _,d in pairs(p) do
				last_tent_id = d["id"];
				create_tent(d["model"], d["x"], d["y"], d["z"], d["rX"], d["rY"], d["rZ"], d["slots"], d["scale"], d["items"], d["id"]);
			end
		end
	end 
	noteAdmins("Tendas Carregadas!");
end

function  start_resource ()
   dbQuery(load_tents, {}, db, "SELECT * FROM `tents`")
   dbQuery(load_vehs, {}, db, "SELECT * FROM `vehicles`")
end
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), start_resource) 

addEventHandler("onPlayerCommand", root, function(cmd)
	if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin"))) then
		if (cmd == "loadtent") then --carregar tendas
			dbQuery(load_tents, {}, db, "SELECT * FROM `tents`");
		elseif (cmd == "loadcar") then --carregar veiculos
			dbQuery(load_vehs, {}, db, "SELECT * FROM `vehicles`");
		elseif (cmd == "savecar") then --salvar veiculos
			backup_vehs();
		elseif (cmd == "savetent") then -- salvar tendas
			backup_tents();
		elseif (cmd == "backup") then --start stop backup  a cada 30 minutos
			if (isTimer(vehbkTimer) and isTimer(tentbkTimer)) then
				killTimer(vehbkTimer);
				killTimer(tentbkTimer);
				noteAdmins(getPlayerName(source).."#FFFFFF Backup Automatico Parado!");
			else
				vehbkTimer = setTimer(backup_vehs, 30*60000, 0);
				tentbkTimer = setTimer(backup_tents, 30*60000, 0);
				noteAdmins(getPlayerName(source).."#FFFFFF Backup Automatico Iniciado!");
			end
		end
	end
end);

 

 

Link to post
On 18/02/2020 at 00:51, Angelo Pereira said:

Seu problema é, o veiculo é explodido, ele retorna no mesmo local da explosão, isto? e você quer corrigir isto?

Sim, o veiculo é pra spawnar no seu devido local, porem o sistema de backup salva ele, e o local que o sistema de backup salvou, se toena o local de spawn dele, ou seja n quero isso, quero que ele salve os veiculos, mas que continue spawnando no seu local normal

Link to post

Tenta usa está função 

function respawnExplodedVehicle()
	setTimer(respawnVehicle, 5000, 1, source)
end
addEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle)

 

Link to post
6 hours ago, #RooTs said:

Tenta usa está função 


function respawnExplodedVehicle()	setTimer(respawnVehicle, 5000, 1, source)endaddEventHandler("onVehicleExplode", getRootElement(), respawnExplodedVehicle)

 

Tinha tentado uma parecida, so que a funcao spawndayzvehicle, tentei esta tbm respawndayzvehicle mas nao funcionou, praticamente esta funcao n fez diferenca, pois ai ela só está usando pra respawnar o veiculo, sendo que o backup salvou ele na posicao que está, sendo assim, eu adicionando esta funcao que vc mandou, ele vai spawnar normalmente porém no mesmo lugar que foi salvo o veiculo, ou seja, está funcão não fez diferença :/, ta complicado to quebrando a cabeça aqui

Mas valeu mano pela ajuda

Link to post
3 minutes ago, Lukkas2201 said:

Tinha tentado uma parecida, so que a funcao spawndayzvehicle, tentei esta tbm respawndayzvehicle mas nao funcionou, praticamente esta funcao n fez diferenca, pois ai ela só está usando pra respawnar o veiculo, sendo que o backup salvou ele na posicao que está, sendo assim, eu adicionando esta funcao que vc mandou, ele vai spawnar normalmente porém no mesmo lugar que foi salvo o veiculo, ou seja, está funcão não fez diferença :/, ta complicado to quebrando a cabeça aqui

Mas valeu mano pela ajuda

Tem alguns pra download na comunidade.. veja se consegue achar

Procura lá por: vehicle

Link to post
1 hour ago, #RooTs said:

Tem alguns pra download na comunidade.. veja se consegue achar

Procura lá por: vehicle

Vou dar uma olhada, não sabia.

Fico chateado porque tem muita gente que sabe arrumar, poderia me falar onde estou errando e oque eu poderia fazer, eu nao quero codigo pronto, eu quero aprender, porem eu nao sei onde eu to errando, e o pessoal sabe arrumar, mas nao podem vir aqui dar uma ajuda, dar uma iniciativa, falar oque eu tenho que fazer, pessoal é muito egoísta, to tentando resolver isso faz semanas já, porém sem sucesso, fica complicado.

Mas agradeço novamente pela ajuda, precisar de algo que eu possa ajudar, estarei a disposição.

Link to post
13 minutes ago, Lukkas2201 said:

Vou dar uma olhada, não sabia.

Fico chateado porque tem muita gente que sabe arrumar, poderia me falar onde estou errando e oque eu poderia fazer, eu nao quero codigo pronto, eu quero aprender, porem eu nao sei onde eu to errando, e o pessoal sabe arrumar, mas nao podem vir aqui dar uma ajuda, dar uma iniciativa, falar oque eu tenho que fazer, pessoal é muito egoísta, to tentando resolver isso faz semanas já, porém sem sucesso, fica complicado.

Mas agradeço novamente pela ajuda, precisar de algo que eu possa ajudar, estarei a disposição.

Peço desculpas pelo fato. Mais não é vergonha estudar alguns códigos prontos e ver como eles fizeram

Dessa maneira aprendi muito fazendo isso.. editando e olhando exemplos. Muitas pessoas me indicaram textos enormes para ler e como havia pouco tempo para criar minhas coisas eu não lia.. e busquei outros meios de como ver/ler códigos e funções prontas

Link to post
On 25/02/2020 at 22:52, #RooTs said:

Peço desculpas pelo fato. Mais não é vergonha estudar alguns códigos prontos e ver como eles fizeram

Dessa maneira aprendi muito fazendo isso.. editando e olhando exemplos. Muitas pessoas me indicaram textos enormes para ler e como havia pouco tempo para criar minhas coisas eu não lia.. e busquei outros meios de como ver/ler códigos e funções prontas

sim, a quetão não é ver códigos prontos, mas sim saber onde está o erro, eu não consigo saber onde está, eu tento varias modificações, e tenho algumas outras gms aqui onde tento procurar também alguma função parecida, pego alguns codigos, mas não da em nada.

--## Copyright (c) 2015 Grosu `PoWeR` Mihaita.
--## MTA:DayZ Backup System v1.5.

local dbType = "SQLite";  --Here set your db type, "MySQL" or "SQLite" <!>
local dbName = "";        --Your database name <!>
local dbHost = "";		  --Your hostname/IP <!>
local dbUser = "";		  --Username for database <!>
local dbPass = "";		  --Password for database <!>
local dbPort = 1234; 	  --This is an port exemple CHANGE IT <!>

local last_veh_id = 0;	  --Don't edit here <!>
local last_tent_id = 0;   --Don't edit here <!>

local itemsDataTable = { -- If your server have different items be sure you imported your item table here!
	{"M4A1"},
{"M4A1 CCO"},
{"M4A1 CCO SD"},
{"Sa-58P"},
{"Sa-58P CCO"},
{"M4A3 CCO"},
{"M16A4 ACOG"},
{"G36C (Camo)"},
{"M16A2"},
{"FN FAL"},
{"AKS-74U"},
{"AKS (Gold)"},
{"MG36"},
{"Bizon PP-19 SD"},
{"AK-107"},
{"AK-107 GL"},
{"AK-74"},
{"G36C"},
{"Gorro Noel"},
{"G36C SD"},
{"AKS-74 Kobra"},
{"AKM"},
{"RPK"},
{"CZ 550"},
{"SVD CAMO"},
{"M40A3"},
{"DMR"},
{"M24"},
{"M107"},
{"AS50"},
{"KSVK"},
{"Cheytac M200"},
{"M249 SAW"},
{"Mk 48 Mod 0"},
{"M240"},
{"PKM"},
{"PKP"},
{"Double-Barreled Shotgun"},
{"M1014"},
{"Remington 870"},
{"Winchester 1866"},
{"Sawn-Off Shotgun"},
{"PDW"},
{"MP5A5"},
{"MP5SD6"},
{"Machete"},
{"Hatchet"},
{"Crowbar"},
{"Shovel"},
{"Makarov PM"},
{"Makarov SD"},
{"G17"},
{"M1911"},
{"M9"},
{"M9 SD"},
{"Revolver"},
{"Balanced Vest"},
{"Press Vest"},
{"Police Vest"},
{"Light Tactical Vest"},
{"Balistic Vest"},
{"UK Assalt Vest DPM Camo"},
{"UK Assalt Vest DPM Black"},
{"Balistic Plus Vest"},
{"Helmet"},
{"Mossy Helmet"},
{"UN Helmet"},
{"Gorro Noel"},
{"Aviator Helmet"},
{"Gas Mask 1"},
{"Gas Mask 2"},
{"Motorbike Helmet 1"},
{"Motorbike Helmet 2"},
{"Motorbike Helmet 3"},
{"Motorbike Helmet 4"},
{"Skate Helmet"},
{"Tanker Helmet"},
{"Welding Helmet 1"},
{"Welding Helmet 2"},
{"Smersh Backpack"},
{"Courier Bag"},
{"Child Briefcase"},
{"Improvised Backpack"},
{"Assault Pack (ACU)"},
{"Alice Pack"},
{"British Assault Pack"},
{"Taloon Backpack"},
{"Omega Backpack"},
{"Alfa Backpack"},
{"Hunting Backpack"},
{"Camping Backpack"},
{"Drybag Backpack"},
{"Mountain Backpack"},
{"Czech Backpack"},
{"Camping Tactical Backpack"},
{"Coyote Backpack"},
{"Coyote Backpack (Desert)"},
{"Coyote Backpack (Mossy)"},
{"Tactical Backpack"},
{"Eskimo Backpack"},
{"Tiger Backpack"},
{"Noel Backpack"},
{"Canned Spaghetti (Fechado)"},
{"Canned Spaghetti (Aberto)"},
{"Canned Baked Beans (Fechado)"},
{"Canned Baked Beans (Aberto)"},
{"Canned Sardines (Fechado)"},
{"Canned Sardines (Aberto)"},
{"Can of Tactical Bacon (Fechado)"},
{"Can of Tactical Bacon (Aberto)"},
{"Water Bottle"},
{"Burger"},
{"Pizza"},
{"Soda Bottle"},
{"Milk"},
{"Cooked Meat"},
{"Raw Meat"},
{"Antibiotics"},
{"Bandage"},
{"Medic Kit"},
{"Heat Pack"},
{"Painkiller"},
{"Blood Bag"},
{"Morphine"},
{"Engine"},
{"Tire"},
{"Tank Parts"},
{"Scrap Metal"},
{"Steel Sheet"},
{"Empty Gas Canister"},
{"Full Gas Canister"},
{"Stinger"},
{"Wood Pile"},
{"Roadflare"},
{"Wire Fence"},
{"Tent"},
{"Empty Water Bottle"},
{"Empty Soda Cans"},
{"Night Vision Goggles"},
{"Infrared Goggles"},
{"Map"},
{"Box of Matches"},
{"Watch"},
{"GPS"},
{"Toolbox"},
{"Radio Device"},
{"Syringe"},
{"Opener"},
{"Hose"},
{"Tire Repair Kit"},
{"Compass"},
-------
{"30Rnd. STANAG"},
{"FN FAL Mag."},
{"G36 Mag"},
{"30Rnd. AK"},
{"CZ 550 Mag."},
{"SVD Mag."},
{"M24 Mag."},
{"DMR Mag."},
{"10Rnd. M107"},
{"5Rnd. KSVK"},
{"5Rnd. Cheytac M200"},
{"100Rnd. M249 SAW"},
{"100Rnd. M240."},
{"PKM Mag."},
{"2Rnd. Slug"},
{"Bizon Mag"},
{"MG36 Mag."},
{"M1014 Slug"},
{"1866 Slug"},
{"PDW Mag"},
{"AKM Mag."},
{"5Rnd 12.7x99mm NATO"},
{"Sa-58 Mag."},
{"MP5 Mag"},
{"Grenade"},
{"Tear Gas"},
{"Binoculars"},
{"Parachute"},
{"Makarov Mag"},
{"G17 Mag"},
{"M1911 Mag"},
{"M9 Mag"},
{".45 ACP"}
};

function noteAdmins(theAlert)
	for _,v in ipairs(getElementsByType("player")) do
		if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(v)), aclGetGroup("Admin"))) then
			outputChatBox("#FF0000[Backup]: #FFFFFF"..tostring(theAlert), v, 255, 255, 255,  true);
		end
	end
end

if (dbType == "MySQL") then
	db = dbConnect("mysql", "dbname="..dbName..";host="..dbHost..";port="..dbPort, dbUser, dbPass, "share=1");
	dbExec(db, "CREATE TABLE IF NOT EXISTS vehicles(model, x, y, z, rX, rY, rZ, slots, fuel, receiver, armorPoints, armorPointsMax, engines, moving, parts, items, id)");
	dbExec(db, "CREATE TABLE IF NOT EXISTS tents(model, x, y, z, rX, rY, rZ, slots, scale, items, id)");
	noteAdmins("Database connected to MySQL!");
elseif (dbType == "SQLite") then
	db = dbConnect("sqlite", "database.db");
	dbExec(db, "CREATE TABLE IF NOT EXISTS vehicles(model, x, y, z, rX, rY, rZ, slots, fuel, receiver, armorPoints, armorPointsMax, engines, moving, parts, items, id)");
	dbExec(db, "CREATE TABLE IF NOT EXISTS tents(model, x, y, z, rX, rY, rZ, slots, scale, items, id)");
	noteAdmins("Database connected to SQLite!");
else
	noteAdmins("Error: `dbType` wrong attribute!");
	return false;
end

function backup_vehs()
	dbExec(db, "DELETE FROM vehicles");
	local vehicleCounter = 0;
	for _,veh in ipairs(getElementsByType("vehicle")) do
		if (not getElementData(veh, "helicrash") and not getElementData(veh, "deadVehicle")) then
			local col = getElementData(veh, "parent");
			if (col and getElementType(col) == "colshape") then
				local model = getElementModel(veh);
				local x, y, z = getElementPosition(veh);
				local rX, rY, rZ = getElementRotation(veh);
				local slots = getElementData(col, "MAX_Slots") or 20;
				local fuel = getElementData(col, "fuel") or 0;
				
				local spawnx = setElementData(col,"spawn_x",getElementData(col,"spawn")[2]); -- Linha para pegar o spawn
				local spawny = setElementData(col,"spawn_y",getElementData(col,"spawn")[3]); -- Linha para pegar o spawn
				local spawnz = setElementData(col,"spawn_z",getElementData(col,"spawn")[4]); -- Linha para pegar o spawn
				
				local moving = getElementData(col, "Tire_inVehicle") or 0;
				local engines = getElementData(col, "Engine_inVehicle") or 0;
				local parts = getElementData(col, "Parts_inVehicle") or 0;
				
				local siren = getElementData(col, "Sirene_inVehicle") or 0;
				local receiver = getElementData(col, "receiver") or 0;
				local armorPointsMax = getElementData(col, "armorPointsMax") or 0;
				local armorPoints = getElementData(col, "armorPoints") or 0;
				
				local items = {};
				vehicleCounter = vehicleCounter + 1;
				for _,v in ipairs(itemsDataTable) do
					local quantity = getElementData(col, v[1]) or 0;
					if (quantity > 0) then
						table.insert(items, {v[1], quantity});
					end
				end
				dbExec(db, "INSERT INTO vehicles(model, x, y, z, rX, rY, rZ, slots, fuel, engines, receiver, armorPoints, armorPointsMax, moving, parts, items, id) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", model, x, y, z, rX, rY, rZ, slots, fuel, engines, receiver, armorPoints, armorPointsMax, moving, parts, toJSON(items), vehicleCounter)
			end
		end
	end
	noteAdmins("Veículos Salvos ["..vehicleCounter.."]");
end
addEventHandler("onResourceStop",getResourceRootElement(),backup_vehs)
setTimer(backup_vehs,3600000,0)

function backup_tents()
	dbExec(db, "DELETE FROM tents");
	local tentsCounter = 0;
	for _,col in ipairs(getElementsByType("colshape")) do
		if (getElementData(col, "tent")) then
			local tent = getElementData(col, "parent");
			local x, y, z = getElementPosition(tent);
			local rX, rY, rZ = getElementRotation(tent);
			local model = getElementModel(tent);
			local slots = getElementData(col, "MAX_Slots") or 300;
			local scale = getObjectScale(tent);
			local items = {};
			tentsCounter = tentsCounter + 1;
			for _,v in ipairs(itemsDataTable) do
				local quantity = getElementData(col, v[1]) or 0;
				if (quantity > 0) then
					table.insert(items, {v[1], quantity});
				end
			end
			dbExec(db, "INSERT INTO tents(model, x, y, z, rX, rY, rZ, slots, scale, items, id) VALUES(?,?,?,?,?,?,?,?,?,?,?)", model, x, y, z, rX, rY, rZ, slots, scale, toJSON(items), tentsCounter)
		end
	end
	noteAdmins("Tendas Salvas ["..tentsCounter.."]");
end
addEventHandler("onResourceStop",getResourceRootElement(),backup_tents)
setTimer(backup_tents,3600000,0)

function create_veh(model, x, y, z, rX, rY, rZ, slots, fuel, receiver, armorPoints, armorPointsMax, engines, moving, parts, items, id)
	local veh = createVehicle(model, x, y, z+1);
	local vehCol = createColSphere(x, y, z, 4);
	setElementRotation(veh, rX, rY, rZ);
	attachElements(vehCol, veh, 0, 0, 0);
	setElementData(vehCol, "parent", veh);
	setElementData(veh, "parent", vehCol);
	setElementData(vehCol, "vehicle", true);
	setElementData(vehCol, "MAX_Slots", tonumber(slots));
	setElementData(vehCol, "Tire_inVehicle", tonumber(moving));
	setElementData(vehCol, "Engine_inVehicle", tonumber(engines));
	setElementData(vehCol, "Parts_inVehicle", tonumber(parts));
	setElementData(vehCol, "fuel", tonumber(fuel));
	setElementData(vehCol, "receiver", tonumber(receiver));
	setElementData(vehCol, "armorPointsMax", tonumber(armorPointsMax));
	setElementData(vehCol, "armorPoints", tonumber(armorPoints));
	xxx,yyy,zzz = setElementData(vehCol,"spawn_x"),setElementData(vehCol,"spawn_y"),setElementData(vehCol,"spawn_z"); -- Linha onde vai puxar o spawn na função acima
	setElementData(vehCol,"spawn",{setElementData(vehCol,"model"),xxx,yyy,zzz}); -- linha que pega o spawn e o model do vehicle
	
	
	for _,v in ipairs(fromJSON(items)) do
		setElementData(vehCol, v[1], v[2]);
	end
end

function create_tent(model, x, y, z, rX, rY, rZ, slots, scale, items, id)
	local tent = createObject(model, x, y, z);
	local tentCol = createColSphere(x, y, z,  4);
	setElementRotation(tent, rX, rY, rZ);
	setObjectScale(tent, scale);
	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", slots);
	setElementData(tentCol,"visible",true)
	for _,v in ipairs(fromJSON(items)) do
		setElementData(tentCol, v[1], v[2]);
	end
end

function load_vehs(q)
	if (q) then
		local p = dbPoll(q, 0);
		if (#p > 0) then
			for _,d in pairs(p) do
				last_veh_id = d["id"];
				create_veh(d["model"], d["x"], d["y"], d["z"], d["rX"], d["rY"], d["rZ"], d["slots"], d["fuel"],d["receiver"], d["armorPoints"], d["armorPointsMax"], d["engines"], d["moving"], d["parts"], d["items"], d["id"]);
			end
		end
	end
	noteAdmins("Veiculos Carregados!");
end

function load_tents(q)
	if (q) then
		local p = dbPoll(q, 0);
		if (#p > 0) then
			for _,d in pairs(p) do
				last_tent_id = d["id"];
				create_tent(d["model"], d["x"], d["y"], d["z"], d["rX"], d["rY"], d["rZ"], d["slots"], d["scale"], d["items"], d["id"]);
			end
		end
	end 
	noteAdmins("Tendas Carregadas!");
end

function  start_resource ()
   dbQuery(load_tents, {}, db, "SELECT * FROM `tents`")
   dbQuery(load_vehs, {}, db, "SELECT * FROM `vehicles`")
end
addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), start_resource) 

addEventHandler("onPlayerCommand", root, function(cmd)
	if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin"))) then
		if (cmd == "loadtent") then --carregar tendas
			dbQuery(load_tents, {}, db, "SELECT * FROM `tents`");
		elseif (cmd == "loadcar") then --carregar veiculos
			dbQuery(load_vehs, {}, db, "SELECT * FROM `vehicles`");
		elseif (cmd == "savecar") then --salvar veiculos
			backup_vehs();
		elseif (cmd == "savetent") then -- salvar tendas
			backup_tents();
		elseif (cmd == "backup") then --start stop backup  a cada 30 minutos
			if (isTimer(vehbkTimer) and isTimer(tentbkTimer)) then
				killTimer(vehbkTimer);
				killTimer(tentbkTimer);
				noteAdmins(getPlayerName(source).."#FFFFFF Backup Automatico Parado!");
			else
				vehbkTimer = setTimer(backup_vehs, 30*60000, 0);
				tentbkTimer = setTimer(backup_tents, 30*60000, 0);
				noteAdmins(getPlayerName(source).."#FFFFFF Backup Automatico Iniciado!");
			end
		end
	end
end);

 Fiz outra alteração, porém não vai também, e da um erro direcionando para a GM, onde da em uma linha que não tem nada a ver com oque estou mexendo, ou seja creio que o erro seja onde editei, porém nao sei aonde estou errando.

Link to post
5 minutes ago, Lukkas2201 said:

sim, a quetão não é ver códigos prontos, mas sim saber onde está o erro, eu não consigo saber onde está, eu tento varias modificações, e tenho algumas outras gms aqui onde tento procurar também alguma função parecida, pego alguns codigos, mas não da em nada.

Entendi.. poste aqui novamente o você já tentou. 

Link to post
19 hours ago, Lukkas2201 said:

sim, a quetão não é ver códigos prontos, mas sim saber onde está o erro, eu não consigo saber onde está, eu tento varias modificações, e tenho algumas outras gms aqui onde tento procurar também alguma função parecida, pego alguns codigos, mas não da em nada.


--## Copyright (c) 2015 Grosu `PoWeR` Mihaita.--## MTA:DayZ Backup System v1.5.local dbType = "SQLite";  --Here set your db type, "MySQL" or "SQLite" <!>local dbName = "";        --Your database name <!>local dbHost = "";		  --Your hostname/IP <!>local dbUser = "";		  --Username for database <!>local dbPass = "";		  --Password for database <!>local dbPort = 1234; 	  --This is an port exemple CHANGE IT <!>local last_veh_id = 0;	  --Don't edit here <!>local last_tent_id = 0;   --Don't edit here <!>local itemsDataTable = { -- If your server have different items be sure you imported your item table here!	{"M4A1"},{"M4A1 CCO"},{"M4A1 CCO SD"},{"Sa-58P"},{"Sa-58P CCO"},{"M4A3 CCO"},{"M16A4 ACOG"},{"G36C (Camo)"},{"M16A2"},{"FN FAL"},{"AKS-74U"},{"AKS (Gold)"},{"MG36"},{"Bizon PP-19 SD"},{"AK-107"},{"AK-107 GL"},{"AK-74"},{"G36C"},{"Gorro Noel"},{"G36C SD"},{"AKS-74 Kobra"},{"AKM"},{"RPK"},{"CZ 550"},{"SVD CAMO"},{"M40A3"},{"DMR"},{"M24"},{"M107"},{"AS50"},{"KSVK"},{"Cheytac M200"},{"M249 SAW"},{"Mk 48 Mod 0"},{"M240"},{"PKM"},{"PKP"},{"Double-Barreled Shotgun"},{"M1014"},{"Remington 870"},{"Winchester 1866"},{"Sawn-Off Shotgun"},{"PDW"},{"MP5A5"},{"MP5SD6"},{"Machete"},{"Hatchet"},{"Crowbar"},{"Shovel"},{"Makarov PM"},{"Makarov SD"},{"G17"},{"M1911"},{"M9"},{"M9 SD"},{"Revolver"},{"Balanced Vest"},{"Press Vest"},{"Police Vest"},{"Light Tactical Vest"},{"Balistic Vest"},{"UK Assalt Vest DPM Camo"},{"UK Assalt Vest DPM Black"},{"Balistic Plus Vest"},{"Helmet"},{"Mossy Helmet"},{"UN Helmet"},{"Gorro Noel"},{"Aviator Helmet"},{"Gas Mask 1"},{"Gas Mask 2"},{"Motorbike Helmet 1"},{"Motorbike Helmet 2"},{"Motorbike Helmet 3"},{"Motorbike Helmet 4"},{"Skate Helmet"},{"Tanker Helmet"},{"Welding Helmet 1"},{"Welding Helmet 2"},{"Smersh Backpack"},{"Courier Bag"},{"Child Briefcase"},{"Improvised Backpack"},{"Assault Pack (ACU)"},{"Alice Pack"},{"British Assault Pack"},{"Taloon Backpack"},{"Omega Backpack"},{"Alfa Backpack"},{"Hunting Backpack"},{"Camping Backpack"},{"Drybag Backpack"},{"Mountain Backpack"},{"Czech Backpack"},{"Camping Tactical Backpack"},{"Coyote Backpack"},{"Coyote Backpack (Desert)"},{"Coyote Backpack (Mossy)"},{"Tactical Backpack"},{"Eskimo Backpack"},{"Tiger Backpack"},{"Noel Backpack"},{"Canned Spaghetti (Fechado)"},{"Canned Spaghetti (Aberto)"},{"Canned Baked Beans (Fechado)"},{"Canned Baked Beans (Aberto)"},{"Canned Sardines (Fechado)"},{"Canned Sardines (Aberto)"},{"Can of Tactical Bacon (Fechado)"},{"Can of Tactical Bacon (Aberto)"},{"Water Bottle"},{"Burger"},{"Pizza"},{"Soda Bottle"},{"Milk"},{"Cooked Meat"},{"Raw Meat"},{"Antibiotics"},{"Bandage"},{"Medic Kit"},{"Heat Pack"},{"Painkiller"},{"Blood Bag"},{"Morphine"},{"Engine"},{"Tire"},{"Tank Parts"},{"Scrap Metal"},{"Steel Sheet"},{"Empty Gas Canister"},{"Full Gas Canister"},{"Stinger"},{"Wood Pile"},{"Roadflare"},{"Wire Fence"},{"Tent"},{"Empty Water Bottle"},{"Empty Soda Cans"},{"Night Vision Goggles"},{"Infrared Goggles"},{"Map"},{"Box of Matches"},{"Watch"},{"GPS"},{"Toolbox"},{"Radio Device"},{"Syringe"},{"Opener"},{"Hose"},{"Tire Repair Kit"},{"Compass"},-------{"30Rnd. STANAG"},{"FN FAL Mag."},{"G36 Mag"},{"30Rnd. AK"},{"CZ 550 Mag."},{"SVD Mag."},{"M24 Mag."},{"DMR Mag."},{"10Rnd. M107"},{"5Rnd. KSVK"},{"5Rnd. Cheytac M200"},{"100Rnd. M249 SAW"},{"100Rnd. M240."},{"PKM Mag."},{"2Rnd. Slug"},{"Bizon Mag"},{"MG36 Mag."},{"M1014 Slug"},{"1866 Slug"},{"PDW Mag"},{"AKM Mag."},{"5Rnd 12.7x99mm NATO"},{"Sa-58 Mag."},{"MP5 Mag"},{"Grenade"},{"Tear Gas"},{"Binoculars"},{"Parachute"},{"Makarov Mag"},{"G17 Mag"},{"M1911 Mag"},{"M9 Mag"},{".45 ACP"}};function noteAdmins(theAlert)	for _,v in ipairs(getElementsByType("player")) do		if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(v)), aclGetGroup("Admin"))) then			outputChatBox("#FF0000[Backup]: #FFFFFF"..tostring(theAlert), v, 255, 255, 255,  true);		end	endendif (dbType == "MySQL") then	db = dbConnect("mysql", "dbname="..dbName..";host="..dbHost..";port="..dbPort, dbUser, dbPass, "share=1");	dbExec(db, "CREATE TABLE IF NOT EXISTS vehicles(model, x, y, z, rX, rY, rZ, slots, fuel, receiver, armorPoints, armorPointsMax, engines, moving, parts, items, id)");	dbExec(db, "CREATE TABLE IF NOT EXISTS tents(model, x, y, z, rX, rY, rZ, slots, scale, items, id)");	noteAdmins("Database connected to MySQL!");elseif (dbType == "SQLite") then	db = dbConnect("sqlite", "database.db");	dbExec(db, "CREATE TABLE IF NOT EXISTS vehicles(model, x, y, z, rX, rY, rZ, slots, fuel, receiver, armorPoints, armorPointsMax, engines, moving, parts, items, id)");	dbExec(db, "CREATE TABLE IF NOT EXISTS tents(model, x, y, z, rX, rY, rZ, slots, scale, items, id)");	noteAdmins("Database connected to SQLite!");else	noteAdmins("Error: `dbType` wrong attribute!");	return false;endfunction backup_vehs()	dbExec(db, "DELETE FROM vehicles");	local vehicleCounter = 0;	for _,veh in ipairs(getElementsByType("vehicle")) do		if (not getElementData(veh, "helicrash") and not getElementData(veh, "deadVehicle")) then			local col = getElementData(veh, "parent");			if (col and getElementType(col) == "colshape") then				local model = getElementModel(veh);				local x, y, z = getElementPosition(veh);				local rX, rY, rZ = getElementRotation(veh);				local slots = getElementData(col, "MAX_Slots") or 20;				local fuel = getElementData(col, "fuel") or 0;								local spawnx = setElementData(col,"spawn_x",getElementData(col,"spawn")[2]); -- Linha para pegar o spawn				local spawny = setElementData(col,"spawn_y",getElementData(col,"spawn")[3]); -- Linha para pegar o spawn				local spawnz = setElementData(col,"spawn_z",getElementData(col,"spawn")[4]); -- Linha para pegar o spawn								local moving = getElementData(col, "Tire_inVehicle") or 0;				local engines = getElementData(col, "Engine_inVehicle") or 0;				local parts = getElementData(col, "Parts_inVehicle") or 0;								local siren = getElementData(col, "Sirene_inVehicle") or 0;				local receiver = getElementData(col, "receiver") or 0;				local armorPointsMax = getElementData(col, "armorPointsMax") or 0;				local armorPoints = getElementData(col, "armorPoints") or 0;								local items = {};				vehicleCounter = vehicleCounter + 1;				for _,v in ipairs(itemsDataTable) do					local quantity = getElementData(col, v[1]) or 0;					if (quantity > 0) then						table.insert(items, {v[1], quantity});					end				end				dbExec(db, "INSERT INTO vehicles(model, x, y, z, rX, rY, rZ, slots, fuel, engines, receiver, armorPoints, armorPointsMax, moving, parts, items, id) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)", model, x, y, z, rX, rY, rZ, slots, fuel, engines, receiver, armorPoints, armorPointsMax, moving, parts, toJSON(items), vehicleCounter)			end		end	end	noteAdmins("Veículos Salvos ["..vehicleCounter.."]");endaddEventHandler("onResourceStop",getResourceRootElement(),backup_vehs)setTimer(backup_vehs,3600000,0)function backup_tents()	dbExec(db, "DELETE FROM tents");	local tentsCounter = 0;	for _,col in ipairs(getElementsByType("colshape")) do		if (getElementData(col, "tent")) then			local tent = getElementData(col, "parent");			local x, y, z = getElementPosition(tent);			local rX, rY, rZ = getElementRotation(tent);			local model = getElementModel(tent);			local slots = getElementData(col, "MAX_Slots") or 300;			local scale = getObjectScale(tent);			local items = {};			tentsCounter = tentsCounter + 1;			for _,v in ipairs(itemsDataTable) do				local quantity = getElementData(col, v[1]) or 0;				if (quantity > 0) then					table.insert(items, {v[1], quantity});				end			end			dbExec(db, "INSERT INTO tents(model, x, y, z, rX, rY, rZ, slots, scale, items, id) VALUES(?,?,?,?,?,?,?,?,?,?,?)", model, x, y, z, rX, rY, rZ, slots, scale, toJSON(items), tentsCounter)		end	end	noteAdmins("Tendas Salvas ["..tentsCounter.."]");endaddEventHandler("onResourceStop",getResourceRootElement(),backup_tents)setTimer(backup_tents,3600000,0)function create_veh(model, x, y, z, rX, rY, rZ, slots, fuel, receiver, armorPoints, armorPointsMax, engines, moving, parts, items, id)	local veh = createVehicle(model, x, y, z+1);	local vehCol = createColSphere(x, y, z, 4);	setElementRotation(veh, rX, rY, rZ);	attachElements(vehCol, veh, 0, 0, 0);	setElementData(vehCol, "parent", veh);	setElementData(veh, "parent", vehCol);	setElementData(vehCol, "vehicle", true);	setElementData(vehCol, "MAX_Slots", tonumber(slots));	setElementData(vehCol, "Tire_inVehicle", tonumber(moving));	setElementData(vehCol, "Engine_inVehicle", tonumber(engines));	setElementData(vehCol, "Parts_inVehicle", tonumber(parts));	setElementData(vehCol, "fuel", tonumber(fuel));	setElementData(vehCol, "receiver", tonumber(receiver));	setElementData(vehCol, "armorPointsMax", tonumber(armorPointsMax));	setElementData(vehCol, "armorPoints", tonumber(armorPoints));	xxx,yyy,zzz = setElementData(vehCol,"spawn_x"),setElementData(vehCol,"spawn_y"),setElementData(vehCol,"spawn_z"); -- Linha onde vai puxar o spawn na função acima	setElementData(vehCol,"spawn",{setElementData(vehCol,"model"),xxx,yyy,zzz}); -- linha que pega o spawn e o model do vehicle			for _,v in ipairs(fromJSON(items)) do		setElementData(vehCol, v[1], v[2]);	endendfunction create_tent(model, x, y, z, rX, rY, rZ, slots, scale, items, id)	local tent = createObject(model, x, y, z);	local tentCol = createColSphere(x, y, z,  4);	setElementRotation(tent, rX, rY, rZ);	setObjectScale(tent, scale);	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", slots);	setElementData(tentCol,"visible",true)	for _,v in ipairs(fromJSON(items)) do		setElementData(tentCol, v[1], v[2]);	endendfunction load_vehs(q)	if (q) then		local p = dbPoll(q, 0);		if (#p > 0) then			for _,d in pairs(p) do				last_veh_id = d["id"];				create_veh(d["model"], d["x"], d["y"], d["z"], d["rX"], d["rY"], d["rZ"], d["slots"], d["fuel"],d["receiver"], d["armorPoints"], d["armorPointsMax"], d["engines"], d["moving"], d["parts"], d["items"], d["id"]);			end		end	end	noteAdmins("Veiculos Carregados!");endfunction load_tents(q)	if (q) then		local p = dbPoll(q, 0);		if (#p > 0) then			for _,d in pairs(p) do				last_tent_id = d["id"];				create_tent(d["model"], d["x"], d["y"], d["z"], d["rX"], d["rY"], d["rZ"], d["slots"], d["scale"], d["items"], d["id"]);			end		end	end 	noteAdmins("Tendas Carregadas!");endfunction  start_resource ()   dbQuery(load_tents, {}, db, "SELECT * FROM `tents`")   dbQuery(load_vehs, {}, db, "SELECT * FROM `vehicles`")endaddEventHandler("onResourceStart", getResourceRootElement(getThisResource()), start_resource) addEventHandler("onPlayerCommand", root, function(cmd)	if (isObjectInACLGroup("user."..getAccountName(getPlayerAccount(source)), aclGetGroup("Admin"))) then		if (cmd == "loadtent") then --carregar tendas			dbQuery(load_tents, {}, db, "SELECT * FROM `tents`");		elseif (cmd == "loadcar") then --carregar veiculos			dbQuery(load_vehs, {}, db, "SELECT * FROM `vehicles`");		elseif (cmd == "savecar") then --salvar veiculos			backup_vehs();		elseif (cmd == "savetent") then -- salvar tendas			backup_tents();		elseif (cmd == "backup") then --start stop backup  a cada 30 minutos			if (isTimer(vehbkTimer) and isTimer(tentbkTimer)) then				killTimer(vehbkTimer);				killTimer(tentbkTimer);				noteAdmins(getPlayerName(source).."#FFFFFF Backup Automatico Parado!");			else				vehbkTimer = setTimer(backup_vehs, 30*60000, 0);				tentbkTimer = setTimer(backup_tents, 30*60000, 0);				noteAdmins(getPlayerName(source).."#FFFFFF Backup Automatico Iniciado!");			end		end	endend);

 Fiz outra alteração, porém não vai também, e da um erro direcionando para a GM, onde da em uma linha que não tem nada a ver com oque estou mexendo, ou seja creio que o erro seja onde editei, porém nao sei aonde estou errando.

Resolver isso não será simples, mas, se o problema está quando faz o salvamento, e quando o carro explode, e ele é respwanado para o local que foi a salvo, faça o seguinte :

Utilize o evento de onVehicleExplode, e então quando explodir, remova este veiculo da tabela. (Uma possível solução, não que possa da certo).

Link to post

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