@@ -21,22 +21,22 @@ public class FRFuel : BaseScript {
21
21
protected float fuelTractionImpact = 0.0001f ;
22
22
protected float fuelRPMImpact = 0.0005f ;
23
23
24
- protected Random random = new Random ( ) ;
25
-
26
- public HUD hud ;
27
-
24
+ public float showMarkerInRangeSquared = 2500f ;
25
+
28
26
#if DEBUG
29
27
public Dev . DevMenu menu ;
30
28
#endif
31
29
32
- public float showMarkerInRangeSquared = 2500f ;
33
- public Blip currentGasStation ;
34
-
35
- public float totalFuelAddedToVehicle = 0f ;
30
+ public HUD hud ;
31
+ public Random random = new Random ( ) ;
36
32
33
+ protected Blip currentGasStation ;
37
34
protected Vehicle lastVehicle ;
35
+
38
36
protected bool currentVehicleFuelLevelInitialized = false ;
39
37
protected bool hudActive = false ;
38
+ protected bool refuelAllowed = true ;
39
+ protected float addedFuelCapacitor = 0f ;
40
40
41
41
protected InLoopOutAnimation jerryCanAnimation ;
42
42
#endregion
@@ -58,6 +58,12 @@ public FRFuel() {
58
58
CreateJerryCanPickUps ( ) ;
59
59
} ) ;
60
60
61
+ EventHandlers [ "frfuel:refuelAllowed" ] += new Action < dynamic > ( ( dynamic toggle ) => {
62
+ if ( toggle . GetType ( ) == typeof ( bool ) ) {
63
+ refuelAllowed = ( bool ) toggle ;
64
+ }
65
+ } ) ;
66
+
61
67
blips = new Blip [ GasStations . positions . Length ] ;
62
68
pickups = new Pickup [ GasStations . positions . Length ] ;
63
69
@@ -160,19 +166,20 @@ public void ConsumeFuel(Vehicle vehicle) {
160
166
} else {
161
167
hud . InstructRefuelOrTurnOnEngine ( ) ;
162
168
163
- if ( Game . IsControlPressed ( 0 , Control . Jump ) ) {
164
- if ( fuel < fuelTankCapacity ) {
165
- fuel += 0.1f ;
166
- totalFuelAddedToVehicle += 0.1f ;
169
+ if ( refuelAllowed ) {
170
+ if ( Game . IsControlPressed ( 0 , Control . Jump ) ) {
171
+ if ( fuel < fuelTankCapacity ) {
172
+ fuel += 0.1f ;
173
+ addedFuelCapacitor += 0.1f ;
174
+ }
167
175
}
168
- }
169
176
170
- if ( Game . IsControlJustReleased ( 0 , Control . Jump ) ) {
171
- // Trigger onRefuelComplete Cient-Side Event. Return 1 argument with amount of fuel added to vehicle.
172
- TriggerEvent ( "onRefuelComplete" , Math . Round ( Convert . ToDouble ( totalFuelAddedToVehicle ) ) ) ;
173
- totalFuelAddedToVehicle = 0f ;
177
+ if ( Game . IsControlJustReleased ( 0 , Control . Jump ) ) {
178
+ TriggerEvent ( "frfuel:fuelAdded" , addedFuelCapacitor ) ;
179
+ TriggerServerEvent ( "frfuel:fuelAdded" , addedFuelCapacitor ) ;
180
+ addedFuelCapacitor = 0f ;
181
+ }
174
182
}
175
-
176
183
}
177
184
178
185
hud . RenderInstructions ( ) ;
0 commit comments