Jump to content
3l0ckad3

Need help with defining a variable ID ?

Recommended Posts

I need help with removing an action, more specifically a hold action..

I have a enemy boat that a diver is going to swim under, he is going to break the fuel line, plant a charge, and then intercept the radio transmission, once the necessary intel is gathered he is going to flip the boat with the kinetic charge, and neutralize the occupants in the water, however, a good portion of that interaction is going to be spent preparing, and hacking their coms, after which they are going to jam the signal and then neutralize the occupants before moving to the next objective, and I noticed that the actions were starting to multiple rather fast. So, the idea is, I need to create an id on the action itself, and remove them after they have been triggered, I could use removeAllActions boat1; but then the other actions would be affected, and, I noticed that I could detonate the charge before it was even placed. I have checked out a lot of threads, but I can't seem to wrap my head around the solution to properly negotiate the desired outcome.
So, I need to remove the action after it has been fired, and, I would like the actions to fire in order, so I'm not getting a touch off option before the charge was set.
This is what I wrote out so far.. And not all functions are written out btw..

initServer.sqf

kc1 hideObjectGlobal true;                         //the charge hidden on the boat until action fires

b1fl1 attachTo [                                   // the fuel line attached to the boat
boat1, [0, -2.4, -1.16]
 ];


_b1fltrg = createTrigger [
"EmptyDetector",
 position boat1, true];

_b1fltrg                                          //tried playing with this, couldn't get it to work
    setVariable [
      "b1fltr", _this];

_b1fltrg
    attachTo [
        boat,[0,-2.5,-1.6]];
_b1fltrg
    setTriggerArea [
        8, 8, 3, false];
_b1fltrg
    setTriggerType
      "NONE";
_b1fltrg
    setTriggerActivation [
      "WEST", "PRESENT", true];
_b1fltrg
    setTriggerStatements [
        "this", "0 = execVM 'FuelL1.sqf'", ""              //script call to cut the fuel line

 ];


 _b1kctrg = createTrigger [
"EmptyDetector",
    position boat1, true];

_b1kctrg setVariable [
"blkctr", this];

_b1kctrg
    attachTo [
        boat1,[0, 0, -.5]];
_b1kctrg
    setTriggerArea [
        11, 11, 0, false];
_b1fltrg
    setTriggerType
        "NONE";
_b1kctrg
    setTriggerActivation [
        "WEST", "PRESENT", true];
_b1kctrg
    setTriggerStatements [
        "this", "0 = execVM 'PlaceKinC.sqf'", ""           // charge placed

  ];

  _b1totrg = createTrigger [
 "EmptyDetector",
     position boat1, true];

 _b1totrg setVariable [
 "bltotr", this];

 _b1totrg
     attachTo [
         boat1,[0, 0, -.5]];
 _b1totrg
     setTriggerArea [
         11, 11, 0, false];
 _b1totrg
     setTriggerType
         "NONE";
 _b1totrg
     setTriggerActivation [
         "WEST", "PRESENT", true];
 _b1totrg
     setTriggerStatements [
         "this", "0 = execVM 'tokc.sqf'", ""                    //fire charge

   ];

 

FuelL1.sqf

