Jump to content

Keep player in the car


Recommended Posts

Posted

Hello.

I've got a really dumb question, but how can I keep the player in the vehicle in any situation? So he stays in the vehicle even if he dies still. Cancelling onClient(Player)VehicleExit/onVehicleStartExit don't really help with that.

Thanks.

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

Tried warping the ped instantly, it works, but the transition is rather visible even for an unarmed eye. Cancelling death didn't seem to help at all. Those falling peds are so annoying. There has to be a way to trick that...

Posted
function test ( theplayer, seat, jacked ) 
   cancelEvent () 
end 
addEventHandler("onVehicleExit", getRootElement(), test ) 

Same stuff, the player falls out of the vehicle when he dies.

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 ) 

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]

Posted

This can work,

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

Not sure.

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.

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.

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

  • 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) 

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