Jump to content

Help whit a function


Ernesto

Recommended Posts

addEventHandler( "onVehicleStartExit", resourceRoot,
	function( player )
		local vehicle = getPedOccupiedVehicle( player )
		if vehicle then
			local data = vehicles[ vehicle ]
			if data then
				if data.vehicleID < 0 then
					outputChatBox( "This temporal car " .. data.vehicleID .. " (" .. getVehicleName( vehicle ) .. ") can´t be parked.", 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.addmap", 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( "The car " .. data.vehicleID .. " (" .. getVehicleName( vehicle ) .. ") has been parked.", player, 0, 255, 0 )
					else
						outputChatBox( "Parking Failed.", player, 255, 0, 0 )
					end
				else
					outputChatBox( "You can´t park thiscar.", player, 255, 0, 0 )
				end
			end
		else
			outputChatBox( "You are not driving any car.", player, 255, 0, 0 )
		end
	end
)

The same thing happens to me :( Any idea how to fix it?

 

There is the function : 

 

Spoiler

addEventHandler( "onVehicleStartExit", resourceRoot,
    function( player )
        local vehicle = getPedOccupiedVehicle( player )
        if vehicle then
            local data = vehicles[ vehicle ]
            if data then
                if data.vehicleID < 0 then
                    outputChatBox( "This temporal car " .. data.vehicleID .. " (" .. getVehicleName( vehicle ) .. ") can´t be parked.", 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.addmap", 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( "The car " .. data.vehicleID .. " (" .. getVehicleName( vehicle ) .. ") has been parked.", player, 0, 255, 0 )
                    else
                        outputChatBox( "Parking Failed.", player, 255, 0, 0 )
                    end
                else
                    outputChatBox( "You can´t park thiscar.", player, 255, 0, 0 )
                end
            end
        else
            outputChatBox( "You are not driving any car.", player, 255, 0, 0 )
        end
    end
)

 

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