Force get out of vehicle

I have a blacklist script i am using and i want to change it from delete vehicle to force get out of vehicle

function checkCarowner(car)
if car then
carModel = GetEntityModel(car)
carName = GetDisplayNameFromVehicleModel(carModel)

	if isCarBlacklistedowner(carModel) then
		_DeleteEntity(car)
		notifycar()
	end
end

end

rather than the _deleteEntity I want to force them to get out. Is this possible at all? I cant find what I would change it to

I guess you could use this, since the Player is essentially a ped:

https://runtime.fivem.net/doc/reference.html#_0xD3DBCE61A490BE02

function checkCarowner(car)
if car then
carModel = GetEntityModel(car)
carName = GetDisplayNameFromVehicleModel(carModel)

	if isCarBlacklistedowner(carModel) then
		TaskLeaveVehicle(ped)
		notifycar()
	end
end

end

would that be correct?

No, you are supplying the incorrect arguments:

local player = PlayerPedId()
local vehicle = GetVehiclePedIsIn(player, false)
local flag = 0
TaskLeaveVehicle(player, vehicle, flag)

For the flags, you can use:

0 = normal exit and closes door.
1 = normal exit and closes door.
16 = teleports outside, door kept closed.
64 = normal exit and closes door, maybe a bit slower animation than 0.
256 = normal exit but does not close the door.
4160 = ped is throwing himself out, even when the vehicle is still.
262144 = ped moves to passenger seat first, then exits normally

function isCarBlacklistedowner(model)
for _, blacklistedCar in pairs(ownercarblacklist) do
if model == GetHashKey(blacklistedCar) then
return true
end
end

return false

end

function checkCarowner(car)
if car then
carModel = GetEntityModel(car)
carName = GetDisplayNameFromVehicleModel(carModel)

if isCarBlacklistedowner(carModel) then
            local player = PlayerPedId()
            local vehicle = GetVehiclePedIsIn(player, false)
            local flag = 16
	TaskLeaveVehicle(player, vehicle, flag)
	notifycar()
	end
end

end

I think this might be it, I will try and implement it if you think its correct.

If its Fax-Core expect a massive update for it in coming weeks. I’m currently re writing the whole thing.

1 Like

Yes it is :slight_smile:

1 Like

But in the meantime, would that code work?

Try it. Hard to read it on this phone :smiley:

I’ll let you know how it is, going to test it now

IT WORKS! (20 characters)

I found a small hiccup, I can no longer put criminals in my car, it just warps them out.

function checkCarowner(car)
if car then
carModel = GetEntityModel(car)
carName = GetDisplayNameFromVehicleModel(carModel)
seat =  TaskEnterVehicle( GetPlayerPed(-1))

if isCarBlacklistedowner(carModel) then
            local player = PlayerPedId()
            local vehicle = GetVehiclePedIsIn(player, false)
            local flag = 0
	TaskLeaveVehicle(player, vehicle, flag)
	notifycar()
	end

i cant get it to only blacklist the drivers seat

1 Like

what you need to do then, is in whatever script allows you to put player in a car, in that client have a variable that is true while person is being put in car / is sitting in car

send the variable to this script in any way you like

then check variable before running your script.


if playerIsInHandcuffs == false then
    if isCarBlacklistedowner(carModel) then
            local player = PlayerPedId()
            local vehicle = GetVehiclePedIsIn(player, false)
            local flag = 0
	TaskLeaveVehicle(player, vehicle, flag)
	notifycar()
    end
end

Did you guys ever get this working nicely? The full code changes for this?