1- using CitizenFX . FiveM . Client ;
1+ using CitizenFX . FiveM . Client ;
22
3+ using vMenu . Enhanced . Data . Ticks ;
34using vMenu . Enhanced . Events ;
45using vMenu . Enhanced . Permissions ;
56using vMenu . Enhanced . Storage ;
7+ using vMenu . Enhanced . Ticks ;
68
79using VehicleOptionsPermissions = vMenu . Enhanced . Data . Permissions . Menus . VehicleOptions ;
810
@@ -12,8 +14,14 @@ namespace vMenu.Enhanced.Menus.Vehicles;
1214// same distinction VehicleWash makes.
1315public static class VehicleKeepClean
1416{
17+ // The dirt watcher only reports a gain big enough to be worth an event, so a slow drizzle of dirt can
18+ // sit under it. This sweep is what catches that.
19+ private const long SweepIntervalMs = 10000 ;
20+
1521 private static bool _watching ;
1622
23+ private static TickHandle ? _sweep ;
24+
1725 public static bool Enabled => UserDefaults . VehicleKeepClean . Value && IsAllowed ;
1826
1927 private static bool IsAllowed => ClientPermissions . IsAllowed ( VehicleOptionsPermissions . KeepClean ) ;
@@ -23,6 +31,8 @@ public static void Initialize()
2331 {
2432 ClientPermissions . PermissionsChanged += Apply ;
2533
34+ _sweep = TickRegistry . Register ( "Vehicle.KeepClean" , Sweep , TickRate . Every ( SweepIntervalMs ) , ( ) => Enabled ) ;
35+
2636 Apply ( ) ;
2737 }
2838
@@ -45,6 +55,8 @@ private static void Apply()
4555
4656 Watch ( on ) ;
4757
58+ _sweep ? . Reevaluate ( ) ;
59+
4860 if ( ! on )
4961 {
5062 return ;
@@ -74,6 +86,8 @@ private static void Watch(bool watching)
7486 LocalVehicleTicks . VehicleChanged -= OnChanged ;
7587 }
7688
89+ private static void Sweep ( ) => Wash ( OwnVehicle . Driven ( ) ) ;
90+
7791 private static void OnDirtied ( VehicleDirtied _ ) => Wash ( OwnVehicle . Driven ( ) ) ;
7892
7993 // The dirt watcher re-seeds on a new vehicle rather than reporting it, so getting into one that is
0 commit comments