#arma3_scripting

1 messages ยท Page 676 of 1

golden storm
#

I think i get it, thanks a lot

analog walrus
#

exactly what I was looking for, thanks

golden storm
#

This worked great! now i just need to solve the position problem (he's on an elevated corridor, so he will be floating at start, so the game won't activate the script at all

fair drum
golden storm
#

But, that's another story, thanks a lot @fair drum

#

Nah, that's the whole script

#

i'm using this in the mission.sqf

this setPosATL [1252.139,3388.702,3991.821]

Besides that, they're just calling the script:

test1 = [this] execVM "scripts\animation.sqf";
fair drum
#

you mean init.sqf? hopefully not putting that in mission.sqm

golden storm
# fair drum you mean init.sqf? hopefully not putting that in mission.**sqm**

No no, i meant, i'm using the init of the unit from the mission.sqm to place the position (is going to be on dedi), and besides the setPosATL they have that little code for calling the animation script, they don't show an error, they just don't execute it but i think it's because they're "floating" in the air for the game engine (even if they're on "solid" ground, in a corridor)

fair drum
#

i'm just wondering why you aren't just using the editors init box to edit things like that and instead going directly to the sqm?

golden storm
fair drum
golden storm
#

yup, i think that's the issue

#

Mainly with the switchmove, because i have 2 other AI but executing "ambientAnim" and they're just fine

#

Nope, didn't work, i think it's just that the map's bugged or something, even disabled "PATH", but it seems the AI will "swim" in the air, then it will not keep the animation, it's weird because if i'm not wrong, it should call it again after 16 seconds, yet it doesn't

fair drum
#

try it on the ground first before you put it in the air and you'll get your answer.

#

i know after a certain height the game goes, yeah that unit is skydiving

#

which there is no way around that afaik

golden storm
#

Anyways, thanks a lot for the help (and the patience)

opal turret
#

Anyone heard of something like this causing disconnects for JIP?

Been having a really difficult-to-pinpoint issue with JIP players getting disconnected after about ten seconds from joining. Resorted to pulling each script until the problem went away and I believe I've isolated it to a script that plays ambient sounds from inside random buildings.

[_chosenBuilding,[_chosenSound, 50, 1, true,0]] remoteExec ["say3D", 0, true];

Building is chosen at random via nearestObjects, sounds are chosen at random and are defined in description.ext (which just points to vanilla sound files).

fair drum
#

maybe try instead of doing true for JIP handle, do _chosenBuilding to tie the JIP to the building itself?

#

idk if it would do anything, but it might be worth a try

opal turret
#

If it fixes the issue I'll probably just remove the JIP portion altogether as it's not game breaking, but I'll definitely try your suggestion first, thank you for that.

Just can't wrap my head around why it would be dumping JIP players and preventing them from joining.

Maybe it becomes an undefined variable and hangs up the player at start until they're kicked? No idea.

trail smelt
#

Exist script which automaticly add editable all objects to all zeus clients .. ?

cosmic lichen
#

Check the note

long hatch
#

Thanks to Dedmen for the help yesterday. I have found a solution to my problem. And sorry for my English, unfortunately it is not my native language.

proven charm
#

what would be best way to implement interactable map objects?

real gorge
proven charm
#

I want an army represented on 2D map and be able to click it and move it around. the army would only exist on the 2D map

copper raven
#

mouse event handlers/drawicon ?

proven charm
#

@copper raven yea that could be one way to do it, still looking for the best way...

real gorge
#

Sorry I can't help ya there, I'm struggling with the vehicle respawn module. It looks like my ignorance of locality might be the issue. I can get it to respawn the vehicle I am driving and add the init I want but my second player on our LAN hosted game receives no init.
(_this select 0) setVariable ["vic2", 123]; (_this select 0) addAction ["<t color='#FF0000'>REPAIR</t>", {vic2 setdamage 0}];

copper raven
#

use remoteExec

real gorge
#

thanks @copper raven I did try a few different hack jobs with that, I've taken too many head bonks I think I can't figure out the right sequence to put it in =/

copper raven
trail smelt
signal kite
#

Hello! I'd like to assign each group a waypoint, but it just doesn't work - any clues?

_array = [O Alpha 1-4,O Bravo 4-6,O Charlie 1-1];
{_x addWaypoint [[15000,17500,0],500];} forEach _array;
copper raven
copper raven
trail smelt
#

mission init

#

yea i start mission on dedicated server

proven charm
#

how can you check if mouse cursor is over the icon drawn by drawIcon? in 2D map

warm hedge
#

getMousePosition, ctrlMapScreenToWorld, distance2D

proven charm
#

ok thx POLPOX I was looking at those commands but havent exactly yet figured them out lol

#

got it now, thanks again!

copper raven
#

use inArea getMousePosition inArea [_ctrlMap ctrlMapWorldToScreen _iconPosition, _iconWidth / 640 / 2, _iconHeight / 480 / 2, _direction, true]

#

a lot more accurate than trying to calculate something with distance/zoom

proven charm
#

hmmm I was thinking of scaling the distance check to ctrlMapScale

still forum
real gorge
#

Would anyone be kind enough to point out how badly I'm screwing this up? I've tried many variations and it's probably way off at this point. (trying to get vehicle respawner to work for second player on LAN)
[_this select 0, ["vic1", 123]] remoteExec [setVariable]; [_this select 0, vic1 setdamage 0] remoteExec [addaction];
just realized I'm missing the "repair" section for my addaction for starters

copper raven
winter rose
real gorge
#

lol I tried! Thanks again @copper raven Like I said head bonks

warm hedge
#

How about regexFind that returns [[match pos1 start,match pos1 end],[match pos2 start,match pos2 end],...]?

polar anchor
#

hi, i'm trying to call a function i created but it doesn't get find

#

inside description.ext i have:

{
    class CRM
    {
        class Functions
        {
            class showWarning {file = "scripts\CRM_fnc_showWarning.sqf";};
        };
    };
};```
#

where path in file = "path", is the path of the file

#

containing the func

warm hedge
#

Make sure you saved the mission everytime you modify description.ext

polar anchor
#

i did

#

i try to call it via: execVM CRM_fnc_showWarning.sqf; and it doesn't get found

copper raven
#

๐Ÿค”

cosmic lichen
#

file = "scripts";

#

the name of the file should be fn_showWarning.sqf

polar anchor
#

why not

winter rose
#

you don't execVM a function, you spawn or call it

#

you execVM a string, a file path

copper raven
#

your function will be compiled to CRM_fnc_showWarning in mission namespace, so just <args> call/spawn CRM_fnc_showWarning

polar anchor
#

i tried many times with call

#

call CRM_fnc_showWarning.sqf;

#

i get "generic error"

winter rose
#

of course

#

no ".sqf"

polar anchor
#

oof

winter rose
#

do you execute BIS_fnc_endMission.sqf? nope

still forum
warm hedge
#

Great to hear, Ded

still forum
#

This is just proof of concept telling me I can do all the regex things ez

copper raven
#

also regexReplace would be nice (don't know if its in the list) blobcloseenjoy

polar anchor
#

Now I donโ€™t get the error anymore but calling the function does nothing

#

Even if it should

#

I renamed the file fn_showWarning.sqf

#

But Description.ext is the same

copper raven
#

so you renamed the file, but didn't change the filepath in the cfgfunctions?

polar anchor
#

Same except for that

polar anchor
#

oof nvm

#

i had to call it via CRM_fnc_showWarning

#

and not fn_showWarning

signal kite
copper raven
#

well it depends how you have it setup, you can give them a variable in the editor

cosmic lichen
polar anchor
#

yeah thx

signal kite
cosmic lichen
#

_groups = call yourFunction;

#

?

copper raven
#

save them to a variable, and use it with your other functions

#

if you're constantly spawning them, just keep appending them to some array

TAG_groups = []; // init

private _groups = ... call tag_fnc_spawnGroups; // whatever it is
TAG_groups append _groups;
#

then you can loop through them like you were asking initially through TAG_groups variable

signal kite
#

ok, now I think I get it: the array of group names I get to see is just a "representation" not the actual thing. So I can't just copy-paste it like an array of numbers.

copper raven
#

correct

signal kite
#

thx

winter rose
#

if you do some (other) development, what you see is a "toString()" representation

signal kite
winter rose
#

nope, you cannot "write a group"

#

you can name them though

signal kite
#

using setGroupId!?

copper raven
#

no

#

through a variable like i told you

little raptor
little raptor
#

STL's default is $

still forum
#

I use STL

#

unless there's a problem it should be 1-to-1 with STL

little raptor
#

nope just wanted to check notlikemeow

still forum
#

yeah is valid question :u

little raptor
#

I still have no idea what ":u" means meowsweats

#

and google doesn't help either!

still forum
#

:U

#

Just to make people stay quiet :U

proven charm
#

does hashmap support count?

#

I mean with condition code?

willow hound
proven charm
#

no mention of hashmap there

winter rose
#

thereforeโ€ฆ?

willow hound
#

Then it probably doesn't work ๐Ÿ˜‰

proven charm
#

yeah got error

#

but will it be supported? ๐Ÿ˜‰

still forum
#

Don't see why

#

what would you want to count?

proven charm
#

count some hashmap sub elements

still forum
#

example?

#

can't see anything that keys/values wouldn't also work fine for

proven charm
#

something like { _y # 0 == west } count forces

still forum
#

yeah values command would work fine enough

#

not worth the effort to implement count

proven charm
#

alright ๐Ÿ™‚

#

thx

#

but to be clear. _x would be the key and _y the value, which is an array

still forum
#

yep

proven charm
#

๐Ÿ™‚

cosmic lichen
#

What's the easiest way to add the values of two arrays e.g. [1,1,1,1] to [3,5,6,4]

winter rose
#
private _result = 0;
if (count _arr1 > 0) then { private _toAdd = _arr1 select 0; _result = _result + _toAdd; };
```etc ๐Ÿ˜„
little raptor
#

