#arma3_scripting

1 messages Β· Page 142 of 1

dire star
#

oooh right

#

idt one created by server works cause when i use in script if isServer that one doesn't work

#

when i run command locally he works fine

proven charm
#

makes sense

drowsy geyser
#

so there is no other way of doing it?

little raptor
#

Not that I know of

dire star
proven charm
#

that guy shoots you even without aiming 😬

dire star
#

yea but he won't shoot even like that if i don't shoot near him

#

i have no idea tf is going on w arma πŸ˜‚

proven charm
#

id start testing with clean scenario without mods

dire star
#

did already πŸ₯²

fair drum
#

post the script you are using to create the units?

outer bay
#

Is there a way to script objects relative to each other without using variable names for individual objects? For example, if I want to attach a bunch of objects to a single vehicle, I am currently setting the variable name for the car to something like mainCar and then putting in the init field of each object: [this, mainCar] call BIS_fnc_attachToRelative;.

But if I want to turn this into a composition and place more than one down, it wouldn't work since the variable name isn't dynamically updated on each new instance of the composition. Is there any way to do this so I can attach the objects, make it a comp, and then place multiple down?

dire star
# fair drum post the script you are using to create the units?
if (isServer) then {
mog_mile_ground_grp1 = createGroup EAST;
_unit = mog_mile_ground_grp1 createunit [selectRandom _myunitarray, [10545.8,7319.01,5.48363e-06], [], 0, "CAN_COLLIDE"];



_unit setSkill ["courage", 1];
_unit setSkill ["aimingAccuracy", 0.1];
_unit setSkill ["spotDistance", 1];
_unit setSkill ["spotTime", 1];
_unit setSkill ["commanding", 1];


sleep 0.5;

[mog_mile_ground_grp1, d1] spawn BIS_fnc_stalk;
};
fair drum
finite bone
outer bay
# fair drum yes: 1.) Select the base object in the editor 2.) Ctrl select the rest of the o...

so my assumption is that it'll look something like this?

