Jump to content

¿Como podria hacer que al bajar del coche se haga esta funccion? :


Ernesto

Recommended Posts

addCommandHandler( "park69",
	function( player, commandName )
		local vehicle = getPedOccupiedVehicle( player )
		if vehicle then
			local data = vehicles[ vehicle ]
			if data then
				if data.vehicleID < 0 then
				elseif ( data.characterID > 0 and exports.players:getCharacterID( player ) == data.characterID and exports.items:has ( player, 1, data.vehicleID ) ) or hasObjectPermissionTo( player, "command.spectate", false ) and not isVehicleJob [ getVehicleName ( vehicle ) ] then
					local x, y, z = getElementPosition( vehicle )
					local rx, ry, rz = getVehicleRotation( vehicle )
					local success, error = exports.sql:query_free( "UPDATE vehicles SET respawnPosX = " .. x .. ", respawnPosY = " .. y .. ", respawnPosZ = " .. z .. ", respawnRotX = " .. rx .. ", respawnRotY = " .. ry .. ", respawnRotZ = " .. rz .. ", respawnInterior = " .. getElementInterior( vehicle ) .. ", respawnDimension = " .. getElementDimension( vehicle ) .. " WHERE vehicleID = " .. data.vehicleID )
					if success then
						setVehicleRespawnPosition( vehicle, x, y, z, rx, ry, rz )
						data.respawnInterior = getElementInterior( vehicle )
						data.respawnDimension = getElementDimension( vehicle )
						saveVehicle( vehicle )
					else
					end
				else
				end
			end
		else
		end
	end
)

 

Lo llevo intentando uno monton de días y no me sale.

Gracias al que me responda y lo lea

 

addCommandHandler( "park",
	function( player, commandName )
		local vehicle = getPedOccupiedVehicle( player )
		if vehicle then
			local data = vehicles[ vehicle ]
			if data then
				if data.vehicleID < 0 then
					outputChatBox( "Tú vehículo temporal " .. data.vehicleID .. " (" .. getVehicleName( vehicle ) .. ") no puede ser parkeado.", player, 255, 0, 0 )
				elseif ( data.characterID > 0 and exports.players:getCharacterID( player ) == data.characterID and exports.items:has ( player, 1, data.vehicleID ) ) or hasObjectPermissionTo( player, "command.spectate", false ) and not isVehicleJob [ getVehicleName ( vehicle ) ] then
					local x, y, z = getElementPosition( vehicle )
					local rx, ry, rz = getVehicleRotation( vehicle )
					local success, error = exports.sql:query_free( "UPDATE vehicles SET respawnPosX = " .. x .. ", respawnPosY = " .. y .. ", respawnPosZ = " .. z .. ", respawnRotX = " .. rx .. ", respawnRotY = " .. ry .. ", respawnRotZ = " .. rz .. ", respawnInterior = " .. getElementInterior( vehicle ) .. ", respawnDimension = " .. getElementDimension( vehicle ) .. " WHERE vehicleID = " .. data.vehicleID )
					if success then
						setVehicleRespawnPosition( vehicle, x, y, z, rx, ry, rz )
						data.respawnInterior = getElementInterior( vehicle )
						data.respawnDimension = getElementDimension( vehicle )
						saveVehicle( vehicle )
						outputChatBox( "El vehículo " .. data.vehicleID .. " (" .. getVehicleName( vehicle ) .. ") fue parkeado.", player, 0, 255, 0 )
					else
						outputChatBox( "Parkeo del vehículo fallido.", player, 255, 0, 0 )
					end
				else
					outputChatBox( "No puedes parkear éste vehículo.", player, 255, 0, 0 )
				end
			end
		else
			outputChatBox( "No estás conduciendo un coche.", player, 255, 0, 0 )
		end
	end
)

Este seria con outputbox

Link to comment
45 minutes ago, Ernesto said:

Esque al hacerlo no me funcciona me dice que no estoy en el vehiculo al salir.

¿Qué puede pasar?

function autoparkeo(thePlayer, seat, jacked, player)
	if thePlayer and seat == 0 then
		local vehicle = getPedOccupiedVehicle( player )
		if vehicle then
			local data = vehicles[ vehicle ]
			if data then
				if data.vehicleID < 0 then
					outputChatBox( "Tú vehículo temporal " .. data.vehicleID .. " (" .. getVehicleName( vehicle ) .. ") no puede ser parkeado.", player, 255, 0, 0 )
				elseif ( data.characterID > 0 and exports.players:getCharacterID( player ) == data.characterID and exports.items:has ( player, 1, data.vehicleID ) ) or hasObjectPermissionTo( player, "command.spectate", false ) and not isVehicleJob [ getVehicleName ( vehicle ) ] then
					local x, y, z = getElementPosition( vehicle )
					local rx, ry, rz = getVehicleRotation( vehicle )
					local success, error = exports.sql:query_free( "UPDATE vehicles SET respawnPosX = " .. x .. ", respawnPosY = " .. y .. ", respawnPosZ = " .. z .. ", respawnRotX = " .. rx .. ", respawnRotY = " .. ry .. ", respawnRotZ = " .. rz .. ", respawnInterior = " .. getElementInterior( vehicle ) .. ", respawnDimension = " .. getElementDimension( vehicle ) .. " WHERE vehicleID = " .. data.vehicleID )
					if success then
						setVehicleRespawnPosition( vehicle, x, y, z, rx, ry, rz )
						data.respawnInterior = getElementInterior( vehicle )
						data.respawnDimension = getElementDimension( vehicle )
						saveVehicle( vehicle )
						outputChatBox( "El vehículo " .. data.vehicleID .. " (" .. getVehicleName( vehicle ) .. ") fue parkeado.", player, 0, 255, 0 )
					else
						outputChatBox( "Parkeo del vehículo fallido.", player, 255, 0, 0 )
					end
				else
					outputChatBox( "No puedes parkear éste vehículo.", player, 255, 0, 0 )
				end
			end
		else
			outputChatBox( "No estás conduciendo un coche.", player, 255, 0, 0 )
		end
	end
)
addEventHandler("onVehicleExit", getRootElement(), autoparkeo

 

Link to comment

@Ernesto

addEventHandler( "onVehicleExit", getRootElement( ),
	function( player, seat )
		if player and seat == 0 then
			local veh = getPedOccupiedVehicle( player )
			if veh then
				local data = vehicles[veh]
				if data then
					if data.vehicleID > 0 then
						local idplayer = exports.players:getCharacterID( player )
						if idplayer == data.characterID or hasObjectPermissionTo( player, "command.spectate", false ) and not isVehicleJob[ getVehicleName( veh ) ] then
							local x, y, z = getElementPosition( veh )
							local rx, ry, rz = getVehicleRotation( veh )
							local success, error = exports.sql:query_free( "UPDATE vehicles SET respawnPosX = " .. x .. ", respawnPosY = " .. y .. ", respawnPosZ = " .. z .. ", respawnRotX = " .. rx .. ", respawnRotY = " .. ry .. ", respawnRotZ = " .. rz .. ", respawnInterior = " .. getElementInterior( veh ) .. ", respawnDimension = " .. getElementDimension( veh ) .. " WHERE vehicleID = " .. data.vehicleID )
							if success then
								setVehicleRespawnPosition( veh, x, y, z, rx, ry, rz )
								data.respawnInterior = getElementInterior( veh )
								data.respawnDimension = getElementDimension( veh )
								saveVehicle( veh )
								outputChatBox( "El vehículo " .. data.vehicleID .. " (" .. getVehicleName( veh ) .. ") fue parkeado.", player, 0, 255, 0 )
							else
								outputChatBox( "Parkeo del vehículo fallido.", player, 255, 0, 0 )
							end							
						end
					end
				end
			end
		end
	end
)

 

Link to comment
55 minutes ago, aka Blue said:

@Ernesto


addEventHandler( "onVehicleExit", getRootElement( ),
	function( player, seat )
		if player and seat == 0 then
			local veh = getPedOccupiedVehicle( player )
			if veh then
				local data = vehicles[veh]
				if data then
					if data.vehicleID > 0 then
						local idplayer = exports.players:getCharacterID( player )
						if idplayer == data.characterID or hasObjectPermissionTo( player, "command.spectate", false ) and not isVehicleJob[ getVehicleName( veh ) ] then
							local x, y, z = getElementPosition( veh )
							local rx, ry, rz = getVehicleRotation( veh )
							local success, error = exports.sql:query_free( "UPDATE vehicles SET respawnPosX = " .. x .. ", respawnPosY = " .. y .. ", respawnPosZ = " .. z .. ", respawnRotX = " .. rx .. ", respawnRotY = " .. ry .. ", respawnRotZ = " .. rz .. ", respawnInterior = " .. getElementInterior( veh ) .. ", respawnDimension = " .. getElementDimension( veh ) .. " WHERE vehicleID = " .. data.vehicleID )
							if success then
								setVehicleRespawnPosition( veh, x, y, z, rx, ry, rz )
								data.respawnInterior = getElementInterior( veh )
								data.respawnDimension = getElementDimension( veh )
								saveVehicle( veh )
								outputChatBox( "El vehículo " .. data.vehicleID .. " (" .. getVehicleName( veh ) .. ") fue parkeado.", player, 0, 255, 0 )
							else
								outputChatBox( "Parkeo del vehículo fallido.", player, 255, 0, 0 )
							end							
						end
					end
				end
			end
		end
	end
)

 

Pasa lo mismo, al respawnear el vehiculo no se respawnea el coche donde sali del vehiculo si no que donde se creo el vehiculo

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