[HELP] Help with simple script(anti seat shuffle)

I’m really dumb, i don’t know lua, but I have a simple script which stops the user from shuffling to the driver seat when he’s in the passenger seat. It works flawlessly. BUT I want it to work like a toggle. If you type /shuffle it will enable the script and say “Anti Seat shuffle enabled” then you type /shuffle again and then it says “Anti Seat shuffle disabled” and enables/disables the script of course. I tired to do it but then the script didn’t work at all(becasue I probably broke it). I’ve been pulling my hair out for 4 days :frowning: :confused:
I’d really appreciate some help, thank you for reading
idk how to upload the script in that little box so I’ll try here:

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)

EDIT
RELEASE HERE

Take a look at the native reference db, I’m pretty sure there’s something like a “canShuffleSeat” native. Maybe that’s what you’re looking for.

yeah I have, i know its a simple script, i know C++ and python, just cannot understand lua, i don’t know the syntaxes, would appreciate it if somebody could just manipulate this a bit to add a simple toggle function, This has been taking me ages, yet for some other people, all it would take is 30 seconds and wouldn’t cause any inconvenience.

local antiShuffleEnabled = false

RegisterCommand('shuffle', function()
    antiShuffleEnabled = not antiShuffleEnabled
    TriggerEvent('chatMessage', '', {255,255,255}, 'Anti Shuffle ' .. ((antiShuffleEnabled) and 'enabled' or 'disabled') .. '.')
end)

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(0)
		if IsPedInAnyVehicle(GetPlayerPed(-1), false) and antiShuffleEnabled 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)

Something like this?

1 Like

Yeah, I’m finding it hard to understand what you’ve done there, but from what i see that looks correctm thanks for the effort, I’ll try that out now and see if it works. I really appreciate it. Thank you

EDIT: I always though chat messages needed to be server side for some reason

Np.

Apparently you’re not the only one who thinks this…

Anyway I just registered a command (/shuffle) that toggles the bool to be the opposite of what it already is (basically a very simple toggle).
Then it sends a chat message to the client and uses the and/or (tertiary operator like) to display either enabled or disabled.
I’ve also added the check in your loop to only disable seat shuffling for cases when the bool is true.

1 Like

Works perfectly :smiley: thanks so much!

and as for the chat messages, i only thought that becasue I was looking at other scripts I had to try and get this working, I followed the basic idea they did and all they’re chat message commands are serverside, like the /handsup script and /cuff etc. Possibly becasue it needs to grab the player ID, but I’m still not sure how it works.
Anyway, again, thanks for helping me out, and also teaching me :slight_smile:

can someone make this into a resource

Citizen.CreateThread(function()
    while true do
        Citizen.Wait(0)
        local ped = GetPlayerPed(-1)
        local vehicle = GetVehiclePedIsIn(ped, false)
        CanShuffleSeat(vehicle, false)
    end
end)

I will release it later today as a resource

https://forum.cfx.re/t/release-disable-seat-shuffling/53526

This ain’t set command. I think it just returns boolean. did you test it before posting?