Jump to content

Respawn vehicle by command


xXGhostXx

Recommended Posts

Posted

you can't just make a default respawn vehicle, that depends on you vehicle resource

but you can make it with

getElementPosition --You can park it
getElementData
setElementPosition
setElementData

 

Posted

As @LyricalMM said,

           you can create a vehicle, and set a data to it that change when player enter the vehicle or when the vehicle get destroyed or something else. then you can use

addCommandHandler

function to add a command to respawn the vehicle if vehicle's data has changed.

Posted
addCommandHandler("createvehicle",
function(player, cmd, id, numberplate)
	if isElement(player) and id then
		local matrix = getElementMatrix(player)
		local x = 3 * matrix[1][1] + 0 * matrix[2][1] - 0 * matrix[3][1] + matrix[4][1]
		local y = 3 * matrix[1][2] + 0 * matrix[2][2] - 0 * matrix[3][2] + matrix[4][2]
		local z = 3 * matrix[1][3] + 0 * matrix[2][3] - 0 * matrix[3][3] + matrix[4][3]
		local rX, rY, rZ = getElementRotation(player)

		local vehicle = createVehicle(id, x, y, z, rX, rY, rZ, numberplate)

		if isElement(vehicle) then
			outputChatBox("You have created a "..getVehicleNameFromModel(id), player, 0, 255, 0)
		else
			outputChatBox("Wrong id", player, 255, 0, 0)
		end
	else
		outputChatBox("/createvehicle [id] [numberplate] (createvehicle 415 X001UY)", player, 255, 0, 0)
	end
end)

 

Posted
9 hours ago, SaNoR said:

addCommandHandler("createvehicle",
function(player, cmd, id, numberplate)
	if isElement(player) and id then
		local matrix = getElementMatrix(player)
		local x = 3 * matrix[1][1] + 0 * matrix[2][1] - 0 * matrix[3][1] + matrix[4][1]
		local y = 3 * matrix[1][2] + 0 * matrix[2][2] - 0 * matrix[3][2] + matrix[4][2]
		local z = 3 * matrix[1][3] + 0 * matrix[2][3] - 0 * matrix[3][3] + matrix[4][3]
		local rX, rY, rZ = getElementRotation(player)

		local vehicle = createVehicle(id, x, y, z, rX, rY, rZ, numberplate)

		if isElement(vehicle) then
			outputChatBox("You have created a "..getVehicleNameFromModel(id), player, 0, 255, 0)
		else
			outputChatBox("Wrong id", player, 255, 0, 0)
		end
	else
		outputChatBox("/createvehicle [id] [numberplate] (createvehicle 415 X001UY)", player, 255, 0, 0)
	end
end)

 

Create vehicle no !

I want respawn vehicle element data "faction" "car"

Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...