[Release] Disable seat shuffling REWRITE

RELEASE | DISABLE SEAT SHUFFLE v2.0.1

Completely rewritten my old script considering I actually know how to code now and it was littered with bugs

Enjoy!

HOW TO USE
As of the current latest version, the player will stay seated in their current seat. Be it, the passenger seat or the driver seat. If you press and hold your sprint button(Lshift[PC], X[PS] or A[XBOX]) it will shuffle you to the neighbouring seat. Alternatively you can type type /shuff to do the same thing

CHANGELOG

  • 2.0.1
    -player can now shoot outside of passenger seat
    -made some optimisations
  • 2.0.0
    -can now shuffle from both driver and passenger seat.
    -added keybind option (sprint key by default)
  • 1.0.1
    -By default, players will stay seated in the passenger seat. If you type /shuff they shuffle into the driver seat.
  • 1.0.0
    -First version. By default the player will shuffle into driver seat, /shuffle enables and disables the script.

KNOWN BUGS

  • Animation glitch when carjacking from passenger seat

DOWNLOADS
Github

7 Likes

Awesome. & first lol :)!

edit: jaf|690x244
also welcome back great timing I literally just downloaded your old to use a couple hours ago but now will use this one!

1 Like

The code is still not ideal…
First of all, don’t use GetPlayerPed(-1) - it does exactly what PlayerPedId() does, but considerably slower.
Secondly, lines 13 and 15 aren’t necessary at all as you already define the exact same values as local entries above the thread.
I also imagine there are ways to optimize this even further but it’s too long to explain in a reply lol

Don’t get me wrong, I’m not trying to hate on this at all - it’s a resource that found its way onto the more popular servers back in the day - I just want it to be better :laughing:
Can you upload it to GitHub so people can PR improvements? That’d be amazing!

2 Likes

Yeah I’m better at coding but still unfamiliar with this API, I’ll take this into consideration and update it occasionally. Check here occasionally because I will hopefully do updates. But for now is it working well? any bugs you experienced?

and as for line 13 and 15. I was actually meant to delete line 13 but I guess I Ctrl+v from an older version when testing. As for line15 I assumed that line 7 would only be executed once at the start but I wanted to constantly have the players current vehicle and update it if they got into a new one so I put it inside the thread. Line 7 is just so it’s assigned to something first. i could put it to nil. But I will clean this up more for sure and thank you for the advice. I’ll get right to testign!

2 Likes

That is really excellent timing ahahhaha

1 Like

With a quick glance; To optimize the script further, you could put a “Citizen.Wait(x)” if the person isn’t in a vehicle, as well as a check to see if the driver seat is occupied or not. It doesn’t look like you have to run the loop every frame unless the person intends to shuffle their seat.

x = Between 100-500 maybe?

Could you perhaps fit everything, or a couple of more things, into one loop rather than having three?
Good script nonetheless. I personally used your first version when I started :]

Thanks for comment, I will take this into consideration! :smiley: What do you mean about check if the driver seat is occupied? I mean I know what it means but why would it improve the script? From my understanding (which may be wrong) I it only starts to reset their position when the animation starts playing and the animation in itself in Rockstar’s code already checks if the seat is available to shuffle to right?

I meant it in terms of optimization.
The loop doesn’t have to run every frame if the driver seat is occupied since you cannot switch into it.

Example

while true do
	Citizen.Wait(0)
	
	if IsVehicleSeatFree(GetVehiclePedIsIn(PlayerPedId(), false), -1) then
		--Do something if the seat is empty
	else
		Citizen.Wait(500) --If the seat is taken we wait 500ms until we check again
	end
end

You can’t shoot from a passenger seat while using this script.

line 13 is needed, if player will change his ped or die and respawn or any other stuff which changes ped id, this script will break. what can be done here is to put this check to a slower loop. we definitely don’t need to update ped id every frame.

While driver seat is empty? or while driver seat is occupied?

1 Like

Thanks for writing this script but it’s not optimized.
First of all, you don’t need to get playerPed or vehicle 60 times in 1 second citizen.wait(0).
So, create another thread with citizen.wait(500) or citizen.wait(1000) for playerPed checker and other natives.

Also, you don’t need to use SetPedIntoVehicle(playerped, currentvehicle, 0) in a loop. This is not a good way to force a player not to move! Instead of that, use SetPedConfigFlag(playerPed, 184, true) only once! This will disable shuffling too.

I hope this will help you to improve your script. Have a great day :slight_smile:

1 Like

That’s not how the code works. The loop needs to constant run to PREVENT them from shuffling. The loop turns off when they want to shuffle

Updating now! thank you for the advice

1 Like

Ok I got it to work that way but for some reason not when entering the vehicle. Will do some testing

You sure? I tried it and it worked.

While driver seat is empty

fixed

I got it to work in the end, I allowed it “setpedinvehicle” if it was shuffling when it wasnt supposed to, which is usually upon entering a vehicle. Works great now, thank you so much

1 Like

This is one of those things seems so small but it has a very real impact on experience overall, so thank you for this. Would it be able to have a function that sets the release time for switching over a bit shorter, I find when I shift I let go like a second early often because it looks like the character has already switched over but then he jumps back. Also its fun to shift while driving lol.