Jump to content

AJUDA COM COMANDO SPAWN VEHICLES


Recommended Posts

Oi, eu fiz um comando para spawnar os veículos do mapa quando eu usasse mas ele nao spawna não sei o que pode ser !

 

function spawnDayZVehicles (ps,cmd)
	if getElementData(ps,"admin") then
		spawnDayZVehicles()
		outputChatBox("#00FF00[INFO] - Veículos spawnados com sucesso!",ps,255,0,0,true)
	end
end
addCommandHandler("spawncars",spawnDayZVehicles)

 

Variavel dos veículos: 

dayzVehicles = {}
function spawnDayZVehicles()
	if getElementData(getRootElement(),"serverhasloadvehicles") then return 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)
		--Engine + Tires
		local tires,engine = getVehicleAddonInfos (getElementModel(veh))
		setElementData(vehCol,"Tire_inVehicle",math.random(0,tires))
		setElementData(vehCol,"Engine_inVehicle",math.random(0,engine))
		--vehicle_indentifikation
		setElementData(vehCol,"spawn",{422,x,y,z})
		--others
		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)
		--Engine + Tires
		local tires,engine = getVehicleAddonInfos (getElementModel(veh))
		setElementData(vehCol,"Tire_inVehicle",math.random(0,tires))
		setElementData(vehCol,"Engine_inVehicle",math.random(0,engine))
		--vehicle_indentifikation
		setElementData(vehCol,"spawn",{470,x,y,z})
		--others
		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)
		--Engine + Tires
		local tires,engine = getVehicleAddonInfos (getElementModel(veh))
		setElementData(vehCol,"Tire_inVehicle",math.random(0,tires))
		setElementData(vehCol,"Engine_inVehicle",math.random(0,engine))
		--vehicle_indentifikation
		setElementData(vehCol,"spawn",{468,x,y,z})
		--others
		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)
		--Engine + Tires
		local tires,engine = getVehicleAddonInfos (getElementModel(veh))
		setElementData(vehCol,"Tire_inVehicle",math.random(0,tires))
		setElementData(vehCol,"Engine_inVehicle",math.random(0,engine))
		--vehicle_indentifikation
		setElementData(vehCol,"spawn",{433,x,y,z})
		--others
		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)
		--Engine + Tires
		local tires,engine = getVehicleAddonInfos (getElementModel(veh))
		setElementData(vehCol,"Tire_inVehicle",math.random(0,tires))
		setElementData(vehCol,"Engine_inVehicle",math.random(0,engine))
		--vehicle_indentifikation
		setElementData(vehCol,"spawn",{437,x,y,z})
		--others
		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)
		--Engine + Tires
		local tires,engine = getVehicleAddonInfos (getElementModel(veh))
		setElementData(vehCol,"Tire_inVehicle",math.random(0,tires))
		setElementData(vehCol,"Engine_inVehicle",math.random(0,engine))
		--vehicle_indentifikation
		setElementData(vehCol,"spawn",{453,x,y,z})
		--others
		setElementData(vehCol,"fuel",10)
	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
		local tires,engine = getVehicleAddonInfos (487)
		setElementData(vehCol,"Tire_inVehicle",math.random(0,tires))
		setElementData(vehCol,"Engine_inVehicle",math.random(0,engine))
		--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
		local tires,engine = getVehicleAddonInfos (497)
		setElementData(vehCol,"Tire_inVehicle",math.random(0,tires))
		setElementData(vehCol,"Engine_inVehicle",math.random(0,engine))
		--vehicle_indentifikation
		setElementData(vehCol,"spawn",{497,x,y,z})
		--others
		setElementData(vehCol,"fuel",10)
end

Se alguém poder ajudar obrigado !

Link to comment
  • Other Languages Moderators

Esses dois códigos estão no mesmo script? Se estiverem em scripts separados, os dois são server-side?

Já usou /debugscript 3 pra saber qual o erro que está gerando?

Edited by Lord Henry
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...