Jump to content

Keep player in the car


Recommended Posts

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

Link to comment

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]

Link to comment

This can work,

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

Not sure.

Link to comment
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.

Link to comment
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.

Link to comment
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

Link to comment
  • Moderators

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) 

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