erikj 1 Posted May 29, 2018 Ok, that's a bit of a complex problem. As far as I know arma uses 2 kinds of variables: private and global and that will be the biggest problem here. I'm trying to call a script from a object (Data Transmiter) that will add a Hold Action to it. No problem for now and works as intended for a single Data Transmiter. But when I use the same script for a second Data Transmiter only the second one will work. Why that happens? Because some parts of the code requires global variables. So, how can I fix it? I honestly have no idea. That's the code for reference, just call it with a handle = [this] execvm "name of the file.sqf" and should work. //select object name and apply to global _datalinkname = this select 0; datalinkname = _datalinkname; //params ["_datalinkname"]; //Set Datalink Color [datalinkname,"blue","orange","red"] call BIS_fnc_DataTerminalColor; //open/arm function fn_potato = { [ datalinkname , "Hack DataLink", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "_this distance _target < 3", "_caller distance _target < 3", { systemChat "Start Hacking"; }, { playSound3D ["a3\sounds_f\sfx\beep_target.wss", datalinkname, false, getPosASL datalinkname, 1, 1, 0] }, { [datalinkname, 3] call BIS_fnc_DataTerminalAnimate; sleep 5; hint "after 5 sec..."; playSound3D ["A3\Sounds_F\sfx\alarm.wss", datalinkname, false, getPosASL datalinkname, 1, 1, 0]; datalinkname call fn_potato2 }, {}, [], 3, 0, true, false ] remoteExec ["BIS_fnc_holdActionAdd", 0, datalinkname]; }; //close/disarm function fn_potato2 = { [ datalinkname , "Hack DataLink", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "_this distance _target < 3", "_caller distance _target < 3", { systemChat "Start Hacking"; }, { playSound3D ["a3\sounds_f\sfx\beep_target.wss", datalinkname, false, getPosASL datalinkname, 1, 1, 0] }, { [datalinkname, 0] call BIS_fnc_DataTerminalAnimate; sleep 5; hint "after 5 sec..."; playSound3D ["A3\Sounds_F\sfx\alarm.wss", datalinkname, false, getPosASL datalinkname, 1, 1, 0]; datalinkname call fn_potato }, {}, [], 3, 0, true, false ] remoteExec ["BIS_fnc_holdActionAdd", 0, datalinkname]; }; //calls first function datalinkname call fn_potato; Share this post Link to post Share on other sites
Grumpy Old Man 3546 Posted May 29, 2018 1 minute ago, erikj said: Ok, that's a bit of a complex problem. As far as I know arma uses 2 kinds of variables: private and global and that will be the biggest problem here. I'm trying to call a script from a object (Data Transmiter) that will add a Hold Action to it. No problem for now and works as intended for a single Data Transmiter. But when I use the same script for a second Data Transmiter only the second one will work. Why that happens? Because some parts of the code requires global variables. So, how can I fix it? I honestly have no idea. That's the code for reference, just call it with a handle = [this] execvm "name of the file.sqf" and should work. Variables are placeholders for data, local and global refer to the scope of the variable. Have a read. You can also use setVariable/getVariable, so the data will be stored on an in game object/group/task or whatever. To your problem: _datalinkname = this select 0; datalinkname = _datalinkname; Doesn't make much sense, and shouldn't work in the first place try using "_this" instead of "this". fn_potato2 and fn_potato are the same, they both use datalinkname as an object. If you want to use fn_potato with multiple different objects try something like this: fn_potato = { params ["_datalink"]; [ _datalink, "Hack DataLink", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", "_this distance _target < 3", "_caller distance _target < 3", { systemChat "Start Hacking"; }, { playSound3D ["a3\sounds_f\sfx\beep_target.wss", _datalink, false, getPosASL _datalink, 1, 1, 0] }, { [_datalink, 3] call BIS_fnc_DataTerminalAnimate; sleep 5; hint "after 5 sec..."; playSound3D ["A3\Sounds_F\sfx\alarm.wss", _datalink, false, getPosASL _datalink, 1, 1, 0];}, {}, [], 3, 0, true, false ] remoteExec ["BIS_fnc_holdActionAdd", 0, _datalink]; }; //then to add it to multiple datalinks: _datalinks = [datalink1,datalink2,datalink3]; { _add = [_x] call fn_potato } forEach _datalinks; Cheers 1 Share this post Link to post Share on other sites
erikj 1 Posted May 29, 2018 35 minutes ago, Grumpy Old Man said: Doesn't make much sense, and shouldn't work in the first place try using "_this" instead of "this". totally forgot to fix this XD The idea was send the ID of the object to the script. Thinking about it now it was kind redundant. 35 minutes ago, Grumpy Old Man said: fn_potato2 and fn_potato are the same, they both use datalinkname as an object. fn_Potato Opens (see [_datalink,3]) and fn_Potato2 Closes (see [_datalink,0). I tried do that a IF/ELSE but didn't work even with the right sintax. 35 minutes ago, Grumpy Old Man said: params ["_datalink"]; oh, that's how it works! I imagined that should be something like that. 35 minutes ago, Grumpy Old Man said: { playSound3D ["a3\sounds_f\sfx\beep_target.wss", _datalink, false, getPosASL _datalink, 1, 1, 0] }, { [_datalink, 3] call BIS_fnc_DataTerminalAnimate; sleep 5; hint "after 5 sec..."; playSound3D ["A3\Sounds_F\sfx\alarm.wss", _datalink, false, getPosASL _datalink, 1, 1, 0];}, I tried your code, but somehow this part it isn't working (it was before). Edit: Fixed it. I needed Quote params ["_datalink"]; inside each part of it. Btw, thank you for the tips o7 Share this post Link to post Share on other sites