Arma 3
Tex Hasselhoff 19. mars 2023 kl. 10.18
[Help] Auto-Gathering
Hello, I'm making a life server on the latest 5.0 version of Altis Life Framework, its up and running smooth. I would like to make gathering toggled/automatic so players don't have to keep hitting the Windows Key to keep gathering ingredients on the map.



Basic Description of desired result: User hits Windows Key to start gathering ingredients and the character will do so until full or until user hits the TAB key to stop gathering ingredients.

"Olympus Entertainment" has this functionality on their life server so, I know its possible, I just don't know how.



What I have done so far is inserted a "while true" statement in the "fn_gather.sqf" file to loop the gathering script which works so far. Now I just need help making the "TAB" key stop/interrupt/cancel/suspend/terminate/pause/exit the "fn_gather.sqf" script. I would also like to adapt this to processing as well to cancel processing by hitting TAB. Any and all help is much appreciated, thanks for reading and have a great day.

#include "..\..\script_macros.hpp" /* File: fn_gather.sqf Author: Devilfloh Description: Main functionality for gathering. */ autogather = 1; while {autogather > 0} do { private ["_maxGather","_resource","_amount","_maxGather","_requiredItem"]; if (life_action_inUse) exitWith {}; if !(isNull objectParent player) exitWith {}; if (player getVariable "restrained") exitWith {hint localize "STR_NOTF_isrestrained";}; if (player getVariable "playerSurrender") exitWith {hint localize "STR_NOTF_surrender";}; life_action_inUse = true; _zone = ""; _requiredItem = ""; _exit = false; _resourceCfg = missionConfigFile >> "CfgGather" >> "Resources"; for "_i" from 0 to count(_resourceCfg)-1 do { _curConfig = _resourceCfg select _i; _resource = configName _curConfig; _maxGather = getNumber(_curConfig >> "amount"); _zoneSize = getNumber(_curConfig >> "zoneSize"); _resourceZones = getArray(_curConfig >> "zones"); _requiredItem = getText(_curConfig >> "item"); { if ((player distance (getMarkerPos _x)) < _zoneSize) exitWith {_zone = _x;}; } forEach _resourceZones; if (_zone != "") exitWith {}; }; if (_zone isEqualTo "") exitWith {life_action_inUse = false;}; if (_requiredItem != "") then { _valItem = missionNamespace getVariable "life_inv_" + _requiredItem; if (_valItem < 1) exitWith { switch (_requiredItem) do { //Messages here }; life_action_inUse = false; _exit = true; }; }; if (_exit) exitWith {life_action_inUse = false;}; _amount = round(random(_maxGather)) + 1; _diff = [_resource,_amount,life_carryWeight,life_maxWeight] call life_fnc_calWeightDiff; if (_diff isEqualTo 0) exitWith { hint localize "STR_NOTF_InvFull"; life_action_inUse = false; }; switch (_requiredItem) do { case "pickaxe": {[player,"mining",35,1] remoteExecCall ["life_fnc_say3D",RCLIENT]}; default {[player,"harvest",35,1] remoteExecCall ["life_fnc_say3D",RCLIENT]}; }; for "_i" from 0 to 4 do { player playMoveNow "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon"; waitUntil{animationState player != "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon";}; sleep 0.5; }; if ([true,_resource,_diff] call life_fnc_handleInv) then { _itemName = M_CONFIG(getText,"VirtualItems",_resource,"displayName"); titleText[format [localize "STR_NOTF_Gather_Success",(localize _itemName),_diff],"PLAIN"]; }; sleep 1; life_action_inUse = false; //switch (_code) do { //case 15: { //exitWith { //hint localize "Action Cancelled"; //life_action_inUse = false;} //}; //}; };
< >
Viser 11 av 1 kommentarer
T3xasR3dRum 23. apr. 2023 kl. 22.53 
for "_i" from 0 to 4 do { player playMoveNow "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon"; waitUntil{animationState player != "AinvPercMstpSnonWnonDnon_Putdown_AmovPercMstpSnonWnonDnon";}; // Add the following condition to check for the TAB key press if ((actionKeys "User20") call {code {_x > 0}} count actionKeys "User20" > 0) exitWith { hint "Gathering canceled"; life_action_inUse = false; autogather = 0; }; sleep 0.5; };`

This condition checks if the "User20" action (which corresponds to the TAB key by default) has been pressed. If it has, the gathering process will be canceled, a hint will be displayed to inform the user, and the autogather loop will be terminated.

To implement the same functionality for processing, you will need to locate the corresponding script file for processing in your life RPG mod (it may be named something like fn_process.sqf). Find the loop that handles the processing action and add a similar condition to check for the TAB key press:

for "_i" from 0 to 4 do { // Your processing animation or other actions go here // Add the following condition to check for the TAB key press if ((actionKeys "User20") call {code {_x > 0}} count actionKeys "User20" > 0) exitWith { hint "Processing canceled"; life_action_inUse = false; }; sleep 0.5; };

Remember to adjust the loop and variable names according to the specific processing script you are using.

By implementing these changes, the TAB key will cancel the gathering and processing actions while they are in progress.
< >
Viser 11 av 1 kommentarer
Per side: 1530 50