_objectArray = [2172cb0c080# 4004: apc_tracked_01_crv_f.p3d,21673794100# 3965: haultruck_01_abandoned_f.p3d,21674377580# 3966: miningshovel_01_abandoned_f.p3d,21674376b00# 3967: haultruck_01_abandoned_f.p3d, ... ]

_modelData = []
{
    _modelData pushBack _x worldToModel [0,0,0];
} forEach _objectArray;

and then that _modelData array would have position data, then I would somehow copy it to my clipboard, paste it as a variable in the code, and then modelToWorld it? The steps are a bit fuzzy for me

outer bay
# finite bone ```sqf if (isNil "COMPOSITION_markerindex") then { COMPOSITION_markerindex= ...

this is a great idea, my only challenge with it is that if I apply this code to all the objects in the composition, it ends up incrementing COMPOSITION_markerindex each time to the number of objects there are in the composition (for mine it was 38). If I instead put that code in just one object (like the base), then I can't guarantee that code will run before any of the attachTo commands, so they don't have the variable name to go off of.

if (isNil "extractorBase_markerindex") then {
    extractorBase_markerindex= 0
};
_compositionMarkerName = format ["extractorBase_%1", extractorBase_markerindex];
hint _compositionMarkerName;
extractorBase_markerindex= extractorBase_markerindex+ 1;
[this, _compositionMarkerName] call BIS_fnc_attachToRelative;
silent comet
#

I'm trying to create a trigger to check if the mission fails, but it gives an error at createTrigger and says it's missing a ";"

_triggerMissionFail createTrigger ["emptyDetector", [0,0,0], true];
_triggerMissionFail setTriggerStatements
[
    "(!alive objOfficer) && !(""task0a"" call BIS_fnc_taskCompleted);",
    "[""task0"", ""FAILED""] call BIS_fnc_taskSetState;",
    ""
];```
fair drum
#
toString { (!(alive objOfficer)... },
toString { ["task0", "FAILED"]... },
""
hallow mortar
#

That's not the problem though

#

The problem is the missing = between _triggerMissionFail and createTrigger

fair drum
leaden needle
#

Hello, the wiki page for Arma's vanilla Conversations system provides an example of using a Conversation Event Handler for a dialogue where the player is given multiple choices. I am a little unclear on how exactly to set this up, as well as how/if this could work in a co-op mission so that any player can initiate the dialogue and everyone could hear it. A little help understanding would be appreciated.

coral pelican
#

Just get rid of the pilot to do that?

proven charm
#

what would be the best way to create airplane reverse script (when plane is on ground)? i was thinking of setVelocity but too much speed with that could destroy the plane

sweet vine
#

How am I able to close display below, i know in it's not closed because systemChat messages are no longer displayed when RscDisplayEmpty is created

works in sp, does not in mp (local hosted or dedi)

RscDisplayEmpty does not cover systemChat in sp, only mp as well

// creates an empty display 
private _emptyDisplay = findDisplay 46 createDisplay "RscDisplayEmpty";

// does not work
_emptyDisplay closeDisplay 1;
_emptyDisplay closeDisplay 2;
leaden needle
#

i see we have a lot of questions and not many answers

proven charm
sweet vine
leaden needle
# winter rose what's the issue/obscurity?

I've understood how I would set up a simple linear conversation. I'm not that experienced with coding/scripting in general, so I don't understand what exactly it is I need to do in order to set up the Event Handler for a multiple choice conversation. I'm also not sure on how/whether this would work in a co-op mission (ideally every player can talk to the NPCs and the player voice line would play from whoever initiated conversation)

winter rose
leaden needle
#

Well it's a small co-op mission where all players are in a squad together and only a few NPCs have dialogue, so I think it should be fine?

winter rose
#

I'd guess so yes
as long as they don't trigger another chat 2km away at the same time πŸ˜‚

leaden needle
#

I'm sorry but I'm really not comprehending how to set up this Event Handler. What file does it go in, do I set up CfgSentences and the bikb files like normal, what is the variable I use so all players are able to call kbTell? Sorry if these are stupid questions, I'm not that good with code, I'm more of a story teller who sometimes has to write some scripts for his silly little missions.

sweet vine
sweet vine
#

baffling, never seen this, thanks i guess

proven charm
#

dont you have the mouse cursor appearing when you run that creation code?

sweet vine
#

I do, disabled only in recording

proven charm
#

ok

winter rose
#

aaah yes it's in the kbAddTopic's last argument @leaden needle

leaden needle
# winter rose aaah yes it's in the `kbAddTopic`'s last argument <@355729027832741889>

thank you, i also realized that this forum post is linked on the Conversation wiki page, which looks helpful
https://forums.bohemia.net/forums/topic/107662-using-dialogue-system-between-player-and-ai/

winter rose
#

I will amend the BIKI page nonetheless, thanks for the report πŸ˜‰

#

done 🍻

sullen trellis
#

How to make FiredNear eventhandler to only activate when player is shot by the specific unit? i tried (isPlayer _unit) got no luck, though it's strange it works on other eventHandlers.

_unit addEventHandler ["FiredNear", 
{ params ["_unit","_firer"];
 
if ((_this select 2) < 5 && (isPlayer _unit) then 
{ 
 systemchat "Your being shot at."; 
}; 
}]; 
stable dune
proven charm
#

you can turn on script errors from the launcher if you havent already

little raptor
#

pilot is the var name of the pilot

little raptor
sullen trellis
dire star
coral pelican
sweet vine
# sullen trellis ops i wrote it wrong here, when i tested it ingame it was full statement, my bad...

Rewrote it for your specific use case

// name the specific unit you want to it to trigger for, someUnitVarName
// FiredNear is triggered only by nearby units, use Suppressed Instead
player addEventHandler ["Suppressed", {
    params ["_unit", "_distance", "_shooter", "_instigator", "_ammoObject", "_ammoClassName", "_ammoConfig"];
    if (_shooter isEqualTo someUnitVarName && {_distance  < 50}) then {
        systemChat "shot by specific unit "
    };    
}];
sullen trellis
#
_unit1 spawn {player addEventHandler ["Suppressed", { 
    params ["_unit", "_distance", "_shooter", "_instigator", "_ammoObject", "_ammoClassName", "_ammoConfig"]; 
    if (_shooter isEqualTo _this && {_distance  < 50}) then { 
        systemChat "shot by specific unit " 
    };     
}];
};

this is what i did, doesnt work

stable dune
#

What you want to achieve?
That your code will be executed if the shooter is _unit1 and distance is below 50m to player?

#

And on SP or in MP?

#

And where do you create your _unit1? Editor placed or via script?

sullen trellis
#

in SP, also in a script i create a local unit named _unit1 , now if that _unit1 shoots near/at the player it would trigger some effect, so i add the event handler to that unit only

#

unit is created using createUnit

#

the idea is that when unit spots the player, thus after shooting towards him it spawns waypoints to chase the player further. basically just like BIS_fnc_stalk but its more like a chance for the player to escape

sweet vine
#

_shooter is a parameter that signifies the shooter that trigered the event hander on the _unit, i.e the player

rename the unit you want to stalk player to unit1, remove prefix

based on your requirement, you don't need to put event handler on shooter, just add it to player as described

player addEventHandler ["Suppressed", {
    params ["_unit", "_distance", "_shooter", "_instigator", "_ammoObject", "_ammoClassName", "_ammoConfig"];
    if (!isNull unit1 && {_shooter isEqualTo unit1} && {!(_shooter getVariable ["isStalking", false])}) then {
        systemChat "shooter is now stalking player";
        _shooter setVariable ["isStalking", true];
        [group _shooter, group _unit] spawn BIS_fnc_stalk;
        _unit removeEventHandler [_thisEvent, _thisEventHandler];
    };
}];

edited per πŸ‘‡

stable dune
#

And you need to define that after you have created unit1 and remove eh if unit1 gets killed/ removed.

#

Or add check that !isNil "unit1" (so entity exists)

sullen trellis
#

thanks this difinitely helps alot, i may use it in many ways, though

_group = createGroup [east, true];
 _unit1 = _group createUnit ["vn_o_men_nva_43", getpos thistrigger, [], 0, "NONE"];

this is what im using, its local because it may spawn more units, and each spawned unit gets its own eventhandler, so if i name it unit1 it will be global thus it will cause some issues

stable dune
#

Same or some other event?

sullen trellis
#

same and lets say a repeatable trigger, so i cant repeat a global named unit each time

sullen trellis
finite bone
thin fox
#

Hello. I'm trying to do an "AAS" sector control style. I had some progress so far. In this video you can see a test on a local server. But when I try this on dedi server, it fails so bad, mainly functions are not working at all. Could someone take a time to see my mission files and test it out? Ty in advance

fair drum
thin fox
#

first time for everything

fair drum
wicked sparrow
#

How can I meak objects placed in eden undeletable for zeus? Like if a zeus uses "add Objects" they can delete objects mid op. How do I disable that for certain objects?

finite bone
fair drum
#

keep in mind, that is for every object. you will not be able to delete anything.

wicked sparrow
#

But how would I do that just for certain objects

fair drum
#

well actually, it could be for singular objects

finite bone
#

It can be used for singular object though.

wicked sparrow
#

yea doing it in a object init could work with this instead of object1

fair drum
#

if it is, we should update the wiki page for more clarification cause as it is written now, I could see it applying for the object or for the curator itself

wicked sparrow
#

yea it is kinda confusing there

finite bone
#

Try it and let us know @wicked sparrow πŸ˜…

fair drum
#

the reason I'm thinking its for the curator itself, is because "Place" is an option. An object can't have already been placed in order to place it. "Edit" would be movement of said object.

finite bone
#

Available actions are:

"place"
"edit"
"delete"
"destroy"
"group"
"synchronize"
``` from https://community.bistudio.com/wiki/Arma_3:_Curator - So yes, it seems like that prevents you from deleting entirely.
thin fox
fair drum
finite bone
fair drum
#

either that, or detect when the curator has selected an object, and change the coef based on what object is selected.

thin fox
fair drum
thin fox
finite bone
#

Plus, the setCuratorCoef only works when all the objects have a cost assigned to them which is yuck

fair drum
thin fox
#

I got started with this topic https://forums.bohemia.net/forums/topic/176089-unlocking-a-sector-when-another-sector-has-been-taken/
and it works on dedi (with function on initPlayerLocal)

little raptor
coral pelican
#

Thanks

#

If it came back as true what’s the best course of action?

bronze temple
#

Is there a way to execute a script for someone else

#

For example I am making a script that steals virtual items from a players virtual inventory, this virtual inventory is stored in a database and there a function that updates this database but it is run on the client.

stable dune
bronze temple
#

I saw that but for some reason I can't make it work

#
_player = (player nearEntities 2 select 1); 
["Hello1"] remoteExec ["hint", _player];
#

I tried something basic like that and I am still getting hints despite there being another unit right next to me

hallow mortar
#

If you're testing in a scenario that's hosted on your machine, and the other unit isn't a player, then you'll still get the hint because the AI unit is local to your machine, and remoteExec targets the machine where the thing is local.

bronze temple
#

Ahhhh

#

Okay makes sense

hallow mortar
#

Also, your nearEntities is potentially unreliable because it doesn't specify that it should look for units. There could be another entity that's closer and not a unit.

#

Try this:

// only detect humans that aren't you
private _nearMen = (player nearEntities ["CAManBase",2]) - [player];
// safety: fail if there are no other near units
if (count _nearMen < 1) exitWith {
  hint "No one here!";
};
// get the nearest remaining unit
private _nearestMan = _nearMen select 0;
["Hello1"] remoteExec ["hint",_nearestMan];```
#

...that's not quite right πŸ€”

#

Fixed

formal stirrup
#

Without making a whole custom GUI, is it possible to make an image flash up on the screen of a player and be animated?

bronze temple
#

Ok so now I got my script in the server and its working but the issue is pulling another players inventory.
It's set with

player setVariable ["life_items",(life_gear select 16)];

but in my script which is called with an addaction on the player

player addAction ["Steal", { [cursorObject] spawn sal_fnc_openDialogStealMenu}, [], 1, false, true, "", "(cursorObject isKindOf 'Man' && stance player ==""CROUCH"")", 1];

and it should get the cursorObject, being the other player, life_items

params ["_target"];
source_life_items = _target getVariable ["life_items",0];

This works on a hosted server but on a dedicated server it's not pulling the cursorObjects life_items.

#

My own life_items is found and added but for some reason on the dedicated server this is not working when using getVariable

#

I think I found it after reading into it JIP setVariables are only synced if you use the alternate syntax and set public to true

trail shale
#

Does anyone know if i can activate a trigger which would then be synced with an ordnance module so it can create an explosion with the AddAction line on an object ?

#

Eg. I want to have a radio which will have an action option "Call Barrage". I want the Action to activate the trigger and (i suppose) with it's activation the ordnance module would fire the artillery automatically

analog mulch
#

hi,
is there a way to control the flight time of under barrel flares, want them to last a bit longer then default

fair drum
#

You'll have to make a mod

analog mulch
#

by config u mean its default and can't be changed, right?

warm hedge
#

Not by a script

thin fox
granite sky
#

I need to generate the minimum range value that the artillery computer outputs in script. The issue is how to calculate the true max elevation: maxElev and minElev in turret config seem to be relative to the "default" elevation in the model, but I can't see any way to extract that. selectionVectorDirAndUp might be a way to get the current elevation, but that's not ideal here because I'd need to spawn a dummy object. Any better ideas?

trail shale
stable dune
#

It only adds current addaction on the server. It won't show up to clients.
Only if you are hosting a local, the host (server) will see action on the object.

You should take if isserver check away and add the same condition to your addaction. So if your actionCompeleted is false it shows your action on radio.
@trail shale ☝️

fair drum
trail shale
#

Should i also put " ActionID " in the Init ?

stable dune
# trail shale Should i also put " ActionID " in the Init ?

You don't need it.
You could just add a condition to your action.

this addAction
[
    "Call for Barrage",
    {
        params ["_target", "_caller", "_actionId", "_arguments"];
    missionNamespace setVariable ["BarrageCalled", true];
  
    },
    nil,
    1.5,
    true,
    true,
    "",
    "!(missionNamespace getVariable ['actionCompleted', false])",
    50,
    false,
    "",
    ""
];

The mission namespace is global, so you don't need to broadcast that again with publicVariable method.

fair drum
# fair drum Is there currently a way to detect if a unit has started to reload? Outside of u...

One Possible Solution:

[{
    params ["_args", "_handle"];
    _args params ["_unit"];

    private _isReloadingMag = (weaponState _unit # 6) > 0;
    private _isReloadingUnit = _unit getVariable [QGVAR(Client_IsReloading), false];

    if (_isReloadingMag) then {
        if (!_isReloadingUnit) then {
            LOG_1(SCRIPTNAME + "Reloading Event:: " + "Unit [%1] is reloading...", _unit);
            _unit setVariable [QGVAR(Client_IsReloading), true, [owner _unit, 2]]
        };
    } else {
        if (_isReloadingUnit) then {
            LOG_1(SCRIPTNAME + "Reloading Event:: " + "Unit [%1] reloading complete.", _unit);
            _unit setVariable [QGVAR(Client_IsReloading), false, [owner _unit, 2]]
        };
    };
}, 0, [_unit]] call CBA_fnc_addPerFrameHandler;
little raptor
#

Just check the currentWeapon's reload action, and see which anim/gesture it maps to

little raptor
little raptor
formal stirrup
kindred zephyr
ornate whale
#

Is there anything like #ifdef #endif preprocessing for Arma 3 functions, like in C.

analog mulch
#

hi,
i would like to edit the contents of the supply crate dropped using the supply drop module to contain exactly these items, what code to write in the crate init?

analog mulch
#

also i've tried using the virtual supply drop and entered the class name of the heli but keeps popping this error

analog mulch
#

thnx that worked

still forum
#

Okey yeah I got it.
I spawned 15k.
87% of frametime is taken up by sorting scripts by age.

It sorts ALL 15k scripts by age, and then only executes only 0.5ms of scripts, because the sorting already used up so much time.
So it only gets maybe a dozen scripts actually done.

So fix should be, only sort the first 512 or so scripts. And process them.
If after executing them all, there is somehow still time left in the 3ms window, it can just sort the next 512 chunk. But it probably won't get to that.

still forum
#

Before:
15k scripts: 150-200fps
18k scripts: 90-180fps
20k: 100-200fps
25k: 150-190fps
30k 140fps-ish.

Ugh I'm having a hard time testing this πŸ˜„
This sorting data seems to all fit in CPU cache, so its not much trouble at all.
But I can see that it takes up 60-90% of frametime.

20k After: 250fps-ish
30k: 250fps
51k: 250fps
And sorting now only 6% of frametime
It'll be more noticable on CPU's with less cache probably.

Also a probably bigger issue than this.
A newly spawned script has a "time since last execution" of zero.
And it sorts scripts and first executes the oldest ones. So the brand new script, will not execute for a long time.
Especially bad when you try to press the "Options" button in menu, when you have 15k scripts spawned. You press and nothing happens.

winter rose
#

A newly spawned script has a "time since last execution" of zero.
set it to int.MAX, problem solved 😎

still forum
#

That would overflow next frame into negative πŸ˜„

#

100k spawned scripts.
250fps. AND you can still access the options menu, if you know where the button that would fade in is at
I'll consider this fixed.
I'm now sorting in 256 script chunks.

meager granite
#

πŸ†

bleak gulch
#

pretty good

#

the overhead which came from the switching between the threads was massive in some scenarios

#

HIG (AI Can't See Through The Glass) caused the leakage with the 0 spawn {waitUntil {};}; 15-20k scripts executing simultaneously caused massive FPS drop from 90-ish to 10-15 with that mod. I patched it so it's ok now (always 1 thread) but we have a LOT of steam workshop content when mission makers cannot control their code.

fair drum
#

The popular Asian WW2 mod also leaked a thread every time a unit was killed. I showed them the fix, they called me a nerd and told me to pound sand. Circa 1-2 years ago.

bleak gulch
#

wow

#

so rude

#

Also I'm wondering which algorythm is used to calculate the distance between two points? The regular c = sqrt(x^2 + y^2 + z^2) or J. Carmack's? For the distance-family commands.

granite sky
#

You mean for the square root?

bleak gulch
#

yep

granite sky
#

I'd be amazed if it wasn't the plain sqrt. It's pretty fast in SSE.

bleak gulch
#

sqrtss is slower than rsqrtss

granite sky
#

And in case you were wondering, a distance b < n is faster than a distanceSqr b < n*n. Language is slow.

still forum
bleak gulch
still forum
#

Basically all of it yes

winter rose
#
FPS++;
winter rose
still forum
bleak gulch
still forum
bleak gulch
#

Ty, good to know. rsqrtss (or even vectorized version rsqrtps) is significantly faster if we're satisfied with 11 bits accuracy.

still forum
#

We're not

#

compiler switch recently changed that code, causing us to be off by one bit. And that already broke mods
You wouldn't notice a performance benefit as you're memory bound anyway

bleak gulch
#

or even use preprocessed constant

bleak gulch
#

The reason I stopped to buy anything from EA or GGG - they don't give a ... about anything related to the modding / API / features / feedback

bronze temple
#
[false, _name, 1] remoteExecCall ["life_fnc_handleInv", cursorObject];
#

I'm trying to remoteExecCall on the cursorobject the rest of the script works fine but for some reason this script isn't being called on the other client

#

Any Insight?

#

Is it because he's not local? and if so how would I go about executing a script on a specific client machine from another client

bleak gulch
#

is cursorObject's object local to that player?

bronze temple
#

cursorObject is another player infront of him

bleak gulch
#

is life_fnc_handleInv properly defined on the client side?

fair drum
#

the function might not exist on the client depending on how you have it defined

bronze temple
#

Essentially how the script works, life_fnc_handleInv is definied for all players

#

If he steals from me it adds the items to his inventory but I never get the remoteexec to remove them from mine

hallow mortar
fair drum
#

someone made a whole fallout conversion? lol

bronze temple
#

Working on it

bleak gulch
#

as a test

#

call hint

#
"sdfsdfs" remoteExecCall ["hint", cursorObject];
fair drum
#

to expand on nikko's comment, if it is blocked by CfgRemoteExec (and you want to keep it locked down), then use the CBA_events (I see you have CBA enabled). They bypass the CfgRemoteExec by using the old way of remoting things via public variables.

granite sky
bronze temple
#

This correct?

bleak gulch
fair drum
#

did you do the test that kat suggested above?

bronze temple
#

About to test

bleak gulch
#

yeah, just simple test with the hint

bronze temple
#

He did not get a hint

bleak gulch
#

interesting

bronze temple
#

Wait there is a cfgremoteExec

#

Sorry

#

Adding it to the list of functions and I'll try it out

bleak gulch
#

remoteExec is the same as remoteExecCall but executes the code in the scheduled environment.

#

oh

#

probably your command not whitelisted

fair drum
bleak gulch
#

It's life

#

every single player on the Life server wants to hack

#

as a developer he has to deal with it πŸ™‚

bronze temple
#

It works now

#

Thank you all

analog mulch
# analog mulch hi, i would like to edit the contents of the supply crate dropped using the supp...

tried the following but gave me an error:

clearMagazineCargo _this;  clearItemCargo _this;  clearWeaponCargo _this;  _this addWeaponCargo ["launch_RPG32_F ", 10]; addMagazineCargo [["RPG32_F", 31], ["DemoCharge_Remote_Mag", 10]]; addItem [["Binocular", 10], ["FirstAidKit", 30], ["Medikit", 10], ["U_I_C_Soldier_Bandit_2_F", 10], ["ItemGPS", 10]]; Signal = "SmokeShellYellow" createVehicle position _this; this allowDamage false;
granite sky
#

_this vs this confusion, plus incorrect syntax on addMagazineCargo and addItem.

analog mulch
#

wut wud be the correction for addMagazineCargo and addItem?

fair drum
#

also, you are passing a wrong right argument

#

basically, everything is wrong lol

analog mulch
#

ok

fair drum
# analog mulch wut wud be the correction for addMagazineCargo and addItem?

always filter in the init box:

// for local arg commands
if (local this) then {
  // blah
};

examples:

this addMagazineCargo ["RPG32_F", 31];
this addMagazineCargo ["DemoCharge_Remote_Mag", 10];

or

private _mags = [
  ["RPG32_F", 31],
  ["DemoCharge_Remote_Mag", 10]
];

{
  _x params ["_mag", "_count"];
  this addMagazineCargo [_mag, _count];
} forEach _mags;

or

for "_i" from 1 to 30 do {
  this addItem "FirstAidKit";
};
analog mulch
#
if (local this) then {
this addWeaponCargo ["launch_RPG32_F ", 10"]
this addItemCargo ["Binocular", 10"]
this addItemCargo ["FirstAidKit", 30"]
this addItemCargo ["Medikit", 10"]
this addItemCargo ["Medikit", 10"]
this addMagazineCargo ["ItemGPS", 10];
this addMagazineCargo ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle position _this; this allowDamage false;
};

full code, would this work if i wanted to add those items and a smoke signal where the supply gets dropped at?

fair drum
#

kinda read it outloud. you know this is all going to happen immediate as the box is created.

add stuff
create a smoke shell at its current position (wherever it is created), physics is applied (falls at its own rate)
make invulnerable

#

and I'm assuming you don't want the smoke signal to start until it reaches the ground or have it fall at its own speed. that is where you need to work on then.

analog mulch
#

If it's created immediately that's fine too

fair drum
#

then try it

bleak gulch
#

_this replace to this

#
KOMOD_Signal = "SmokeShellYellow" createVehicle (getPos this);
#

_this is not defined in that scope. Personally I don't like the idea of using the same variable name for the two different purposes.

#

BI at least could use _args or something like that πŸ™‚

hallow mortar
#

You need ; after each instruction. The first 5 lines (inside the {}, don't put one on the actual first line) don't have it.

analog mulch
#

used this:

if (local this) then {
this addWeaponCargo ["launch_RPG32_F ", 10"];
this addItemCargo ["Binocular", 10"];
this addItemCargo ["FirstAidKit", 30"];
this addItemCargo ["Medikit", 10"];
this addItemCargo ["Medikit", 10"];
this addMagazineCargo ["ItemGPS", 10];
this addMagazineCargo ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle (getPos this);
fair drum
#

you're missing the closing } on the then

hallow mortar
#

You've removed the last two lines, which includes the closing }; (and the allowdamage false, which might be important)

analog mulch
#
if (local this) then {
this addWeaponCargo ["launch_RPG32_F ", 10"];
this addItemCargo ["Binocular", 10"];
this addItemCargo ["FirstAidKit", 30"];
this addItemCargo ["Medikit", 10"];
this addItemCargo ["Medikit", 10"];
this addMagazineCargo ["ItemGPS", 10];
this addMagazineCargo ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle position _this; this allowDamage false;
};
hallow mortar
#

The format of your addItemCargo are wrong

junior moat
#

hey is it possible to just constantly play an ambient sound at a position? i want players to spawn in a static C-130 and then paradrop into the AO but the c-130 has no sounds which just doesnt feel right. what would be the best way to add an engine hum sound whilst inside the c-130?

bleak gulch
#

10" <- ?

hallow mortar
#
this addItemCargo ["Binocular", 10"];
this addItemCargo ["FirstAidKit", 30"];```
`" "` denote the ends of a string. You can't put single `"` in random places, it will confuse the game.
Corrected format:
```sqf
this addItemCargo ["Binocular", 10];```
Also, there's an extra space in the RPG32 classname string - spaces do matter in strings, you need to get rid of that
analog mulch
#

did those changes (thnx for pointing them out) code as follows:

if (local this) then {
this addWeaponCargo ["launch_RPG32_F", 10];
this addItemCargo ["Binocular", 10];
this addItemCargo ["FirstAidKit", 30];
this addItemCargo ["Medikit", 10];
this addItemCargo ["Medikit", 10];
this addMagazineCargo ["ItemGPS", 10];
this addMagazineCargo ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle position _this; this allowDamage false;
};
#

still getting an error

hallow mortar
#

Okay, in what context is this code being run? Object Editor init field? Some other script?

analog mulch
#

in the Crate init of the Supply Drop Module

#

want to customize the crate paradropped rather than the default items in it

hallow mortar
#

Hover over the title of that field and see if it describes what variables are available

junior moat
#

hey is it possible to just constantly play an ambient sound at a position? i want players to spawn in a static C-130 and then paradrop into the AO but the c-130 has no sounds which just doesnt feel right. what would be the best way to add an engine hum sound whilst inside the c-130?

junior moat
#

for all instances of this

#
if (local _this) then {
_this addWeaponCargo ["launch_RPG32_F", 10];
_this addItemCargo ["Binocular", 10];
_this addItemCargo ["FirstAidKit", 30];
_this addItemCargo ["Medikit", 10];
_this addItemCargo ["Medikit", 10];
_this addMagazineCargo ["ItemGPS", 10];
_this addMagazineCargo ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle position _this;
_this allowDamage false;
};
#

like that

junior moat
junior moat
#

its saying "itemGPS" doesnt exist, is that the actual class name for the gps?

#

youre also trying to add it as a magazine for some reason?

#

hold on

analog mulch
#

i got it from the crate items "Export to SQF" in 3den

junior moat
#

hold on

#
_this addItemCargoGlobal ["launch_RPG32_F", 10];
_this addItemCargoGlobal ["Binocular", 10];
_this addItemCargoGlobal ["FirstAidKit", 30];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["ItemGPS", 10];
_this addItemCargoGlobal ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle getPos _this;
_this allowDamage false;
};
``` try this.
#

if that doesnt work, try this

_this addWeaponCargoGlobal ["launch_RPG32_F", 10];
_this addItemCargoGlobal ["Binocular", 10];
_this addItemCargoGlobal ["FirstAidKit", 30];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["ItemGPS", 10];
_this addItemCargoGlobal ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle getPos _this;
_this allowDamage false;
};
analog mulch
#

isnt there supposed to be few lines that preceed this that clear the default supply drop crate contents?

junior moat
#

right click the crate > attributes > object: Equipment storage > clear

analog mulch
#

yeah i get that i meant in the Supply Drop Crate init

#

unless i'm missing something like synching an existing crate to the Supply Drop Module that will replace the default (which i tried and didnt work)

junior moat
fair drum
#

@little raptor how can I bring down this menu to default once it was accidentally maximized? I don't see an option and the sides don't drag lol

fair drum
analog mulch
#
clearMagazineCargo _this;  clearItemCargo _this;  clearWeaponCargo _this;
_this addWeaponCargoGlobal ["launch_RPG32_F", 10];
_this addItemCargoGlobal ["Binocular", 10];
_this addItemCargoGlobal ["FirstAidKit", 30];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["ItemGPS", 10];
_this addItemCargoGlobal ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle getPos _this;
_this allowDamage false;
};
junior moat
# analog mulch ``` clearMagazineCargo _this; clearItemCargo _this; clearWeaponCargo _this; _t...
clearMagazineCargoGlobal _this; 
clearItemCargoGlobal _this; 
clearWeaponCargoGlobal _this;
_this addWeaponCargoGlobal ["launch_RPG32_F", 10];
_this addItemCargoGlobal ["Binocular", 10];
_this addItemCargoGlobal ["FirstAidKit", 30];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["ItemGPS", 10];
_this addItemCargoGlobal ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle getPos _this;
_this allowDamage false;
};
#

