[HELP] Improving an existing script


#1

Hi guys, I’m new into FiveM Scripting and I(we) need your help to improve an existing script.

So here’s the said so script:

It prevents the ped(player) at the 2nd seat to access to the driver seat if it’s free.
The problem is that it kind of “force” the ped to the passenger seat by “teleporting” him through an infinite loop.

Here’s the code so you see what I’m talking about:

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

(credits: callmejaf)

(PS: as you can see, the script “detect” the ped task “shuffle” which make the ped go from passenger seat to the driver seat.)

The main problem is that it cancel other tasks that the ped is doing (i.e: shooting/aiming), and a pretty big secondary problem is that the animation is “glitching” on other vehicles(bike, etc…)

I would be really thankful if someone could contribute, since it would contribute to everyone.

Here’s what I already tried:

the following natives:

SetVehicleExclusiveDriver(vehicle, p1)
SetVehicleExclusiveDriver2(vehicle, ped, p2)

(It may help if you want a certain ped(player), to be the only one that can drive, but here we want to let the driver seat empty.)

SetPlayerResetFlagPreferRearSeats(player, flags)

By making the flags go from 0 to 6 (seats , it seems), doesn’t work, unfortunately.(Maybe I did wrong so try it by yourself if you think it would work)

  • Trying to detect if the ped is aiming/shooting, and if so, disable the script. But the ped would shuffle to driver seat anyway.

And some other newbies (trying to make the function wait, etc…)

PS: CanShuffleSeat(vehicle, p1) returns a bool (true or false) thus just help to get an information, not to set things.

Thank you guys, hope someone will help.

ISSUE 1

ISSUE 2


#2

No idea?

if you want me to resume the post:

How to disable seat shuffling without using this ???

if GetIsTaskActive(GetPlayerPed(-1), 165) then
            SetPedIntoVehicle(GetPlayerPed(-1), GetVehiclePedIsIn(GetPlayerPed(-1), false), 0)
end