you mean like vector sum right?

#

the result should be [4,6,7,5]?

cosmic lichen
#

I mean like vectorAdd but for 4 dimensions ๐Ÿ˜„

little raptor
#

apply then notlikemeow

winter rose
#

vectorAdd does it now no?

cosmic lichen
#

The result will be in UI screen coordinates, so anything is possible ๐Ÿ˜„

#

vectorAdd is only 2D and 3D

little raptor
#

Dedmen said he was gonna fix it to take any number of elements

#

not sure if he did

cosmic lichen
#

Probably not

winter rose
#

I member Ded & KK arguing about it yeah

little raptor
# cosmic lichen Probably not

I think he might've done something. because he even was arguing about the performance with KK notlikemeow
KK said it would be slower, but Ded tested it and said there wasn't much difference

cosmic lichen
#

well on dev vectorAdd just trims the array to 3

little raptor
#

for now just do apply
or even for notlikemeow

winter rose
#

then I believe BIS_fnc_vectorAdd does it - yet somehow I doubt the perf? ๐Ÿ˜„

cosmic lichen
#

It does

#

and Idc about performance

#

Ty

#
params ['_ctrlButton']; private _pos = ctrlPosition ((ctrlParent _ctrlButton) displayCtrl 2401);\
      _ctrlButton ctrlSetPosition ([_pos, [_pos # 0 + (((safezoneW / safezoneH) min 1.2) / 40), 0, 0, 0]] call BIS_fnc_vectorAdd); _ctrlButton ctrlCommit 0;

might work ๐Ÿ˜„

willow hound
#

Why not use set (as you're only changing one index)?

winter rose
#

to inline it I suppose?

cosmic lichen
#

I could use set

#

but why would I ๐Ÿ˜„

#

Might actually get a different fix anyway.

polar anchor
#

how do i know the content of #include "\a3\ui_f\hpp\definecommoncolors.inc"?

#

Colors used in Arma 3, like background color set by the user.

#

but what are the actual macros?

little raptor
#

you can just unpbo ui_f.pbo

#

and find it there

polar anchor
#

ty

cosmic lichen
#

use 3den Enhanced and open the Functions viewer ๐Ÿ˜‰

digital hollow
#

Is this the best way to make a copy of an array? _a = _b apply {_x}

little raptor
dusk galleon
#

What I intended to do
Player acquires weapon -> Player doesn't shoot for X seconds -> Trigger is activated, instructor says something -> Player doesn't shoot for another X seconds again -> Trigger reactivates on its own, instructor says something again
(Basically trigger reactivates on its own every X seconds)

What I got
Player acquires weapon -> Player doesn't shoot for X seconds -> Trigger activates, instructor says something -> Is only activated once -> Player shoots, timer resets -> Once player doesn't shoot for another X seconds, then only trigger reactivates, instructor says something

#

so if i did it like this:

#

playerLastFired + 15 <= time && someAmmo player && triggerActivated t8

while [true] do {
[] spawn {sleep 15; mikee say "Voice17"};
[] spawn {sleep 15; VO sideChat "You okay? Are you going to shoot or what?"};
};

#

will it work?

warm hedge
#

Never

winter rose
#

while [true] is incorrect

dusk galleon
#

{True} ?

warm hedge
#

Also absolutely no point to [] spawn {sleep 15; twice if you wanted to do it in the same timing

winter rose
#

use { } with while

also, all it would do is every cycle create two waiting threads, unlimited

dusk galleon
#

hmm

winter rose
#

(and maybe run out of memory, too)

warm hedge
#

And you put this into a trigger? Without spawn'ing?

dusk galleon
#

huh, no

#

just an idea i came up with

#

haven't actually put it in

warm hedge
#

Write first, run second, debug last

dusk galleon
#

yeah i'm gonna give it a run after

winter rose
#

Think* first actually ๐Ÿ˜

cosmic lichen
#

Thinking is overrated

dusk galleon
#

uninstall brain then

astral tendon
#

so, for me Extended_Init_EventHandlers is not working in dedicated server for a UAV, it works on editor but not in a dedicated server, and I see the same problem from 2016, is this just not going to be fixed and there is another alternative for unit init?

winter rose
#

Learn SQF:
https://community.bistudio.com/wiki/Introduction_to_Arma_Scripting
SQF Commands:
https://community.bistudio.com/wiki/Category:Scripting_Commands
SQF Functions:
https://community.bistudio.com/wiki/Category:Functions

Multiplayer Scripting:
https://community.bistudio.com/wiki/Multiplayer_Scripting

Post SQF snippet:
```sqf
/* your code */
hint "good!";
```
โ†“

/* your code */
hint "good!";

If your SQF sample is more than a few lines, please post it to https://www.sqfbin.com/ and paste the link in the channel with a description, thanks

polar anchor
#

how can i specify a path to the game folders and not of my current mission file?
example: \A3\ui_f\data\map\gui\cfg\debriefing\endDeath_ca.paa
currently it will look in C:\user\documents\Arma 3\mpmission\missionname\\A3\ui_f\data\map\gui\cfg\debriefing\endDeath_ca.paa how do i specify the game path itself?

still forum
cosmic lichen
#

@polar anchor You have posted the solution already

#

\A3\ui_f\data\map\gui\cfg\debriefing\endDeath_ca.paa this is the path

polar anchor
#

yeah but

#

it doesn't follow that

#

by default

#

it starts from mission file path

cosmic lichen
#

What are you trying to do?

polar anchor
#

iconPicture = "\A3\ui_f\data\map\gui\cfg\debriefing\endDeath_ca.paa";

cosmic lichen
#

where is that used?

polar anchor
#

descriptiom.ext

dusk galleon
#

at least that's what i think he's trying to say

cosmic lichen
#

saving isn't possible

polar anchor
#

i just want to get that path

#

i dont want to save

cosmic lichen
#

overViewPictureLocked="\A3\Ui_f\data\Logos\arma3_white_ca.paa";

#

this works for example

dusk galleon
#

well uhh

polar anchor
#
{
    class DeathZoneEnter
    {
        title = "Death Zone";
        iconPicture = "\A3\ui_f\data\map\gui\cfg\debriefing\endDeath_ca.paa";
        //iconPicture = "imgs\deathIcon.paa";
        description = "Entering death zone... You have 10 seconds to go back!";
        duration = 5;
    };
};```
dusk galleon
#

can't you just do that in Attributes -> General?

#

no need for the description.ext file

polar anchor
#

this doesn't

dusk galleon
#

wait ok now i get what you're trying to make

polar anchor
cosmic lichen
#

Let me check the function

#

maybe is does something funky with the path

#

fileExists "\A3\ui_f\data\map\gui\cfg\debriefing\endDeath_ca.paa"
returns false

#

Make sure the path is correct

#

and that the file exists

polar anchor
cosmic lichen
#

That's that path

#

"\a3\ui_f\data\gui\cfg\debriefing\enddeath_ca.paa"

polar anchor
#

how did u use that texture finder?

#

thx btw

cosmic lichen
#

3den Enhanced Mod

polar anchor
#

oh nice

#

tyty

cosmic lichen
#

yw

still forum
#

@little raptor does regexFind really need a "returnAll" flag? doesn't really hurt to just always return all hits

willow hound
polar anchor
#

what's the issue here?

[] spawn {
    "DeathZoneEnter" call BIS_fnc_showNotification;

    player setVariable ["timeInDeathZone", 0];

    while {true} do {
        _time = player getVariable ["timeInDeathZone", nil];
        player setVariable ["timeInDeathZone", _time + 1];
        sleep 1;

        if (isNil _time) exitWith {};
        if (_time > 10) exitWith {
            player setDamage 1;
            systemChat format ["%1 has been killed by death zone!", name player];
        }
    }
};```
https://prnt.sc/11sq5sn
cosmic lichen
#

isNil

polar anchor
#

yeah but why?

cosmic lichen
#

read the doc

polar anchor
#

i did

cosmic lichen
#

read it again

polar anchor
#

Tests whether the variable given by its name is nil or undefined, or whether the given expression evaluates to nil or Nothing.

cosmic lichen
#

there is more than just the description

willow hound
#

(but the description already contains it)

Tests whether the variable given by its name

winter rose
#

@polar anchor ^

polar anchor
#

yeah got it

#

i just had to read that ๐Ÿ˜…

#

thx again

tender spear
#

Yo anyone here got some expierence with [how to make Item] and is willing to help me with [make item]? ๐Ÿ˜ฎ

tender spear
#

Been trying to put Atropine back into ACE cuz I kinda need it for Purposes but it flat out refuses to exist

sacred slate
#

how can you save R3F Logistics placed objects between sessions?

still forum
#

now also with case insensitive mode :3

warm hedge
#

Fooooooooo

#

/i means insensitive, and what's /o? Case onsensitive?

winter rose
#

In a nutshell, the /o modifier to causes any interpolation in a regular expression to happen only once; the final regular expression is then cached, and repeated execution wonโ€™t incur the penalties of interpolation.

warm hedge
#

Ah, so it won't return wookie booKie cookie but wookie booKie cookie separated?

still forum
#

:u

#

o is optimize

cosmic lichen
#

and i is inoptimized of course ๐Ÿ˜„

still forum
#

o gets you slower creation of the patten, but faster execution.
Better when you run it over long texts

warm hedge
#

However in the current progression how long it takes to execute? Kinda curious

winter rose
#

it takes one

still forum
#

I'm running unoptimized debug build. Maybe I can tell you in a few hours

winter rose
#

one speed

warm hedge
#

I c

still forum
#

Is that everything or am I missing anything?

#

Probably no multiline support (^$)
regexFind maybe supports it, need to test. But most likely won't work

polar anchor
#

anyone got an idea on why i am getting "No display" message when trying to hint format ["%1", findDisplay 3000];?
Description.ext:

import RscText;
import RscListbox;

class RscMapSelector
{
    idd = 3000;
    class ControlsBackground
    {
        class CtrlBackground : RscText
        {
            idc = 3001;
            colorBackground[] = {0,0,0,0.7};
            x = 0.29375 * safezoneW + safezoneX;
            y = 0.225 * safezoneH + safezoneY;
            w = 0.4125 * safezoneW;
            h = 0.55 * safezoneH;
        };
    };
    class Controls
    {
        class CtrlLocationsList : RscListbox
        {
            idc = 3002;
            colorBackground[] = {0,0,0,0};
            x = 0.335 * safezoneW + safezoneX;
            y = 0.291 * safezoneH + safezoneY;
            w = 0.1 * safezoneW;
            h = 0.418 * safezoneH;
        };
    };
};```
warm hedge
#

How did you do actually?

polar anchor
#

?

warm hedge
#

Because findDisplay does only detect currently shown display. You apparently need to launch it before

cosmic lichen
polar anchor
#
hint format ["%1", findDisplay 3000];```?
cyan dust
#

Good day. Sorry for generalized question, I'm kinda lost, so about arsenal, biki says, quote
Not all assets are automatically present, designer has to whitelist allowed classes.
https://community.bistudio.com/wiki/Arma_3:_Arsenal

But... how do I whitelist it? With BIS_fnc_addVirtualWeaponCargo ?

cosmic lichen
#

Yes

#

You have to either add the things manually or use the %ALL thing to whitelist all items.

cyan dust
cosmic lichen
#

yes

still forum
austere granite
#

Ugh... excuse me what
๐Ÿ˜„ w-whattttt

still forum
#

omg

C++ itself is weird.

"wook1e boOk2e cook3e" regexReplace [".oo/gio", "[$`]"]

C++ both GCC and MSVC
[]kie [k1e ]k2e [k2e ]k3e

https://regexr.com/
[]k1e [wook1e ]k2e [wook1e boOk2e ]k3e
Javascript
[]k1e [wook1e ]k2e [wook1e boOk2e ]k3e

still forum
#

the regex itself no, allocating the result values yeah a bit.

#

But I gave that to you via regex flags itself.
If you don't specify /g flag you only get first result

little raptor
still forum
#

not an option

little raptor
#

What does Notepad++ use? meowsweats

still forum
#

ยฏ_(ใƒ„)_/ยฏ

#

[]k1e [k1e ]k2e [k2e ]k3e
The same c++ one it seems

little raptor
#

It's boost's I think

still forum
#

omg this was so terrible to do ๐Ÿ˜„

#

I had to implement exceptions, with exceptions disabled

winter rose
#

use SQF try/catch!

potent depot
#

Anyone able to provide any insight on the quote: The Dynamic Simulation system settings are divided into 2 areas - global 'system' settings that define the rules and behaviour of the system - mainly the activation distances for different types of entities - and local object / group settings that tell the system if the object / group should use the Dynamic Simulation or not. in https://community.bistudio.com/wiki/Arma_3:_Dynamic_Simulation#Setup ?

The question this raises for me is how commands such as enableDynamicSimulation apply. I haven't dived too far into DynamicSim with scripts so im a little confused by the quote. Do AI need to have such commands run on all clients to have full effect? Or would running them on the server after the unit is spawned/processed work?

potent depot
#

This is for units/objects spawned after mission start. So Im wondering how it will work mid mission.

winter rose
#

scripting commands exist

potent depot
#

indeed they do, the question is about if the unit/object needs to be enabled on all clients individually or if enabling it on one sends it to the others

willow hound
#

We have no info on the multiplayer effects of the DSS commands on the wiki, so you'll have to try that out I'm afraid.

potent depot
#

KK, was asking to find out if someone had already done so to save time.

winter rose
#

and if you do so, please let us know in #community_wiki so we can share the knowledge ๐Ÿ˜‰

potent depot
#

I can add notes to the pages themselves an I will ๐Ÿ˜‰

winter rose
potent depot
#

Ill let you guys know as well

#

?

winter rose
potent depot
#

Ah,

winter rose
#

Local Argument, Global Effect

#

unless you want to edit the page itself ofc

potent depot
winter rose
#

sure thing! thanks a lot

potent depot
#

The end goal is to roll this with a HC system to result in pseudo caching.

willow hound
copper raven
#

id assume running it on machine who owns the ai is enough blobdoggoshruggoogly

winter rose
dusk galleon
#

i want to make it so that after the player shoots a target 10 times, then only the task would be considered finished. how do i get that to work?

little raptor
# dusk galleon i want to make it so that after the player shoots a target 10 times, then only t...

if your target has hitpoints, you can try handleDamage/hit/etc. event handlers.
if the instigator is the player, increase a variable (e.g. player setVariable ["hit_cnt", (player getVariable ["hit_cnt", 0]) + 1]
if cnt reaches 10, task is completed. you can complete it using BIS_fnc_taskSetState

if it doesn't support hitpoints, either use an invisible target and do the above, or use FiredMan event handler and trace the bullets meowsweats

dusk galleon
#

i get the part as to increasing hitpoints, but don't really get about adding variables to the player.. mind if you gave me an example code?

#

or it's already there

dusk galleon
#

well then i'm gonna haftah figure out how to use it

#

where should i put the
player setVariable ["hit_cnt", (player getVariable ["hit_cnt", 0]) + 1]
to? do i put it in the player's init field?

little raptor
#
params ["_target",..."_instigator"];
if (isPlayer _instigator) then {
  _cnthits = (_instigator getVariable ["hit_cnt", 0]) + 1;
  if (_cntHits >= 10) exitWith {
    ["task1", "SUCCEEDED"] call BIS_fnc_taskSetState;
    _target removeEventHandler ["HandleDamage", _thisEventHandler];
  };
  _instigator setVariable ["hit_cnt", _cnthits];
}
dusk galleon
little raptor
little raptor
dusk galleon
#

hmm, alright

little raptor
dusk galleon
#

yeah

little raptor
#

the name of it in my example is "task1"

#

change it to your task's name

dusk galleon
#

aight

little raptor
#

also complete this part from the wiki (handleDamage):

params ["_target",..."_instigator"];
copper raven
#

(_instigator getVariable ["hit_cnt", 0]) + 1]; random ] there

little raptor
#

copy paste error meowsweats

cyan dust
polar anchor
#

Are there classes / structs in arma scripting?

still forum
#

no

round scroll
#

is there a script command to find out if a missile is air to air or air to ground?

copper raven
#

some config value maybe you can look for

polar anchor
#

is there a way to get an array containing all the elements inside a listbox?

#

something like lbSelection but that returns an array of all the elements within the listbox and not only the selected one

#

also, to define but not inizialize a variable shoud i use nil?

little raptor
little raptor
#

nil deletes a variable

polar anchor
#

private _var;?

little raptor
#

private "_var";

polar anchor
#

ok thx

polar anchor
little raptor
#
_arr = [];
_lb setVariable ["lb_texts", _arr];
lbClear _lb;
{
  _lb lbAdd _x;
  _arr pushBack _x;
} forEach _someTextArray;
copper raven
#
lbClear _lb;
_lb setVariable ["lb_texts", _someTextArray apply {_lb lbAdd _x; _x}];

better, no?

little raptor
#

yeah

polar anchor
#

or maybe just use lbSize

little raptor
#

yes

or use a for loop and pushBack the lbText to it

polar anchor
little raptor
#

no

#

but your loop is off by 1

#

(to value is inclusive)

little raptor
#

gives you the exec time in ms

grave thistle
#

Is there a biki page explaining the relationship of

  1. altitude(seemingly ATL),
  2. object view distance,
  3. player zoom / fov??
    affecting whether the object is rendered or not (think that'd be the right way to say it :D)

E.g. I'm at 5700ATL / 5705ASL (VR map) and have one of these "20*10*8 VR OBSTACLES-boxes" 1100 meters (at same altitude) from my pos, it "disappears" when I zoom in either holding rmb or with a scope. View distance is 12000 (I don't see how CH view distance could conflict here).

little raptor
#

it doesn't explain why that happens

fair drum
#

oh I thought he just wanted some pages on each topic.

#

nvm

grave thistle
#

Ye, not really. I don't know basically anything of rendering & any of that, but have played around enough with different position types ๐Ÿ˜„

little raptor
#

sometimes I zoom in on a tree and it gets lower quality, while those out of my view get better meowsweats

grave thistle
#

Ah ye, been there. I'm wondering if the fact that there's "nothing" "behind" the object could affect it. I mean, the UAVs etc don't seem to have problems with rendering stuff far away :D.

exotic tinsel
#

will isEqualTo return true when comparing two arrays that have the same values but in different orders?

copper raven
#

no

#

wait, wdym?

exotic tinsel
#

[1, 2, 3] isEqualTo [2, 1, 3]??

copper raven
#

yeah that will return false

exotic tinsel
#

i edited it. confirm please

copper raven
#

still false

exotic tinsel
#

rgr, thx mate

polar anchor
#

i want to add an empty array and a _x key to an hashmap, what's the right way to do it?

private _playersVotes = createHashMap;

for "_i" from 0 to lbSize 7112 do {
   _playersVotes insert [[_i, []]];
}```
Currently doing it this way but it doesn't work
copper raven
#

what's that supposed to do?

#

_x doesn't define anything

#

ah nvm

copper raven
#

why even use hashmap here? just use an array, you're mapping to indices anyway

polar anchor
#

i am doing a sort of map voting and when a player clicks on a specific map he gets added to the map value

#

for example:
MAP1 -> [0, [currently empty array]];
MAP2 -> [1, [currently empty array]];
and when i vote MAP2, it becomes:
MAP2 -> [1, [myPlayerObject]];

#

so i know which map has been voted the most

little raptor
#

hashmaps are not needed here (they're slower)

polar anchor
#

i do because if i vote for a game-map and i want to change my vote i need to remove the vote for the previous game-map and add it to the new one

#

and with game-map i mean something like : city

copper raven
#

๐Ÿค”

polar anchor
#

Say for example you join a FFA/gungame/deathmatch/etc server and you start by selecting the map (factory, city, etc...)
U join and u get a GUI showing the playable maps and u can vote one of them and in 10 secs the game starts, if u vote one map and the game didn't start yet u can still vote another one but the vote for the previous one has to be removed, how u do that with an array?

#

i can't think of anything other than hashmap

winter rose
#

hashmaps have unique indexes, not values?

little raptor
#

you have indices for maps and an array of players
it has nothing to do with hashmaps

#

when you vote:

_arr set [_lastMapIndex, _arr#_lastMapIndex - [player]];
_arr#_mapIndex pushBack player;
winter rose
#

where player vote is unique would be the player unit as key, and the vote as value

little raptor
#

hashmaps don't take object as keys

polar anchor
#

can't i just do:

   _playersVotes insert [str _i, []];
}```?
little raptor
#

I'd say why you're doing any of this in the first place?
this is a local gui

#

this is what you should do:

#

show the gui to players

#

when they vote, save the index in player's namespace and broadcast

#

then on the server collect the votes

_votes = _maps apply {[0, _x]};
{
  _vote = _x getVariable ["voted_map", -1];
  if (_vote >= 0) then {
    _votes#_vote set [0, _votes#_vote#0+1];
  };
} forEach allPlayers;
_votes sort false;
_map = _votes#0#1;
#

done

fair drum
#

are groundweaponholders entities or objects?

exotic flax
#

a vehicle ๐Ÿคฃ

winter rose
fair drum
#

is there a way to detect when a new group is created using the dynamic group system?

exotic flax
#

there are quite some events and MP stuff going on, so you might want to take a look at the source of BIS_fnc_dynamicGroups

fair drum
#

so I'm running into an issue, its not a big one, but I'm confused where I messed up.
https://sqfbin.com/purilideberiwevojoro
specifically lines 29-112.

what happens, is that the units spawn at the initial change of "launcher_captured" on line 5. great, that's what I want. I go up to a unit to move it out of its spawn position. Now, the intent is that every 120 seconds there is a check to see if the vehicle has a crew or if it is dead, respawn a unit, then overwrite that unit's position in the array.

however, what happens is that any unit that was moved initially, gets send to the [0,0,0] zone and killed (great), but it doesn't respawn until the NEXT iteration of the loop.

#

all other vehicles that were untouched, get sent and killed, and respawn correctly

cosmic lichen
#

diag_log and systemChat are you friends

copper raven
#

that code is crying for hashmaps so bad

fair drum
cosmic lichen
#

Doesn't even need a hashmap

#

it's only a few entries, a simple array with find or findif is enough

#

But first get it working.

copper raven
fair drum
#

first iteration works right. 2nd iteration doesn't work as intended, but 3rd iteration works as intended... so its confusing me

#

hmmm could it be that there may be an error (that I don't see) that is being thrown at line 35-42 if I didn't have a check to make sure that there was objects in the array on the first iteration? i think that could be it.

#

no, cause if it errored, it wouldn't progress in the script past then would it, then the first iteration wouldn't work at all then?

little raptor
#

why not just delete them?

#

private _vehiclename = str _launcher + "vehicle" + str _forEachindex;
_vehicle setvehicleVarName _vehiclename;

#

is that needed?

fair drum
#

i did that for debugging when I initially wrote the script. so I could better understand what things were where using your dev tools

little raptor
#

when you delete them they become objNull

#

and they will be at [0,0,0]

copper raven
#

unsure if there is a better way blobdoggoshruggoogly

little raptor
#

waitUntil {
_launcher getVariable ["launcher_captured", false]
};
notlikemeowcry

little raptor
#

why wait?!

copper raven
#

you modify that variable yourself somewhere, so that means you know when exactly it will be true

little raptor
#

you're spawning a new code for every launcher
that's bad meowsweats

copper raven
#
  • that ^
fair drum
#

i know, this is part of a few functions with the end result being like how in battlefield, each point that is captured, spawns its own units depending on the side that captured it, and each point has its own individual timers

#

how should I go about doing that then without spawning 5 individual loops? cause I need 5 different timers

#

i have a launcher init that sets up the control points, the launcher actions etc, and then in the mission init, I start the main launcher loops for every launcher. they just wait for the initial capture

copper raven
#

run the code there and then, instead of waiting, no need to do this bounce between two scripts

hushed tendon
#

Is there a way to import an exported kit using a script?
This is the exported script/kit

[["CUP_sgun_M1014_vfg","","CUP_acc_Flashlight","",["CUP_1Rnd_12Gauge_Slug",1],[],""],[],["ACE_VMM3","","","",[],[],""],["CUP_I_B_PMC_Unit_13",[["ACE_quikclot",10],["ACE_packingBandage",10],["ACE_elasticBandage",10],["ACE_epinephrine",3],["ACE_morphine",3],["ACE_Flashlight_XL50",1],["ACE_CableTie",5],["ACE_splint",2],["ACE_tourniquet",2],["ACE_salineIV_500",2]]],["CUP_V_PMC_IOTV_Black_Gren",[["ACE_surgicalKit",1],["ACE_salineIV_500",2],["ACE_salineIV",2],["CUP_1Rnd_12Gauge_Slug",50,1],["ACE_M84",2,1],["ACE_Chemlight_HiGreen",10,1]]],[],"CUP_H_Ger_M92_Black_GG_CF","G_RegulatorMask_F",[],["ItemMap","","","ItemCompass","ItemWatch",""]]
lyric girder
#

In ace arsenal you should be able to just click import

hushed tendon
#

Trying to give it to a unit using a script. Will I have to give each item individually?

lyric girder
#

You should be able to just copy-paste the unit you gave the kit

fair drum
copper raven
#

yep

fair drum
#

best to set these up globally at mission start in a variables file?

copper raven
#

yea

fair drum
copper raven
#

can also map sides

#

but yes, that's the way

fair drum
# copper raven but yes, that's the way

and I can use variables that contain arrays as well correct? like an array of arrays that contains [[x, y, z], direction] so it would be like

silo_positionsHash = createhashmapfromarray [
    ["silo_1", silo_1_vehiclepositions],
    ["silo_2", silo_2_vehiclepositions],
    ["silo_3", silo_3_vehiclepositions],
    ["silo_4", silo_4_vehiclepositions],
    ["silo_5", silo_5_vehiclepositions]
];

// one of these variables contains an array of arrays that has [[x, y, z], direction] for each
copper raven
#

yep

fair drum
#

yeah I'm reading through this while writing them. just figuring out the limitations

copper raven
#

so what you could have is, hashmap of hashmaps, in the end you could retrieve your vehicle class by doing TAG_vehiclesHash get _type get _side

robust hollow
#

you would use createhashmapfromarray on those values too

copper raven
#

that ^ and don't stringify sides

#

just west/east, no quotes

fair drum
# copper raven just west/east, no quotes
vehiclehash = createhashmapfromarray [
    [
        west,
        createhashmapfromarray [
            ["antiair", "B_APC_Tracked_01_AA_F"],
            ["apc", "B_APC_Wheeled_01_cannon_F"],
            ["transport", "B_Truck_01_covered_F"],
            ["mrap", "B_MRAP_01_hmg_F"],
            ["buggy", "B_LSV_01_armed_F"],
            ["quad", "B_Quadbike_01_F"],
            ["attackheli", "B_Heli_Attack_01_dynamicloadout_F"],
            ["transportheli", "B_Heli_Transport_01_F"],
            ["scoutheli", "B_Heli_Light_01_F"],
            ["jet", "B_Plane_Fighter_01_F"],
            ["tank", "B_MBT_01_cannon_F"]
        ]
    ]
];
#

so the first get goes to the side key, then it returns a hash itself, which then the second get goes through the second hash. i got it now

fair drum
#

I'm getting an error with that...

vehiclehash = createhashmapfromarray [ 
 [ 
  west, 
 >
22:12:19   Error position: <createhashmapfromarray [ 
 [ 
  west, 
 >
22:12:19   Error Type Side, expected Array
robust hollow
#

that snippet above works for me. you will need to paste the full snippet you're using

fair drum
#

i found the error. was a copy pasta error

little raptor
#

probably you did something like:
createhashmapfromarray [...west...]

fair drum
#

as is usual. missing ] in one of the arrays of arrays

still forum
#

Nice to see that HashMaps are going good :3

signal kite
signal kite
tough abyss
proven charm
#

getMissionPath ?

tough abyss
#

Exactly. Thank you!

cosmic lichen
#

@tough abyss If you get it to work with that, can you post the code in #community_wiki

#

So we can update the page?

tough abyss
# proven charm getMissionPath ?

Sorry if it seems obvious. Googling "mission path" and such things gets me totally different answers. And the BIKI only accepts exact matches. So appreciate it!

proven charm
#

np

tough abyss
winter rose
#

(and you don't copy-paste groups, you copy-paste numbers)

proven charm
#

will there be select for hashmaps also?

still forum
#

no

proven charm
#

ok

pearl temple
#

I have been sitting with this fairly easy script for hours now, and just can't seem to get i to work.
Hope you guys can help me out.

if ( isServer ) then 
        {
            
            testVehicleSpawn1 = "Land_MultiScreenComputer_01_black_F" createVehicle position player1;
            sleep 0.1;
            testVehicleSpawn1 AttachTo [Player1];
            sleep 0.1;
            testVehicleSpawn1 = [["m2IEDCheck1",true]] remoteExec ["playsound",0];
            sleep 20;
            deleteVehicle testVehicleSpawn1;
            
        }
        else{};`
When it gets to the deleteVehicle part, it throws an "Type string, expected object" error
If I use the in-game debug console it shows:
'|#|deleteVehicle testVehicleSpawn1;
'
Error deleteVehicle: Type String, expected object`
winter rose
#

@pearl temple see how to use syntax highlight in pinned messages, thanks ๐Ÿ˜‰

#

Your possible issue:
using isServer + player

grim ravine
#

Do you have to detach it first?

pearl temple
#

Thx @winter rose
But there is no error if I execute the commands in the debug console individually?

#

@grim ravine Sorry, mistype.. code edited ๐Ÿ™‚

winter rose
#

@pearl temple the debug console doesn't always return everything

It tells you the issue btw, apparently you feed deleteVehicle a string

#

โ€ฆbecause you are assigning your remoteExec return value to the variable

#

@pearl temple ^

pearl temple
#

@winter rose Of Course ๐Ÿ˜€
But I can't figure out how to make the object the soundsource of a remoteExec Playsound, and then delete it after a time.

winter rose
pearl temple
#

@winter rose Right you are! ๐Ÿ˜€
Will try the say3D command instead, thx.

faint oasis
#

someone know why the "BIS_fnc_selectDiarySubject" command doesn't work ? i have tried ["Diary"] call BIS_fnc_selectDiarySubject; but this doesn't change anything in my map.

grim ravine
#

Works alright for me

#

Running the wiki example in debug

cosmic lichen
trail smelt
#

Script from wiki (https://community.bistudio.com/wiki/addCuratorEditableObjects) "zeus_obj.sqf":

if isServer then
{
  [] spawn
  {
    while {true} do
    {
      {
        _x addCuratorEditableObjects
        [
            entities [[],["Logic"],true /*Include vehicle crew*/,true /*Exclude dead bodies*/],
            true
        ];
      } count allCurators;
      sleep 60; //Change to whatever fits your needs
    };
  };
};

init.sqf (inside mission)

execVM "scripts\zeus_obj.sqf";

But only few object add to other zeus clients.. (picutures..)
Pictrures: https://imgur.com/a/CqoOhBe
I would like to achieve the same effect with all zeus curators as with the one from the gif any tip ?

hushed tendon
#

I'm trying to remove the selected player from an array but it doesn't seem to be working. Anyone know what I'm doing wrong?

_runners = [p1,p2,p3];
_lurker = selectRandom [_runners];
_runners = _runners - [_lurker];

//--- For Testing ---//
hint str(_runners);
{_x setDamage 1;}forEach _runners;

They all show up in the hint and die

jolly bone
little raptor
drifting portal
#

Hello, I would like to ask if its possible to have an ARMA 3 script that detects if a building (which is a pre-placed building in the map, part of the map basically) is destroyed by a player, I'm going to be using it for a MP mission.
By buildings I mean houses and buildings, not fences or lamp posts or other types of unimportant infrastructure.
If its possible to cover a certain area with that script it would be great.
I'm level medium at scripting so I can't really make it myself.
I will be using it to detect if CAS is going to destroy buildings so I can set a punishment later for them destroying civilian buildings.
Thanks!

little raptor
drifting portal
#

yes but I can't get how to actually find the unit that destroyed the building

#

((player))

little raptor
#

which event handler do you use?

drifting portal
#

BuildingChanged for detecting if a building is destroyed

#

not sure if MPKilled will help to find the unit

little raptor
drifting portal
#

I wish there is a way to view the map through eden

drifting portal
# little raptor wdym?

KP Liberation detects when a building is destroyed by a player, I meant that I wish I was able to have an eye at the triggers and stuff

little raptor
drifting portal
little raptor
#

Idk, try it
but many objects already inherit from "house" (or was it "house_f"?)
so you could get some unrelated stuff

#

check the simulation to get buildings

drifting portal
#

by simulation you mean dynamic simulation and stuff right?

little raptor
#

no

#

it's in config

drifting portal
#

oh ok

little raptor
#

getText(configOf _obj >> "simulation")

drifting portal
#

thanks

little raptor
proper sail
#

If you make a marker in your mission.sqm and use it on your server; does the server execute the mission.sqm too? And if only the clients do it; are the markers local or is that global

winter rose
proper sail
#

right right, but if you add a marker in your mission.sqm; do the clients execute it locally or does each client create the same global marker i.e when doing createmarker on every client instead of createmarkerlocal

#

i cant find anything about mission.sqm global/local effect

winter rose
#

it's "local" anyway (as in created on every machine) but synchronised because they have the same name

still forum
distant oyster
#

wasnt there a command to get an unlocalized string from the config?

distant oyster
#

yep thanks :)

warm hedge
#

get3DENSelected is the command to get โ€œcurrently opened attributes' objectsโ€?

cosmic lichen
#

yes

drifting portal
#

I will also edit it to include || getText(configOf _obj >> "simulation") == "building"

little raptor
#

There's no such simulation meowsweats

drifting portal
#

oh god

#

arma 3 really needs an engine change doesn't it

drifting portal
#

must make another EH right?

little raptor
#

Houses are buildings

drifting portal
#

but I need buildings too

#

like mosques

little raptor
#

A house IS a building (and vice versa)
Am I saying it wrong?

ivory lake
#

'house' is the simulation used in arma for (most) buildings

#

so that code will cover what you're looking for

drifting portal
#

alright

ivory lake
#

it's just a name, like how static weapons use the simulation 'tank'

drifting portal
#

been playing the game for 1 month so its too much info pardon me

hushed tendon
#

With this code it should choose one of the _runners and make them the _lurker while also removing them from the list of _runners right?

_runners = [p1,p2,p3];
_lurker = _runners deleteAt floor random (count _runners);

//--- For Testing ---//
hint str(_runners);
{_x setDamage 1;}forEach _runners;

//Redress the "lurker" code below

What happens is that the _lurker gets redressed but is killed while one of the _runners is still alive

fair drum
#

i've always done it this way

_runners = [p1, p2, p3];
_lurker = selectRandom _runners;
_runners = _runners - [_lurker];
hushed tendon
#

Both ways one of the three gets redressed, one lives, and two die. Instead of what should happen with the "lurker" getting redressed and staying alive while the other two die.

robust brook
hushed tendon
robust brook
#

No runners wont include the lurker, go try it

fair drum
#

if you are really concerned, just make a _lurker array, a _runnersPre array, and a _runners array

#

and then just use _runners for your final script

hushed tendon
#

Oh I see why, because the _lurker is not unique to the _runners array so it gets removed.
"Adds element to the back of the given array but only if it is unique to the array." - Wiki

robust brook
#

It checks to see if _x is not equal to the lurker, if its not then add it to the array

#

pushBackUnique is used to prevent same player/element being added again

hushed tendon
#

oh

#

I want to make it a function so I can call a few times to reassign _runners and _lurker at the start of new games. This is correct right?

fnc_definePlayers = {
private _lurker = (selectRandom _players);
private _runners = [];

{
    if !(_x isEqualTo _lurker) then {
        _runners pushBackUnique _x;
    };
} forEach _players;
};
private _players = [p1,p2,p3];
[_players] call fnc_definePlayers;
robust brook
tough abyss
#

Am very curious what lurkers and runners are, in this context ๐Ÿคจ

#

Had a question of my own

hushed tendon
tough abyss
#

Ah. Interesting. Then you maybe also have an opinion on my question ๐Ÿ˜„

#

I am intending on having a large AI vs AI battle at the end of a mission that players have to traverse through. It's a small map, 6 players, running on dedicated cloud, so I think I can push the server load pretty well in terms of latency and AI FPS.

#

My question is: does it perform better for the players when the all AI units are loaded at scenario start invisible and with simulation off (then turned on later), or better to spawn the AI fully enabled (perhaps in phases over several minutes) ?

fair drum
robust brook
#

If they are already spawned in and are hidden/disable sim that would be more network intensive than just spawning them in.

#

Also spawning each one over time is a lot better than just spamming all at once.

tough abyss
#

Yeah, and cause more scenario loading times for players. It's server processing vs network vs player loading dilemma. I'm asking if anyone has experience and can give me an estimate.

robust brook
#

Idk I've never touched AI, they are pretty network intensive in a3

hushed tendon
#

What I would do is spawn gunfights in front of players as they move. That way there is ambient gunfire, saves fps, and the players can clean up fights.

#

Think of it like chunk loading. As the players move on they load new chunks (aka gunfights)

fair drum
#

if its AI vs AI and you don't want the players to fight, just create a smaller amount of AI, set them to invulnerable, and add some tracer effects or spawn some explosions. do ambient warfare. because adding 100s of AI won't be a good experience imo.

hushed tendon
#

If you are looking to create atmosphere music and effects are the best way to go.

tough abyss
#

Just experimenting with a different atmosphere here. Let me dig up an example video

fair drum
#

you can also create a fired event handler for the units that deflect the rounds just slightly away from the player for increased atmosphere without killing them or having invulnerability flinching

tough abyss
#

^So this displays a lot of vehicle combat and bangs that the player has to avoid. I'm interested in setting up a 10 minute segment where the player(s) cross 2 km of this.

fair drum
#

you got a quantum computer?

hushed tendon
#

For horror and spooks having the players hear distant screams and gunfire while also only seeing what remains of something that happened is good way to set their nerves off. Then you come in later with the real spooky stuff like zombies or some anomalies (AliasCartoons has some good scripted anomalies).

tough abyss
hushed tendon
hushed tendon
tough abyss
# fair drum you got a quantum computer?

I don't think calculating qubits will help with the single core processing here ๐Ÿ˜ฉ . But more seriously, I have tried to limit variables by low player size and using an Amazon computing instance. Has performed quite spectacularly until now with 150 AI and small groups, of course dynamically simulated.

#

But gents, I hear you; effects are cheaper than AI.

drifting portal
#
addMissionEventHandler ["BuildingChanged", {
    if (_this select 2) then
    {
      player addMPEventHandler ["Killed", {
      if (_this select 0 == _previousObject && _this select 1 == player) then
      {
          counter = (counter + 1);
          systemChat format ["%1 has destroyed a building.", _this name select 1];
         };
    }];
    };
}];
#

there is something wrong with this code

#

let me type the error code

willow hound
#

_previousObject

drifting portal
#

addMissionEventHandler |#|["BuildingChanged", {
if (_this select 2...'
error generic error

}];'
Error Missing ]

fair drum
#

well that's not the only error you got goin on

drifting portal
#

@fair drum come on man I can't find a good tutorial on eventhandlers

#

lol

drifting portal
fair drum
#

well the errors don't really involve event handlers, they are scripting in general errors. _previousObject is undefined. You are changing scopes without bringing previous arguments into the new scope.

#

whats the goal you are looking for here?

drifting portal
#

Wait

drifting portal
#

I mean is it even achievable?

fair drum
#

If I'm correct in thinking that the buildingchanged event handler detects terrain objects, then yes it would be. if not, then no, using that event handler.

drifting portal
#

I have been trying to do this for the past two days

fair drum
#

lets clean up your script first

drifting portal
#

But isn't _previousObject local? Shouldn't it function normally here?

fair drum
#

well you never defined _previousObject ever

tough abyss
#

i guess youre mimicking the example code in the documentation? you're missing the "params" part where _previousObject and a few other parameters are defined

drifting portal
#

Yes

#

Exactly

tough abyss
#

also BuildingChanged is no good for your needs. HitPart is better since it actually tells who fired the shot

tough abyss
#

i assume so bc HitPart fires when i shoot the building

#

only tested with rifles though, not sure if it changes when the shooter is a plane

drifting portal
#

I think it does work

fair drum
#

place a building object and do getAllHitPointsDamage object and see if anything pops up

fair drum
#

nah, just give it a variable, start the mission then run it from debug

drifting portal
#

Oh wait sorry

#

I'm on phone, ok I will do it now

#
[["hitzone_1_hitpoint","hitzone_2_hitpoint","glass_1_hitpoint","glass_2_hitpoint","glass_3_hitpoint","glass_4_hitpoint","glass_5_hitpoint","glass_6_hitpoint","glass_7_hitpoint","glass_8_hitpoint","glass_9_hitpoint","glass_10_hitpoint","glass_11_hitpoint","glass_12_hitpoint","glass_13_hitpoint","glass_14_hitpoint"],["dam_1","dam_2","glass_1","glass_2","glass_3","glass_4","glass_5","glass_6","glass_7","glass_8","glass_9","glass_10","glass_11","glass_12","glass_13","glass_14"],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]
#

I don't think those are parts

#

so HitPart won't help?

fair drum
#

i think its going to use the values for the second array

#

starting with "dam_1"

drifting portal
#

oh ok

fair drum
#

that command gives [[hitpoints], [selection names], [values]]

drifting portal
#

all values are zero then

fair drum
#

because nothing is damaged yet

#

0 - undamaged, 1 - fully damaged

drifting portal
#

yes

#

I know about that but

#

question is HitPart is effective?

fair drum
#

i think it would be. you'd need to apply it to all terrain objects that have the parent class of "building"

drifting portal
fair drum
#

well, you'd have to do a more specific subclass

drifting portal
#

"house"

fair drum
drifting portal
#

is this relative ?

fair drum
#

sort of. its not as clean. maybe someone will link a clean hierarchy page for arma 3.

#

we just want to exclude things like telephone poles and stuff

drifting portal
#

private _buildingARR= nearestObjects [_loc, ["House", "Building"], _area];

#

I have found this

#

but not sure how would I use it

#

lol

#

_loc are coordinates of the center

#

_area is the radius?

drifting portal
#

well I'm not sure what _buildingARR is

fair drum
#

if you didn't place the building yourself, they aren't part of mission objects

#

they are terrain objects

drifting portal
#

yes

#

pre placed buildings

#

not editor placed

fair drum
#

_buildingARR is the array name that that person gave the return for the command

drifting portal
#

its local

#

would it work if I place it on top of EH?

fair drum
#

yes because what you'll do with it is

private _buildingArray = // setup nearestTerrainObjects here

_buildingArray apply {

    _x addEventHandler ["HitPart", {
        (_this select 0) params ["_target", "_shooter", "_projectile", "_position", "_velocity", "_selection", "_ammo", "_vector", "_radius", "_surfaceType", "_isDirect"];

        //code here
    }];
};
#

then for the code you'd use any of the local variables created by the params command above it to access what you want

drifting portal
#

I will need to check if _target is a building?

fair drum
#

actually, you could do it differently too

drifting portal
#

here we go again

fair drum
#

you could add the event handler to each player, but have an array of buildings you want to check for using the same nearestTerrainObjects

#

then do a check to see if the _target is in _buildingArray

#

there's just so many ways lol

drifting portal
#

how did you learn to use eventhandlers?

fair drum
#

probably leo, lou, or polpox helped me a while ago. i don't remember lol. there's always more to learn. always learning new applications of things

drifting portal
#

I have no idea how to use the eventhandlers by myself sadly

#

no videos about it at all

fair drum
#

like I never considered hitpart as a solution to your problem until wipeout mentioned it

tough abyss
#

i dont think you actually need to check if target is in the array, you just want to know when a building is hit right

#

so if event fires, then someone shot a building, then punish the shooter

drifting portal
#

but

#

what if the AI

#

shoots the building

#

lol

tough abyss
#

true, then check if shooter is AI. if not punish

fair drum
#

using if then - typeOf _target == "buildingclass" && _shooter == player and forgoing the array

drifting portal
tough abyss
#

that's better

drifting portal
#

So

#

if (_shooter == player) then {code};

#

?

fair drum
#

need to check to see what his target is as well

drifting portal
#

Yes

fair drum
# drifting portal That would check it?
player addEventHandler ["HitPart", {
    (_this select 0) params ["_target", "_shooter"];

    if (_target isKindOf "house" && _shooter == player) then {

        //code
    };
}];
drifting portal
#

Now I got how to use the EHs thanks to you

#

You saved the wall next to me from being banged

fair drum
#

eh it happens. i was stuck for two days when I realized that I just had a specific line of something in the wrong scope which was causing an overwrite. hard to find in hundreds of lines when there isn't an error thrown.

drifting portal
#

Isn't there a way to compile arma's code?

#

Like when I make an sqf and stuff?

#

Other than reloading the mission

fair drum
#

if you have a file in the mission folder, you can just call it directly from debug if you want

drifting portal
fair drum
#

oh i see what you mean

drifting portal
#

But when I want to check inti.sqf is it possible?

fair drum
#

what you mean "check" it

winter rose
#

you can rerun init.sqf with execVM yes

drifting portal
#

Compile

copper raven
#

compileScript ["init.sqf"] ?

drifting portal
#

So instead of reloading the mission till eternity

#

I just compile it

#

Without having to reload the mission

#

So I can fix errors quickly

#

Instead of reloading everything for 1 sqf

winter rose
#

execVM "init.sqf"

#

as I said

drifting portal
#

Debug console in the editor?

#

Alright

fair drum
drifting portal
#

But I don't want to exec

#

Anyway got it

willow hound
winter rose
#

just run the compiler on it to see if the code is not wrong, OKโ€ฆ

drifting portal
fair drum
drifting portal
fair drum
#

yeah but we didn't do anything with them. idk I had a brain fart

#

you could maybe do "dammaged" with an array of terrain objects

#

in a similar fashion

drifting portal
#

You mean check if its damaged?

little raptor
fair drum
#

maybe something like this?

private _buildings = nearestTerrainObjects [[0,0,0], ["HOUSE"], 100000];

_buildings apply {

    _x addEventHandler ["Dammaged", {
        params ["_unit", "_selection", "_damage", "_hitIndex", "_hitPoint", "_shooter", "_projectile"];
    
        if (_damage > 0.8 && isPlayer _shooter) then {
            //code
        };
    }];
};
fair drum
#

idk tweak it to what you want lol

little raptor
drifting portal
little raptor
#

it takes a few second and it's done

drifting portal
fair drum
#

also 100k radius lol

#

i forgot what it is to get the center of the map as a position

#

ah worldsize / 2 for each x and y

little raptor
#

and worldSize / sqrt 2 for radius

dusky wolf
#

Does anybody know how to pass additional variables onto an addEventHandler?

#

This work, but I'm trying to generalize it so it doesn't rely on a public variable

params ["_vehicle", "_dest"];

destination = _dest;

_vehicle  addEventHandler ["GetIn", {
    params ["_vehicle", "_role", "_unit"];

        moveOut _unit;
        _unit moveInCargo destination;

}];
fair drum
copper raven
#

setvariable

fair drum
#

dang we took him out back and hit him with a machine gun

dusky wolf
#

Hmm, never used it like that. Alright, appreciate it. Too easy

drifting portal
#

but where is the string? isn't that an array?

fair drum
#

oh

copper raven
#

has to be an array of types, not just single type

fair drum
#

put "HOUSE" in an array

#

my b

drifting portal
#

oh ok

#

lol

winter rose
drifting portal
#

here comes arma 3 dev

drifting portal
#

rip

#

systemChat format ["%1 shot %2", _shoot,_unit]; I added in the code

#

it should say something

fair drum
#

you mean _shooter?

drifting portal
#

nope

#

it didn't work

fair drum
#

like you caused greater than 80% damage to the building and it didn't work?

drifting portal
#

the entire building

#

went down

fair drum
#

what did you use to blow it up?

drifting portal
#

I hit it with a 125mm HE-FRAG-FS

drifting portal
fair drum
#

maybe instead of isPlayer _shooter try _shooter == vehicle player?

drifting portal
#

ok

#

wait one

#

it worked

#

thanks man

#

again you saved the wall

#

from being demolished

fair drum
# drifting portal thanks man

be sure to add that event handler to every player, every time they spawn. so put it in onPlayerRespawn.sqf + init.sqf, or if they don't respawn, put it in the init.sqf

drifting portal
#

thing is

#

now

#

if somebody shoots FRAG

#

it will record 30 times hits

#

lol

#

and you know Su-25 only uses frag

#

rip

#

is there a way to use HitPart instead?

#

doesn't that check the server?

#

why would it stop the error? lol

fair drum
#

ooooooh I see, fragmentation of the rounds hitting.

drifting portal
#

yes

#

they already warned about it

#

in the docmuentation

#

If simultaneous damage occured (e.g. via grenade) EH might be triggered several times.

fair drum
#

will the frag ever destroy the building?

#

i guess it would... hmm let me think

drifting portal
#

it explodes

#

sending fragments

#

the explosion destroys the building

#

then the frags damage the building a bit

#

so it records both

fair drum
#

i was thinking that the damage threshold we added would filter that out since it has to be 80% damage in one instance

#

guess not

drifting portal
#

arma 3 moment

fair drum
#

maybe try the "hit" handler

drifting portal
#

HitPart?

#

it doesn't register

#

lol

fair drum
#

no just "hit"

drifting portal
#

oh ok

#

would

#

MPHit

#

work in SP?

fair drum
#

yes it will

drifting portal
#

anything wrong?

willow hound
#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

```sqf
// your code here
hint "good!";
```
โ†“

// your code here
hint "good!";
drifting portal
#

thanks

#

damit

#

lmao

#
_buildings = nearestTerrainObjects [[6083,7315,0], ["HOUSE"], 100];

_buildings apply {

    _x addEventHandler ["Hit", {
        params ["_unit", "_causedBy", "_damage", "_instigator"];
    
        if (_damage > 0.8 && _causedBy == vehicle player) then {
            counter = (counter + 1);
            systemChat format ["%1 shot %2", name _causedBy,_unit];
        };
    }];
};
#

there

fair drum
#

so much hotter

drifting portal
fair drum
#

yeah but have you seen that RED?

drifting portal
#

ahhh

#

kinda agree

#

do be lookin good doe

fair drum
#

doesn't give one?

drifting portal
#

nope it doesn't fire up

fair drum
#

the damage on this handler is the damage done in a single hit i believe. did you do more than 80% damage in a single hit?

#

but remember, it also says it most likely fires when the object is killed

#

so take out the damage condition and see if anything happens, the adjust accordingly

drifting portal
drifting portal
#

worked

#

but it counted it 7 times

#

lmao

#

wait let me see

#

if it counts every building 7 times

#

then we can divide the varaible by 7 and get the acutal result

#

nope its not constant

#

everytime you hit it counts

velvet merlin
#

how to make a camera point down?

#

tried to position in the the air (camSetPos) and same position but zero height for camSetTarget
also tried cameraEffect ["INTERNAL","TOP"]
but all you get is some weird angle or cam snaps back to horizontal

fair drum
# drifting portal everytime you hit it counts

so you might need to add back the damage conditional and change the threshold. or try the "MPKilled" handler. I would just do the killed one if you just want a final whoever killed it result instead of on the basis of damage. But now you have to make sure with that command that you have a server filter in it

willow hound
drifting portal
#
_buildings = nearestTerrainObjects [[6083,7315,0], ["HOUSE"], 100];

_buildings apply {

    _x addMPEventHandler ["MPHit", {
        params ["_unit", "_causedBy", "_damage", "_instigator"];
    
        if (_instigator == vehicle player) then {
            counter = (counter + 1);
            systemChat format ["%1 shot %2", name _instigator,_unit];
        };
    }];
};
#

is it not working because I haven't used _causedBy == vehicle player?

velvet merlin
#

Hit isnt that reliable. try damaged or handleDamage or hitPart

drifting portal
#

same thing

fair drum
#

try "MPKilled"

drifting portal
# fair drum try "MPKilled"
_buildings = nearestTerrainObjects [[6083,7315,0], ["HOUSE"], 100];

_buildings apply {

    _x addMPEventHandler ["MPKilled", {
        params ["_unit", "_killer", "_instigator", "_useEffects"];
    
        if (_killer == vehicle player) then {
            counter = (counter + 1);
            systemChat format ["%1 shot %2", name _instigator,_unit];
        };
    }];
};
#

doesn't fire up

#

ouch

fair drum
#

try isPlayer _instigator

drifting portal
#

ok

fair drum
#

because remember, _instigator is who pulled the trigger, so we don't use vehicle player for that

drifting portal
#

yes

#

I know

#

I used it earlier in MPHit

#

and it didn't work

#

thats why I didn't try it again

#

but I will do it now again

#

lol

velvet merlin
#

we use HandleDamage

#

however keep in mind terrain objects may behave a bit different to editor placed

drifting portal
#

and it didn't work

#
_buildings = nearestTerrainObjects [[6083,7315,0], ["HOUSE"], 100];

_buildings apply {

    _x addMPEventHandler ["MPKilled", {
        params ["_unit", "_killer", "_instigator", "_useEffects"];
    
        if (_instigator == vehicle player) then {
            counter = (counter + 1);
            systemChat format ["%1 shot %2", name _instigator,_unit];
        };
    }];
};
velvet merlin
#

for testing you should remove that if condition

#

first you need to see if the EH triggers at all

drifting portal
#

ok

#

its not firing

#
_buildings = nearestTerrainObjects [[6083,7315,0], ["HOUSE"], 100];

_buildings apply {

    _x addMPEventHandler ["MPKilled", {
        params ["_unit", "_killer", "_instigator", "_useEffects"];
    
       systemChat format ["%1 shot %2", name _instigator,_unit];
    }];
};
spark sun
fair drum
#

we have gone full circle now lol

hushed tendon
#

What is he trying to do? See if a plane destroys a building or something?

fair drum
#

go back to the buildingChanged

drifting portal
fair drum
#

it was the original idea before others suggested other handlers which sent you in a spiral lol

drifting portal
#

yes

#

but Is there a way to find out if the player did it?

fair drum
#

but now you know how to define local variables correctly lol

drifting portal
#
_buildings = nearestTerrainObjects [[6083,7315,0], ["HOUSE"], 100];

_buildings apply {

    addMissionEventHandler ["BuildingChanged", {
        params ["_isRuin"];
        if (_isRuin)
        {
            _x = addMPEventHandler ["MPHit", {
            params ["_unit", "_causedBy", "_damage", "_instigator"];
                if (_unit in _buildings && (_causedBy == vehicle player || _causedBy == player)) then
                {
                    counter = (counter + 1);
                    systemChat format ["%1 shot %2", name _instigator,_unit];
    
                };
            }];
        };
    }];
};
#

tried merging them

#

giving me a weird error

fair drum
#

not how you would do that

#

sec

drifting portal
#

reeeeeeeeeeeeeeeeeeeeeeeee

#

I may have found it

#

still gives me the same error

#

bruh

#

it says there is something wrong with line 8

fair drum
#

its not even close, give me a sec to write something

hushed tendon
drifting portal
#

forgot the "then"

robust brook
hushed tendon
#

I'm testing it by killing the runners

#

The lurker will get redressed but die sometimes with one of the people who are supposed to be runners stay alive like the lurker should

fair drum
drifting portal
#

lol

#

he just

#

used BuildingChanged

#

but

#

he said he didn't try to figure out

#

who destroyed it

#

since even if the AI destroys it

#

they will blame the player

#

for invading their country

fair drum
#

he is one of the top guys in the community, if he didn't figure it out, its probably not possible

drifting portal
#

arma 3 dev where are you

fair drum
#

not their job lol

drifting portal
#

extreme bruh moment

fair drum
#

you could get an area's terrain objects, collect their placement, their direction, their classes into an array, then do a mass hide of those objects THEN create those objects in place of their old ones so now they are considered "mission objects" THEN use one of the killed handlers

winter rose
#

laughs in the shadows

drifting portal
#

cries with extreme pain

winter rose
#

pain au chocolat ?

drifting portal
#

le fishe au chocolat

winter rose
#

๐Ÿค˜ ๐Ÿฅ–

fair drum
#

meanwhile i need to get back to troubleshooting this hud dialog problem I'm having for days

#

which i just solved...

drifting portal
#

I like the fact how this is impossible

#

lol

fair drum
#

i guess i just needed to look away from it for a little bit

drifting portal
#

well

#
_x = addMPEventHandler ["MPHit", {
#

anything wrong with this line of code?

#

oh god here we go

hollow thistle
#

You could try writing a script that replaces map object with script spawned ones.

fair drum
hollow thistle
#

I doubt MP event handlers will work on the terrain building as they're basically "globally local"

#

Every client has local copy of the object with same id.

#

but idk, never tried it.

drifting portal
#

how would I detect

#

if it was hit by a player

hollow thistle
#

I assume the Hit or Dammaged or HitPart or HandleDamage will work on non terrain buildings.

drifting portal
#

so look let me explain

#

Hit, Dammaged, HitPart do acutally work on terrian objects

#

the problem is

#

when you shoot HE FRAG

#

It registers a "hit" more than once

#

like the building goes down

#

and it registers 30 hits

#

but it should only be one

hollow thistle
#

that's normal for indirect damage

drifting portal
#

yes, and its a CAS mission

#

so.....

fair drum
#

so just make a conditional to skip that _projectile for the count

fair drum
#

and you'll have to suffice

#

let me go back to the code that was working for you

drifting portal
#

well

#

wait one

fair drum
#

i already found it. sec