its not required but its good practice to always start a new line after a ;

#

oh also

#

making things globally will execute the code on every client so its sycronised

analog mulch
#

still an error

#

missing { somewhere not sure where tho

junior moat
#

my bad, shouldnt have a }; at the end.

clearMagazineCargoGlobal _this; 
clearItemCargoGlobal _this; 
clearWeaponCargoGlobal _this;
_this addWeaponCargoGlobal ["launch_RPG32_F", 10];
_this addItemCargoGlobal ["Binocular", 10];
_this addItemCargoGlobal ["FirstAidKit", 30];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["ItemGPS", 10];
_this addItemCargoGlobal ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle getPos _this;
_this allowDamage false;
analog mulch
#

thank you, this worked

junior moat
# analog mulch thank you, this worked

no worries! just as a quick tip btw, assuming this is for a multiplayer scenario, do try and open a local hosted server and connect a second client to it and see if it works in multiplayer

analog mulch
#

ill do that but its for solo play

#

last thing, any idea to have the smoke grenade stick to the crate?

junior moat
analog mulch
#

attachTo kinna perhaps

junior moat
fair drum
#

consider checking out my mod Modules Enhanced for additional paradropping of supplies and even vehicles

analog mulch
# junior moat at the end of the code block, add `Signal attachTo _this`

tried the following but the box detached from the chute but smoke nade was attached:

clearMagazineCargoGlobal _this; 
clearItemCargoGlobal _this; 
clearWeaponCargoGlobal _this;
_this addWeaponCargoGlobal ["launch_RPG32_F", 10];
_this addItemCargoGlobal ["Binocular", 10];
_this addItemCargoGlobal ["FirstAidKit", 30];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["Medikit", 10];
_this addItemCargoGlobal ["ItemGPS", 10];
_this addItemCargoGlobal ["DemoCharge_Remote_Mag", 10];
Signal = "SmokeShellYellow" createVehicle getPos _this;
Signal attachTo _this;
_this allowDamage false;
fair drum
#

Local Handle Damage Expert, @meager granite, what do you use to detect only the first instance of direct or indirect damage? I get multiple entries on both for a single hit. Do you save the frame and filter out things only on that frame? I just need to know if the thing was hit, and what by. nothing more.

junior moat
fair drum
#

there is no list, unless I collect in a time frame, then execute a few frames later. say you hit something with a rocket, you might get 6-8 firings of the handle damage event which can mess that up

bleak gulch
#

the second one is fired for indirect damage

#

HandleDamage or Hit?

fair drum
#

handle damage, because I do have to return 0 damage at the end after my custom work

#

each trio of messages is 1 firing of the event handler. only fired 1 rocket

bleak gulch
#

the BI Wiki updated, HandleDamage now has additional arguments

