Ernesto Posted April 8, 2018 Share Posted April 8, 2018 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
KaR0n! Posted April 9, 2018 Share Posted April 9, 2018 (edited) usa el evento onVehicleExit . Edited April 9, 2018 by KaR0n! Link to comment
Ernesto Posted April 9, 2018 Author Share Posted April 9, 2018 9 hours ago, KaR0n! said: usa el evento onVehicleExit . Esque al hacerlo no me funcciona me dice que no estoy en el vehiculo al salir. ¿Qué puede pasar? Link to comment
Ernesto Posted April 9, 2018 Author Share Posted April 9, 2018 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
aka Blue Posted April 9, 2018 Share Posted April 9, 2018 @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
Ernesto Posted April 9, 2018 Author Share Posted April 9, 2018 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
MisterQuestions Posted April 17, 2018 Share Posted April 17, 2018 por que no debes de checar por el vehículo en el que está puesto que este evento es cuando ya salió de este, en todo caso usa source que es el vehículo del que salió. Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now