#arma3_scripting

1 messages · Page 150 of 1

timber shore
#

''' _rnd1 = floor random 4;
if((typeOf cursorTarget == "Obj1") || (typeOf cursorTarget == "Obj2") || (typeOf cursorTarget == "Obj3") || (typeOf cursorTarget == "Obj4") && (player distance cursorTarget < 7) && ( _rnd1 == 0 )) then {
action1 = player addAction ["Knock Knock", {deleteVehicle cursorTarget; player removeAction action1; removeAllActions player; hint "Who is there!";}];
} else {
player removeAction action1;
removeAllActions player;
};'''

hallow mortar
#

(https://community.bistudio.com/wiki/Arma_3:_Functions_Library)

// fn_addMyAction.sqf
params ["_target"];
private _actionID = _target addAction [ ... ];
_target setVariable ["my_var_actionID",_actionID];

// fn_removeMyAction.sqf
params ["_target"];
private _actionID = _target getVariable ["my_var_actionID",0];
_target removeAction _actionID;

// when you want to add the action
[_target] remoteExec ["my_fnc_addMyAction",0,"myActionJIPID"];

// when you want to remove the action
[_target] remoteExec ["my_fnc_removeMyAction",0,"myActionJIPID"];
timber shore
#

test

hallow mortar
#

However, for your specific system, it might be better to make it so that both actions are actually present all the time, and each one has a condition that only makes it visible when the cargo is loaded or not loaded, as appropriate. This is often simpler than doing add/remove action all the time.

timber shore
#
    if((typeOf cursorTarget == "Obj1") || (typeOf cursorTarget == "Obj2") || (typeOf cursorTarget == "Obj3") || (typeOf cursorTarget == "Obj4") && (player distance cursorTarget < 7) && ( _rnd1 == 0 )) then {
        action1 = player addAction ["Knock Knock", {deleteVehicle cursorTarget; player removeAction action1; removeAllActions player; hint "Who is there!";}];
    } else {
        player removeAction action1;
        removeAllActions player;
    };```
tired cargo
#

Thanks a lot)

timber shore
#

so I can't figure out why it always allows it, as _rnd1 can't always == 0

#

secondly, I'm trying to turn that into a waitUntil, so it can run and the addaction will come up when the conditions are met (random = bla) (cursorTarget = bla) (within 7m)

#
    _objects = ["Obj1","Obj2","Obj3","Obj4"];
    waituntil {typeOf cursorTarget in _objects && player distance cursorTarget < 7 && _random == 0};
    action1 = player addAction ["Knock Knock", {deleteVehicle nearestObjects [player, [_objects], 15]; hint "Who is there";}];
    waituntil {!typeOf cursorTarget in _objects && player distance cursorTarget > 7 && _random != 0};
    player removeaction action1;
    removeAllActions player;```
#

but that doesn't seem to work

#

any help?

blissful current
#

I am trying to fire a trigger when any player gets in a vehcile. Right now I have this but it only works in SP not MP:

player in (crew ptboat);
faint burrow
stable dune
blissful current
#

I found this one on reddit too:

(allPlayers - crew ptboat) isEqualTo []
#

Now I know there lots of ways to do the same thing but which is optimal?

#

Or rather what considerations should I be thinking of?

faint burrow
blissful current
faint dove
#

@timber shore have you swapped out actual classnames for Obj1,2,3,4 in that script?

blissful current
#

But to ask from a performance perspective. If I used a if statement, does that mean its constantly being calculated? If so, does that inhibit performance?

faint dove
#

cos typeOf returns a classname

faint burrow
#

If I used a if statement, does that mean its constantly being calculated?
No. Yes, if it was placed in a loop.

If so, does that inhibit performance?
Same as above.

blissful current
#

I racked my brain trying to find a solution to this JIP issue:

  1. I want the mission to start with a black screen, run some type text, then fade in. The only way I've been able to get it to work seemless is placing the code into init.sqf because that gets ran before the briefing screen. Otherwise the mission starts without a black screen for a second then flashes to black screen and then back in. Unfortunately though, this meathod this means that any JIP has to sit through this intro because their init will run again when they JIP.

  2. So then I tried remoteExec a SQF with the code at the start of the mission with a BLUFOR present trigger. This works good for JIP because I can set the trigger to Server Only so it wont run again for JIP players. But I still get that brief second before the code runs and turn the screen to black.

What would be a good workaround for this?

hallow mortar
#

Use a variable to detect whether the intro has already been run

#

For example:

if !(missionNamespace getVariable ["my_var_introdone",false]) then {
  // insert intro here
};
// on the server, some time later:
missionNamespace setVariable ["my_var_introdone",true,true];```
JIP clients will receive the variable broadcast from the server before they run init.sqf. The variable being set to true will tell them the intro has already happened and they can skip running it.
blissful current
#

Hmmm. Okay this kinda makes sense to me but I'm struggling a little bit with the if portion.

So the if is looking for just my_var_introdone right?

#

And if it see it then it wont run the code?

sharp grotto
#

Since the false is "default parameter" this will be also the case if the var is not set

blissful current
#

Is that what the ! is?

sharp grotto
#
if(alive player) then {systemChat "Player Alive"};
if!(alive player) then {systemChat "Player Dead"};
blissful current
#

Whould this be the same?

if (isNil "my_var_introdone") then {};
sharp grotto
#

No, it checks if var is defined or not

#

So not the same, but can also be used

fair drum
#

We will have a chat tonight @blissful current when I get home

blissful current
tulip ridge
blissful current
#

This is my first time writing a Fired event handler. The hint message doesn't print so I've done something wrong.

if (triggerActivated ExtractConvo) then {
    _player addEventHandler ["Fired", {
        params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
            if ("vn_m18_purple_mag" in _magazine && 
               (_unit inArea "Grenade_Marker" || _unit distance markerPos "Grenade_Marker" < 100)) then {
               hint "Purple Seen";
        };
    }];
};
tulip ridge
#

You'd have to show more of your code, if that is your entire file then _player is undefined when trying to add the event handler.

blissful current
#

I do have _player defined several lines up do I need to define it multiple times in the SQF?

tulip ridge
#

No, but I don't know the context of your code

blissful current
#

this is directly above it (and works)

params ["_player", "_didJIP"];
if (isNil "mission_SmokeThrown") then {
    _player addEventHandler ["FiredMan", {
        params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile",                          "_vehicle"];
        if !isNil "mission_SmokeThrown" exitWith {
            _unit removeEventHandler [_thisEvent, _thisEventHandler];
        };
        if ("vn_m18" in _magazine && {_unit inArea "marker_1_LZ" || {_unit distance markerPos                         "marker_1_LZ" < 100}}) then {
             missionNamespace setVariable ["mission_SmokeThrown", true, true];
        };
    }];
};

I used it as a guide to write the other one I posted.

tulip ridge
#

if !isNil "mission_SmokeThrown" exitWith
Missing parenthesis

blissful current
#

Oh wow. And that one works fine without any error codes too. Good catch. But it doesn't explain where I've gone wrong in the first example.

tulip ridge
blissful current
#

Will it add any dependencies to my mission?

tulip ridge
#

Nope

blissful current
#

Nice. I just asked ChatGPT to check mine for errors and its say its fine (I know chat GPT can be wrong)

tulip ridge
#

It will almost certainly be wrong

fair drum
#

especially with SQF

#

also, remember to make threads @blissful current . you have a lot of questions independent of each other

tulip ridge
#

I can't stand any sort of AI assistant. Especially for programming.

fair drum
#

i think its pretty good at teaching human languages though. possibly better than duolingo

blissful current
#

Im sure it gets me in trouble. But its been a quick way to help me find my beginner mistakes.

tulip ridge
#

That's what a debugger is for

blissful current
#

Is that a function of notepad++?

#

thats what im using

fair drum
#

vscode i like better. especially when you start integrating with github

tulip ridge
#

No, SQF is a scripting language for arma. No text editor is going to have built in support for it. You'll be mostly fine with writing and/or testing your code in ADT's debug console

blissful current
#

Event Handler Advice Needed

still forum
#

Actions can also be used by AI units. Which do exist on servers.
Though I would hope no one does that, and I don't know how you would do it.

still forum
winter rose
still forum
#

Eject, getout, rearm are also the mouse wheel actions, that can also be triggered by action command.
Same system.
If anything then that

#

But addAction doesn't have a unique name.

#

I might look it up later

drifting spire
#

If I were wanting to make a script so people who disembark from a boat near a dock gets placed on the dock, would it be best to have a trigger at said dock, and then somehow capture the disembark event, and if the disembark comes from a boat object, then run the teleport to ontop of the dock?

proven charm
#

true. but personally I wouldnt put anything on server that doesn't belong there, even if it fails silently

still forum
#

Wiki says addAction is ignored on server. But.. Its not.
There isn't any server check there in the code.

#

The type for the action command is "User"
And then you have to use the actions id/index

#

So with that, you can addAction on a server, and let server-side AI units execute it

proven charm
#

interesting, I wonder what are the use cases for that

still forum
#

Seems stupid and backwards for me.
Why run a script to run a action that runs a script.. If you could just.. run the script

willow shore
#

Do I define functions that my module(s) will use in the pre-init?

still forum
#

or just CfgFunctions

willow shore
#

Ah that makes more sense

#

Thank you

still forum
#

No, I hope noone uses that

willow shore
#

Ok if I were to have multiple functions defined in CfgFunctions e.g. function1, function2 and a module module1.
Would it be a problem if module1 called function1 which then called function2?

#

I'm not sure if I'm overthinking it but would there maybe be a problem where a function calls another function before it exists?

still forum
#

calling functions is a natural part of scripting

#

it won't cause problems

willow shore
#

Ok so functions defined in CfgFunctions are created before the init of a module for example is executed?

still forum
#

yes

willow shore
#

Thank you, think I'm beginning to understand it

velvet onyx
#

How to make Get in task?
Ok, so first, I have this script for my scenario,
https:/ibb.co/J7y72Xn and this script was working
but not the way I wanted it to, so in the opening of
my scenario, I was already in the car, so the problem
here is that the task that was supposed to show
later when I enter the vehicle was already showing
in the opening, so the problem here is that the task that was supposed to be later was already showing up because I have this task where I need to get in the vehicle, so that mission needs to show up, but italready shows up because I was already in the car.So what I wanted is that there's a different car that
will activate the mission, but I don't know how. I'm
sorry if this is confusing. I don't know how to explain
it properly.

willow shore
# still forum yes

Just wanted to say everything works so much better now and my code is so much cleaner, thank you very much!

still forum
#

I didn't even do anything, its all you

willow shore
#

Thank you anyways salute Might've seemed simple but it helped alot.

stable dune
tired cargo
#

Hi guys!

Does an AI unit become removed from the server if it joins a player's group?

granite sky
#

Its locality switches to the player's client, if that's what you mean.

tired cargo
#

After join

granite sky
#

"removed" is an odd word to use.

flint topaz
#

With CBA Settings is there a way to make a settings hidden, aka you can only view the contents of the setting if you are logged in as an admin/able to change it. I want to store a password and for obvious reasons want it to remain secure

tired cargo
granite sky
#

"remote" if you like.

tired cargo
#

Well ? remote or still local ?

granite sky
#

A unit is only local on one machine at a time.

#

So yeah, if the locality switches to a client, it's no longer local where it was local before.

tired cargo
#

Thanks)

willow hound
#

There is no BIS_fnc_unitCapture* in that screenshot 🙃

#

Other than that it looks good. What does systemChat str [_v1_2dothings, _v1_1dothings, _V2dothings] give you?

true frigate
true frigate
true frigate
#

That's weird. systemChat str [_v1_1pewdata, _v1_2pewdata]; returns [any,any]

willow hound
true frigate
#

That is odd. Mine only has 2 elements in each array. [213.368,"UK3CB_BAF_CannonM621"]

#

Let me check my previous scripts

#

Nope, apparently my last working scripts have 2 elements. Huh.

willow hound
#

Maybe check systemChat str [count _v1_1pewdata, count _v1_2pewdata] too.

timber shore
#

yes

radiant nova
#

I have a problem, when the gunner's sight is aimed as low as possible, the bullets fly above the sight, when the gunner's sight is aimed as high as possible, they fly below the sight, how can I make it so that they always fly to the center?

hallow mortar
#

Unless this whole thing is somehow being controlled by scripting, this is a problem with the vehicle's animations/config, not a scripting issue - the gunsight and the guns themselves aren't properly aligned.

sullen sigil
blissful current
granite sky
#

What waypoint is it on when you order it to land?

#

for the general case, lockWP should work.

blissful current
#

I am trying to use scripting to do the waypoints because the in editor stuff wasn't doing what I wanted.
This is the first waypoint that get the helicopter to the area and loiter through an addAction. Works perfect.

_group = ExtractHeli; //names heli group
_markerName = "marker1";  //name of marker
_waypointPosition = getMarkerPos _markerName; // adds waypoint to marker
_waypoint = _group addWaypoint [_waypointPosition, 0]; //moves group to waypoint
_waypoint setWaypointType "LOITER"; // group loiters waiting for my next addaction

Once it gets to the area the idea is to use an addAction to have it land on a specific marker. I haven't tried using markers yet for the next waypoint because I haven't gotten it to stay landed. First I gotta do that then I'll try to incorporate markers.

ExtractHeli land "LAND"; //immediatley takes off and hovers after landing. DOH!
granite sky
#

You're adding a move waypoint after the loiter waypoint as well though?

blissful current
#

I tried to do that then set the waypoint type as land but it gave a foreign error.

#

If thats what you are getting at

granite sky
#

There is no "land" waypoint type.

blissful current
#

I found that out the hard way. lol

granite sky
#

I need it to stay landed (with engine on) until I trigger it to move to the next waypoint.

#

So there is no other waypoint at the moment? There's just the loiter?

blissful current
#

Correct. I'm trying to build it one step at a time. Ive got it to loiter in the area. Next step is to get it to land.

granite sky
#

But you did get it to land?

#

You could just delete the loiter waypoint when you give the land command. Probably works.

blissful current
#

Yes. What I am saying is helicopter land mode lets the helicopter land then it immediatley takes off. I want it to STAY landed.

granite sky
#

If it's still in the loiter waypoint then that wouldn't be surprising.

#

Not gonna loiter on the ground :P

blissful current
#

Okay I will try to delete the waypoint. I suppose the best time to do that is right before I issue that land in the script.

granite sky
#

setCurrentWaypoint to one beyond the loiter might also work.

blissful current
#

I assumed that if you used addWaypoint it would cancel out the last assigned one.

granite sky
#

addWaypoint never overwrites. Default behaviour is to add the new waypoint at the end. You can also insert with the third parameter.

#

but you only have one waypoint anyway.

blissful current
#

What am I supposed to put in the index? deleteWaypoint [group, index] The in editor tells you a number but since I am using script should I just count in my head? If so, does that mean the first one is 0 like in the editor or would it be 1?

granite sky
#

you should check what waypoints you actually have using waypoints

#

Sometimes groups get a default move waypoint on creation, so the first one you add is actually index 1.

#

Never pinned down the logic there.

#

(might also have been a local bug. I figured more shit out since)

blissful current
granite sky
#

first waypoint is [group, 0] anyway. Second is [group, 1]

#

unconfirmed. Just check what's actually happening with waypoints and currentWaypoint

#

Also forward-deleting multiple waypoints was buggy IME.

blissful current
#

Oh wow so basically for any waypoint I need to use waypoints then somehow script it to grab the value?

granite sky
#

Probably not. I just don't remember the exact behaviour off the top of my head.

#

Waypoint scripting is extremely poorly documented, and quite buggy. You have to do your own research to a degree.

blissful current
#

I guess that means most people just use the in editor one then? I found that to be quite restrictive on what I wanted to do.

For example if I wanted to have a ANY waypoint AFTER the loiter one (which I would skip with a waypoint trigger at the appropriate time), the helicopter would no longer do circles but would just hover in place.

That's what led me down this rabbit hole of waypoints in scripting.

granite sky
#

I think that's normal for loiter waypoints, regardless of whether you script them or not.

#

There is an argument with scripting for dropping waypoints entirely, given that they're a buggy black box full of shit, but that's rather more work and you're still quite limited with what you can do with the AI.

blissful current
#

Well I tried the deleting waypoint and it worked. 1/5 times. LOL. the time it did work it turned the engine off too . DOH!

granite sky
#

If you make a simple mission demonstrating the issue then I can look at it.

blissful current
#

And just as you have said waypoints is returning 2 different ones even though I only have one at the moment. So its creating one on spawn.

#

For sure I always build and idea in a test mission first before then integrate it when it actually works.

#

do you want PBO or just the files?

restive topaz
#

Heyo, I'm trying to run a multiplayer operation of a steam workshop mod, but we're instantly dying, respawning, and Game Over-ing at grid 000000 like the mission maker didn't add respawnOnStart = 0; to description.ext. Is there any way I can correct this to allow the mission to play in online multiplayer as somebody who does not own the mission?

dapper cairn
#

is it possible to have a tv on the ground to emit light in a room?

restive topaz
#

Helpful answers also work too, gonna try and PBO manage it back into a mission file and add the appropriate scripting. (P.S. That did the trick!)

tribal gazelle
#

Hey I am new to scripting on Arma 3 and I am trying to learn some basics, any tips are welcome. I am having an issue with saving custom loadouts from arsenal this is for players,

My code for onPlayerRespawn.sqf:

removeAllweapons P1;
removeAllweapons P2;
removeAllweapons P3;
removeAllweapons P4;
removeAllweapons P5;
removeAllweapons P6;
removeAllweapons P7;
removeAllweapons P8;

removeGoggles P1;
removeGoggles P2;
removeGoggles P3;
removeGoggles P4;
removeGoggles P5;
removeGoggles P6;
removeGoggles P7;
removeGoggles P8;

removeHeadgear P1;
removeHeadgear P2;
removeHeadgear P3;
removeHeadgear P4;
removeHeadgear P5;
removeHeadgear P6;
removeHeadgear P7;
removeHeadgear P8;

removeVest P1;
removeVest P2;
removeVest P3;
removeVest P4;
removeVest P5;
removeVest P6;
removeVest P7;
removeVest P8;

removeAllAssignedItems P1;
removeAllAssignedItems P2;
removeAllAssignedItems P3;
removeAllAssignedItems P4;
removeAllAssignedItems P5;
removeAllAssignedItems P6;
removeAllAssignedItems P7;
removeAllAssignedItems P8;

removeAllItemsFromBacpack P1;
removeAllItemsFromBacpack P2;
removeAllItemsFromBacpack P3;
removeAllItemsFromBacpack P4;
removeAllItemsFromBacpack P5;
removeAllItemsFromBacpack P6;
removeAllItemsFromBacpack P7;
removeAllItemsFromBacpack P8;

removeBackpack P1;
removeBackpack P2;
removeBackpack P3;
removeBackpack P4;
removeBackpack P5;
removeBackpack P6;
removeBackpack P7;
removeBackpack P8;

P1 setUnitLoadout (P1 getVariable["Saved_Loadout_P1",[]]);
P2 setUnitLoadout (P2 getVariable["Saved_Loadout_P2",[]]);
P3 setUnitLoadout (P3 getVariable["Saved_Loadout_P3",[]]);
P4 setUnitLoadout (P4 getVariable["Saved_Loadout_P4",[]]);
P5 setUnitLoadout (P5 getVariable["Saved_Loadout_P5",[]]);
P6 setUnitLoadout (P6 getVariable["Saved_Loadout_P6",[]]);
P7 setUnitLoadout (P7 getVariable["Saved_Loadout_P7",[]]);
P8 setUnitLoadout (P8 getVariable["Saved_Loadout_P8",[]]);

#

My code for onPlayerKilled.sqf:

P1 setVariable ["Saved_Loadout_P1", getUnitLoadout P1];
P2 setVariable ["Saved_Loadout_P2", getUnitLoadout P2];
P3 setVariable ["Saved_Loadout_P3", getUnitLoadout P3];
P4 setVariable ["Saved_Loadout_P4", getUnitLoadout P4];
P5 setVariable ["Saved_Loadout_P5", getUnitLoadout P5];
P6 setVariable ["Saved_Loadout_P6", getUnitLoadout P6];
P7 setVariable ["Saved_Loadout_P7", getUnitLoadout P7];
P8 setVariable ["Saved_Loadout_P8", getUnitLoadout P8];

#

I keep getting error unidentified variable p2

meager granite
#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

```sqf
// your code here
hint "good!";
```

// your code here
hint "good!";
meager granite
#

I don't think you really need to do that for every single player each time somebody dies or player respawns

#

Also you don't need to remove stuff before using setUnitLoadout as it already deletes everything first

#

All you really need is:
onPlayerKilled.sqf:

params ["_oldUnit", "_killer", "_respawn", "_respawnDelay"];
if(_oldUnit == player) then { // I don't remember if this script is global
    _oldUnit setVariable ["Saved_Loadout", getUnitLoadout _oldUnit];
};

onPlayerRespawn.sqf:

params ["_newUnit", "_oldUnit", "_respawn", "_respawnDelay"];
_newUnit setUnitLoadout (_newUnit getVariable "Saved_Loadout");
tribal gazelle
#

Thanks so much man! Worked like a charm been trying to figure out this for to long lol your a life save. Thanks for the link too going to come in handy, have a goodnight or day depending on where you are in the world!

meager granite
#

Since introduction of cursorObject many years ago typing curs autocompletes into cursorObject instead of cursorTarget and you end up with random crap instead of relevant objects:

#

Unplayable 😡

#

(Disclaimer: This is a joke rant about writing quick test scripts and them failing because of autocomplete to command you don't want)

ivory lake
#

i dont remeber the last time I wanted cursortarget over cursorobject

meager granite
#

cursorObject picks all entities, even proxies

#

For example looking at soldier and cursorObject can return proxy weapon in their hands

#

cursorTarget likes to ignore unrevealed objects though and revealing can take unreasonable amount of time for something in front of you in a real game

#

I don't use either for anything serious

ivory lake
#

true but cursorTarget for example will change when using a lock on launcher to whats locked onto despite the player not looking at it

#

or at least it used to

meager granite
#

I think it still does, yeah

#

Other cursor targets in command mode, main map cursor, etc.

still forum
tired cargo
#

Hi guys!

I have many addAction commands in my "init" file. Would it be a good idea to put these commands in a separate file for loading them, or in "initPlayerLocal" for example?

And in general, what is correct to place in the "init" file?

#

And if place them in a separate file, what file should this be? Function or .sqf ?

meager granite
#

Many places are correct, depends on what you're trying to do. Its better to keep editor fields small and put bigger stuff into files.

tired cargo
meager granite
#

Up to you for it being a file or a CfgFunctions. First one is quicker, second is more organized and if you want to use it later elsewhere.

meager granite
#

If you add same actions to lots of objects, either do call compile preprocessFileLineNumbers "" or lazier execVM with your entity as arguments for each object. Or call to CfgFunctions.

#

initPlayerLocal can work too but this is somewhat different context, it executes much later than init fields of objects

#

For example if you'll have your stuff there it won't execute on say dedicated server because there is no player

#

You need to understand context for your code to decide where to put it better

#

I can advise if you can give more details. If its just add actions, you can just move them into files so its easier to manage

tired cargo
meager granite
tired cargo
#

So, in my addAction I use exactly functions with "spawn" command

tired cargo
meager granite
#

Yeah, that's what initial loading is for, preload as much as possible.

#

There is also a matter of scheduled and unscheduled environment. Engine events like init field in editor, events like Fired all execute in unscheduled (everything is halted until script finished execution), so if you want do so something instant like say delete the bullet right in the Fired event handler by some condition, neither spawn nor execVM will do. Even call compile ... is a terrible fit because it will read and compile the function each time something fires a bullet. For such cases the only correct way is to preload the function (call compile ... on load or CfgFunctions) and then call it

#

Another upside for editor init fields is that you don't need to assign variable names to stuff as you can easily refer to the object with this magic local variable (no _), while if you'd put your stuff into say init.sqf, you'll need to find the object somehow (refer by variable name which is rather ugly if you have lots of them)

#

For example, you have 10 boxes in the map, with 3 of same actions on each, you can:

  • Add 3 actions right in init field in each: this addAction ["Action 1", ...]; this addAction ["Action 2", ...]; ... and copy-paste it into each of 10 boxes. Huge pain, when you'll want to change something in one action you'll need to change it in each 10 boxes and I guarantee you'll forget something somewhere
  • Name each box box1, box2, etc. Then in init.sqf do:
{
    _x addAction ["Action 1", ...];
    ...
} forEach [box1, box2, ...];
```This is a better approach but later if you add more boxes or delete some you'll mess up variable names, forget to remove some variable from this array, get undefined variables error, etc. Better but still plenty of ways to mess up.
- Declare your function with actions addition in `CfgFunctions`, then add init field for each box: `this call TAG_fnc_addBoxActions`; And have that function do
```sqf
_this addAction ["Action 1", ...];
...
```which is easy to edit, no need to mess with box variables, you can easily delete, copy boxes to any amount without a worry.
#

There are variations to these approaches but the last one is defeinitely the best one by all means, except having to learn how CfgFunctions work but you do that once and you're good forever.

#

Honestly I remember being confused about script entry points quite a lot back when I started in 2012, there were a lot of options and not much info, small bits all scatered everywhere. Maybe we could use an article like this on wiki.

#

I probably should have added execVM way between approach #2 and #3 as a lazier solution without CfgFunctions too

#

this execVM "addBoxActions.sqf", you get the idea

tired cargo
meager granite
#

Then you can either have code for actions right inside addAction or call another function

#
_this addAction ["Action 1", {systemChat format ["Box action one for %1", _this select 0]}];

vs

_this addAction ["Action 1", {call TAG_fnc_boxAction1}];
```TAG_fnc_boxAction1:```sqf
systemChat format ["Box action one for %1", _this select 0];
#

Second approach is better if you want to use that action elsewhere, in other actions, functions, etc.

#

But for small one-time actions you can just inline it all

#

Up to you again

quaint oyster
#

Does ⬇️ still function in Current Arma?

 "password" serverCommand "#restartserver";
meager granite
#

Unless you mean #restartserver specifically, didn't use it

quaint oyster
#

(I haven't tested it)

meager granite
tired cargo
meager granite
#

But it works, we actively use it in our servers

quaint oyster
#

Thanks, I was going to make a restart script. My thoughts were having it count up every hour, then when it counts to 12 runs that snippet among other things to restart it.

#

for a 12 hour restart.

faint burrow
tired cargo
#

// actionsLoad

[hostage_1] spawn GM_fnc_addActionHost;

// addActionHost

params["_hostage"];

_hostage addAction
[
        "Follow me",
        "[_hostage] spawn MEC_fnc_hostageFollow",
        nil,
        1.5,
        true,
        false,
        "",
        "true",
        2.5,
        false,
        "",
        ""
];

// hostageFollow

params["_hostage"];

private _hostageGroup = group _hostage;
private _playerGroup = group player;

if(_hostageGroup != _playerGroup) then
{
    switch (_hostage) do
    {
        case hostage_1: { _hostage say3D "HostageReplic_one"};
        case hostage_2: { _hostage say3D "HostageReplic_two"};
        case hostage_3: { _hostage say3D "HostageReplic_three"};
    };

    [_hostage] joinSilent player;
} else
{
    hint "You already taken a hostage";
};

I missed something ?

faint burrow
#

Yes, _hostage is out of scope.

#

Use variables passed to the action script.

stable dune
#

You don't need spawn your events (functions) , no needed scheduled event.
So you can just

// Hostage follow me action
..
{
   params  ["_target", "_caller", "_actionId", "_arguments"];
    _target call MEC_fnc_hostageFollow;
}
..

Target is the unit where the current addAction is added.
See

faint burrow
#

You don't need spawn your events (functions) , no needed scheduled event.
But according to BIKI:
The script, whether it is a file or a code, will run in scheduled environment
I.e. it will be spawned.

tired cargo
faint burrow
#

You can't since it's impossible.

stable dune
#

What is impossible?

faint burrow
stable dune
faint burrow
#

Why? What's the difference?

still forum
south swan
#

running a piece of code that only contains spawn in scheduled environment is kinda pointless and can be viewed as a code smell blobdoggoshruggoogly call should work just as well without creating an extra task/thread/whatever is the proper name of a piece of scheduled code

lone glade
faint burrow
south swan
#

i believe it was about this part

faint burrow
#

If so, then I am all for this.

stable dune
faint burrow
#

No, as I wrote. Who suggested this?

stable dune
#

I mean,
It can

"_target call MEC_fnc_"
south swan
#

@stable dune your point no need for nested spawns, Schatten's point i don't see where nested spawns were proposed blobdoggoshruggoogly

faint burrow
tight cloak
#

so, abit of an extended question. ive written up some stuff to turn the USS freedom into a flying carrier for sci fi alternative history shenanigans, it works perfectly in singleplayer but on dedicated it doesnt seem to be firing the functions properly,

[] call CBB_fnc_init;``` is inside the initserver.sqf
```sqf
carriervelocity = [0,0,0];
    carrierthrust = 0.01;
    carrierdrag = 0.995;
    carrierRotVelocity = getDir carrier_phys;
    carrierRotThrust = 0.05;
    carrierBank = 0;
    carrierBankSpeed = 0.1;
    carrierBankDrag = 0.99;
    carrierPitch = 0;
    carrierPitchSpeed = 0.1;
    carrierPitchDrag = 0.99;
    [] call CBB_fnc_carrier_Move; /// initialises the handler
``` is the fn_init.sqf
```sqf
carriermove = addMissionEventHandler ["EachFrame", 
{ 
    carrier_phys setPosWorld (carrier_phys modelToWorldWorld carriervelocity);
    carrier_phys setdir carrierRotVelocity;
    carriervelocity = carriervelocity vectorMultiply carrierdrag;
    [carrier_phys, carrierPitch, carrierBank] call BIS_fnc_setPitchBank;
    carrierBank = carrierBank * carrierBankDrag;
    carrierPitch = carrierPitch * carrierPitchDrag;

is the fn_carrier_move.sqf
the values are adjusted by keybindings setup in the init.sqf for the players to adjust as such.
any idea why it works in singleplayer but not MP?
i can brute force the scripts to run if i execute it globally in the debug console but that leads to unfavourable behaviours such as moving too fast and jittering, presumably from the global execution screwing with it. I have tried various things such as checking the executing machine is the server -sqf if !(isServer) exitwith {}; but to no avail
im assuimg its a locality thing but its the first time ive attempted something of this scope. any help would be appreciated

#

i even attempted

publicVariableServer "carrierPitch";

in the keybindings to make sure the server is aware of the updated variables, but has no effect leading to the conclusion the issue is how its executed / handled

proven charm
tight cloak
#

it is

#

thats the curious bit

proven charm
#

make sure clients doesnt run anything

tight cloak
#

all they run are the keybinds which in turn pokes the server with the new values to then pass into the handle. i might just rip apart the current structure of locality and put it back together again

proven charm
#

ok, what about those CBB_ functions, are they defined in server?

tight cloak
#
class CBB
{
    class carrier
    {
        file = "scripts\functions";
        class init {};
        class carrier_Move {};
    };
};

the functions cfg

proven charm
#

well id put some diag_log debugging in the code to make absolutely sure the code is running and variables are defined

tight cloak
#

aye

#

it seems so

#

time to stuff my code with it

tired cargo
#

Does anyone know how to disable the capacity of supply or ammo boxes?

faint burrow
winter rose
#

that would empty it, but to disable it, it's something else

south swan
#

define "disable". Unlimited mags can be taken out? Unlimited mags can be stored by players? Nothing can be stored (storage disabled)?

trim tree
#

hi, is it possible to limit what weapons can be loaded onto a helicopters pylons and/or allow none to be carried?

fair drum
trim tree
tribal crane
#

And because if you don't I'll take it personally.

south swan
#

wat

hallow mortar
#

Restricting the pylons depends on the system that's being used to change them.
If they're being changed by someone with direct access to script commands, then they can do whatever they want and you can't stop them.
If it's via a particular mod or scripted customiser system, then how or if the loadout can be restricted depends entirely on which one and how it works.

trim tree
#

nvm, i had worries about something that doesnt even need to happen. I forgot that the ace pylon menu can be disabled and isnt needed for rearming pylons... I feared that players could mount weapons I didnt intend for them to have access to and on pylons they shouldnt be able to. But that worry was unfounded. Thanks anyway

blissful current
spring stone
#

All h

#

All hail the params! xD

blissful current
#

I'm gaving an issue creating a smoke module in Multiplayer. The following works in SP only:

_smokeEmitter = "ModuleSmoke_F" createVehicleLocal getPos _thrownSmoke;

After looking closer I see that createVehicleLocal is indeed a local effect. So I changed it to createVehicle which is MP compatible. But it wont create the smoke in MP like that. Here is the full code for reference:

[_projectile] spawn {
      params ["_thrownSmoke"];
      waitUntil {uiSleep 1; abs speed _thrownSmoke == 0}; //unsure what this does
      if !(_thrownSmoke inArea "Smoke_Marker") exitWith {}; //run code below when smoke thrown
            _smokeEmitter = "ModuleSmoke_F" createVehicle getPos _thrownSmoke; //creates smoke
            _smokeEmitter setVariable ["repeat", 1]; //makes smoke never stop
            _smokeEmitter setVariable ["type", "SmokeShellYellow"]; //yellow smoke
};```
kindred zephyr
#

modules and emitter only work with the local version fo the command iirc.

Create a function and remoteExec to the necessary clients.

faint burrow
#

Or try to broadcast values using 3rd param.

blissful current
#

I think you are right. I replace smoke emitter with a car and it spawned fine.

#

I haven't made a function before so that seems overwhelming. But I have used remoteExec. Could I just use that without the function?

blissful current
faint burrow
#

setVariable

blissful current
# faint burrow `setVariable`

Now that I think about it. Since createVehicle wont even work in SP with the smoke module, that means it doesn't really have to do with MP issue right?

#

IDK my head hurts.

fair drum
faint burrow
fair drum
#

Also if using modules via script, you don't create the module, you call the function that the module points to.

blissful current
blissful current
fair drum
#

If you are doing particle stuff, skip the module and create your own particles. There is a full wiki page on this.

#

And yes you have to find the function name and read how it works.

#

Use the in game function viewer or with ADT

blissful current
#

What I have is when a player throws a smoke grenade it turns it into the smoke module. The result and goal is infinite smoke.

#

Works great in SP but since "ModuleSmoke_F" doesn't work with creatVehicle I now search for a workaround. @kindred zephyr says to create a function. Maybe it's time to learn that. Is it hard to do? Any tutorials out there on it?

faint burrow
#

There are infinite smoke grenades -- SmokeShellXXX_Infinite, e.g. SmokeShellGreen_Infinite.

#

Remove general smoke grenade and create the infinte one on its position.

blissful current
#

Oh really? Interesting! Are those the class names?

faint burrow
#

Yes, SmokeShellGreen_Infinite is class name.

blissful current
#

I will try this at once!

faint burrow
#

You can look for other class names for other colors in Config Viewer.

dapper cairn
#

is it possible to have the police lights for the offroad actually lighting up the area instead of basically being blue lights that turn on and off

radiant nova
#

Hey, guys, i make tank, when i as commander vehicle i chose Manual fire control, to get control of gunner gun/turret, i can`t move gunner turret, only stuff i can do is shoting and swap ammo. Whats the problem? What parameters are responsible for manual fire control?

Do i need use
isManualFire "vehicleName"? And sqf stuff?

blissful current
sage ravine
#

can anyone assist me in making a simple tdm 1v1 gamemode for me and my friends to play together. I am new to arma and dont know anything about scripting it. I tried respawn tickets but dont understand how to do it.

sullen sigil
blissful current
#

Is there a way to put quotations within the addAction description?

fair drum
#
'He said, "I like big butts!"'
"He said, ""I like big butts!"""
format["He said, %1", str "I like big butts!"];
blissful current
blissful current
#

Im trying to get this to activate in init on MP but it only works in SP:
if (hasInterface && !(missionNamespace getVariable ["MissionIntro", false])) then
I thought the hasinterface would do the trick but it appears not

#

It might had to do with the varible. I tried true and tried false in the initserver and it triggers either way. so I might have an error there

fair drum
#

remember that logging I told you about? do you know if MissionIntro is true, false, or nil?

blissful current
#

My understanding is that the default is false so originally I have nothing in the initserver.

fair drum
#

yes, but are you sure that its not being modified elsewhere, so that at that moment in time, its different

blissful current
#

Hmm I'll admit I got overwhelmed with the debugging options. I need to learn those for sure. I'm afraid Id need a hand hold though.

blissful current
#

its the first line in the init

fair drum
#

Replace in your Init.sqf for this
Then check the RPT folder

private _missionIntro = missionNamespace getVariable ["MissionIntro", false];
diag_log format["Frame: %1 - Mission Time: %2 - Multiplayer: %3 - MissionIntro - %4", diag_frameNo, serverTime, isMultiplayer, _missionIntro];
if (hasInterface && !_missionIntro) then {
    // something
};

where else are you changing MissionIntro?

blissful current
#

It gets turned to true... wow, idk lemme see

#

its appears no where.

#

but that would just mean a JIP player would always run the code below. So it shouldnt explain why it isnt run in MP if my logic is correct

fair drum
#

if your logic is correct. did you apply the above code and start the mission?

#

it should appear like this

blissful current
#

Im having a brain fart. Lemme plug that in again.

#

20:52:23 "Frame: 529601 - Mission Time: 0 - MissionIntro - false"

#

interesting that it doesnt say multiplayer true. Thats different than yours

fair drum
#

did you recopy it? i had changed it to include it

#

bet you have the old one

blissful current
#

lemme see

#

I have the current one.

fair drum
#

send me your mission again

blissful current
#

0:52:26 [CBA] (xeh) INFO: [530415,9909.58,0] PostInit started. MISSIONINIT: missionName=ORB%20-%20COOP, missionVersion=54, worldName=Cam_Lao_Nam, isMultiplayer=false, isServer=true, isDedicated=false, CBA_isHeadlessClient=false, hasInterface=true, didJIP=false

fair drum
#

also, did you start using vscode yet? it has a remote feature where i can hop in and look at stuff while you work on things too. its pretty cool

blissful current
#

interesting that it says ismultiplayer=false

blissful current
fair drum
#

and it says false, because you aren't in multiplayer lol how are you previewing it?

blissful current
#

joining on dedicated server.

#

I dont have a test mission for this portion yet. It my huge file. Wait...

fair drum
#

are you sending your RPT of your client or server... or the right RPT current file

blissful current
#

if im the only player connect to the ded server will it count that as multiplayer false?

fair drum
#

rpt is different for both

blissful current
#

Dang I did't know. Okay. I gotta go in a couple minutes. I'll pick this back up tomorrow. Thanks for the help. I'll get that vscode working tomorrow.

fair drum
#

also, no more "test missions" just send the full package. you probably are testing right, but when you put everything together, you are messing up somewhere

blissful current
#

I kinda have to because if I want to test something at the end of the mission after its implemented I was tired of wasting time teleporting through triggers for 5 mins just to get to that one spot.

fair drum
#

you'll eventually want to program in skips. if you take a look at the BI missions, you'll notice they have skips to skip past areas for debugging

blissful current
#

Are those missions not encrypted? How do you unpack the pbo to look at them? And that sound like an amzing idea.

#

I restarted ARMA and now its working as intended... Im done lol. Ill look at this tomorrow.

fair drum
#

stop using the dedi to test lol. do the host + client way with 2 arma clients 😛

blissful current
#

So correct me if im wrong but the problem with that is I can only really trust the client one for true behavior. Sometime I need two clients right? like when I was testing to make sure the 3d position audio was working. Or is the thought process if it works on one client it works on all I guess.

fair drum
dapper cairn
meager granite
#

Bitrate something-something, there should be exact settings on the wiki something

flint topaz
proven charm
#

"Effect of the manager - the entity simulation change - is global."

flint topaz
#

Perfect thanks might be worth updating that wiki page if that’s possible. But I’ll use it like it’s a global effect and just run it on the server. I will also test that theory when I have some time.

proven charm
#

"To achieve best results it is suggested to manage dynamic simulation on one place - ideally on server."

tired cargo
#

Hey guys, does anyone know what is the problem: player can attach to oneself a hostage to lead him along. My idea is to bring a hostage into the building and leave it there ( leave - detach a hostage ). So, to bring a hostage, player should choose one menu item ("Lead"), after that, hostage attach to player, and to leave him somewhere, player need again choose one menu item ( "Stop lead" ). But the problem is when I am in the building and my sight is aim at any parts of building, player doesn't see a menu items, but when my sight is not aim at any parts of building, player see a menu items and can choose something

nocturne bluff
#

I will toooo.

blissful current
#

I want to make sure I'm understanding this logic correctly. This if statement will only return true if Trigger 1, 2, and either 3 or 4 are activated right? Would it be possible for it to return true if ONLY trigger 1 and 2 are activated?

     (triggerActivated Trigger3 || triggerActivated Trigger4)) then{
     //stuff
}```
hallow mortar
#

That is 1 & 2 & (3 or 4), so it requires 1 and 2 to be activated, and one of 3 and 4

#

This isn't special SQF logic, just normal logic :U

proven charm
#

when you have ATL position and you need to get objects at sea is this the proper thing to do (turn to ASL)? ```sqf
if(surfaceIsWater _aroundpos) then
{
_aroundpos = atlToAsl _aroundpos;
};

private _wrecks = _aroundpos nearObjects .....

granite sky
#

I'm not sure whether nearObjects uses 2d or 3d. Would need to check.

proven charm
#

from wiki: "position: Array format PositionAGL, Position2D or Object"

granite sky
#

Yeah, it's wrong.

#

It's 3d and uses ATL not AGL.

#

So you can skip the first four lines.

#

_pos nearObjects _radius form is the same. 3d & ATL-based.

dapper cairn
#

Is it possible to put a script on a vehicle to have its turret pointed a certain way like the m2 on a offroad or the main turret of a MNT

#

MBT*

granite sky
#

for what it's worth, if you really needed AGL from ATL, you'd need to do ASLtoAGL ATLtoASL _posATL

proven charm
granite sky
#

Busted test case or bug. You'd need to check.

#

You're checking what, undewater terrain objects?

proven charm
#

hmm the wrecks get deleted with my current code, it didnt work before

#

wrecks on carrier deck

proven charm
#

theoretically thinking if nearObjects would take AGL would my code then be right?

granite sky
#

I don't think there's any useful theory here. It seems to be using different coordinate systems for different object types.

proven charm
#

i just wonder if i get AGL right?

tawdry sparrow
#

I want my players to be able to fire a rocket Launcher 3 times in quick succession. I don't care about them having ammo for it, its not a serious Mission.
I currently have the following event handler:

player addEventHandler ["Fired",{ params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; if (_weapon in ["launch_MRAWS_sand_rail_F", "rhs_weap_maaws"]) then { _shots = _unit getVariable ["rocketsShot", 0]; if (_shots < 2) then { _unit addSecondaryWeaponItem _magazine; _unit setWeaponReloadingTime [ _unit, _muzzle, 0]; _unit setVariable ["rocketsShot", _shots + 1, true]; } else { _unit setVariable ["rocketsShot", 0, true]; _unit setWeaponReloadingTime [ _unit, _muzzle, 1]; }; }; }];

This "works" but the problem is that the launcher is in a reloading state after adding the ammo with addSecondaryWeaponItem, and therefor can't be fired for some seconds.
Using setAmmo with _weapon or _muzzle just does nothing (I assume thats because there is no empty magazine in the launcher after a shot)

granite sky
#

for what it's worth, if you really needed AGL from ATL, you'd need to do ASLtoAGL ATLtoASL _posATL

#

but just ATLtoASL _posATL should work for stuff that's over water.

granite sky
#

Looks like nearObjects uses ATL for flying vehicles and AGL for floating ones.

#

which I'm pretty sure is a bug.

proven charm
#

weird

hallow mortar
#

Isn't that the same as createVehicle?

proven charm
#

and why dont we have ATLToAGL or is that not doable?

granite sky
#

ah, I guess FLY overrides anyway

hallow mortar
#

That was reported as being the case in 2017. Perhaps it's changed since then 🤷

brave mountain
#

would there be a way to start an animation (cutscene) at a specific time (seconds) of it?
Some cutscnes are too long and the "Interesting" part are only some seconds of it

fair drum
blissful current
#

I've got a helicopter (group behavior set to careless) that likes to avoid my landing zone and try to hunt a tank if he see's it. If I remove the tank from the mission he will land no problem, even if under infantry attack. Is there a way to script him to avoid the armor?

fair drum
#

careless should avoid everyone and everything. are you running anything that modifies the behavior/AI mods? when is the group being switched to careless? units themselves in a group can also have different behaviors, check those?

blissful current
#
  1. No
  2. Editor - doublle click on group
  3. I didn't know that. There isn't a behavior drop down when I double click on the pilot.
#

I think I remember a setbehavior command now that use mention it.

fair drum
#
  1. its done via script via setCombatBehaviour so you won't see it in editor. that's why i asked AI mods
blissful current
#

Are AI mods effective at disabling the AI wall hacking me through vegetation? That would be pretty cool.

fair drum
#

ai isn't wall hacking through veg. it finds your last seen + last velocity and predicts where you will be behind veg and fires

#

so if it catches a glipse through a gap, it redoes that calc

blissful current
#

Oh clever. It's very effective. If I lowered one of these would it make it less effective?

fair drum
#

skill is how they move, flank, outsmart you etc. precision is their ability to hit you

#

a decent setting for difficult but giving some time to react is 1.0 skill, 0.3 precision

#

the greater the group count, the more stupid the AI get so keep that in mind.

#

the inverse is true as well

blissful current
#

as in the more ai with a group. or the more groups on the terrain?

fair drum
#

more groups on the map, the unit count doesn't matter as much. its the group count that makes a big difference

#

which is why if you have a bunch of civilian units all in their own groups, performance can take a hit. instead for ambient things, you use agents which are AI that lack a lot of the AI features and aren't in the group system. (you can't use waypoints with them for instance, you have to use setDestination)

blissful current
#

Is there a ball park figure on when you would notice such an increase/decrease? I probably have 15 groups.

fair drum
#

you're fine

#

arma 3 handles a max of 288 groups, 10,000+ units per group

blissful current
#

I definitely noticed now AI impacts performance. I have an area that runs around 54fps. I have like 200 dynamic simulated objects in the area. If I delete all of them I get no improvement on fps. But if I delete the 10 groups in the area I get 10 fps more.

quiet cypress
#

Anyway to lower audible fire and visible fire when using suppressors ? If so please help. Thanks

quiet cypress
#

Is it complicated ?

#

Are there any mods that assist with this or is it something I would need to do?

quiet cypress
#

Ok thanks man

dim kelp
#

life_actions pushback (player addAction["Push","player action [""getOut"", vehicle player];","",999,false,false,"",'(vehicle player isKindOf "helicopter" && (assignedVehicleRole player) select 0 in ["driver","Turret"] && locked vehicle player isEqualTo 0)']);
Can I add other code to this code?
life_actions pushBack (player addAction["In Drive", "player moveInDriver _x; closeDialog ;"];

warm hedge
#

Add... what?

#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

```sqf
// your code here
hint "good!";
```

// your code here
hint "good!";
warm hedge
#

Add what into where

dim kelp
#

life_actions pushBack (player addAction["In Drive", "player moveInDriver _x; closeDialog ;"]; this

#

life_actions pushback (player addAction["Push","player action [""getOut"", vehicle player];","",999,false,false,"",'(vehicle player isKindOf "helicopter" && (assignedVehicleRole player) select 0 in ["driver","Turret"] && locked vehicle player isEqualTo 0)']);

#

I want to adapt the upper one according to the lower one and add it

warm hedge
#

Let me rephrase my question. What is your goal

dim kelp
#

I want to turn driving into code player moveInDriver

warm hedge
#

And what is your problem you got

dim kelp
#

I am adding this code but it is not working, I cannot interact, can you help me edit it?

life_actions pushBack (player addAction["In Drive", "player moveInDriver _x; closeDialog ;"];

warm hedge
#

It still is taking quite a big effort to understand what you want to tell

#

I guess state your current code that doesn't work and error you got makes it easier to understand

dim kelp
#

life_actions pushBack (player addAction["In Drive", "player moveInDriver _x; closeDialog ;"]; I can't run this code

warm hedge
#
  1. Missing bracket )
  2. Missing closeDialog argument
  3. _x is not defined there
dim kelp
#

Is there any chance you can help me with proper code?

warm hedge
#
life_actions pushBack (player addAction["In Drive", {player moveInDriver whateverYourVehicle; closeDialog 0;}]);```
dim kelp
#

The option came, but it comes not only when looking at the vehicle, but also all the time, and when I say in drive next to the vehicle, it does not get in.

warm hedge
#

Because... I guess, the script doesn't know what is the vehicle you want to use?

neon plaza
#

Trying to find a correction to this script. Meant to create a timer for 15 seconds and then the option vanishes.

#

 player addaction [
    "Server Information and Discord", 
    {
        0 spawn MRTM_fnc_MRTM_welcome;
    },
     
     [nil, 1, true, true, "", "true", 5];  sleep 15;
    player removeAction actId;
    nil,
    1.5,
    false,
    
];
    
warm hedge
#
  1. ; cannot be used to interrupt a script within a script
  2. , mismatch
warm hedge
#

...Write what?

dim kelp
#

Vehicles

neon plaza
warm hedge
# dim kelp Vehicles

If you mean how do you change the vehicle to use, whateverYourVehicle is the variable used there

warm hedge
neon plaza
#

just need the message to fade away after 15 seconds

warm hedge
#

What message

neon plaza
# warm hedge What message

We have something similar to that line of code. The player on death can scroll the wheel button and at the top left hand corner the menu for "Server Infor and discord" pops up and will only be avlb for 15 seconds

#

something like this...

#

    switch (side group player) do
{
    case west: { // WEST SIDE CODE
        actId = player addAction ["Teleport to Nato Base", 
        {   
            params ["_target", "_caller", "_actionId", "_arguments"];   
            if !((incapacitatedState b_tele)== "UNCONSCIOUS") then {   
                _caller setPosASL (getPosASL b_tele);   
            };   
        }, nil, 1, true, true, "", "true", 5];  sleep 15;
player removeAction actId;

warm hedge
#

Do you mean you just want to use removeAction?

neon plaza
#

we have that due to players during sessions accidently opening this menu every time they use space bar to set down a turret or something.

#

Yes we want the menu to be removed after 15 seconds

dim kelp
#

Does this work?

life_actions pushBack (player addAction["In Drive", {player moveInDriver ["C_Kart_01_Blu_F","C_Kart_01_Red_F","C_Kart_01_Fuel_F","C_Kart_01_Vrana_F","C_Offroad_02_unarmed_F","B_T_LSV_01_armed_F","B_T_LSV_01_unarmed_F","O_T_LSV_02_armed_F","O_T_LSV_02_unarmed_F","B_T_UAV_03_F","C_Plane_Civil_01_F","O_T_UAV_04_CAS_F","B_T_VTOL_01_armed_F","B_T_VTOL_01_infantry_F","C_Van_02_vehicle_F","C_Van_02_transport_F","C_Tractor_01_F","C_Offroad_01_comms_F","C_Offroad_01_covered_f","O_LSV_02_unarmed_F","B_GEN_Van_02_transport_F","O_T_VTOL_02_infantry_F","I_C_Boat_Transport_02_F","C_Scoooter_Transport_01_F","B_Heli_Transport_03_unarmed_F","O_Heli_Transport_04_F"]); closeDialog 0;}]);

warm hedge
#

No

warm hedge
neon plaza
#


 player addaction [
    "Server Information and Discord", 
    {
        0 spawn MRTM_fnc_MRTM_welcome;
    },
    nil,
    1.5,
    false,
     nil, 1, true, true, "", "true", 5];  sleep 15;
    player removeAction actId;
];
    
warm hedge
#

I said no

minor turtle
#

Hey guys, just wondering how do I initialise a disableAI script for ALL units within a mission?

I wish to apply disableAI "SUPPRESSION";

but currently only figured out how to apply it to individual groups, is there anyway to apply this globally to every single unit within the mission?

warm hedge
#
{_x disableAI "SUPPRESSION"} forEach allUnits;```
dim kelp
#

So how can we do it? can you help me?

warm hedge
#

No idea what your idea is, so right now, no

#

I have no reliable crystal ball to see through your mind

dim kelp
#

I want you to be able to ride the vehicles I mentioned there when I say in drive.

warm hedge
minor turtle
dim kelp
minor turtle
warm hedge
warm hedge
neon plaza
# warm hedge Or anywhere else, yes

As for me, Where would I put the line of code to cause the menu to sleep? This Is the last thing I do and Arma3 can suck It. Im going to bed.

warm hedge
#

What do you mean cause the menu to sleep?

dim kelp
warm hedge
#

Maybe

dim kelp
#

I was able to get it to work but every opportunity comes up just when I look at the vehicle, how can I get it working?

south swan
#

"help, i've added an action to be displayed when i look at the vehicle and now it gets displayed when i look at the vehicle" blobcloseenjoy

dim kelp
#

I want to add this to altislife can you help me?

deft zealot
#

in which situations local player may return false?

tough abyss
#

On a dedicated server, where player is objNull.

#

Or in the main menu with -world=empty

gleaming rivet
#

Commie give urself a picture.

tough abyss
#

That would mean I'd have to register.

deft zealot
#

agree but here is something new: when a player goes back into the lobby (on dedi) and rejoins the owner of his player is the server

#

and local playeris false

tribal crane
#

If you can see pictures you need to switch to compact mode.

tough abyss
#

I hope that changes as soon as you rejoin the mission.

gleaming rivet
#

But rejoining the mission will force a locality change no?

tough abyss
#

Also I'm pretty sure that player IS objNull in that scenario.

deft zealot
#

i think the state is during the briefing screen

gleaming rivet
#

Is it only set there?

deft zealot
#

and no player is the same unit you had before

tough abyss
#

So there you go. You have your scenario.

deft zealot
#

now tell me how to do some fancy publicVariableClient stuff when i am unable to get the clientID with owner serverside

#

is there something other than player which is ALWAYS local to the client?

tough abyss
#

Send it together with the object to the server and do publicVariableClient from there.

deft zealot
#

thats what i am currently doing

tough abyss
#

Or use the local eventhandler?

deft zealot
#

but in the scenario is described it fails

sullen marsh
#

could createvehiclelocal

#

That'd always be local

tough abyss
#

So wait. the object is local to the server , but the server is not the owner?

deft zealot
#

server is the owner

tough abyss
#

So where is the problem?

deft zealot
#

i thought that the client is always the owner of its player object (when its not objNull)

tough abyss
#

Apparently not.

minor turtle
#

Hey guys, I'm hoping to initialise some disableAI commands via a "behaviour.sqf" script, hoping to disable cover, suppression and fleeing for some units.

I'm able to call up the "behaviour.sqf" script in the unit Init box, however it's giving me this error regarding my script" "Error Undefined Variable in expression"

I'm wondering how should I initialise the following parameters via SQF scripts?
this disableAI "COVER";
this disableAI "SUPPRESSION";
this allowFleeing 0;

I'm really new in scripting so would appreciate any guidance on this!

deft zealot
#

i wonder if that is on purpose

flint topaz
#

Can you show us the current sqf file?

faint dove
#

you can't just keep it simple and wait until the client is the owner?

flint topaz
#

And how you are calling it

#

@minor turtle

tough abyss
#

Probably not.

warm hedge
#

this is not a valid variable within an SQF file. It is only available for some context

flint topaz
#

Yeah I was going to explain it once I’ve got that

minor turtle
#

Yeah haha, this is actually what I wrote within the SQF 😁

this disableAI "COVER";
this disableAI "SUPPRESSION";
this allowFleeing 0;

What should be the SQF equivalent of these parameters, that's applying to the whole group?

tough abyss
#

I don't get where the issue is.

faint burrow
#

{ ... } forEach (units (group _this));

minor turtle
sacred turret
#
_marker = createMarkerLocal ["DeploymentPosition", _pos, 1, player];
_marker setMarkerTypeLocal "b_installation";
_marker setMarkerText "Allied Installation";

this results in a translucent marker, does anyone knows why?

faint burrow
#

The marker was created in another channel.

tough abyss
#

If the player object is local to the server and you send the object already to the server first, then you can do from there whatever you want

proven charm
#

setMarkerText <--- seems to be missing "local"

faint burrow
#

Important note for multiplayer mission.

sullen marsh
sacred turret
# proven charm setMarkerText <--- seems to be missing "local"

the wiki says that in order to reduce network load, one can perform only the last operation and the entire marker state will be propagated

Multiplayer optimisation: Global marker commands always broadcast the entire marker state over the network. As such, the number of network messages exchanged when creating or editing a marker can be reduced by performing all but the last operation using local marker commands, then using a global marker command for the last change (and subsequent global broadcast of all changes applied to the marker).

I've tried to make every operation global too and it didn't work, seems to be the channel indeed

proven charm
#

oh ok so its a optimization

sacred turret
#

Since I'm playing in singleplayer, I can't change channels, right?

faint burrow
#

Don't remember. But you passed the channel to createMarkerLocal.

warm hedge
#

Even in SP, they have channels that the marker belongs to

sacred turret
#

removing the last two arguments from createMarkerLocal fixed it, but I assume the marker now is visible to everyone and not only it's own side

sacred turret
faint burrow
sacred turret
#

Ah, ok. Thanks

tough abyss
#

Fake debug console :^)

undone flower
#

quick n easy way to figure out if a mission has proper started?

#

(after or during postinit)

#

missionStart sounds like a solution but according to the https://community.bistudio.com/wiki/missionStart, it might be available during preinit, which is something I don't want. It needs to be something unavailable during preinit but available in postinit

deft zealot
#

did KK reveal if this changes during mission?

#

looks like it doesnt (as he is ingame)

tough abyss
#

I never had issues with player not being local during a mission, You are probably overthinking something

#

If the player wouldn't be local it would be a PITA to control him.

#

You probably couldn't

deft zealot
#

how can i get the id of a client on the dedicated server if the player of that client is local to the server?
and just wait is not an option - createVehicleLocal may be but it seems dirty

sullen marsh
#

It certanly doesn't make much sense for a player to be remote

#

Could get it on connect, with the connected eh

meager granite
#

getClientStateNumber >= 10 on server

#

then broadcast a flag to clients

tough abyss
#

Use a local eventhandler on the dedicated server.

deft zealot
#

@sullen marsh but i would lose it if he goes back to the lobby

tough abyss
#

And setvariable public

deft zealot
#

ah that sounds good

#

no need for an EH i think

tough abyss
#

But wth are you trying to do?

deft zealot
#

basically i just want to transmit some stuff to the client on mission start

tough abyss
#

To all or to one?

deft zealot
#

one-by-one

tough abyss
#

And what exactly?

deft zealot
#

or "not to JIPs"

sullen marsh
#

Can't you use didJIP

tough abyss
#

if (didJip) exitWith {}

deft zealot
#

no i just stated this to throw publicVariable out of your mind

tough abyss
#

Use publicVariable

#

^^

sullen marsh
#

I don't see why you need the client to know it's own id if you're just transfering stuff from the server to the client

tough abyss
#

^

deft zealot
#

no i need the server to know the client id

tough abyss
#

owner _unit

deft zealot
#

thats why i send the player with publicVariableServer to the server and then i do _clientID = owner _recievedPlayer;

undone flower
#

@meager granite allow me to DM you about a predicament sometime

blissful current
#

My understanding of triggers in the editor was tested and broken last night. One thing that might help me is to know where that code in the on activation field is ran? Like, is it the same as placing it in initPlayerLocal or maybe its more like init. Just where is this code?

Here is my now current level of understanding regarding in editor triggers, please let me know if any of these statements are incomplete or flat-out false:

  1. (Server Only unchecked) Trigger activation is global. The code in the On Activation field is ran on every client. This means that even if something that is normally local effect like side chat is ran, it will still go to every client. Additionally, every client is updated that the trigger state was activated.

  2. (Server Only checked) Trigger activation is not global. Whatever code is ran happens only on the server unless there was something to send it to the clients like remoteExec. However, the clients don't receive ANY info that the trigger was EVER fired. This means that if you have a trigger in this style and try to use if triggerActivated in initPlayerlocal the if statement will never fire because the server didn't broadcast its activation state, just potentially the activation code.

  3. JIP players bring every trigger their local copy of the trigger back to their inactivated state. This means if a player enters a trigger zone with a hint it will fire like normal and never again (repeatable unchecked). Unless a player JIP. In that case the trigger can fire again if the conditions are met.

deft zealot
#

but when the client rejoins from the lobby the owner is 2 (which is the server)

#

i hope you got it now

sullen marsh
#

Yeah I get it

tough abyss
#

Do you have AI enabled?

sullen marsh
#

Have you tried waiting a few seconds

#

To make sure the server isn't in the process of transferring locality back to the player

deft zealot
#

i tried waitUntil {!isNull player && local player} on the client. looks like this s never true

tough abyss
#

that can't be

sullen marsh
#

It just doesn't make sense for the player object to not be local to the player

deft zealot
#

so true

#

but thats what it is

tough abyss
#

Do you have AI enabled in your mission?

deft zealot
#

no AI disabled

ornate whale
#

Is there a way how to set a vehicle to play a specific animation, e.g. heli rotor rotating with disabled simulation? And where would I find the anim name? Thanks

hallow mortar
# blissful current My understanding of triggers in the editor was tested and broken last night. One...

When placed in the Editor, a separate copy of the trigger exists on every machine. The condition is checked locally on every machine, and the activation code is run on every machine where the condition is satisfied. Which machines the trigger activates on depends on which machines satisfy the condition; a any BLUFOR in this area will be satisfied on every machine at the same time because that's globally detectable, while player in thisList will only activate on machines where their player is in the trigger area, because player is machine-specific.
When Server Only is checked, the trigger only exists on the server.
The trigger is "reset" when a player joins because their local copy of the trigger is newly-created according to its Editor attributes.

tough abyss
#

The player has to be local.

sacred turret
#

is private necessary for initializing private variables or just starting with an underscore will do? Just got confused on it

hallow mortar
#

Underscore indicates a local scope variable. A private variable is an even more restricted type of local scope variable.

#

Technically, private is not always necessary to make a private variable, because params also does it

sullen marsh
#

Check what getPlayerUID returns on the player object when it's saying it's not local

hallow mortar
#

(and in 2.18 we'll have privateAll)

sullen marsh
#

If it returns the correct UID that's fucked

sacred turret
#

sorry, but I just got even more confused; is

_myVariable = 5;

the same as

private _myVariable = 5;
``` or is the underscore just a convention? Does the former declares a global variable, or does the former declares a **local** variable with the latter declaring a **private** variable?
deft zealot
#

you should be able to reproduce it if you put

hint "TEST";```
in your init.sqf
tough abyss
#

^

granite sky
#

You got it the second time. The underscore isn't just a convention.

hallow mortar
#
my_var_name = 1; // global scope variable
_my_localvar_name = 2; // local scope variable
private _my_privatevar_name = 3; // private local scope variable (global variables can't be private)```
deft zealot
#

@sullen marsh execute it on client or server?

sullen marsh
#

client when it's saying player isn't local

sullen sigil
#

Have got some weird fuckiness happening and I suspect it could be playSound3D recycling IDs when local

In object's init, I have:

if !(isNil "zp_opflow_radioEH") exitWith {};

this addEventHandler ["HitPart",{["zp_opflow_radioHit",[]] call 
CBA_fnc_globalEvent;}];

zp_opflow_radioEH = [{_this#0 params ["_obj1"]; zp_opflow_radioSound = playSound3D [getMissionPath "sfx\carmen.ogg", _obj1, true, getPosASL _obj1, 0.5, 1, 0, 0, true];}, 270, [this]] call CBA_fnc_addPerFrameHandler;```

in `initPlayerLocal.sqf`, I have:

```sqf
["zp_opflow_radioHit", {
    stopSound zp_opflow_radioSound;
    [zp_opflow_radioEH] call CBA_fnc_removePerFrameHandler;
    //systemChat "hit";
}] call CBA_fnc_addEventHandler;```

Works fine in SP, doesn't work in Dedi, cannot figure out why for the life of me
deft zealot
#

ok

sullen sigil
#

...nvm... works fine now??????

#

so confused

#

i had it being inconsistent in SP too before but never really figured out why

meager granite
#

Are you saying that owner returns 2 on server even though client already has their unit local to them?

#

Also there is clientOwner command coming that returns own owner id on clients

deft zealot
#

what i do is: connect -> lobby -> briefing -> lobby -> briefing (here player is not local anymore)

proven charm
#

what's best way to detect if player respawned by clicking the respawn button?

meager granite
#

Briefing? Are you restarting the mission?

#

Did you mean in-game?

#

Anyway its normal for player not being local after you join, server creates unit for client the first time, then waits till client loads (downloads mission, clicks through error messages) and then transfers locality to them

#

Player unit might even be isPlayer => true and return uid while still being owned by the server

deft zealot
#

@sullen marsh getPlayerUID player is always the correct value

sullen marsh
#

lol that's retarded

#

At least it lets you do a workaround

#

Get the ownerid when they connect and store it somewhere

deft zealot
#

connect -> lobby -> briefing (player IS local) -> lobby -> briefing (here player is not local anymore)

sullen marsh
#

Send UID instead

#

look up ownerid based on uid

willow hound
#

Probably onButtonClick 🙂

meager granite
#

So you mean that game isn't started at all and still in briefing stage?

#

You simply back out from briefing and join again?

deft zealot
#

i think something like _receivedPlayer setVariable ["clientID", owner _receivedPlayer, true] at the first briefing

proven charm
#

gui hax only way?

faint dove
#

"i" before "e" except after "c"

deft zealot
#

@meager granite there is no difference if i start playing or not before gettin back to the lobby

meager granite
#

Then I still don't get what's your issue

#

Player unit is created by the server when client starts playing and owned by the server for some time before transferring locality to the client

deft zealot
#

ok then some time has passed and i is local to client now

#

then the client goes to the lobby

#

and the unit gets transferred to the server again

#

then the client joins again

#

and the unit will never be transferred again

meager granite
#

Did you say you had AI disabled?

deft zealot
#

yes

tough abyss
#

you broke it.

meager granite
#

Then you would spawn as different unit

frozen seal
#

I've got a high level question.
I've got an important script running throughout a mission. A complex one. I thought I tested it thoroughly enough, since it was working in these cases:

  1. SP - Works fine ✅
  2. Local MP - Works fine✅
  3. Dedicated with 1 player - Works fine✅
  4. Dedicated with 3 players(!) - Works fine✅
  5. Dedicated with 8 players - Everything broke ❌

Worst thing is the last scenario happened during our scheduled op.. I had to shamefully tell all the players that the op is not gonna happen today, which sucked.
So my question is.. how do I even approach debugging this? How can I reproduce a bug that only happens when 5+ people have joined the server? Do I just casually ask 8 people to join and hang around for a few hours? Are there any best practices for such a situation?

deft zealot
#

str player has still the name i set in the editor

#

so i guess its the same unit

tough abyss
#

That doesnn't mean anything

#

str player can collide

hallow mortar
#

This sounds like something (scheduled script probably) being multiplied by the number of players. I'd look for remoteExecs and "forEach allPlayers" type stuff, as well as while loops with no sleep to keep their pace controlled.

deft zealot
#

does it even matter if its the same unit or not?

flint topaz
#

As stated above this sounds like a scaled locality issue. Being very careful with your locality and following best practices should help prevent these issues from occuring. Ensuring you are understanding what context each function is called in be that local, global, server etc it's the hardest part to get right unfortunately, experience is king

meager granite
#

Units are different, you get second player unit with same vehicle var name you set in editor

tough abyss
#

^

frozen seal
#

It was my suspicion at first and to try to remedy that I moved initialization of my script to initServer. Does it not guarantee that the code won't be executed on the clients?

#

I do have a few while -> sleep loops in the script

deft zealot
#

ok i could be that its a different unit but that doesn't solve the problem

meager granite
#

Do you store player unit on server somehow to do that owner check later?

hallow mortar
#

It's hard to pin down an exact cause without seeing the code, there are a lot of different ways to cause complete failures in SQF

deft zealot
#

nope i send it with publicVariableServer every single time

meager granite
#

After player is local to client?

frozen seal
#

Yeah I get it, though I don't think I should be posting the whole code here, it's like 200+ lines so I think that would be asking for too much 😄

I did inspect the code and I don't have a single remoteexec here. The only commands that actually affect the game world are
setVehicleAmmoDef doSuppressiveFire doArtilleryFire currentCommand

I do have one place where I execute spawn inside of a while loop that runs every few seconds. Could that be dangerous?

hallow mortar
#

Depends on exactly how it's structured

#

You can use Pastebin to post large bits of code

#

Keep in mind it's possible that it's something other than this main script

deft zealot
#

after player is not null

meager granite
#

That's the issue then, client might already know of their player unit but it still will be owned by the server

deft zealot
#

but locality never changes back

meager granite
#

How do you check it?

frozen seal
#

fn_suppressionLoopForGroupManual is the method that is supposed to loop indefinitely, but stops doing it after ~5th player joins

deft zealot
#

waitUntil {local player}

blissful current
#

I am trying to detect if a trigger has been activated. It works fine in the editor trigger field but then I had the bright idea since I have a lot of these that it would be nice to have them all in one place to look at.

So I placed the code in initPlayerLocal and now it doesn't work. I assume this is because that SQF is ran at mission start so how could the trigger possibly have been activated yet. (I assumed that stuff in that SQF is constantly being evaluated, which seems not to be the case)

So is there a place I can put all these so I can see them at a glance instead of hunting for the trigger in the editor that contains the specific one I'm looking for in the moment?

if (triggerActivated TestTrigger) then {
NPC sideChat "Blah, blah, blah.";
};
meager granite
#

Do you control your unit on second join fine?

#

If you do then it should be local to you

#

Pretty sure you have some problem in the sqf that gets you wrong results

deft zealot
#

pretty sure thats not the case :)

hallow mortar
#

The only 2 places in the game that automatically continually evaluate code are the debug console watch fields, and trigger condition fields. If you want anything else of that sort, you need to make your own while loop, waitUntil, or eachFrame event handler.

hallow mortar
deft zealot
#

did someone test it?

blissful current
hallow mortar
#

You'll know you've made something bad for performance if things start to slow down or stutter

blissful current
#

So you need to just look at your fps and see if that drops?

hallow mortar
#

Generally, more commands = slower, commands that affect many objects are slower, commands that search wide areas are slower. There is a code performance analyser function, as well as a button for it in the debug console

hallow mortar
# blissful current So you need to just look at your fps and see if that drops?

That can be part of it. If your code is doing a lot of stuff to the world, moving/creating objects, sending messages etc then that can affect frame rate. Per-frame unscheduled code can also do it, as the game will wait for it. But scheduled code isn't directly tied to frame rate. If you bung up the scheduler with slow/excessive code, then all scheduled code will slow down, but the main simulation won't.

frozen seal
#

It's started in initServer

call fn_suppressionMain;
call fn_startBigArty;
tough abyss
#

Make a simple repro mission

hallow mortar
blissful current
hallow mortar
hallow mortar
deft zealot
#

workin on it

blissful current
# hallow mortar I believe it's just for the JIP client. But of course, if the trigger does stuff...

Copy that. My concern is that I have whole bunch of triggers and I'm afraid if a JIP comes then ALL these triggers are gonna start popping off and cause weird behavior. So far it seems that only ones that do this are the condition: BLUFOR/ANYPLAYER Present ones. I can fix this by turning them to Server Only and remoteExec the code. For some reason this wont reset that trigger when a player JIP. Once it's activated it wont ever be again.

hallow mortar
#

For some reason
I mean, we've just been over why :U

blissful current
hallow mortar
#

The trigger exists separately on every machine. On JIP machines, their local trigger has only just been created as new when they joined, so it can activate if the conditions are then satisfied.
When the trigger is set to Server Only, that changes - the trigger only exists on the server, not on any other machine.

blissful current
#

When the trigger is set to Server Only, that changes - the trigger only exists on the server, not on any other machine. If it's only on the server then how come I can walk into it with BLURFOR Present and activate it?

#

Using a dedicated Server that is.

#

I get that the player is the Server in local host.

hallow mortar
#

Well, because you're a BLUFOR unit and you're in the trigger area. That's all it's checking for - a BLUFOR unit that is in the trigger area. The server knows about you, you are a globally-existing entity.

blissful current
#

Ah OK duh.

hallow mortar
#

The player unit is local to its player's machine, but that's about who has authority. Other machines still know about that player's unit - they have to, in order to render it and interact with it.

blissful current
#

Okay so circling back. A JIP player enters the area of the BLUFOR Server Only trigger. You're saying this wont activate because its on the server only, right? But at the same time other players before the JIP were able to activate it. This is where I'm not understanding. This is conflicting info.

hallow mortar
#

I'm saying it won't activate again if it was a non-repeatable trigger

#

The server's copy has already been activated, and the JIP player doesn't create their own new non-activated copy to then activate

blissful current
#

JIP player doesn't create their own new non-activated copy to then activate But this *will * happen if Server Only is *unchecked * right?

hallow mortar
#

Yes, that's what's causing the "reset" behaviour you encountered - a JIP machine is arriving with their fresh trigger and that's then activating

meager granite
#

You're not addressing player by vehicle var name, are you?

deft zealot
#

no i use player

blissful current
#

Okay sorry I'm not quite getting it. This will help me. Are these 3 statements true?

  1. A player enters the area of a Server Only trigger. The trigger exists only on the server. But because the players are global entities it fires.

  2. A JIP player arrives and enters the area of a Server Only trigger. JIP player doesn't create their own new non-activated copy to then activate. So this trigger will never fire again.

  3. A JIP player arrives and enters the area of a Unchecked - Server Only trigger. It fires because he brought his own non-activated copy.

tough abyss
#

You broke your game. Ask for a refund or get a new one.

fair drum
deft zealot
#

netId player should change if its not the same unit?

blissful current
#

My brain hurts.

sullen marsh
#

yes

blissful current
#

Can you see how examples above 2 and 3 are contradictory? Or is it just me?

#

Why does a JIP player not bring copies of a server only trigger. But he does non server only triggers. I guess that's what it boils down to.

hallow mortar
#

Because when a trigger is Server Only, it literally only exists on the server

#

No other machine has a copy of a Server Only trigger, JIP or otherwise

blissful current
#

And it's not reset when the JIP arrives. But a JIP will reset the non-server only ones because his mission.sqm(?) has them I guess.

#

I think I'm finally getting it. A JIP player can't bring a Server Only copy into the game because he is a client and not the server. He doesn't have access to them. But the server can update his client to let it know if it was fired already.

little raptor
deft zealot
#

ok netId changes

blissful current
#

Can you use the hide module to hide other modules? Since I think delete vehicle wont work for modules.

fair drum
#

that background script might have some early exits, like detecting if the module is destroyed, some run forever, etc

blissful current
#

Can they disabled or removed through a trigger perhaps? In SOGPF there is a module that plays ambiet village noise. I want to diable it when blufor is detected for immersion.

fair drum
blissful current
#

I found isDisposable = 1. That kinda sounds like it maybe could be turned off.

#

It plays ambient village noise. I want to disable it when BLUFOR is detected for immersion.

fair drum
vestal turret
#

any one know how to do planes in the IFA3 AIO mod

fair drum
#

what do you mean do planes

vestal turret
#

like retexture them and put in the editor

fair drum
#

2 methods:

via script: setObjectTexture or setObjectTextureGlobal with your custom texture - used in missions - post editor

via mod: changing the class's hiddenTextures[] with your custom texture - used for universal use and in editor

vestal turret
blissful current
vestal turret
#

in Eden editior

fair drum
#

unless, they have some early exits you can exploit in the code

fair drum
mellow pilot
#

would someone add to this script so it gives a random facewear and backpack? and if posible random things in the back

warm hedge
#

Facewear is CfgGlasses. Backpack is CfgVehicles

mellow pilot
#

the problem is that im so dumm, i really don't know how to script. it dosn't seem to work everytime i try

fair drum
#

hes telling you what to change

#

on the _allFacewear line, go passed configClasses where it says (configFile >> "CfgWeapons") and change that to (configFile >> "CfgGlasses")

mellow pilot
#

ohhh i will try

fair drum
#

that should fix the facewear issue (but you still need to select one of them and apply it)

mellow pilot
faint burrow
#

Debug it.

fair drum
faint burrow
#

There is no addGlasse command.

mellow pilot
#

could you try do write it? couse i don't get the problem in the code

mellow pilot
faint burrow
#

Sure, there is NO such command.

mellow pilot
fair drum
#

would someone add to this script so it

#

moving this to a thread

faint burrow
neon plaza
deft zealot
#

is think i found the issue

tough abyss
#

Tell us.

deft zealot
#
            if (local _x) then {
                _x setGroupOwner (owner (allCurators select (count allCurators - 1)));
            };
        } count allGroups;```
#

this is running serverside

tough abyss
#

The fuck is that

deft zealot
#

haha

tough abyss
#

👊

deft zealot
#

in fact i set the group owner of the group to 2 which prevents the unit from being transfered to the client

tough abyss
#

You should add a false at the end of all your count loops

#

If BI decides that setGroupOwner returns a value your loop might crash

fallen locust
#

whitch makes it slower then foreEach 😉

tough abyss
#

no

deft zealot
#

nil is faster

tough abyss
#

no

#

well maybe. adding a "nil" command is not

deft zealot
#

i throw this stuff away cause it breaks JIP and costs me almost 7 hours of troubleshooting

tough abyss
#

What was the purpose of it in the first place?

#

Now try with add a nil

deft zealot
#

"move" AI to zeus players to reduce serverside calculations

scarlet tiger
fallen locust
#

still slower 😉

tough abyss
#

As an engineer I apply the 10% rule to this and claim it's the same

fallen locust
#

still faster 😉

south swan
ivory lake
#

what are you actually trying to do

#

addweaponitem spawns the magazine so it doesn't get 'taken' from anywhere

#

and you can specify muzzlename to load ugl

#

If magazines already exist in inventory when the weapon is added it will automatically load them

#

requires 2.18 tho

#

yeah if you dont want to touch inventory at all you'll probably have to use takeweapon, really the only thing you'd have to do though is:

  1. Add the weapon
  2. check what magazine etc gets autoloaded by engine
  3. delete said magazine and readd it to inventory
  4. add the magazine it was meant to have via addweaponitem etc
#

now the problem with 3 is yeah it might not end up in the right spot but usually arma goes uniform->vest->backpack in terms of priority, and addmagazine commands etc use that same priority

tough abyss
#

I get more loops with
{false} count allVariables missionNamespace
than with
{} forEach allVariables missionNamespace

nocturne bluff
#

I consider using count instead of foreaching a crime against everything holy.

tough abyss
#

They forced me the use count D:

deft zealot
#

@fallen locust how you prove that you didnt add/remove variables from missionNamespace to manipulate the results :P

split nebula
#

by doing the test yourself? 😃

fallen locust
#

^^

#

exactlly

proven charm
#

does anyone know why I sometimes get automatically respawned without being able to select respawn position?

neon plaza
#

We have any scripts that can remove vehicle hubs? The Information In the top left and right hand corner?

ivory lake
#

'info'

neon plaza
#

Server side yes?

ivory lake
#

no local

neon plaza
#

I am trying to find a script that will force It In the server.

neon plaza
#

Those two options removed. We removed weapon Info on foot but cannot remove vech Info.

hallow marsh
#

Hello everyone, I want to create a mission with dialogs, I use the voices from 11labs. There is one nuance, I create dialog through CfgSentences using ConversationsAtBase but CfgSentences does not see ConversationsAtBase. The truth is that I use ORBAT Group in description.ext together with CfgSentences.

I don't know programming and how to use scripts, I do everything by samples from the internet.
Naturally, run via:
this = [] execVM “talk1.sqf”;

proven charm
#

anyone knows why i get auto respawn sometimes? cant pick the respawn position then

kindred zephyr
#

depends on the mission, but I assume you mean in the same mission. Perhaps you are pressing space

proven charm
#

my mission yes

#

not pressing space

faint burrow
#

Enabled autorespawn?

proven charm
#

i doubt it works like half the time like supposed to

kindred zephyr
#

I had inconsistent results if enabled in the SQM via the editor and then adding the scripting parameter in init in the pass, maybe such is the case?

proven charm
#

if you mean the multiplayer settings in editor I have those disabled

kindred zephyr
#

perhaps a mod then

proven charm
#

just tried disabling them all , no luck

proven charm
#

maybe its lag causing it, in light map respawn works but when there's heavy laggy map this problem comes up

proven charm
#

yep it was the lag and I have a repro

faint dove
#

why do some people do double underscores on private vars? like __foo? it serves no practical purpose, right?

sacred turret
opal zephyr
#

You can just set the height of the unit high in the air. Are you trying to make their parachute open automatically as well?

sacred turret
#

preferably yes, but won't setting the height high in the air make the unit just fall if it doesn't have a parachute backpack, unline in the function above?

grizzled cliff
#

the fact of the matter in SQF is the less code syntax you write the better, because literally everything is a command

opal zephyr
grizzled cliff
#

nil, true and false

#

are all nular sqf commands

sacred turret
#

thank you, worked perfectly

grizzled cliff
#

@candid sun in sqf locals no idea, but i do it in global variables in sqf

#

cause in C++ it often signifies that its some sort of very private, interal, do not touch thing

#

so like namespaces or classes that are not to be used outside of the internal system

formal stirrup
#

Trying to get the vector from one object to another and im not sure how to go about it, any suggestions?

#

I had tried to use weaponDirection since its a turret im trying to get vectors for ultimatly, but It seems to only return a dir value and not values for vectorUp aswell

formal stirrup
#

That uses vector's doesnt it? is there something similar that just uses the objects?

faint burrow
#

Don't know. Find in group of related commands.

sacred turret
#

guys, I'm confused: is this "missionNamespace" argument from the caller of the remoteExec or is it from the target (server)? Does it makes a difference in this context (is missionNamespace the same in the server and the client)? Is there a better way to set a variable in the server only? I've found BIS_fnc_setServerVariable, but I'm not sure this is what I want because it has it's get counterpart; Is every server variable retrievable from clients with BIS_fnc_getServerVariable, regardless of how it was defined as long as it is global?

[missionNamespace, "varname", "varvalue"] remoteExecCall ["setVariable", 2];
south swan
#

inb4 missionNamespace setVariable ["varname", "varvalue", 2];

kindred zephyr
#

^

sacred turret
#

That's so much simpler, thank you, missed it in the wiki

kindred zephyr
#

to answer the rest, mission and object namespaces are local to each pc, what you do with the example artemoz gave is broadcast it as you set it so its synced to the target machine. Each machine has each space of its own except for server namespace, which is only available on host or server machine. The rest each hold a local copy of the space in their own locality allowing to have async variables that can be used for a multitude of stuff, or be synced to a specific machine as artemoz did (or also be globally synced,etc).

#

yup, just corrected it

sacred turret
#

got it, thanks, what about the remoteExec params: are they local to the target or local from the source? For example: in the statement [missionNamespace] remoteExec [...], is the missionNamespace variable from the scope of the caller or of the target?

sacred turret
#

another question: does calling predefined functions from the remoteExec instead of writing the code in it saves bandwith and server performance?

kindred zephyr
faint burrow
#

what about the remoteExec params: are they local to the target or local from the source?
They are local to the the source.

does using {} in between the missionNamespace of this example change it's behavior?
Yes. You can write:

[["varname", "varvalue"], { missionNamespace setVariable _this; }] remoteExec ["call", 2];

another question: does calling predefined functions from the remoteExec instead of writing the code in it saves bandwith and server performance?
Yes.

kindred zephyr
#

^ not only yes to the last one, but its also prefered, since each function is local to each machine its also faster to execute besides saving performance and bandwidth

sacred turret
kindred zephyr
#

yes, what ever parameter you remote execute its interpreted as a non referenced value that has to be picked up by using _this, params or fetching each param individually. This is also true in any function itself, parameters passed into them become non referenced values until properly fetch.

sacred turret
#

got it, thanks guys

tired nimbus
#

Hey can someone help me out? I’m making a custom mission for a group of friends and in that mission I want to add custom voice lines I made along with some friends of mine. I’m not super familiar with Arma 3 scripts and such but is it possible to add audio to Intel items, have NPCs talk with certain triggers and such, and have audio play with certain actions/places the player does or goes to? I want this mission to feel like a proper mission. I have audio lines for NPCs in it and everything, I just wanna know if there’s a way to put it into the mission itself

#

If this is a problem for a different channel let me know

faint dove
#

wait, you can have a global var __foo?

fair drum
#

There are a

blissful current
#

I want to have my mission end with this code when all players are dead. What are some good ideas? I was thinking using a trigger condition to check the alive status of players then executing the code when it is met.

["end1", false, true, true, true] remoteExecCall ["VN_fnc_endMission"] //shows mission failed screen
#

Im trying to avoid this screen which wont let you spawn if there aren't any players left.

#

Or maybe there is a way to disable this screen entirley if no other units are alive.

fair drum
# blissful current Im trying to avoid this screen which wont let you spawn if there aren't any play...

use the ticket system. i'm assuming you want them per side? then do a check when the tickets are 0 && all players are dead

// description.ext
respawnTemplates[] = {"RespawnTickets", "MenuPosition"};
// Adding tickets at start of scenario - to blufor
[west, 5] call BIS_fnc_respawnTickets;
// End condition - for blufor
[west] call BIS_fnc_respawnTickets <= 0 && { (units west select {isPlayer _x}) findIf {alive _x} == -1 };
blissful current
#

This is PVE so there isn't another side. If I'm understanding what you have here, after 5 tickets there are no more respawns?

fair drum
blissful current
#

would 0 be infinite tickets? Thats what I want

fair drum
#

when no more tickets, it won't let them spawn. they will stay at the respawn screen

#

oh i think i missunderstood you

blissful current
#

Ohhh no Im actually trying a way to turn the respawn screen off.

#

when all players die I want it to go straight to the end mission screen. right now it hand out in the respawn screen for a few seconds then goes to the end mission screen. It feels clunky like that

fair drum
blissful current
#

How do I do this part please? find the IDD/IDC or saved uinamespace variable for the respawn screen

fair drum
blissful current
#

luck indeed! How can I search effectivley for these functions? the wiki search bar seems to want EXACT matches (no spelling errors, etc)

fair drum
#

i just go to the function list page and ctrl f something relavent

blissful current
#

How do you execute code in the editor?

fair drum
#

you start using advanced developer tools yet?

blissful current
#

What is that again?

fair drum
#

leopard's wonderful mod. download it, use it.

#

then use ctrl-d in the editor

blissful current
#

This isn't quite what I thought it would be. It lets you spawn on position of death if set to close. In the SOG:PF missions when all players are dead you get this nice splash screen that says all player are KIA or something like then it goes to the end mission screen without going back to the spawn screen. That's the effect I'm trying to reproduce.

["close"] call BIS_fnc_showRespawnMenu```
fair drum
#

i wouldn't know. i don't have sog atm.

#

you are doing the vn end mission function after that?

#

if it still doesn't reproduce, you might have to make your own custom ending, which can be a pain

blissful current
#

I hear that. Time to let this one go I think. On to the next one.

opal zephyr
#

Does anyone have any suggestions on how to optimize this code, I can't come up with any more improvements. (its a global function that's executed unscheduled)

        params ["_modelVectorDirAndUp", "_modelVector", "_unit"];
        _vy = _unit vectorModelToWorld(_modelVectorDirAndUp #0);
        _vz = _unit vectorModelToWorld(_modelVectorDirAndUp #1);
        _vx = _vy vectorCrossProduct _vz;
        
        _mat = matrixTranspose [_vx, _vy, _vz];
        _output = flatten (_mat matrixMultiply (_modelVector apply {[_x]}));
        _output;
vapid scarab
#

Why are you trying to optimize this any more?

opal zephyr
#

Beacuse it's one of the heaviest parts of my code (which runs every frame)

fair drum
#

remove the variables and do everything inline

#

chaos

opal zephyr
#

you mean do it all in a single line.....??

#

apart from the params obviously?

fair drum
#

whats your current times?

vapid scarab
#

You can inline the params using (_this select 0) (or 1 or 2)

opal zephyr
#

Hm, doing everything inline would mean having to call things like vectorModelToWorld and crossProduct more times then I currently am

fair drum
#

and have you run it through arma script profiler to see its impact?

#

whats the current execution time

opal zephyr
fair drum
#

0.002ms average with 10k iterations?

opal zephyr
fair drum
#

you probably aren't going to get that much more speed out of it at the moment. it would be better to consider not doing it every single frame, but have a simulation rate. not even ACE does every single frame for its vectormodels. use something like 0.05. (advance ballistics uses 0.05 for default sim rate)

opal zephyr
vapid scarab
#

Not sure inlining this really optimizes this much.

_vy = (_this select 2) vectorModelToWorld (_modelVectorDirAndUp select 0);
_vz = (_this select 2) vectorModelToWorld (_modelVectorDirAndUp select 1);
// return
flatten (
 (
  matrixTranspose [
   _vy vectorCrossProduct _vz,
   _vy,
   _vz
  ]
 ) matrixMultiply (_this select 1 apply {[_x]})
)
fair drum
#

have you tried it on MP anyways right now? theres already a network update lag that is going to happen as the object position is updated globally

#

like you can have something super smooth in SP, but its janky in MP due to network speed

opal zephyr
vapid scarab
#

smart

#

What is this for?

#

Have you consider other solutions?
There are keyframe animations that handle smoothly moving objects around. Would that be something could work for you?
Typically when you run into problems like this, you have to make a sacrifice or reshape the problem to be easier to solve

fair drum
#

also, your speed tests are going to be different than my speed tests. i could be running it on a toaster and you just crashed my system or gave me a slideshow

opal zephyr
# vapid scarab What is this for?

I'm making a large quantity of objects follow the player. I've tried a couple different solutions and the one I have now seems to be the best balance between performance and visuals

opal zephyr
#

Well thankyou both for the suggestions and feedback, I'll take them into account and try some modifications :)

vapid scarab
#

Sounds awesome man.

tired cargo
#

Hi guys!

Is there a way to avoid loops? Or is this not such a bad way to implement something? If you run them in a separate thread
As far as I know they can put a heavy load on the server

My case: I want to players can't attach the object and enter into the trigger zone. So, if the player attach the object, when he come into the trigger area, attached object should detach

#

I think, that one way is to make loop, which tracks attached objects in area. If such exist, then they are detach

hallow mortar
#

Loops aren't automatically bad, you just have to use them carefully. They can cause performance problems if you let them run too frequently.
A simple check over the players in a reasonably-sized zone is perfectly fine to run every second or two.

faint burrow
tired cargo
faint burrow
#

You can check all objects detected by the trigger activated by any object for attached objects.

sonic lodge
#

How do I make a UserAction/ AceInteraction to replace item A with item B in the inventory?

sonic lodge
tired cargo
faint burrow
#

And? Once he/she enters the trigger, it activates, and you can detach all attached objects.

#

The only problem is that players will be able to attach objects inside the trigger. In this case, you should either disable this possibility or add a check where attaching occurs.

tired cargo
#

Well, I did it. Thank you so much

#

But, I have one more question : scripts in the trigger are executed on the server or client side ?

faint burrow
#

Depends on the trigger settings.

tired cargo
#

I completely forgot)
In my case, should on the client, because I have hints in my script

faint burrow
#

In you case I would recommend setting up the trigger to be server side. In this case scripts will be executed, obviously, on server side.

tired cargo
faint burrow
#

Then use 2 triggers: one for client (with client related stuff [hint's, etc] and one for server (which will detach attached objects).

#

Client side trigger will detect only local player.

blissful current
#

What are some good ideas to implement a destroy cache task? Right now I am using invisible ballons near the cache. The idea being that when a player sets and explosive the balloon will pop and then I can deleteVehicle the cache object (some ammo crates). But the problem with this is it is so unreliable. Sometimes the balloon pops and sometimes not.

Worst case scenario I could use hold action to "plant explosives" but I would rather use the in game explosives because it forces the player to think ahead about inventory management.

Any other ideas?

south swan
#

i've seen people using destroyable props with custom damage handlers that block non-plantable-explosive damage

indigo snow
#

if that speed difference has an actual impact in your code performance theres something wrong with your code

flint topaz
#

Is there any way minus delaying the creation of the next display to ensure that the onUnload event triggers on any previous displays before my display opens?
as currently all the onUnload events just get stacked up until I use closeDialog 0; with no opening of new displays

closeDialog 0;

private _display = createDialog ["RCI_FactionEditor_Blocked_UI",true];
proven charm
flint topaz
#

yeah unfortunate. I was trying to find a way to detect which of my displays is the current active one. I may just use onLoad and set a common variable in uinamespace for it

proven charm
flint topaz
#

yeah cause the initial plan was to do this

private _display = uiNamespace getVariable ["RCI_FactionEditor_GroupCreate_UI",uiNamespace getVariable "RCI_FactionEditor_GroupEdit_UI"];
#

as the code is reusable in either GroupCreate or GroupEdit UIs as an example. So I just wanted an easy way to determine which of the two was currently open

#

but noticed this creates a bug where if you have tried creating a group, it will never make that GroupCreate nil again until all displays are closed. So it grabbed the wrong display

#

it's wild

#

from what I can tell, there are two options. One is a more resilient approach but it requires me to do a bunch of restructuring, or I can try to find a different way to detect what display is currently open.

proven charm
#

not sure if i follow but another way to do something like that: ```sqf
onLoad = "uiNamespace setVariable ['MyDialog', _this select 0];";
onUnload = "uiNamespace setVariable ['MyDialog', displayNull];";

flint topaz
#

the issue is

#

onUnload will only trigger once all the displays are closed

#

it's delayed

#

engine limitation magic

proven charm
#

hmm ok well thats a problem

flint topaz
#

yeah that's what's driving me crazy

#

but I think I have a solution that will work

fair drum
fair drum
#

But mine is for a PvP scenario and requires a high amount of precision. For you, a silly work around will probably be fine.

hallow marsh
blissful current
fair drum
fair drum
blissful current
fair drum
#

Or use a put event handler, that then adds an async check to find if that placed explosive is dead