Re: RELEASE : DaiZy Chernarus 1.7.7 FACTIONS 2.2
Posted by
Haleks on
Jun 13, 2013; 8:33pm
URL: http://kodabar-dayz-daizy-single-player-forum.163.s1.nabble.com/RELEASE-DaiZy-FACTIONS-3-0-2-20-01-2014-UPDATED-w-Car-Patrols-tp8540p8634.html
TheLegendDevil wrote
Any chance of you adding Auto-refuel? Or make a tutorial how to add it :D
Here's a quick tuto :
Open the mission file, and inside of it create a text file called "kh_actions.sqf".
Copy/paste the following code in it :
private ["_vehicle", "_vehicle_refuel_id"];
_vehicle = objNull;
diag_log "Running ""kh_actions"".";
while {true} do
{
if (!isNull player) then
{
private "_currentVehicle";
_currentVehicle = vehicle player;
if (_vehicle != _currentVehicle) then
{
if (!isNull _vehicle) then
{
_vehicle removeAction _vehicle_refuel_id;
_vehicle = objNull;
};
if (_currentVehicle != player) then
{
_vehicle = _currentVehicle;
_vehicle_refuel_id = _vehicle addAction ["Refuel", "kh_vehicle_refuel.sqf", [], -1, false, false, "",
"vehicle _this == _target && local _target"];
};
};
};
sleep 2;
}
Save and create another sqf file called "kh_vehicle_refuel.sqf"; copy/paste the following code :
private ["_target", "_caller", "_id", "_isNearFeed"];
_target = _this select 0;
_caller = _this select 1;
_id = _this select 2;
if (isNil "ib_refueling_in_progress") then { ib_refueling_in_progress = false; };
if (!ib_refueling_in_progress) then
{
_isNearFeed = count ((position _caller) nearObjects ["Land_A_FuelStation_Feed", 10]) > 0;
if (!_isNearFeed) then
{
titleText ["You must be near a fuel station pump.", "PLAIN DOWN", 3];
titleFadeOut 3;
}
else
{
ib_refueling_in_progress = true;
titleText ["Refueling", "PLAIN", 3];
while {(vehicle _caller == _target) and (local _target)} do
{
private ["_velocity", "_fuel"];
_velocity = velocity _target;
_fuel = fuel _target;
if ((_velocity select 0 > 1) or (_velocity select 1 > 1) or (_velocity select 2 > 1)) exitWith { };
if (_fuel >= 1.0) exitWith { };
sleep 0.5;
_fuel = _fuel + 0.005;
if (_fuel >= 1.0) then { _fuel = 1.0; };
_target setFuel _fuel;
};
titleFadeOut 1;
ib_refueling_in_progress = false;
};
};
And, finally, open the init.sqf file and add this line :
if (!isDedicated) then {
[] execVM "kh_actions.sqf";
};
Repack your mission and you should be good! I don't know who wrote the script so I cannot give proper credit to it, but I think it comes from a Taviana dayz mod.