[boat1,
"<t color='#FF0000'>Pull Fuel line</t>",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"player distance boat1 < 8",
"player distance boat1 < 8",
{},
{},
{boat1 setFuel 0;deleteVehicle b1fl1;},                                   // cuts fuel and deletes the fuel line
{hint "You Let Go of the Key"},
[],
10,
10,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", [0,-2] select isDedicated, true];

[boat1 , 0] Scall BIS_fnc_holdActionRemove;                                //where I'm stuck

 

PlaceKinC.sqf

[boat1,
"<t color='#FF0000'>Place Kinetic Charge</t>",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"player distance boat1 < 5",
"player distance boat1 < 5",
{},
{},
{kc1 hideObjectGlobal false;},
{hint "You Let Go of the Key"},
[],
10,
8,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", [0,-2] select isDedicated, true];

tokc.sqf

[boat1,
"<t color='#FF0000'>SET OFF CHARGE!</t>",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"player distance boat1 < 20",
"player distance boat1 < 20",
{},
{},
{_boat = _this select 0;sleep 5;_boat setCenterOfMass ((getCenterofMass _boat) vectorAdd [2.6, 0, 0]),
{ unassignVehicle _x } forEach crew _boat;},
{hint "You Let Go of the Key"},
[],
2,
7,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", [0,-2] select isDedicated, true];
deleteVehicle kc1;



So far I have no scripted the hacking and jamming functions, but they are simple enough..
Thnx for any help I can get
Cheers!

Share this post


Link to post
Share on other sites

Scall ?

You just have to place your bis_fnc_holdActionremove in the completion code (the one before code interrupted) . As you can read in BIKI, in this code completed, you can use the params ["_target", "_caller", "_actionId", "_arguments"];

So replace 0 by _actionId

  • Like 1

Share this post


Link to post
Share on other sites

I read the wiki already, I just don't know how to go about it

 

can I get away with ['"","","0",""];

or


["_target", "_caller", "_0", "_arguments"];

??

I probably read like 50 threads last night lol
I just don't understand the _this select 0 command all that well,,,, well,,,, I understand it, I just don't know how to implement it, but I understand it selects functions or objects.. this was very helpful in understanding the block, but the id eludes me, I'm okay with addActions because I can easily give them a handle, but, this one has my number lol 

Share this post


Link to post
Share on other sites

params ["_target", "_caller", "_actionId", "_arguments"];

is equivalent as:

_target = _this select 0 (as you used in your code)

_caller = _this select 1;

_actionId = _this select 2;

_arguments = _this select 3 (which can be an array itself)

 

So, in the code (like any other code using local variables)

params ["_target", "_caller", "_actionId", "_arguments"];

[boat1 , _actionId] call BIS_fnc_holdActionRemove;

(or even [_target , _actionId] call BIS_fnc_holdActionRemove);

 

If you write:

params ["", "", "_actionId"];

that means you will not use _target and _caller (and _arguments of course) but "" are here to place _actionId on the right index (2).

  • Like 1

Share this post


Link to post
Share on other sites

Ohhhhhh, k. I got it now.
It looks like params negate the need for the select command.

Since I remote execed the block, I'm under the understanding that it will not duplicate for every client machine ? or should I toss a server shell on her ? 
Thank you for taking the time, once again. 

Share this post


Link to post
Share on other sites

Simple, all players must "see" the hold action. So the Bis_fnc_holdActionAdd must be present on all PCs (of the needed players)

If you script from server (why not), you need to remoteExec this function.

If you script from init.sqf, or from init field of the boat1, or in any shared sqf, you must not remoteexec it. Simple?

 

Now, the codes inside the hold actions are local to the player who acts it. So... if you need a local effect, say hint "good job" , you don't need to do anything more. But... if you want to use a command for the boat (say push it), some commands like setvelocityModelSpace  (AL EG command) then you need to remoteExec the command where the boat is....

Where is the boat? If you never jump into it, an empty boat is on server, if there is a player as driver, the boat is on this player's PC, if you jumped into it and disembark, the boat can be manage by your PC.  To conclude, if you don't remoteExec this kind of command, you have a little chance to "push" the boat (if you managed it just before). If not, that will not work. So, always remotExec where the boat (or other object of course) is:

[boat1, [0,10,0]] remoteExec ["setVelocityModelSpace",boat1] (example)

(or  [_target, [0,10,0]] remoteExec ["setVelocityModelSpace",_target] to follow the previous posts).

  • Like 1

Share this post


Link to post
Share on other sites

The server will have ownership of the boat till it is deleted, ai are patrolling in the vehicle, and we commence tasks on them, and when it is all said an done, the boat is sinking to the bottom of the sea, so, no, we will never take ownership from the server.

And yes, the scripts are fired on the vehicle, however, once I get it more polished the scripts will be ran off the fuel line, and the object I have attachToRelative  to, kinda, the end result will be to attach triggers on the areas of the boat where I want players carrying out the tasks, it is just being very finicky right now, so I just pushed it forward for mission making flow, because it was taking too long,,, I already have all the triggers attached to the boat, however, they are execVM..

It's fired from the ServerInit.sqf, I could make mention of it in the InitPlayerLocal ?

 

I could prepare players if it is in the file, just behind a server shell with this _myVarName = []; ???
It's not a jip mission, it is just going to be a campaign, so, at least in my case it will be multiplayer local hosting.

What I mean
 

_myVarName = [];


if (isServer) then {

 /* --- block of code --- */

};

Will that work ?? Because that is how some of my personal scrips are written lol
I normally have some units out that are doing certain actions, like leaning or sitting or whatnot, but I rely on my script, and deleting empty groups, so I can spawn a 1000 units if I so wish, that script looks like this

 

/* Alpha East null = [this] execVM "IQ_Spawn\RED\IQ_AE.sqf";*/
_ae1 = [];

if (isServer) then {

_ae1 = [getmarkerpos "aewps", EAST, ["O_Soldier_TL_F","O_HeavyGunner_F","O_Soldier_TL_F","O_HeavyGunner_F","O_Soldier_TL_F","O_HeavyGunner_F"],[],[],[],[],[],265.921] call BIS_fnc_spawnGroup;

{
    [_x] execVM "IQ_Skill\RedCon\RedCSkill.sqf";
    [_x] execVM "IQ_Load\RedL\Adv_Load_ISIS.sqf";
    [_x] execVM "IQ_INIT\RedInit\Rin.sqf";
} forEach units _ae1;

_aewp0 = _ae1 addWaypoint [getmarkerpos "aewp1", 0];
    _aewp0 setWaypointType "MOVE";
    _aewp0 setWaypointSpeed "NORMAL";
    _aewp0 setWaypointBehaviour "AWARE";
    _aewp0 setWaypointFormation "LINE";
    _aewp0 setWaypointCombatMode "RED";
    _aewp0 setWaypointCompletionRadius 5;
    _aewp0 setWaypointDescription "Move here.";

_aewp1 = _ae1 addWaypoint [getmarkerpos "aewp1", 0];
    _aewp1 setWaypointType "MOVE";
    _aewp1 setWaypointSpeed "NORMAL";
    _aewp1 setWaypointBehaviour "AWARE";
    _aewp1 setWaypointFormation "LINE";
    _aewp1 setWaypointCombatMode "RED";
    _aewp1 setWaypointCompletionRadius 5;
    _aewp1 setWaypointDescription "Move here.";

 };

This is how I make massive missions with almost 0 lag or spikes, because they are spawned as needed.
Never really showed this to someone, so I'm I'd like your input on how this would would run in multi or dedi environments, since locality is not my strong suit.



---------------------
Wow, I got a lot of reading to do, remoteExec is a huge topic lol
Lots of examples to learn from..

Share this post


Link to post
Share on other sites

On server (initserver.sqf or if (isServer) then [...} in init.sqf, you can do all the stuff for AIs and objects staying on server (no localization change), so no need to remoteExec something (to server).

For triggers, depending on what you script... To spawn AIs, the trigger must be on server only to avoid duplication by each players (usually the triggers fires for generic conditions like BLUFOR present, which is global to all players. On the other end a radio ALFA is local if I remember)

After that, you need to check all commands (and functions) for their arguments_local.gif/arguments_global.gif/Exec_Server.gif   and effects_local.gif/effects_global.gif behaviors.

Same in all commands in execVMed sqf, depending on where you spawned them. Just keep on mind, which PC will execute sqf, when, for what units/objects.

 

Spawn units/objects on server (headless client needs some extra skills and I'm not familiar with that);

Usually, markers and waypoints are MP friendly. Run them somewhere. Server is fine of course;

Tasks have their own behaviors embedded in the functions (see bis_fnc_setTask . I'd rather use this one than taskcreate);

All HUDs, hints, specific data for a player should run locally.

 

 

 

 

  • Like 1

Share this post


Link to post
Share on other sites

I just write my tasks out, so it is no biggy for me, I only use the modules to get workflow to keep building on an idea.
But I learned the hard way with that script, had about 20 people log onto my server back in the day, and yeah, 200 enemies turned into A LOT more Real fast, so I tossed a server shell on her. 

The scripts themselves are not fired from the ServerInit, however, the triggers that fire them are, not sure if that is a problem.
And Eventually once I get that spawn script further along it will just spawn  them via setPosASL, my goal is to limit editor dependency to learn, most the stuff I work on it's just to push myself to learn more, even my personal script pack isn't a big deal to me, it does random loadouts  within defined arrays, or specific, it handles skill attributes, snipers, heli transport under fire, it is just a pack to help me cut down on mission making time, it isn't finished yet tho..

Thnx a ton Pierremgi,,, much,, appreciated!

  • 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

×