#
params ["_unit", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint", "_directHit", "_context"];

context: Number - some additional context for the event:

#

For AoE damage it's called multiple times

#

It would be nice to see that additional information here

bleak gulch
#

LastHitPoint - the last hitpoint from iteration is processed

#

it's definitely called for the each part of the body

#

you need _selection, _hitIndex and _hitPoint. These vars contain exact part of the body which was processeed by the engine

fair drum
#

I don't even see any hitpoints/selection in the config for "Land_Device_disassembled_F"

it has some simple object animations though for the damage LOD

#

I think what I'll do is make two handlers. one handle damage to remove engine damage, then use the hit to detect the hit for the custom one

#

well... maybe... I still need the projectile which hit doesn't give

#

hmm lets see what hitPart gets me

bleak gulch
#

if Selection is empty ("") the damage considered over-all structural

#

so techicanlly you can filter the damage by ignoring the other damage events with non-zero context

fair drum
#

what about using a fired event, grabbing the projectile, using the projectile hitpart event to grab the thing it hits, then do the calculation from there. I just need to know if the main projectile hits the object

bleak gulch
#

you can store proj name into object-specific variable and grab it from the Hit

#

Fired EH is only reliable if fired locally

fair drum
#

yeah doesn't track explosives either. nvm

bleak gulch
#

so you can store projectile to the var

// HandleDamage EH
// ----------------------
if ((_unit getVariable ["projectile", ""]) isEqualTo "") then
{
    _unit setVariable ["projectile", _projectile];
};
// ----------------------

// Hit EH
// ----------------------
private _projectile = _unit getVariable ["projectile", ""];

// process...

// Allow overwrite
_unit setVariable ["projectile", ""];
// ----------------------
fair drum
#

gotcha i'll try it out

somber latch
#

Hey, I’m trying to create a new faction in arma 3, but I haven’t done scripting before. I wanted to know if there was a good video/guide for creating factions without using ALIVE that helps me learn from scratch.

Also wanted to know if there was a way to add patches onto my faction. Thanks.

fair drum
bleak gulch
#

moreover you can completely ignore all the damage events which have empty _projectile variable

#

Hit is not fired on minor damage, keep in mind

somber latch
fair drum
fair drum
bleak gulch
#

try to test Hit on the tank or wall by shooting at it with the pistol

#

17:33:39 [CARRIERSTRIKE] (Mission) LOG: Reactor Damage Handler:: Projectile: R_PG32V_F

fair drum
bronze temple
#
_view = floor(_object getDir player);
_objectView = floor(getDir _object);
_distance = _view - _objectView;

for "_i" from 1 to _distance do 
    {
        _object setDir (_objectView + _i); sleep 0.001;
    };
#

I'm confused for some reason when I do this script it works fine, the object turns towards me, but everytime after it simply stops working

#

The rest of the script after this works it's just after first use this part no longer functions

#

It's because it can bark a negative number

fair drum
#

was just about to say that

#

what do you want it to do?

bronze temple
#

Rotate an object towards the player smoothly

fair drum
#

like make it the objects face each other?

bronze temple
#

Just gonna create a separate variable for the for loop that will be positive and just do an if statement for two different equations one to add to the degrees and one to subtract from it

#

Like an object is facing away from you and then it slowly turns towards you when you execute this script

bronze temple
#
_view = (_object getDir player);
_objectView = (getDir _object);
_distance = _view - _objectView;
_forDistance = _distance;
if (_distance < 0) then 
{
    _forDistance = _forDistance * -1;
};
for "_i" from 1 to _forDistance do 
    {
        if (_distance > 0) then 
            {
                _object setDir (_objectView + _i); sleep 0.001;
            }else 
            {
                _object setDir (_objectView - _i); sleep 0.001;
            };
    };
_object setDir (_object getDir player);
fair drum
#

there is a abs for absolute value command btw

bronze temple
#

Ah didn't know that lmao

granite sky
#

That won't necessarily take the shortest rotation direction, btw.

queen cargo
#

@hasty violet No, but there is a group cap

meager granite
#

There is no way to tell if its direct or indirect damage from HandleDamage

#

Only assume by shot class that its an explosive

fair drum
#

but my issue is just trying to grab the first instance of damage and the projectile and skip all the others. I currently have this:
https://pastebin.com/JX093WkZ

which works, except for when you stack a few explosives on top of each other and detonate them all at once. but that seems to be firing all within one frame then.

meager granite
#

I didn't read the chat further, what's your general goal? Count number of direct hits?

fair drum
#

end goal is I have some reactors on the carrier that I want to handle with my own damage scale depending on the simulation of the ammo that hits it. so I need to grab the first shot that hits the reactor and skip the event from firing on all the other hits since that handler can fire 8 or so times for a single ammo hit, multiple for direct and indirect damage.

with my pastebin above, I have gotten it down to only working on the first firing of the handle damage by collecting all the handle firings, and processing them next frame to grab the first instance

#

only issue is now, if you place down multiple satchels or whatever, and remote detonate them all at the same time, it won't pick up the different instances of the explosives, as they both apparently hit in the same frame

meager granite
#

Yeah this can also happen with other shots too

#

Any network hiccup and damage messages will arrive and process in same frame

#

even if firing client did sequential hits

#

So checking frames is very unreliable

#

What you need is to only consider events with _context = 0

#

Say your hit does 8 HD calls, two hits will be 16 HD calls, you can tell when next projectile handling starts when _context is 0

#

It will be like 0 1 1 1 1 .. 2 0 1 1 1 .. 2

#

Or just 0s if entity has no hit parts

fair drum
#

that text paste is all from one rpg hit

meager granite
#

Hmm, looks like there is HandleDamage cycle for each penetration

#

Yeah, just double checked that

#

Well, there is no reliable way to say if that was same projectile or not

#

Only possible on shooter side with HitPart

#

What do you want to change depending on simulation btw?

#

Also your simulation checks are case sensitive

fair drum
meager granite
#

If you want it 100% reliable you'll need to count from shooter side

#

HitPart has projectile entity so you can easily count exactly how many projectiles hits there were

#

You can track penetrators with SubmunitionCreated

#

You can save variables on shots now so you can easily pass a flag to submunition/penetrator that hit was already registered on certain object

#

There is no damage info on shooter side though

#

Only a fact that some hit was done or not

bleak gulch
#

submunition like pellets also casuing to fire the HD multiple times from the single shot

bleak gulch
#

to resolve this, we need additional argument in EH which is not implemented

#

the shot identifier. So each HD EH called with the same ID are fired from the certain shot.

#

Also as @meager granite proposed to use client-side FIred EH to count actual shots (and probably mark them with the ID) is also unreliable if the client has FPS < fire rate.

meager granite
#

For this case you don't even need Fired, just HitPart on target

#

Actually no, for SubmunitionCreated you will need Fired

#

So you don't register two hits from RPG and its penetrator

#

There is no problem with FPS though, shots are proper entities, you just carry a flag that certain objects were hit already and there is no need to report to server/do the calc again

#

I think HitPart is called before SubmunitionCreated?

bleak gulch
#

it should)

#

but the network traffic will increase if client will report to the server each shot

meager granite
#

Oh there is also a bug where there is no projectile in HitPart for shotRocket/shotMissile simulation shots, its fixed in 2.18 though

meager granite
bleak gulch
#

But it's still a lot even if you report one hit

#

I don't like that idea... it's... ehm duct tape - like solution

meager granite
#

It shouldn't be much, even if you reported like 30 hits from 30 DAR shots within 1 second, its very little traffic

#

Wish we had PreHandleDamage on shooter side or something

#

With more info in it

bleak gulch
#

_shotID parameter.

fair drum
#

since its something that determines win/loss and gameflow of the round, I need to keep it server side. can't rely on a client and its fps/lag

meager granite
#

Becuause right now the victim client only gets a sum of the damage with very little damage information, pretty much only: source, instigator, shot class string, damage, hit parts damage, that's it

bleak gulch
#

multiple EHs fired with the same _shotID came from the single shot so we can filter the events with the same ID

meager granite
#

Even if HandleDamage had something like shot's previous netid (many shots don't have it like bullets), you still won't be able to tell if that penetrator belonged to previous RPG explosion or not

bleak gulch
#

I am talking about the identifier of the shot, not net ID

meager granite
#

But its complicated

#

If you aim for 2.18 the its less complicated because it has null entity bug fixed

bleak gulch
#

I don't like that idea because engine already knows who and what was the source of specific submunition / penetrator. By adding HitPart EH on the clients basically we have to duplicate the information sent to the server about the shots.

meager granite
#

This is the only way, engine itself only sends very brief damage info to the target which is why HandleDamage is so barren with damage source information

fair drum
#

could the EH be extended further still? or is it at its limit under the hood

meager granite
#

I don't think there is anything else to add, only extend network messages content to include more stuff about the shot

#

I've been trying to ask to add some kind of "damage kind" enum/value so you could distinguish nameless damages apart easily (drowning, fire, fall damage, collision damage, etc-etc) to no success

#

Not sure what could be added to HandleDamage to solve your particular goal

bleak gulch
#

As workaround you can filter everything related to the submunitions, but in this case you have to make a whitelist of your _projectiles.

meager granite
#

It is solvable on shooter side already right now though

#

Btw I was working on connecting HitPart/Explosion with HandleDamage so you could get exact hit info for each damage cycle. Its a huge pain in the ass but possible to some extent

#

HitPart/Explosion order corresponds with HandleDamage order, but only server is able to build full picture because RE is always 1-2 frames late from engine-driven messages

fair drum
#

are you saying use the projectile hit part from fired client side?

meager granite
#

Like you can't use this info to adjust damage/do decision exactly on moment of HandleDamage due to scripted messages always being frame late, but can end up with whole picture on server side and then send that picture to either target or shooter

meager granite
fair drum
#

for bullet then, I'd probably have to do it the old way cause every bullet hit would be a network nightmare

meager granite
#

There you have shots as proper projectiles, you can filter out repeated penetrations, submunitions and only count them as single hit

bleak gulch
#

I am just wondering what happens if the client will drop the bomb on the enemy position with 20-30 units / objects in the area.

#

that's tons of network spam

meager granite
#

I don't think it will be much

#

Having your EH code as optimized as possible is more important than amount of data you send

#

Traffic itself is not really an issue, serialization of it usually is

#

Serialization is CPU time just like EH code, traffic volume is a drop in the ocean nowadays

bleak gulch
#

it's another issue

meager granite
#

You don't need to send entire HitPart arrays either, just check the first entry, see if its same shot entity, if it is, skip

#

What you can do is assign same array into each shot and submunition so it doesn't delete along with projectile

bleak gulch
#

having the attached EH callback which will be called on the client side, then sent to the server via the RE and fired second time to process. And sure, if the victims were local to the server HandleDamage will be fired too.

fair drum
#

Its only 4 reactors per carrier, so it shouldn't be too bad for explosions and rockets. bullets will be problematic though if players damage with LMGs

bleak gulch
meager granite
#

Fired:

_shot setVariable ["reactors_hit", []];
_shot addEventHandler ["SubmunitionCreated", ...];

SubmunitionCreated:

params ["_shot", "_subshot"];
_subshot setVariable ["reactors_hit", _shot getVariable "reactors_hit"];
_subshot addEventHandler ["SubmunitionCreated", ...];

HitPart on reactors:

if(_this select 0 select 2 getVariable "reactors_hit" pushBackUnique (_this select 0 select 0) >= 0) then {
    // First time this projectile or its children hit this reactor, send the data to server!
};
#

This is for 2.18, bit harder in 2.16 as projectile will be null in HitPart

#

I solved this by adding hit stack on relevant targets and projectile HitPart part adding to stack while entity HitPart pop'ed the stack

#

I only added this workaround for bugged simulations, other simulations don't need that

#

This can be solved a bit easier but less optimized by doing the check right inside the projectile HitPart. It will fire for everything it hit though.

bleak gulch
#
// SubmunitionCreated
_subshot addEventHandler ["SubmunitionCreated", ...];

Does submunition create new "sub-" submunition in some cases?

meager granite
#

Yes

#

I think arty mine shells do?

#

But its possible in the engine for sure

