Jump to content

Glue vehicle on a moving object.


S3M

Recommended Posts

Posted

I made my own attachment script so, that when you drive a vehicle on a marker on a ship and type a command, it will be attached to the marker. The marker is attached to the ship. When you drive, the marker is attached to the ship and the car is still glued to the marker. It's simple.

Posted
I made my own attachment script so, that when you drive a vehicle on a marker on a ship and type a command, it will be attached to the marker. The marker is attached to the ship. When you drive, the marker is attached to the ship and the car is still glued to the marker. It's simple.

Ah oke nice idea THX, i gonna try that.

Posted
I made my own attachment script so, that when you drive a vehicle on a marker on a ship and type a command, it will be attached to the marker. The marker is attached to the ship. When you drive, the marker is attached to the ship and the car is still glued to the marker. It's simple.

You use server side only?

Thx

Posted

I got this.

Working almost, only after detach the vehicle fall through object.

    local vehicleHydra = createVehicle ( 520, -1409.5, 496.0, 11.9, 0, 0, 358.99487304688 ) 
    local vehicleHydra2 = createVehicle ( 520, -1419.5, 496.0, 11.9, 0, 0, 358.99487304688 ) 
  
    local deckMarker1 = createMarker ( -1410.3000488281, 506.79998779297, 10, "cylinder", 4, 255, 0, 0, 50 ) 
  
    local deck1 = createObject( 3114, -1414.4000244141, 505, 9.65, 0, 0, 0.2445068359375) 
  
addEventHandler("onResourceStart", gResRoot, 
    function () 
        setElementData ( deck1, "pos", "ground" ) 
  
  
  
     attachElements ( deckMarker1, deck1, 5, 0, 0 )   
  
function attach1 ( hitElement, deckMarker1 ) 
  
    if ( getElementType( hitElement ) == "vehicle" ) then 
        attachElements ( hitElement, deck1, 5, 0, 2.37 ) 
    end 
  
end 
  
addEventHandler ( "onMarkerHit", deckMarker1, attach1 ) 
  
    end 
) 
  
addCommandHandler("dck",  
    function () 
        if getElementData( deck1, "pos") == "ground" then 
            moveObject( deck1, 5000, -1414.4000244141, 520.90002441406, 9.7) 
            setElementData( deck1, "pos", "top") 
  
        else 
            moveObject( deck1, 6000, -1414.4000244141, 505, 9.7) 
            setElementData( deck1, "pos", "ground") 
        end 
    end 
) 
  
function detach ( thePlayer, commandName ) 
  
    local pVehicle = getPedOccupiedVehicle( thePlayer ) 
  
    detachElements ( pVehicle, deck1 ) 
  
 end 
  
addCommandHandler ( "detach", detach ) 

Posted

I'm away from mta scripting for a long time, but I am sure that the problem is because that your object doesnt have collision shape.

You need to do it with another object, or try to make a custom collision shape to that object (dont know if its possible..)

Good luck ;)

Posted
try lifting the vehicle a few inches from the moving object so that it reenters the colshape of the object. Should solve it

Exactly. Try to lift it with the setElementPosition function.

Posted

Like psydomin said, The problem is the lifting object don't have collision like grass, leaves of trees.

(I will say a above object "A".)

So, you can attach object (that imitates collision of A) to A.

The collision of the attached object should be similer to "A".

And you can hide the attaced object by using "setElementAlpha()".

If the object in video have collision, your ped and your vehicle can stand up the object.

Posted
vehicleHydra = createVehicle ( 520, -1409.5, 496.0, 11.9, 0, 0, 358.99487304688 ) 
vehicleHydra2 = createVehicle ( 520, -1419.5, 496.0, 11.9, 0, 0, 358.99487304688 ) 
deckMarker1 = createMarker ( -1410.3000488281, 506.79998779297, 10, "cylinder", 4, 255, 0, 0, 50 ) 
deck1 = createObject ( 3114, -1414.4000244141, 505, 9.65, 0, 0, 0.2445068359375 ) 
deck2 = createObject ( 3114, -1414.4000244141, 505, 8.5, 0, 0, 0.2445068359375 ) 
setElementAlpha ( deck2, 0 )  
attachElements ( deckMarker1, deck1, 5, 0, 0 )  
canMove = false 
  
addEventHandler ( "onMarkerHit", deckMarker1,   
    function ( hitElement ) 
        if ( getElementType( hitElement ) == "vehicle" ) then 
            attachElements ( hitElement, deck1, 5, 0, 2.37 ) 
        end 
    end 
, false )  
  
addCommandHandler ( "dck", 
    function ( thePlayer ) 
        if not canMove then 
            moveObject ( deck1, 5000, -1414.4000244141, 520.90002441406, 9.7 ) 
            moveObject ( deck2, 5000, -1414.4000244141, 520.90002441406, 9 ) 
            canMove = true 
        else 
            moveObject ( deck1, 6000, -1414.4000244141, 505, 9.7 ) 
            moveObject ( deck2, 5000, -1414.4000244141, 520.90002441406, 9 ) 
            canMove = false 
        end 
    end 
) 
  
addCommandHandler ( "detach",   
    function ( thePlayer )  
        local pVehicle = getPedOccupiedVehicle ( thePlayer ) 
        detachElements ( pVehicle, deck1 ) 
    end 
) 

Posted
vehicleHydra = createVehicle ( 520, -1409.5, 496.0, 11.9, 0, 0, 358.99487304688 ) 
vehicleHydra2 = createVehicle ( 520, -1419.5, 496.0, 11.9, 0, 0, 358.99487304688 ) 
deckMarker1 = createMarker ( -1410.3000488281, 506.79998779297, 10, "cylinder", 4, 255, 0, 0, 50 ) 
deck1 = createObject ( 3114, -1414.4000244141, 505, 9.65, 0, 0, 0.2445068359375 ) 
deck2 = createObject ( 3114, -1414.4000244141, 505, 8.5, 0, 0, 0.2445068359375 ) 
setElementAlpha ( deck2, 0 )  
attachElements ( deckMarker1, deck1, 5, 0, 0 )  
canMove = false 
  
addEventHandler ( "onMarkerHit", deckMarker1,   
    function ( hitElement ) 
        if ( getElementType( hitElement ) == "vehicle" ) then 
            attachElements ( hitElement, deck1, 5, 0, 2.37 ) 
        end 
    end 
, false )  
  
addCommandHandler ( "dck", 
    function ( thePlayer ) 
        if not canMove then 
            moveObject ( deck1, 5000, -1414.4000244141, 520.90002441406, 9.7 ) 
            moveObject ( deck2, 5000, -1414.4000244141, 520.90002441406, 9 ) 
            canMove = true 
        else 
            moveObject ( deck1, 6000, -1414.4000244141, 505, 9.7 ) 
            moveObject ( deck2, 5000, -1414.4000244141, 520.90002441406, 9 ) 
            canMove = false 
        end 
    end 
) 
  
addCommandHandler ( "detach",   
    function ( thePlayer )  
        local pVehicle = getPedOccupiedVehicle ( thePlayer ) 
        detachElements ( pVehicle, deck1 ) 
    end 
) 

Thx, the vehicle dont fall through anymore.

Only i can use the attach functie 1 time, the second vehicle don't attach only if i restart resource.

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