Jump to content

Save-system for vehicle?


Cronoss

Recommended Posts

I want to save the last position of a car (with owner) but the console keeps giving me a error (getAccount line) :/

function guardarAuto(player)
	local veh = getNearestVehicle(player,5) or Ped.getOccupiedVehicle(player)
	if (veh) then
		local acc = player:getAccount()
		local owner = acc:getName()
		local location = player:getPosition()
		local rotation = player:getRotation()
		local int = player:getInterior()
		local dim = player:getDimension()
		local loc = toJSON({location.x,location.y,location.z})
		local rot = toJSON({rotation.x,rotation.y,rotation.z})
		if (veh:getData("vehicles:owner") == owner) then
			local id = getElementData(veh, "vehicles:id")
		end
	end
end)
addEventHandler("onPlayerQuit", root, guardarAuto)

I know I post many scripting questions, sorry :/

Link to comment
function guardarAuto()
  player = source
	local veh = getNearestVehicle(player,5) or Ped.getOccupiedVehicle(player)
	if (veh) then
		local acc = player:getAccount()
		local owner = acc:getName()
		local location = player:getPosition()
		local rotation = player:getRotation()
		local int = player:getInterior()
		local dim = player:getDimension()
		local loc = toJSON({location.x,location.y,location.z})
		local rot = toJSON({rotation.x,rotation.y,rotation.z})
		if (veh:getData("vehicles:owner") == owner) then
			local id = getElementData(veh, "vehicles:id")
		end
	end
end)
addEventHandler("onPlayerQuit", root, guardarAuto)

Can you try this

  • Like 1
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...