forked from Wyste/ServerSync
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathss_cli_windows.lua
40 lines (36 loc) · 1.42 KB
/
ss_cli_windows.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
if ss_enable_door_window_sync then
local vehicleState = { windowsDown = false }
RegisterNetEvent('VehicleWindow')
AddEventHandler( "VehicleWindow", function( playerID, windowsDown )
local vehicle = GetVehiclePedIsIn( GetPlayerPed( GetPlayerFromServerId( playerID ) ), false )
if windowsDown then
RollDownWindow( vehicle, 0 )
RollDownWindow( vehicle, 1 )
else
RollUpWindow( vehicle, 0 )
RollUpWindow( vehicle, 1 )
end
end)
Citizen.CreateThread( function()
while true do
Citizen.Wait(10)
if IsPedInAnyVehicle( GetPlayerPed( -1 ), false ) then
local pressedUp = IsControlJustPressed( keybinds.windows.inputGroup, keybinds.windows.up ) or false
local pressedDown = IsControlJustPressed( keybinds.windows.inputGroup, keybinds.windows.down ) or false
if pressedUp or pressedDown then
local vehicle = GetVehiclePedIsIn( GetPlayerPed( -1 ), false )
if GetPedInVehicleSeat( vehicle, - 1 ) == GetPlayerPed( -1 ) then
if pressedUp then
vehicleState.windowsDown = false
TriggerServerEvent( "ServerSync:SetVehicleWindow", vehicleState.windowsDown )
end
if pressedDown then
vehicleState.windowsDown = true
TriggerServerEvent( "ServerSync:SetVehicleWindow", vehicleState.windowsDown )
end
end
end
end
end
end)
end