Jump to content

Keep player in the car


Recommended Posts

Posted

i dont think its possible, its built in gta so that when u die inside a car that u fall out the door, unless u explode in car

though u could try random crazy experiments like freezing the player, or setting position or something, or maybe cancel event of death and "create your own" death system(like fake the death, but still consider it death)?

Posted

i don't know if this will work if it will work then if the player die he will get teleported to 0, 0, 0 position

function test ( player ) 
   setElementPosition ( player , 0, 0, 0 ) 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), test ) 

sup?

Posted

its impossible to keep player in car, only possible thing u could do is fake it but it wont look real, try suggesting this as feature on mantis(feature to block player getting out)

[but i believe that that request would be ignored like other ones since it's not a bug, but a request, and they're busy]

If you find my post useful or if it helped you, please like my post :)
Ingame name: ZoeN

560x95_FFFFFF_FF9900_000000_000000.png

Posted

This can work,

function keepPlayerInVehicleOnDie() 
   removeEventHandler("onVehicleExit", getRootElement(), keepPlayerInVehicleOnDie) 
   removeEventHandler("onVehicleStartExit", getRootElement(), keepPlayerInVehicleOnDie) 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), keepPlayerInVehicleOnDie) 

Not sure.

Resources I made:

Do not PM me for help with leaked scripts! I WILL NOT HELP YOU!

 

Posted

setVehicleHandling animGroup "GetOutF" could maybe have worked, but it was disabled because

Get works, set is disabled due to people not knowing this property was vehicle-based and caused crashes.
Posted
This can work,
function keepPlayerInVehicleOnDie() 
   removeEventHandler("onVehicleExit", getRootElement(), keepPlayerInVehicleOnDie) 
   removeEventHandler("onVehicleStartExit", getRootElement(), keepPlayerInVehicleOnDie) 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), keepPlayerInVehicleOnDie) 

Not sure.

onVehicleExit can't be canceled.

A unique GangWar gamemode waiting for you!
Click here for more information.

560x95_FFFFFF_FF9900_000000_000000.png

Posted
This can work,
function keepPlayerInVehicleOnDie() 
   removeEventHandler("onVehicleExit", getRootElement(), keepPlayerInVehicleOnDie) 
   removeEventHandler("onVehicleStartExit", getRootElement(), keepPlayerInVehicleOnDie) 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), keepPlayerInVehicleOnDie) 

Not sure.

onVehicleExit can't be canceled.

My bad.

Resources I made:

Do not PM me for help with leaked scripts! I WILL NOT HELP YOU!

 

Posted
This can work,
function keepPlayerInVehicleOnDie() 
   removeEventHandler("onVehicleExit", getRootElement(), keepPlayerInVehicleOnDie) 
   removeEventHandler("onVehicleStartExit", getRootElement(), keepPlayerInVehicleOnDie) 
end 
addEventHandler ( "onPlayerWasted", getRootElement(), keepPlayerInVehicleOnDie) 

Not sure.

onVehicleExit can't be canceled.

though you can reverse it

If you find my post useful or if it helped you, please like my post :)
Ingame name: ZoeN

560x95_FFFFFF_FF9900_000000_000000.png

  • Moderators
Posted

Try something like this:

Client:

addEventHandler("onClientPreRender",root, 
function () 
    local vehicle = getPedOccupiedVehicle(localPlayer) 
    if vehicle and  
        local i, firstPlayer = next(getVehicleOccupants(vehicle))  
        if firstPlayer == localPlayer then 
            if getElementHealth(vehicle) < 250 and not isVehicleDamageProof (vehicle) then 
                setVehicleDamageProof(vehicle,true) 
                triggerServerEvent("blowUpVehicle",vehicle) 
            end 
        end 
    end 
end) 
  

Server:

addEvent("blowUpVehicle",true) 
addEventHandler("blowUpVehicle",root, 
function () 
    if isElement(source) then 
        setVehicleDamageProof(source,true) 
        local x,y,z = getElementPosition(source) 
        createExplosion (x,y,z,0,client) 
        local players = getVehicleOccupants(source) 
        if players and next(players)  then 
            for i,player in pairs (players) do 
                killPed(player) 
                -- add here peds or something like that. 
            end 
        end 
    end 
end) 

Do you want to improve your Lua programming skills and make less mistakes?   Start with Lua Language Server!   🙀

 

  Useful functions  3x 

  Tutorials  4x 

 

Posted

How about setting an uninterruptible animation onto the player? I guess that would work, but can't really test it myself at the moment.

Previously known as MrTasty.

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