Chrimam Posted August 11, 2013 Share Posted August 11, 2013 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
bandi94 Posted August 11, 2013 Share Posted August 11, 2013 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
Chrimam Posted August 11, 2013 Author Share Posted August 11, 2013 Nope it's not working. Link to comment
bandi94 Posted August 11, 2013 Share Posted August 11, 2013 what's the problem ? debugscript error ? Link to comment
Chrimam Posted August 11, 2013 Author Share Posted August 11, 2013 There is no error in debugscript. It doesn't give parachute, it doesn't take me to the pZ + 10. and i think it doesn't detach the seat either because i can't get in my car again. Link to comment
bandi94 Posted August 11, 2013 Share Posted August 11, 2013 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
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