[FREE][SCRIPT] Advanced Window Control

Hello everyone! I am releasing this Advanced Window Control Script in the hopes that someone will be able to take this and finish it; I am unable to due to my limited scripting knowledge. If someone could finish it and share the final result with the community, it would be awesome!

That being said, it is 100% working and able to be used in its current state, I just cannot make guarantees everything is synced between players since I am just a simple man without a partner to test.

License:
GNU GPLv3

Download:
advanced_windows.zip (14.8 KB)

Preview:

Ever wanted to roll down just your driver window during a traffic stop? With this script, now you can WITHOUT having to enter a command or navigate through menus!

Features:

- Driver can roll down their own window, and roll down all passenger windows once their own window is down.

- Driver can roll up all currently down passenger windows before rolling up their own window.

- Passengers can roll up and down their own windows, they cannot control other passenger
windows unless they switch seats WITHOUT getting out. Variables currently reset on vehicle exit,
hoping someone will be able to change that so they update based on the vehicle window state
upon entering a new vehicle.

- Passengers can also roll their windows back up or down if the driver rolled all windows up or
down.

- Handcuffed passengers cannot use windows? I simply just put a check for the handcuff in
GetPedConfigFlag, might be done incorrectly and need modifying.

- Server script to sync the windows? This is untested with players, but it appeared the scripts were
communicating properly and working)

- NO COMMANDS! This is designed for true ease, no more menus or commands to get those
windows down, it is all done through simple keybinds!

- Optimized based on what I see others showing for their times. 0.00ms while out of a vehicle and
0.04-0.05ms while inside a vehicle. 0.00ms when in any vehicle that is NOT a regular vehicle with
rollable windows (Bikes, Motorcycles, Quads, Boats, Subs, Planes or Helis).

- Can change if notification should have a sound, as well as notification duration in cl_windows.lua.

- Emergency vehicles by default act like 2 door vehicles and the rear windows are not able to be
rolled up or down.

- Does NOT work on Bikes, Motorcycles, Quads, Boats, Subs, Planes or Helis.

- Addon vehicles should work correctly, as long as they are made and classed correctly.

- Compatible with LUXART VEHICLE CONTROL V3, just open the cl_lvc.lua file in the UTIL folder and
change the following lines:

Line 614
Change "if IsDisabledControlJustReleased(0, 85) then" to "if IsDisabledControlJustReleased(0, 85) and not IsControlPressed(1, 99) then" 

Line 639
Change "elseif IsDisabledControlJustReleased(0, 19) then" to "elseif IsDisabledControlJustReleased(0, 19) and not IsControlPressed(0, 99) then"

Line 681 
Change "elseif IsDisabledControlJustReleased(0, 172) and not IsMenuOpen() then" to "elseif IsDisabledControlJustReleased(0, 172) and not IsControlPressed(0, 99) and not IsMenuOpen() then"

Gamepad Controls

Hold X/Square and tap Dpad down once to roll down the window. The driver can then hold X/Square 
and tap Dpad down again whenever they want all passenger windows to go down.

Hold X/Square and tap Dpad up once to roll up the window. When the driver does this, if any 
passenger windows are down, they will be rolled up. Holding X/Square and tapping Dpad up again 
will then roll the driver's window up. If no passenger windows are down, then the driver's window 
will go up if down.

Keyboard Controls

Hold TAB and tap the DOWN KEY once to roll down the window. The driver can then hold TAB and 
tap the DOWN KEY again whenever they want all passenger windows to go down.

Hold TAB and tap the UP KEY once to roll up the window. When the driver does this, if any 
passenger windows are down, they will be rolled up. Holding TAB and tapping the UP KEY again 
will then roll the driver's window up. If no passenger windows are down, then the driver's window 
will go up if down.

Install Instructions:
Really simple install. Unzip advanced_windows and put it in your server resources folder. Add “start advanced_windows” to your server.cfg and start your server!

Additionally if your server is running, you can unzip advanced_windows and put it in your server resources folder. From there open your server console in game with F8 and type “refresh”. After that you can type “start advanced_windows” and you should be good to go.

What needs to be completed:
A way to keep track of the window states of each vehicle and update the player variables upon entering a new vehicle so they do not reset. They are currently set to reset to false when the player is out of a vehicle to avoid possible bugging. I am unsure if this is accomplished through an array or a table or some other method that is NOT through a database, as I was trying to make this standalone and as plug and play as possible.

To add to the previous, I did try to use IsVehicleWindowIntact() to get the window state upon entering vehicles, but it is not reliable because even a single bullet hole renders that check useless as the window is deemed NOT INTACT, even if the window is otherwise intact and able to roll up and down.

I believe that is all I could not accomplish with this as it is pretty complete otherwise… I may have missed something though.

KNOWN Issues:
- None that I know of outside of variables resetting on exiting a vehicle as intended because I am unsure how to update the window states of vehicles server wide so the variables update properly upon entering a vehicle.

- The console prints are intentional, if you want to remove them, just edit the sv_windows.lua.

Final Words:
I have no real idea what the hell I am doing lol. Like my SA-MP days, I am learning through looking at releases and trying to figure out how things work. I have no real knowledge in Lua or experience coding outside of my long forgotten PAWN days. I mess with things until they work, and when I say I mess with them, I MESS WITH THEM. Very meticulously.

Documentation helps and does not help me, it mostly doesn’t because I am the type to learn visually and through an example I can see. But again I have no real idea what the hell I am doing, I am still learning and really am hoping someone in the community with knowledge can help finalize what I could not. I think it would be awesome for the community and I would be able to see what needed to be done to get it truly complete!

Please note my post formatting may be horrible, I apologize if it is!

Enough from me, have a nice day!

1 Like

Is there a way to get rid of the button sound ? It’s anoying as hell, good job on the script tho !

1 Like

Yeah, just go into cl_windows.lua and change NotifySound from true to false! You can also change how long it shows by changing NotifyTime from 1500 to whatever you want in milliseconds.

1 Like

how do we change it from being the tab key to something else

Open cl_windows.lua and find IsControlPressed(1, 99) and change the 99 to whatever else from Controls - Cfx.re Docs

Do note that changing it might cause issues with gamepad users so make sure the key remains X/Square for gamepad. Unless gamepad is a moot point for your purpose, then use whatever key fits best.