English Auto Gather & Mine

  • Auteur de la discussion Auteur de la discussion AltisLifeDev
  • Date de début Date de début
17/4/23
16
2
1
100
I know a lot of people have been asking how to add auto gather, well here is a very easy way to do it.

At the end of fn_gather.sqf below:
C++:
sleep 1;
life_action_inUse = false;

Add the following:
C++:
// Automatically gather again if there are resources nearby
_ie585895 = -1;
_zoneSizeCfg = getNumber(_resourceCfg >> "zoneSize");
if (_zone != "") then {
  waitUntil {
      if (speed player > 0)exitWith{_ie585895  = 0;true};  //moved
      if (life_interrupted) exitWith {_ie585895  = 1;true};  //interrupted key press
      if ((player distance (getMarkerPos _zone)) < _zoneSizeCfg) exitWith {_ie585895 = 2;true}; // left area
    true
  };
    
if (_ie585895 >= 0) exitWith{
   switch _ie585895 do {
        case 0 : {hint "You moved so you stoped gathering"};
        case 1 : {hint "Dont do anything <life_interrupted>"};
        case 2 : {hint "You left the gathering area";};
        };
    };
    [] spawn life_fnc_gather;
};

At the end of fn_mine.sqf below:
C++:
sleep 1;
life_action_inUse = false;

Add the following:
C++:
// Automatically gather again if there are resources nearby
_ie585895 = -1;
_zoneSizeCfg = getNumber(_resourceCfg >> "zoneSize");
if (_zone != "") then {
  waitUntil {
      if (speed player > 0)exitWith{_ie585895  = 0;true};  //moved
      if (life_interrupted) exitWith {_ie585895  = 1;true};  //interrupted key press
      if ((player distance (getMarkerPos _zone)) < _zoneSizeCfg) exitWith {_ie585895 = 2;true}; // left area
    true
  };
    
if(_ie585895 >= 0)exitWith{
   switch _ie585895 do {
        case 0 : {hint "Stay still <player speed>"};
        case 1 : {hint "Dont do anything <life_interrupted>"};
        case 2 : {hint "You left the mining area";};
        };
    };
   [] spawn life_fnc_mine;
};
 
Dernière édition: