Jump to content

ejector seat


Chrimam

Recommended Posts

Hi. This is my script and what i am trying to do is, when you type /e in a vehicle, it will eject you through air and will make you land safely via a parachute. but i think i need to use setTimer thing because everything happens so fast that i can't even move through air and as soon as my seat is created, it is destroyed. hope you understand and help.

function carEject(source) 
    ocVeh = getPedOccupiedVehicle(source) 
        if (ocVeh) then 
             vehSeatNo = getPedOccupiedVehicleSeat(source) 
                if vehSeatNo == 0 then 
                    removePedFromVehicle(source, ocVeh) 
                    pX, pY, pZ = getElementPosition(source) 
                    rX, rY, rZ = getElementRotation(source) 
                    ejectorSeat = createObject(1562, pX, pY, pZ, rX, rY, rZ) 
                    setElementAlpha(ejectorSeat, 0) -- make the seat invis. 
                    setElementCollisionsEnabled(ejectorSeat, false) -- make the seat untouchable so as to avoid crashes 
                    attachElements(source, ejectorSeat, 0, 0, 0, 0, 0, 0) 
                    giveWeapon(source, 46) 
                    moveObject(ejectorSeat, 5000, pX, pY, pZ + 10) -- fly through air 
                    detachElements(source, ejectorSeat) -- when we reach our destination (pZ +10) it should detachElement 
                    destroyElement(ejectorSeat) -- after detaching is done, it should destroy it 
                end 
        end 
end 
addCommandHandler("e", carEject) 

Link to comment

Try this

function carEject(source) 
    ocVeh = getPedOccupiedVehicle(source) 
        if (ocVeh) then 
             vehSeatNo = getPedOccupiedVehicleSeat(source) 
                if vehSeatNo == 0 then 
                    removePedFromVehicle(source, ocVeh) 
                    pX, pY, pZ = getElementPosition(source) 
                    rX, rY, rZ = getElementRotation(source) 
                    ejectorSeat = createObject(1562, pX, pY, pZ, rX, rY, rZ) 
                    setElementAlpha(ejectorSeat, 0) -- make the seat invis. 
                    setElementCollisionsEnabled(ejectorSeat, false) -- make the seat untouchable so as to avoid crashes 
                    attachElements(source, ejectorSeat, 0, 0, 0, 0, 0, 0) 
                    giveWeapon(source, 46) 
                    moveObject(ejectorSeat, 5000, pX, pY, pZ + 10)  
                    setTimer(detachElements,5500,1,source,ejectorSeat) 
                    setTimer(destroyElement,6000,1,ejectorSeat)  
                end 
        end 
end 
addCommandHandler("e", carEject) 

Link to comment

EDIT: tested and working (it must be min + 100 on pZ to have time to open the Parachute , you will get the Parachute after you are deatached from the seat)

function carEject(player) 
    ocVeh = getPedOccupiedVehicle(player) 
        if (ocVeh) then 
             vehSeatNo = getPedOccupiedVehicleSeat(player) 
                if vehSeatNo == 0 then 
                    removePedFromVehicle(player, ocVeh) 
                    pX, pY, pZ = getElementPosition(player) 
                    rX, rY, rZ = getElementRotation(player) 
                    ejectorSeat = createObject(1562, pX, pY, pZ, rX, rY, rZ) 
                    setElementAlpha(ejectorSeat, 0) -- make the seat invis. 
                    setElementCollisionsEnabled(ejectorSeat, false) -- make the seat untouchable so as to avoid crashes 
                    attachElements(player, ejectorSeat, 0, 0, 0, 0, 0, 0) 
                    giveWeapon(player, 46,1,true) 
                    moveObject(ejectorSeat, 5000, pX, pY, pZ + 100) 
                    setTimer(detachElements,5000,1,player,ejectorSeat) 
                    setTimer(destroyElement,5000,1,ejectorSeat) 
                end 
        end 
end 
addCommandHandler("e", carEject) 

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