TorturedChunk
Valued Member!
Well, I spent some time with this and built a working siphon fuel script.
One issue I ran into was the jerry can size and refueling under 20 liters of fuel in the vehicle. You could siphon 20 liters of fuel regardless of fuel level. To avoid exploitation, I made it so you cannot siphon a vehicle with 20 liters or less of fuel. If anyone has a way around that, let me know.
This allows you to siphon fuel from any vehicle as long as the vehicle fuel level is above 20 liters and you have an empty jerry can in your inventory.
I also got lazy on the translations for the strings. If you don't want to use strings you can edit the strings in the code to be a static value.
Anyway, on to the CODE!
dayz_code.pbo >> actions >> siphon.sqf
Create This:
dayz_code.pbo >> compile >> fn_damageActions.sqf
Below This:
Insert This:
Below This:
Insert This:
dayz_code.pbo >> strinables.xml
Add These:
If anyone wants to write this up as a "fixes" hook, I'm sure there are plenty of people who would appreciate it.
I will be launching this in DayZ Mercenary 1.4.1 this weekend and have tested it fully on my development server.
Any questions, let me know!
ADMIN EDIT: ORIGINAL CONCEPT OF THIS SCRIPT IS LOCATED HERE. The code on the GitHub was posted 2 months ago. This post was posted on March 19. This is a friendly reminder to give everyone credit where it is due.
One issue I ran into was the jerry can size and refueling under 20 liters of fuel in the vehicle. You could siphon 20 liters of fuel regardless of fuel level. To avoid exploitation, I made it so you cannot siphon a vehicle with 20 liters or less of fuel. If anyone has a way around that, let me know.
This allows you to siphon fuel from any vehicle as long as the vehicle fuel level is above 20 liters and you have an empty jerry can in your inventory.
I also got lazy on the translations for the strings. If you don't want to use strings you can edit the strings in the code to be a static value.
Anyway, on to the CODE!
dayz_code.pbo >> actions >> siphon.sqf
Create This:
Code:
private["_vehicle","_curFuel","_newFuel","_timeLeft","_newFuel"];
_vehicle =cursorTarget;
_canSize =getNumber(configFile >> "cfgMagazines" >> "ItemJerrycan" >> "fuelQuantity");
_configVeh =configFile >> "cfgVehicles" >> TypeOf(_vehicle);
_capacity =getNumber(_configVeh >> "fuelCapacity");
_nameType =getText(_configVeh >> "displayName");
_curFuel =((fuel _vehicle) * _capacity);
_newFuel =(_curFuel - _canSize);
//if (_newFuel < _capacity * 0) then {_newFuel = 0};
if (_curFuel < _canSize) then {
cutText [format[localize "str_player_siphon_2",_text], "PLAIN DOWN"];
} else {
_newFuel = (_newFuel / _capacity);
player removeMagazine "ItemJerrycanEmpty";
player addMagazine "ItemJerrycan";
player playActionNow "Medic";
_dis=10;
_sfx = "refuel";
[player,_sfx,0,false,_dis] call dayz_zombieSpeak;
[player,_dis,true,(getPosATL player)] spawn player_alertZombies;
sleep 6;
dayzSetFuel = [_vehicle,_newFuel];
dayzSetFuel spawn local_setFuel;
publicVariable "dayzSetFuel";
cutText [format[localize "str_player_siphon",_nameType,_canSize], "PLAIN DOWN"];
sleep 1;
call fnc_usec_medic_removeActions;
r_action = false;
};
dayz_code.pbo >> compile >> fn_damageActions.sqf
Below This:
Code:
_hasJerry ="ItemJerrycan" in magazines player;
Code:
_hasJerryE = "ItemJerrycanEmpty" in magazines player;
Code:
//CAN WE REFUEL THE OBJECT?
if ((fuel _unit < 1) and _hasJerry) then {
r_action = true;
_action = _unit addAction [format[localize "str_actions_medical_10",_typeVeh], "\z\addons\dayz_code\actions\refuel.sqf",[_unit], 0, true, true, "", "'ItemJerrycan' in magazines player"];
r_player_actions set [count r_player_actions,_action];
};
Code:
//CAN WE SIPHON THE OBJECT?
if ((fuel _unit > 0) and _hasJerryE) then {
r_action = true;
_action = _unit addAction [format[localize "str_actions_siphon_1",_typeVeh], "\z\addons\dayz_code\actions\siphon.sqf",[_unit], 0, true, true, "", "'ItemJerrycanEmpty' in magazines player"];
r_player_actions set [count r_player_actions,_action];
};
dayz_code.pbo >> strinables.xml
Add These:
Code:
<Key ID="str_actions_siphon_1">
<Original>Siphon %1</Original>
<English>Siphon %1</English>
<German>Siphon %1</German>
<Russian>Siphon %1</Russian>
<Spanish>Siphon %1</Spanish>
<Dutch>Siphon %1</Dutch>
<French>Siphon %1</French>
<Czech>Siphon %1</Czech>
</Key>
Code:
<Key ID="str_player_siphon">
<Original>%2 liters of Fuel has been siphoned from %1</Original>
<English>%2 liters of Fuel has been siphoned from %1</English>
<German>%2 liters of Fuel has been siphoned from %1</German>
<Russian>%2 liters of Fuel has been siphoned from %1</Russian>
<Spanish>%2 liters of Fuel has been siphoned from %1</Spanish>
<Dutch>%2 liters of Fuel has been siphoned from %1</Dutch>
<French>%2 liters of Fuel has been siphoned from %1</French>
<Czech>%2 liters of Fuel has been siphoned from %1</Czech>
</Key>
Code:
<Key ID="str_player_siphon_2">
<Original>You cannot siphon less than 20 liters from a vehicle.</Original>
<English>You cannot siphon less than 20 liters from a vehicle.</English>
<German>You cannot siphon less than 20 liters from a vehicle.</German>
<Russian>You cannot siphon less than 20 liters from a vehicle.</Russian>
<Spanish>You cannot siphon less than 20 liters from a vehicle.</Spanish>
<Dutch>You cannot siphon less than 20 liters from a vehicle.</Dutch>
<French>You cannot siphon less than 20 liters from a vehicle.</French>
<Czech>You cannot siphon less than 20 liters from a vehicle.</Czech>
</Key>
If anyone wants to write this up as a "fixes" hook, I'm sure there are plenty of people who would appreciate it.
I will be launching this in DayZ Mercenary 1.4.1 this weekend and have tested it fully on my development server.
Any questions, let me know!
ADMIN EDIT: ORIGINAL CONCEPT OF THIS SCRIPT IS LOCATED HERE. The code on the GitHub was posted 2 months ago. This post was posted on March 19. This is a friendly reminder to give everyone credit where it is due.