#
    class AT_Mine_155mm_AMOS_range: SubmunitionBase
    {
        submunitionAmmo = "Mo_ATMineRange";

    class Mo_ATMineRange: ShotDeployBase
    {
        submunitionAmmo = "ATMine_Range_Ammo";
#

Double submunition creation from same arty shot

bleak gulch
#

yeah, I see

#

Just give us _shotID or _triggerID so we can identity all EHs fired from the single shot (including children submunitions) πŸ™‚

#

just one size_t / long variable πŸ™‚

meager granite
#

Yeah, would be very useful to not jump through such hoops with shooter-side projectile and HitPart event handlers

#

@fair drum if you're going to do this client-side approach I can help with that 2.16 null entity bug fixed easier without any complicated stacks

copper cipher
#

can anyone advise on how to remove unlocked items from my antistasi arsenal?

quaint oyster
#

Is there a way to detect when a player is talking in game with the microphone hotkey? Maybe input detecting the hotkey for speaking?

#

My goal is to make a draw3D a speaker above the player, but first step is figuring out how to detect VoIP activation.

digital rover
meager granite
#

But its more of a UI thing

#

So you might want to broadcast local talking state to others

bleak gulch
#

alternatively if you have to detect the mic key, use key handler and inputAction

queen junco
#

Hey, I am trying to create a script that physicalizes vehicle ammo(So you have an item for rounds and magazines). This is working quite well so far, however I seem to struggle with the vehicle smokescreens. The reloading itself works kind of wobbly with the addMagazineTurret-command. The HUD shows the added ammo only after reentering the commander seat, the reload-time is about 1 minute and it breaks it if you do anything.

When going near a rearmtruck the reload process only takes a few seconds and shows up just fine. Any idea why this happens?
PS: I only tried smokescreens yet, countermessures from planes/helicopters havnt been tested yet.

placid root
#

Do you guys have a suggestion for the sensible use of remoteExecCall ? E.g. is it already too demanding for this command the spawn a composition of about 20 objects?

meager granite
#

Smoke screens usually take a long time to reload in the game

#

I guess it assumes your guy gets out to put the grandes into launchers or something

bleak gulch
#

what's the fastest way to access specific array value (1-dimensional array) and increment it (without using select)

C++

++someArray[idx];
_arr set [idx, (_arr select _idx) + 1]; // <- garbage
placid root
#

Or ist this actually only usefully for really small operations like "hint" or "a+b"

winter rose
#

garbage seems right πŸ˜„

bleak gulch
#

we have vector commands but they require the array to have 2 or 3 elements

winter rose
#

if you want to have fun, vectorAdd [0, 0, 0, 0, 0, 0, 1, 0, 0, 0] 🀣

bleak gulch
#

hm

#

nvm, for some reason it works...

#
[0] vectorAdd [1];
placid root
#

(Executed only on server)

bleak gulch
#

well, vectorAdd produces new array instead of changing the old one 😦

#
PRO_arr = PRO_arr vectorAdd [1];          // 0.0009 ms
PRO_arr set [0, (PRO_arr select 0) + 1];  // 0.0011 ms
stable dune
#

Same result with

PRO_arr = PRO_arr vectorAdd [PRO_arr select 0)+1];

Or to 1st

PRO_arr set [1,1];

You cannot compare diag time because using different solutions

bleak gulch
nocturne bluff
#

what

#

just use it to transmit events?

proven charm
#

we need add command _array add [0,123];

#

adds 123 to 0 index

bleak gulch
#

this is exactly what I need, it won't copy array to the new one with incremented (changed) value

#

set can be used but not without select
vectorAdd can be used but it makes a copy of array. Also for the big arrays you have to fill the vector with the zeroes:

private _arr = [1, 1, 1, 1, 1, ...]; // 1000 elements
_arr vectorAdd [0, 0, 0, 0, 0, ... 2, 0, 0, 0, ...] // add 2 to index 700
meager granite
#

maybe ARRAY inc INDEX and ARRAY dec INDEX

#

Wanted that for a good while

#

Several set in one call, also return array it operated on

#
private _pos = getPosWorld player;
_pos set [2, 0];
_obj setPosATL _pos;
```=>
```sqf
_obj setPosATL (getPosWorld player setN [2, 0]);
bleak gulch
#

not sure about the syntax
ARRAY = ARRAY setN [INDEX_1, VALUE_1, ..., INDEX_N, VALUE_N, (BOOL insertOnly)];

#

But I understand the idea, with this setN is compatible with the regular set

meager granite
#

I dont care about insertOnly flag to be honest, but its there by analogy with normal set's insertOnly flag for hashmaps

#

Array is flat to skip on creating arrays

#

Wish you could createHashMapFromArray with flat array like that too

#

muh microseconds

bleak gulch
#

I mean, probably this one will be more consistent
ARRAY = ARRAY setN [[INDEX_1, VALUE_1], ..., [INDEX_N, VALUE_N], (BOOL insertOnly)];
or
ARRAY = ARRAY setN [[INDEX_1, ..., INDEX_N], [VALUE_1, ..., VALUE_N], (BOOL insertOnly)];
similar to getMagazineCargo format

#

the second option is good if in and/or find commands are used

meager granite
#

The idea was to set many values in one go AND have set command that returns the array it operates on

#

Setting Z to position array is most used case, if array was two-dimentional, you'd have to do getPosWorld player setN [[2, 100]], extra array

#

Sure new arrays are fairly fast, but I was looking at most optimised way for both goals

candid harbor
queen junco
meager granite
#

Ammo trucks reload existing mags (include empty ones)

#

So it reloads already loaded one

queen junco
#

thanks ^^

meager granite
#

setVehicleAmmo also does that

#

But unlike normal spending while shooting which leaves the mags empty in the vehicle, the command deletes them

#

Doing setVehicleAmmo 1 will full up empty mags though

placid root
#

Well I "remoteexec"-ed the creation of a composition. Unfortunately it went really slow. Like one min for 20 objects. So I thought maybe it will be faster when I remoexeccall them. Or did I get the concept of using them wrong.

little raptor
#

Then you can move/resize it freely

bleak gulch
dire star
#

how do i cancel the Amb animation? whenever i [_unit, BIS_fnc_ambientAnim__terminate] remoteExec ["call", 0]; it stops animation for like 5 seconds then he goes into animation again

kindred zephyr
#

1- dont remoteExec calls
2- switchmove

dire star
#

nvm got it to work i anyways i just needed to use script instead setting anim from editor

cosmic lichen
dire star
#

btw can u send me a function just in case im gonna need it?

cosmic lichen
#

ENH_fnc_ambientAnimations_exit

#

I wonder if I forgot to document that. Does it not show in the tool tip?

dire star
#

not sure but ty

proven charm
#

any tips on using "user actions" with addaction?

#

like how am i supposed to tell player to use those πŸ™‚

little raptor
proven charm
# little raptor wdym?

the custom key bindings thing. like im supposed to let player know he can bind keys to the user actions number, that will trigger the addaction

little raptor
proven charm
granite sky
#

yeah but modded keybinding is better :P

#

Get it working once and then it's easy to add stuff.

little raptor
#

At least you know there's no conflict. How many user actions were there? 20?

proven charm
#

yep 20

#

ok thx guys im going to try that

bleak gulch
#

Please don't use key bindings πŸ˜„

#

or at least make it custom

proven charm
#

so with modded keys can they trigger the addAction?

proven charm
#

thx but i dont use CBA πŸ™‚

sullen sigil
#

start using it now

#

theres a reason it exists

proven charm
#

i just want to do this simple thing XD not become mod depend

bleak gulch
#

it's good approach, less code -> less dependency and less errors

sullen sigil
#

if someones modpack doesnt already have cba then theyre using exclusively shitty mods 99.99% of the time

bleak gulch
#

don't need to be so rude πŸ™‚ using framework(s) have its own pros and cons

sullen sigil
#

oh no, the truth

#

anyway

bleak gulch
#

CBA is not ideal, it has some legacy and slow code

sullen sigil
#

prs welcome

bleak gulch
#

binding some actions to the User Keys is not so bad

hallow mortar
#

If someone doesn't want to use CBA just let them not use it. Everything can be done without it.

proven charm
#

so i take modded keybinds wont work with addAction?

sullen sigil
#

certain gamemodes just hanging because theyve run out of scheduler lenience

#

anyway what flavour crisps should i buy

hallow mortar
bleak gulch
#

shortcut: String - (Optional, default "") one of the key names defined in bin.pbo (e.g. "moveForward"). Adding available shortcut will bind corresponding keyboard key to this action. Shortcut availability can be tested with inputAction command

hallow mortar
#

I'd definitely suggest using modded keybinds rather than using the pre-existing custom action keys if you can - it's much more cross-compatible with other mods. (If you're not making a mod then unfortunately you can't make modded keybinds)

#

It looks like modded keybinds are detected by inputAction, so they should also be detected by addAction - same system

proven charm
bleak gulch
#

@lucid hill
don't let your users to use your custom settings as raw scripts!!!

#

it's huge security hole

#

by call compile <option> you basically let them execute the code via console

#

you're supposed to parse the string, filter all characters / symbols and assemble the structures rather than compiling number or the string into the code

#
_string = toArray _string;
_string = toString (_string - (_string - ((toArray "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789_.") + (toArray _separator) + (toArray _separator2))));
#

if it's an array split the string

#
private _result = if (_separator isEqualTo "") then {[_string]} else {_string splitString _separator};
#

if it's nested array(s) then call the split function recursively

#

I strongly recommend you to use the counter to control the call stack size

#

do not ever trust the user even if he plays ArmA πŸ™‚

#

(we're supposed to trust him)

shrewd nebula
#

I have 2 questions:
1- init vs postinit: What is essentially the practical difference (Both seem to do the same thing)?
2- Does having a script file that is triggered by an event handler have different behavior than code executed directly by the event handler?

granite sky
bleak gulch
# shrewd nebula I have 2 questions: 1- init vs postinit: What is essentially the practical diffe...
  1. init is a stage where code in the init fields of the objects are executed
    postInit is useful if you want to execute code if you want to be sure everything related to the specific object is up. For example you have object named "object":
// init. Set the flag which indicates not to move this object
this setVariable ["doNotMove", true];

// postInit. The code which moves the objects grouped in the array
// but only if an object doesn't have a flag set to true
{
    if !(_x getVariable ["doNotMove", true]) then
    {
        _x call fnc_doMove;
    };
} forEach allObjects;

2 - yes, there is slight difference between these two methods of using scripts. When you "trigger" a file (actually you're executing it) it reads from your drive, preprocesses, compiles and then executes. When you call a code directly, the function is already preprocessed and compiled. So it's about performance.

preInit stage is a good place to define your functions. But sure, you're not limited. You even can define the functions sent by the server via the network if you want to counter the thieves. Not very efficient but it can be useful for the events.

For example you're running something like Weekly Opene Games or Tushkino. You don't want to publish the mission file with the spawn points, mission tasks and other stuff. so people on the briefing time (10-60 minutes) could not unpack your mission and gain the advantage over others. You start the mission and all stuff, coordinates, tasks, objects, etc are loaded dynamically. Profit!

Also some script-based anti-cheats are loaded dynamically after mission start.

You have a choice.

#

if you're talking about init.sqf - it's just an option to use it or not

granite sky
#

Oh, object event handlers.

#

Vanilla vehicles don't even agree on which one to use there :P

shrewd nebula
#

So, if I understood correctly, if I'm working on some gear randomization script/code, it would make more sense for it to be triggered by the postinit event handler correct?

bleak gulch
#

I think you can do it even at init stage

#

keep in mind init code is executed on all machines, including JIP

shrewd nebula
#

I did some testing and it worked with both, but I was wondering if there would be some weird multiplayer interactions.

bleak gulch
#

yes, it's possible. For example if you're randomizing the ammo box content using global commands. Each time someone (re)joins the server - the ammo boxes will have the different content

#

it will affect the whole server

#

in this case it's good to execute the code strictly on the machine which always persists inthe network - The Server.

#

for example

#
// init field, executes only on the server
if (isServer) then
{
    // clear the cargo space of the object
    clearWeaponCargoGlobal this;

    // select random magazine classname from the list
    private _randomMag = selectRandom ["magname1", "magname2", "magname3"];

    // select random amount of the mag. From 1 to 6.
    private _randomCount = ceil (random 6); // from 1 to 6

    // Add the magazines to the object's cargo space globally
    this addMagazineCargoGlobal [_randomMag, _randomCount];
};
#

so even if the player will rejoin, the ammo box won't have different content. The magz will be preserved because the content is under server control.

#

But if you remove the if (isServer) block, the behaviour of this script may lead to the problems

#

But sure you can intentionally randomize the content locally, just remove the isServer check and use local commands instead of Global ones

shrewd nebula
#

Alright, thank you. I may have learned quite a few things from this.

ornate whale
#

Will config.hpp be loaded automatically from the root of the mission folder?

fair drum
#

No. Only description.ext. Config.cpp is for mods.

ornate whale
hallow mortar
#

None

#

The extension just tells your code editor what language to do syntax highlighting for

ornate whale
#

OK. Thanks

#

And can I use #include in the .ext file?

hallow mortar
#

Yes

hallow mortar
ornate whale
#

Is it better to have config values which are usually constant in .sqf or in a config file? Is there any rule of thumb/common practice?

granite sky
#

Depends if you need them in config.

#

Note that the preprocessor is (nearly?) the same for both, so it's common when writing UI to have files with just #defines that are included from both SQF and config files.

ornate whale
#

Currently, I use a single .sqf file which initializes all vars as global on the server, like this:

STMOD_CFG_spotAngle = 62.5;
STMOD_CFG_headVisTreshold = 0.50;
STMOD_CFG_bodyVisTreshold = 0.55;
STMOD_CFG_visionDetectCoef = [[20, 1],[500, 0.15]];
STMOD_CFG_detectMeterTimeout = 8;
STMOD_CFG_detectMeterStep = 0.20;
hallow mortar
#

That's perfectly fine as long as you're certain they're initialised before they're needed.

#

Having them in SQF means they can be co-located with all your other scripts, and makes them easier to change later if you do need to do that. Having them in config means all the config stuff is in the config, and you can do things with inheritance and stuff like that.
There's not really a "one's better" AFAIK, it's just whichever suits your purpose or preference.

proven charm
#

defines in include file is one way to go as well

queen cargo
#

just so that i do not have to write this ...
anybody already has a function which gets me the complement of an array?

delicate cedar
#

Hi guys im trying to find a script that counts the amount of alive enemy units of a certain type are in the map. My goal is to adjust the amount of reinforcements to the number of HTV's alive in the map, to give the snipers a valuable objective that can change the course of the battle

For example: if there are 15 "B_support_AMG_F" then [ALIVE_globalForcePool,"BLU_F",2000] call ALIVE_fnc_hashSet;

if there are 10 "B_support_AMG_F" then [ALIVE_globalForcePool,"BLU_F",1700] call ALIVE_fnc_hashSet;

and so on

granite sky
#

What's the definition of "enemy"?

#

And does it matter or is it fine to just count the types?

outer bay
#

If I create an empty helipad (invisible) with this in the init field:

player createDiaryRecord ["Diary",[
"Mission Intel",
"some mission intel here"
]];

and then save it as a composition and place it in a public zeus session, why is it that only I get the briefing added to my player? My assumption was that when the helipad is placed in the world and synced with all clients, the init code runs on each client machine and therefore player belongs to each player's instance. I can't use remoteExec on pub zeus due to security limitations (it kicks you when you try), so is there a good workaround to adding intel via script mid-session?

fair drum
#

As opposed to all machines like the normal editor/game start

undone flower
#

I ran into this issue too

#

use:
removemagazineturret
addmagazineturret
loadmagazine

#

in this order

thin heron
#

is there a script that will add custom unit patches to gear, or you have to mod each pack/uniform/vest?

for example, have someone looking to add unit patch to backpacks. would we have to mod each pack texture or is there a script?

delicate cedar
last tapir
#

hey guys, is it possible to use volumetric fog in a specific area of the map only?

outer bay
# fair drum init code of objects placed in Zeus, only fire on the Zeus machine

I am trying to imitate a zeus module with self-deleting helipad compositions. Does that mean that compositions like Enhanced Zeus Modules only creates modules that run on the zeus' machine as well? https://github.com/expung3d/Enhanced-Zeus-Modules

GitHub

Enhanced Zeus Modules is a Vanilla Arma 3 enhancement script for Public Zeus Servers. - expung3d/Enhanced-Zeus-Modules

#

I can add my own custom modules to a fork of that project, but it will probably yield the same outcome and kick me from the server. I wonder if there is a way to achieve these without remoteExec

fair drum
granite sky
fair drum
#

through description.ext for your mission you do not need to have a mod. if you want it for every mission, you either have to put it in for each one, or make a mod

delicate cedar
#

Ill test it in a couple of minutes

hallow mortar
fair sable
#

I'm trying to figure out what to replace on this script `_o = _this select 0;

_o setVariable ["running", 1];

while {(_o getVariable "running") == 1} do
{

 sleep 0.5;

 _o animateSource ["motor_source", 1];
 
 sleep 14.6;
 
 _o animateSource ["motor_source", 0];
 
 sleep 14.6;

};` I've tried to replace "_o" with my object's variable name but no animation starts or stops

hallow mortar
hallow mortar
#

The most efficient way to use it would be to make a function, but let's skip that for now

#

The script is meant to be used like this:

[object] spawn {
    // insert all of that code here
};```
#

This creates a scheduled script thread (so sleep can be used), and passes your object reference into that thread. The script receives the object reference and turns it into _o.

fair sable
#

oooh okay, I had a laptop with this addAction ["Start Mover","TargetMove.sqf",nil,1.5,false,true,"","",3,false,"",""]; Do I just scratch that and insert the script you pasted?

hallow mortar
#

No. If you've already got it in a separate script file, then you can use that like a function (reusable piece of code called by name rather than typing the whole thing out each time)

#

So, there's a couple of ways to make this work in this context

fair sable
#

Works perfect now thank you!

hallow mortar
#

The first way would be to use addAction's arguments parameter (currently nil in your code)

#

Oh, okay then

fair sable
#

but I think it could use a little cleaning up because I copied this this addAction ["Call Artillery","scripts\arty.sqf",nil,1.5,false,true,"","",3,false,"",""]; no clue what if the rest of the stuff is good

hallow mortar
#

You probably don't need any of the ones after 3 (radius) because they're all optional, they're all currently set to their default values, and I don't think you need to use them for this purpose. But, since they're set to the default values, they're not hurting anything by being there.

fair sable
#

I appreciate your help man, I told myself I'd give it a week and just an hour ago I figured out the sqf was in the pbo lmao

queen junco
ivory lake
#

yeah I dont think the readding the weapon thing works for vehicles

proven charm
#

is it possible to turn the keyboard code/number to the letter (string)?

winter rose
#

sorry what?

proven charm
#

like you have DIK_K for example which represents a number but can you turn it to "K"

winter rose
proven charm
#

nice , ty πŸ™‚

still forum
sullen trellis
#

I have a question, this code below deletes a vehicle when player is 2000m distance away, but I don't want the vehicle to get deleted if any blufor unit was a driver of this vehicle. I tried changing the variable name of the vehicle setting it to "nil" but it still gets deleted, obviously this is a local variable. so How can I achieve this?

_vehicle spawn {  waituntil {  {_x in _this} foreach (allunits select {side _x == Blufor}) }; 
 missionNamespace setVariable ["_this", nil, true]; hint "blufor driver"; 
waituntil {player distance _this > 2000}; deletevehicle _this; hint "delete vehicle";}; 

still forum
#

Your forEach there is nonsense.

waituntil {  {_x in _this} foreach (allunits select {side _x == Blufor}) }; 

is equal to

waituntil { ((allunits select {side _x == Blufor}) select -1) in _this }; 

which doesn't seem like you intended that.

missionNamespace setVariable ["_this", nil, true];
_this is a local variable, you cannot set local variables with setVariable.
And you can especially not make local variables public (with that last true)

#

So you want

if (player is > 2000m away AND the vehicle does not have a blufor driver inside it) then delete the vehicle

right?

sullen trellis
#

yes exactly

still forum
#

instead of going through every unit that exists, and checking if they are in the vehicle.
Which might be hundreds of checks when only one unit is in the vehicle.

You can instead go through every unit in the vehicle, and check if they are blufor. Which would only be one check, instead of hundreds

#

you specifically only want the driver seat? Your old in code would check any seat

sullen trellis
#

any seat, doesnt matter if driver

still forum
#
waitUntil {
  (player distance _this > 2000) && (((crew _this) findIf { side _x == blufor }) == -1)
};
deleteVehicle _this;

Wait until:

  • player has more than 2000m distance to vehicle
    AND
  • trying to find a bluefor unit, inside the vehicles crew/passengers, doesn't find anything.
#

I would also recommend adding a sleep 5; into the top of the waitUntil, so it only checks every 5 seconds and doesn't waste as much performance

winter rose
#

(and deleteVehicleCrew?)

sullen trellis
#

thanks i didnt think of "findIf" , let me try it

still forum
#

alternative to findIf would be count.
Count number of blufor units in the crew, and check if the count is zero.

But if there is blufor unit inside, findIf is more efficient

sullen trellis
#

thanks really nice explanation

dire star
#

if i use switchMove on if isServer do i need to remoteExecute it?

proven charm
#

switchMove takes local argument, so if its player unit run switchMove on client, if the unit is local to the server then run switchMove on server

dire star
#

oh that's why i didn't see animation on player gotcha now so if i spawned createUnit on server i don't need remoteExec switchmove

proven charm
#

yes just run all the code in server

bleak gulch
#

or even less

thin fox
#

Hello. What is the right way to remote call a function? Let's say, remote call to a side or group in specific

bleak gulch
#

remoteExecCall

#

and whitelisting the functions

still forum
thin fox
bleak gulch
#

yep

#

keep in mind it's unschedulled ^

thin fox
#

so no sleep, etc?

bleak gulch
#

yes, no sleep, no slow code

thin fox
#

damn it... is there another way?

warm hedge
#

remoteExec

bleak gulch
#

remoteExec

thin fox
#

well, I tried that but seems it doesn't work

bleak gulch
#

as a test use old good hint

"Hello, World!" remoteExecCall ["hint", _group];
"Hello, World!" remoteExec ["hint", _group];

It should work

#

also

Group - the order will be executed on machines where the player is in the specified group (not where said group is local!)

#

if the specified group is local to some player but the player is NOT in that group, the order will not be executed

#

assuming, the _group has at least one real player

thin fox
thin fox
#

on host it's working just fine, this problem I have on dedi

granite sky
#

If you just want something remoteExec'd once at group locality, you can use groupOwner _group

bleak gulch
#

if you're using CfgRemoteExec, make sure the function is whitelisted

thin fox
#

i'm using CfgFunctions

granite sky
#

So what exactly are you trying to do?

thin fox
#

i'm gonna put it on github

queen junco
#

Hey, I am trying to get the initial Speed of a magazine. However, the hint shows me the Path instead of the value. Why is that?

Thanks for helping ^^

private _currentMagazine = currentMagazine _vehicle;
private _muzzleVelocity = (configFile >> "CfgMagazines" >> _currentMagazine >> "initSpeed");

hint str _muzzleVelocity;
granite sky
#

getNumber

bleak gulch
#

^

#

and one remark

queen junco
#

jup, was missing that >.<

bleak gulch
#

Do not use getNumber πŸ™‚

queen junco
#

thanks a lot^^

bleak gulch
#

some values in the config can be presented as a plain text, then evaluated to the code which return the NUMBER. It mean if you will try to extract the value with getNumber, it will throw an error, "String blah-blah-blah... expected Number blah-blah-blah". In this case it's better to make a small function which check the type of the value and then extracts it converting to number if it's text. Something like this:

fnc_GetConfigValueAsNumber =
{
    if (isNil "_this") exitWith {-1};

    call
    {
        // If config value is number - just extract
        if (isNumber _this) exitWith
        {
            getNumber _this;
        };

        // if config values is text - extract and compile
        if (isText _this) exitWith
        {
            call compile (getText _this);
        };

        -1;
    };
};
#

Here is example where numbers are replaced by the text:
ACE Realistic Dispersion mod / component:

// GM6 Lynx
class GM6_base_F: Rifle_Long_Base_F
{
   class Single: Mode_SemiAuto
   {
      dispersion = QUOTE(MOA_TO_RAD(0.45));
   };
};
granite sky
#

That mod is garbage, don't use it :P

bleak gulch
#

it doesn't matter, I only show it as a sample. Jeroen's Arsenal has the same issue. He extracts numeric values as text and the game throws an error.

#

Antistasi still affected by that

thin fox
bleak gulch
#

You have to be sure you're extracting number when using getNumber.

granite sky
#

Is there any actual reason why they're using QUOTE there though?

bleak gulch
#

No idea

granite sky
#

I'm not sure if you can trust the game to process those correctly.

bleak gulch
#

we have tons of mods where numbers coded as strings

#

including CBA

granite sky
#

It's often done with UI stuff because you need dynamic commands like pixelW

#

but this is just constants.

bleak gulch
#

well, for example I'm using text instead of number in one of my projects:

// M200 Intervention
class LRR_base_F: Rifle_Long_Base_F
{
    class Single: Mode_SemiAuto
    {
        dispersion = MOA_TO_RAD(0.50);
        aiDispersionCoefX = "(1.4 * 0.00018) / (0.5 * 0.00029088)";
        aiDispersionCoefY = "(1.7 * 0.00018) / (0.5 * 0.00029088)";
    };
};

It's just better to understand for me what I am doing πŸ™‚

#

sure, it's just a constant

granite sky
#

shouldn't you use __EVAL?

bleak gulch
#

probably

#

Also... using text which is compiled from config is a security hole

granite sky
#

btw the aiDispersionCoefs are only read from the weapon config, not the fire mode.

bleak gulch
#

Some guys are succefully abusing this way without any BE detection

#

are you sure?

granite sky
#

Yeah, I tested it once.

#

And made notes for a change.

#

Dispersion is read from the mode, aiDispersion is read from the weapon.

bleak gulch
#

hm

granite sky
#

Set high enough values and the effects are pretty obvious :P

bleak gulch
#

Okay, good to know. I'll take a look.

dire star
#

is it possible to use createUnit to spawn unit with exact name for exp his name is John Johnny without using setIdentity or set name after spawning him?

granite sky
#

If you created a unit config with that name, I guess.

#

seems weird to ask that in a scripting channel though :P

bleak gulch
#

if it's related to speed of execution you can use critical section

dire star
#

i've created identities in desc.ext but they only work in sp

bleak gulch
#
isNil
{
    ...createUnit...
    ...change name, identity, sex, habits, favourite music and movies...
};
thin fox
#

I don't what I did, but my function is now working on dedi πŸ‘ it's arma

granite sky
#

setIdentity is local-effect so you need to run it everywhere, including JIP.

dire star
bleak gulch
thin fox
dire star
#

but yea nvm i think it's probably due to DUI radar not reading the names cause i think code is correct

thin fox
granite sky
#

ACE name needs to be set separately. Not sure what DUI uses.

dire star
#

ik it works in SP i've delayed spawns on each units cause when they spawned all on same time nobody recived name so i delayed a lil bit and i can see names in SP but when im playin MP i haven't seen any names, but i do see name i've set when i go edit unit with zeus

granite sky
#

Where are you looking?

dire star
#

when you dobule click on unit u want to edit in zeus u can see his name is correct as i set it but im seeing different on DUI radar

bleak gulch
thin fox
bleak gulch
#

Global variable without prefix: myVariable = 1;
Global variable with prefix: PiG_myVariable = 2;

#

PiG_ is your prefix

thin fox
#

Ah okay

bleak gulch
#

if you don't do that there is a high risk of intererring the same named vars

thin fox
#

but the rest of the code is okay?

bleak gulch
#

this type of errors is very hard to debug

#

use private keyword when you define your local variable, for example

granite sky
#

Looks like DUI has its own name variable that gets set on unit init.

bleak gulch
#

scripts/PiG_halo.sqf

_teltime = 5

// must be

private _teltime = 5
granite sky
#

why do mods do this :/

dire star
granite sky
#

timing.

dire star
#

anway i can change it?

granite sky
#

Yeah but I have to reverse engineer this mod first.

#

fucking QGVAR

bleak gulch
#

lol

dire star
#

btw u said timing u mean i need to spawn them in same time to see name i want or?

bleak gulch
#

pronounced as "Kugvar"

granite sky
#

actually there might be at least two different vars you need to set.

thin fox
#

thank you @bleak gulch

granite sky
#

I mean you're fighting against a mod that's doing something at a time that Arma doesn't define.

#

wait, it also has a loop over allUnits setting this shit?

bleak gulch
#

are you talking about DUI?

granite sky
#

yeah

#

the nametags PBO specifically, which I'm not sure is even the one you care about :P

#

_x setVariable [QGVAR(name), _x getVariable [QEGVAR(main,customName), _x getVariable ["ACE_Name", name _x]]];

#

...beautiful

#

Maybe you can just set ACE_Name.

dire star
#

I mean i just don't understand how it works in SP but not MP πŸ˜‚

dire star
granite sky
#

Are you running ACE btw?

dire star
#

yea both ACE and DUI

granite sky
#

Ok, worth a shot to just _unit setVariable ["ACE_name", "whatever", 0]

bleak gulch
#

the names make sense if you're running campaign

granite sky
#

Although that's faster than remoteExec timing so it might not work.

dire star
#

i mean im making BHD based on movie and i wanted to add some details like unit names for crucial Units

bleak gulch
#

that's good approach.

dire star
#

some that are made in editor have names so i wanted to make them then all have names ik were said in movie

granite sky
#

Actually better:
_unit remoteExec ["ace_common_fnc_setName", 0];

#

actually, make your own function that runs setIdentity locally and then the ace function.

#

Otherwise you can't guarantee the order with setIdentity.

#

but try that remoteExec as a test first.

#

Not really clear whether DUI will pick up on it or not.

dire star
#

so how do i include it then in my script im kinda lost tbh πŸ˜‚

formal stirrup
#

Needing some help with positions and stuff, Currently doing some floaty BS and its grabbing the player's model to world with an offset to set a positon to where the player moves, Currently it only functions with 6 positions all relative to the map [x,y,z], And with it being static directions diagonals work fine, But now after swapping back to modelToWorld X isnt always X relative to the player and diagonals wont work because of that. Anyone have ideas on how I could fix that?

findDisplay 46 displayAddEventHandler ["keyDown",{  
        params ["_ctrl","_key"];  
        _posArrow = getPosATL arrow; 
        _pos = getPosATL player; 
        newPos = _posArrow;
        newPosX = _posArrow; 
        newPosY = _posArrow; 
        newPosZ = _posArrow;
        if (_key == 42) then { 
        WBK_Boost_Capacity = player getVariable ["WBK_Boost_Capacity", 1000]; 
        if (WBK_Boost_Capacity <= 0) exitWith {WBK_SpeedFloat_Acc = 6}; 
        WBK_Boost_Capacity = WBK_Boost_Capacity - 10; 
        player setVariable ["WBK_Boost_Capacity", WBK_Boost_Capacity]; 
        player setVariable ["WBK_IsBoosting", true]; 
        WBK_SpeedFloat_Acc = 12; 
        }; 
        if (_key == 57) then { 
                //arrow setPosATL [_pos select 0,_pos select 1,(_pos select 2) + 6];  Up
                newPosZ = [_posArrow select 0,_posArrow select 1,(_pos select 2) + (WBK_SpeedFloat_Acc / 2)]; 
        }; 
        if (_key == 46) then { 
                //arrow setPosATL [_pos select 0,_pos select 1,(_pos select 2) - 6]; Down
                newPosZ = [_posArrow select 0,_posArrow select 1,(_pos select 2) - (WBK_SpeedFloat_Acc / 2)]; 
        }; 
        if (_key == 17) then { 
                //arrow setPosATL (player modelToWorld [0,WBK_SpeedFloat_Acc,0]); Forwards
                _vel = (player modelToWorld [0,WBK_SpeedFloat_Acc,0]); 
                newPosX = (player modelToWorld [0,WBK_SpeedFloat_Acc,0]);
        }; 
        if (_key == 31) then { 
                //arrow setPosATL (player modelToWorld [0,-WBK_SpeedFloat_Acc,0]); Backwords
                _vel = (player modelToWorld [0,-WBK_SpeedFloat_Acc,0]); 
                newPosX = (player modelToWorld [0,-WBK_SpeedFloat_Acc,0]); 
        }; 
        if (_key == 30) then { 
                //arrow setPosATL (player modelToWorld [-WBK_SpeedFloat_Acc,0,0]); Left
                _vel = (player modelToWorld [-WBK_SpeedFloat_Acc,0,0]); 
                newPosY = (player modelToWorld [-WBK_SpeedFloat_Acc,0,0]); 
        }; 
        if (_key == 32) then { 
                //arrow setPosATL (player modelToWorld [WBK_SpeedFloat_Acc,0,0]); Right
                _vel = (player modelToWorld [WBK_SpeedFloat_Acc,0,0]); 
                newPosY = (player modelToWorld [WBK_SpeedFloat_Acc,0,0]); 
        }; 
        newPos = [(newPosX select 0) + (newPosY select 0) - (newPos select 0), (newPosX select 1) + (newPosY select 1) - (newPos select 1), (newPosX select 2) + (newPosZ select 2) - (newPos select 2)]; 
        arrow setPosATL newPos; 
}]; 
bleak gulch
#

kek

dire star
#

i can send you the script file if u want

granite sky
#

Don't. Just try it in the console

#

Question is whether the method can work at all. It'd take me a full day to disentangle DUI to be sure otherwise :P

#

You can tell whether the command worked by what name is shown in the ACE medical display, but then it's an open question whether DUI picks it up.

bleak gulch
#

unpack DUI and find where it picks the name, from which variable and / or command

dire star
#

yea i think neither ACE picked it up in MP cause as i said i see name i've set when i open unit in zeus editor but when i killed it and picked up dog tag it was different

granite sky
#

Yeah, that's normal.

bleak gulch
#

Why don't you use vectorized commands?

#
newPos = [(newPosX select 0) + (newPosY select 0) - (newPos select 0), (newPosX select 1) + (newPosY select 1) - (newPos select 1), (newPosX select 2) + (newPosZ select 2) - (newPos select 2)]; 
#

It's basically adding / subtracting the vector components

formal stirrup
dire star
granite sky
#

You know how to use the debug console, right?

dire star
#

yea nvm i tought u said to make script to only run locally

granite sky
#

I'm just telling you to test whether changing the ACE name (locally) also changes the DUI name.

#

The ace function, run as local is just _unit call ace_common_fnc_setName;

#

but you'd need to identify the target unit somehow.

#

cursorObject if you can walk up to them.

dire star
#

i'll spawn unit on me w name so i'll try that

still forum
dire star
#

weeeell, c1_steele setVariable ["ACE_name", "Steele", 0]; works

granite sky
#

IIRC there is a good reason to call the ACE function instead :P

#

but I guess you have a potential solution now

bleak gulch
#

I bet in the past I had bad experience with the numbers coded as strings in the config!

granite sky
#

That code in the wiki comment for getNumber would break, I guess, because it checks isNumber.

#

I wonder if the engine ends up running multiple SQF snippets to fire each bullet.

bleak gulch
#

case (isNumber _cfg): { getNumber _cfg };
just won't work

still forum
granite sky
#

BIS_fnc_getCfgData does the same thing and would return a string.

dire star
bleak gulch
#

exactly, user has to "type cast" the extracted value explicitly

granite sky
#

Or you just use getNumber because it's supposed to be a number :P

bleak gulch
#

For some reason it didn't work for me year or two ago. I see it works fine for now. What happened?

granite sky
#

shrugs

still forum
#

Its been like this since ofp
or arma 1.. whenever configs were introduced

bleak gulch
#

Can you clarify what's the best practice?

// CASE 1: contains variable, which initialized at runtime
x = "3.14 * r * r / 2";
y = __EVAL(3.14 * r * r / 2);

// CASE 2: no variables, just expression
w = "3.14 * 1 * 1 / 2";
h = __EVAL(3.14 * 1 * 1 / 2);
still forum
#

Eval will evaluate it at game start when config.cpp is loaded.
For config.bin it depends on what the Tool binarizing the config does.

The other is executed on access

#

Eval is config parser so it would run at parse time.

If you have a binarization tool like CfgConvert, that can execute the script when it packs it to config.bin. that's the best way.

With variables it cannot pack it into bin and I don't know if it will do a eval at load or at access then.

#

Your w and h example though looks like it's for a UI.
And these usually depend on uiSize and screen resolution.

So if you pre-evaluate these offline, or at game start. Your UI will get messed up when user changes resolution or UI scale

proven charm
#

__EVAL works good in mission (also mis configs) #defines

still forum
#

Eval has nothing to do with preprocessor and #defines

#

Also you must use eval if you want to script a string entry.

proven charm
#

dunno, i just do #define CALC_PRICE(p) __EVAL( ceil (p) ) for mission config stuff etc

bleak gulch
#

@winter rose I think @still forum answers should be placed somewhere in the BI Wiki, because it's a bit confusing when you have two ways to use expression in config.bin but has no clear way to do that.

winter rose
bleak gulch
#

we have, but there is no use-case examples for the __EVAL vs " "

winter rose
#

pls provide, I don't know these things 😬

bleak gulch
#

oh... it was Mikero responsible for the __EVAL, okay)

still forum
#

Only usecase I've seen is random loading screen in description.ext

nocturne bluff
#

why would you remoteexec it?

bleak gulch
#

so as I understood for the config.bin, at runtime it's better to use TEXT if there is/are variable(s) involved into expression. And __EVAL if expression is not dependent from the variable(s) (or any data which can be aquired at runtime) and it's just a constant, because that expression can be evaluated by the PBO packer saving some CPU time on game load?

winter rose
vapid scarab
#

link for quick reference: https://community.bistudio.com/wiki/remoteExec

I am currently having an issue with remoteExec jip.
Case 1: I call a remoteExec spawn that adds multiple actions to a data terminal object.

fnc_function = {
params ["_terminal"];
_reString = [[_terminal],{/*Add Actions and hint 'hello world' for testing*/}] remoteExec ["spawn",0,_terminal];
hint _reString; // Hints "2:6899"
};
[_terminal] call fnc_function;

This is not JIP as when I connect a second client, it does not run on and does not hint a jip player.
This is ran in debug console using local exec.

Case 2: I run the remote exec directly in debu

_reString = [[terminalObject],{/*Add Actions and hint 'hello world' for testing*/}] remoteExec ["spawn",0,terminalObject];
hint _reString; // Hints "2:6899"

This is JIP.

Both return a jip string, but only case 2 works.....

#

Does anyone know why?

bleak gulch
#
[_terminal] call fnc_function;

is _terminal defined in this scope?

#

probably should be

[terminalObject] call fnc_function;
granite sky
#

A limitation of remoteExec JIP using the object as JIP ID is that you can only do it once. If you have any other code that uses the same object as JIP ID then only the last one executed remains in the JIP queue.

vapid scarab
vapid scarab
tough abyss
#

Hello, I’m working on a single player campaign.

I’m having trouble saving the inventory of a crate and loading its inventory in another mission. Does anyone know how to do this by chance?

I got it to work with the player’s inventory, but can’t seem to get it with a weapon crate

vapid scarab
tough abyss
#

Thanks!

tranquil nymph
devout geode
#

Does anyone know how to use Jeroen-Notenbomer/Limited-Arsenal? Like adding it to a mission? Read the readme and still having issues

granite sky
#

Server-side init:

["Preload"] call jn_fnc_arsenal;
arsenalBoxObject call jn_fnc_arsenal_init;

Then to add the action on clients:

arsenalBoxObject addAction ["Arsenal", jn_fnc_arsenal_handleAction];
#

This assumes that you have it registering the functions already.

devout geode
minor chasm
#

Didn't mean to ask the question here <.<

molten yacht
#

RopeCreate implies that it has to be a transport vehicle that you spawn a rope from. Is there any way to spawn a rope dangling from an arbitrary item / connecting two arbitrary items?

granite sky
#

huh, they don't even define transport vehicle. They just give a list...

molten yacht
#

Yeah, the wiki's vague, and I just want a rope dangling off of a ledge.

granite sky
#

I guess you could attach one of the smaller objects there and hide it.

#

this list is hurting my soul

queen cargo
#

@hasty violet yes, the group will have additional calculations
but those are async anyway and you do not rly need to care about em as they are no massive performance impact

#

write your scripts nice
that will affect the performance more then some additional groups running native code

hallow mortar
# granite sky this list is hurting my soul

That list smells like such BS. The broken wave power buoy is counted? Helipad lights? Sound set sources? And this was updated somewhat recently too since it's got Contact stuff. Someone's been actively checking this.
There must be something, config probably, that actually controls this, and they just haven't figured out what. Or it's actually just any PhysX object and the person who wrote this is an idiot.

pulsar bluff
#

it’s bothersome to not have some invisible helper objects

#

like rope attach point objects with good simulation

#

mods like CBA add these, but they should be in vanilla

#

same with things like invisible AI targets

tough abyss
#

My educated guess would be that more groups require more computing time.

acoustic abyss
#

I have faked an underground chamber during a night mission. Problem: the moon is reflecting on the water. Figured I could hide it using setDate in a trigger when players enter/exit. But I read that date values are periodically synchronized with the server. What would you recommend as a solution?

warm hedge
#

Maybe weather is a workaround

acoustic abyss
#

I tried setOvercast, and it sortof works. Will have to disable environment sounds as well. But isn't that also synchronized?

warm hedge
acoustic abyss
#

Very cool. Can you recommend/link me some default values?

warm hedge
#

An example would be located in configfile >> "CfgWorlds" >> "Stratis" >> "Weather" >> "LightingNew" >> "Lighting0" and other classes. Since it should have completely different lighting in and out, you can re-write the lighting I guess?

#

It would require a bit to get the desired result though

still forum
proven charm
#

__EVAL shows error if something goes wrong

#

but sometimes it fails silently and config variable when obtained with getText will be "scalar NaN". or "any" in some cases

sullen trellis
#
waitUntil {isTouchingGround player}; hint "Player on ground";

why does this not work? even if player is in some height it still triggers

proven charm
#

where you run that?

sullen trellis
#

in an active trigger

proven charm
#

does the player start in air?

warm hedge
#

Why you're using waitUntil within a trigger?

sullen trellis
sullen trellis
warm hedge
#

Even if it is a test, what is the concept you want to achieve

#

Because a trigger already waits the condition to filfull

proven charm
#

the script should work probably issue is where its being run

sullen trellis
#

its for an enemy group that spawn dropped by helicopter, once they are on ground they start hunting/ moving to player

proven charm
#

but dont you need to check the enemy soldiers rather than player in that case

sullen trellis
#

true, but i always like to test before creating a whole code

proven charm
#

oh ok

warm hedge
#

The point still stands. You can use a Trigger or waitUntill, not both

#

Also you can't even use waitUntil within Trigger's onActivate too

acoustic abyss
#

I am trying to get players to teleport between ladders, in order to make a tunnel entrance sort of seamless. See picture. Problem is that I don't know how to teleport players between ladders (the dotted arrows). The command-

player action ["ladderUp", ladder_1, 0, 1];

Will move players unto ladders, but not if they are currently climbing one. In that case, the command will execute once the player steps off their current ladder. I tried using actionNow, but am getting a syntax error. Does anyone have experience with this?

#

PS please don't make fun of my colonoscopy sketch.

warm hedge
#

Unfortunately you can't. Ladders are one of the most not loved feature

#

Also actionNow is a 2.18 command

sullen trellis
#

i just tested the code in an eventhandler in sqf file, but still triggers even if units in air

 if ({isTouchingGround _x} foreach units hunt_group1) then { hint "hunting group"; hunt_group1 move position player;};
warm hedge
#

Wait you're not using a Trigger?

proven charm
#

foreach doesnt go to if use count instead

warm hedge
#

And what is the eventhandler you mean here

sullen trellis
#

"foreach" is working, "count" not working, also its an eventhandler "suprressed" that runs everytime an enemy shoots towards player, in conclusion everything is running smooth, only the "isTouchingGround" doesnt work properly, it triggers even if units in air

still forum
#

if ({isTouchingGround _x} foreach units hunt_group1)
That code is equal to
if ( isTouchingGround ((units hunt_group1) select -1) )

You are only checking the last unit in the array

sullen trellis
still forum
#

How does the unit get into the air?

sullen trellis
still forum
#

by itself without any vehicle?

sullen trellis
still forum
#

So by the time you call isTouchingGround, its in a vehicle?

sullen trellis
still forum
little raptor
still forum
#

It works for me if unit is not in vehicle

sullen trellis
#
if (isTouchingGround player) then {hint "Player on ground";};

but even the simplest codes like this wouldnt work why?

little raptor
#
units hunt_group1 findIf {!isTouchingGround _x} == -1

It means all units are touching the ground

still forum
little raptor
#

If units are in a vehicle you need to check if the vehicle is touching the ground:

units hunt_group1 findIf {!isTouchingGround vehicle _x} == -1
little raptor
sullen trellis
mystic scarab
#

Is it possible to set custom AI Interact actions for objects? Like how you can point to a vehicle and have the contextual interact option "get in"

little raptor
#

They mean the AI command menu

mystic scarab
little raptor
#

Afaik no. But you can check for yourself
iirc the class name was RscMenuRoot or RscMenuGroupRoot (or maybe main instead of root)

#

In config

#

You can probably add your own items to it, but not sure if you can interact with an object with it (i.e. whether it's context aware and whether it passes the context object to the script)

mystic scarab
#

Thanks for answering, that seems more complex than the addAction option so I'll go with that. Do you know if it's possible to order AI to execute an action set on an object or does the action need to be set on the AI?

proven charm
#

addaction is something used by the player

little raptor
astral saddle
#

Hey there, Im looking for a script that allows for ambient AA fire in the backround. Burst of like 3 seconds then a pause for 5 etc and rearm script if possible

proven charm
astral saddle
#

A small bit

#

Not enough to be brainy to do this though haha

proven charm
#

well i hope you find what you are looking for

astral saddle
little raptor
#
  • lockCameraTo if you want to fire at dummy targets
dire star
#

not sure where to ask but, prob asked before too, any suggestions how to prevent videos from having delayed sound when played with BIS_fnc_playVideo? Idk if that's due to my recording software or it's just arma being arma

agile pumice
#

thanks ian but I was hopng for a proper formula rather than another loop

#

I was thinking 70/distance should cut it

nocturne bluff
#

@tranquil nymph lets hope, the next best solution is selectplayer into the unit

hallow mortar
night dove
#

Has anyone got a KAT class name list?

#

For whitelisting in the arsenal, just to save time

molten yacht
#

What's the best way to convert an object to a simple object in place for MP? Can I do something with the init fields in a way that holds up if I need to copy and paste objects a lot?

#

Some way that scales into the low hundreds would be ideal.

daring cave
#

I'm trying to make a vehicle destroy if it receives greater than or equal to 0.5 damage, can someone fix this?
{this addEventHandler ["Dammaged", {if ((_this select 2) <= 0.5) then this setDamage 1;}];}

ornate whale
#

Hello guys, does any of you know how I can, roughly speaking, synchronize all events which fired in a single frame. I mean, how I can be sure, that all the EHs in that frame has already been executed before I execute a follow-up function which would do something based on those events, like solve a conflicting situation, etc. The only thing I came up with is to do the generalizing operation in the frame right after. What do you think? Thanks

Like this:
EH1,
EH2,
MyFunction.

Not like this:
EH1,
MyFunction,
EH2.

bleak gulch
molten yacht
#

i.e. how do I properly do this in a way that's JIP friendly

bleak gulch
#

or [_damage, 1000] select {_damage >= 0.5};

bleak gulch
fair drum
bleak gulch
fair drum
#

gets me every time. you'd think it would be [true, false] intuitively

molten yacht
#

Is there a way to get both the vector dir and up in a way that enables one to run setvectordirandup safely?