Jump to content
Flightcaptain93

Passing Arguments via addaction

Recommended Posts

_spawn1 = player addAction
[
    "Place spawn",    // title
    "scripts\placerespawn.sqf", // script 
    [_tent,_spawn2],    <========= HERE spawn2 cant be used in the placerespawn.sqf     // arguments
    1.5,        // priority
    true,        // showWindow
    true,        // hideOnUse
    "",            // shortcut
    "true",     // condition
    50,            // radius
    false,        // unconscious
    "",            // selection
    ""            // memoryPoint
];

 

_spawn2 = player addAction
[
    "Cancel placing spawn",    // title
    "scripts\cancelrespawn.sqf",// script 
    [_tent,_spawn1],        // arguments
    1.5,        // priority
    true,        // showWindow
    true,        // hideOnUse
    "",            // shortcut
    "true",     // condition
    50,            // radius
    false,        // unconscious
    "",            // selection
    ""            // memoryPoint
];

 

I added two addActions via one script. _spawn2 can handle the passed variable _spawn1 but _spawn1 cant handle the passed variable _spawn2 because it is created later... How can i pass _spawn2 into the script from _spawn1? in both scripts both of these actions are deleted. 

or should i use another approach?

Share this post


Link to post
Share on other sites

Use global handles. No need to pass them as arguments (particularly when they don't yet exist).

 

Add actions:

test1 = player addAction ["TEST 1", "test.sqf"];
test2 = player addAction ["TEST 2", "test.sqf"];

Remove actions (test.sqf) :

player removeAction test1;
player removeAction test2;
  • Like 1

Share this post


Link to post
Share on other sites

You don't need 2 actions. use setUserActionText. Example for spawning/deleting a single tent:

 

private _tentType = "Land_TentDome_F";
private _actiontentTxt = "Place spawn";
private _spawnTent = player addAction
  [
    _actiontentTxt,
    {
      params ["_tgt","_caller","_id","_tentType"];
      private _tent = objNull;
      if ((_caller actionParams _id)#0 isEqualTo "Place spawn") then {
        plyr_tent = createVehicle [_tentType,_caller getPos [10,getdir _caller],[],0,"NONE"];
        _caller setUserActionText [_id,"Cancel placing spawn"];
      } else {
        if (_caller distance2D plyr_tent < 15) then {
          deleteVehicle plyr_tent;
          _caller setUserActionText [_id,"Place spawn"];
        }
      }
    },
    _tentType,
    1.5,
    true,
    true,
    "",
    "isNull objectParent _this"
];

 

  • Like 1

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×