I’m trying to write a script that stops front seat passengers from shuffling to the driver’s seat when it is empty, does anyone have a better way than what I have done? Also the code I wrote is broken, as if you get in a vehicle as the front seat passenger, then get out and get in the driver’s seat, you teleport into the front passenger seat.
--[[------------------------------------------------------------------------
Vehicle Anti-Shuffle
------------------------------------------------------------------------]]--
function ManageAntiShuffle()
local ped = GetPlayerPed( -1 )
if ( DoesEntityExist( ped ) and not IsEntityDead( ped ) ) then
if ( IsPedInAnyVehicle( ped, false ) ) then
local veh = GetVehiclePedIsIn( ped, true )
if ( GetLastPedInVehicleSeat( veh, 0 ) == ped and GetPedInVehicleSeat( veh, -1 ) == ped ) then
SetPedIntoVehicle( ped, veh, 0 )
end
end
end
end
Citizen.CreateThread( function()
while true do
ManageAntiShuffle()
Citizen.Wait( 0 )
end
end )
-- TaskExitVehicle = 2
if GetPedInVehicleSeat(veh, 0) == ped and IsVehicleSeatFree(veh, -1) and not GetIsTaskActive(ped, 2) then
SetPedIntoVehicle( ped, veh, 0 )
end
Or
-- TaskExitVehicle = 2
-- TaskInVehicleSeatShuffle = 165
if GetPedInVehicleSeat(veh, 0) == ped and GetIsTaskActive(ped, 165) and not GetIsTaskActive(ped, 2) then
SetPedIntoVehicle( ped, veh, 0 )
end
This one works but only for parked vehicles and only if the door is not already open, weird
function AntiSeatShuffle()
local ped = GetPlayerPed(-1)
if DoesEntityExist(ped) and not IsEntityDead(ped) then
if IsPedInAnyVehicle(ped, false) then
local veh = GetVehiclePedIsIn(ped, false)
if GetIsTaskActive(ped, 2) == false and GetPedInVehicleSeat(veh, 0) == ped and IsVehicleSeatFree(veh, -1) then
SetPedIntoVehicle(ped, veh, 0)
end
end
end
end
Citizen.CreateThread(function()
while true do
AntiSeatShuffle()
Citizen.Wait(0)
end
end)
I know the dude doing the vRP Framework has it working (Was amazed it worked correctly last night)… No clue on specifics, sorry… But maybe ask on his vRP post?.. Just a thought
Got this so far, works better but it’s still weird as the player shuffles to the driver’s seat, then gets teleported back when they’re half way.
function ManageAntiShuffle()
local ped = GetPlayerPed( -1 )
if ( DoesEntityExist( ped ) and not IsEntityDead( ped ) ) then
if ( IsPedInAnyVehicle( ped, false ) ) then
local veh = GetVehiclePedIsIn( ped, true )
if ( GetPedInVehicleSeat( veh, 0 ) == ped and IsVehicleSeatFree( veh, -1 ) and GetIsTaskActive( ped, 165 ) and not GetIsTaskActive( ped, 2 ) ) then
SetPedIntoVehicle( ped, veh, 0 )
end
-- if GetPedInVehicleSeat(veh, 0) == ped and IsVehicleSeatFree(veh, -1) and not GetIsTaskActive( ped, 2 ) then
-- SetPedIntoVehicle( ped, veh, 0 )
-- end
end
end
end
Citizen.CreateThread( function()
while true do
ManageAntiShuffle()
Citizen.Wait( 0 )
end
end )
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if IsPedInAnyVehicle(GetPlayerPed(-1), false) then
if GetPedInVehicleSeat(GetVehiclePedIsIn(GetPlayerPed(-1), false), 0) == GetPlayerPed(-1) then
if GetIsTaskActive(GetPlayerPed(-1), 165) then
SetPedIntoVehicle(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 0)
end
end
end
end
end)