#arma3_scripting
1 messages ยท Page 676 of 1
exactly what I was looking for, thanks
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
whats the rest of the script look like? if its too big, use sqfbin.com
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";
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)
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?
Was just trying, but it still won't execute, anyways, i'll check that
is this corridor in a custom map?
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
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
Anyways, thanks a lot for the help (and the patience)
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).
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
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.
Exist script which automaticly add editable all objects to all zeus clients .. ?
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.
what would be best way to implement interactable map objects?
@proven charm Do you mean something like this? If not you might want to explain what you are looking for more. That could mean a lot of things. https://community.bistudio.com/wiki/addAction
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
mouse event handlers/drawicon ?
@copper raven yea that could be one way to do it, still looking for the best way...
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}];
use remoteExec
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 =/
A command B, with remoteExec you pass arguments like this instead: [A, B] remoteExec ["command", <targets>] https://community.bistudio.com/wiki/remoteExec
Thanks but, i copy paste the code in "zscript.sqf" and add execVM to init.. script dont do any change
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;
to what init? you're supposed to run that on server
that's not how you reference groups
how can you check if mouse cursor is over the icon drawn by drawIcon? in 2D map
getMousePosition, ctrlMapScreenToWorld, distance2D
ok thx POLPOX I was looking at those commands but havent exactly yet figured them out lol
got it now, thanks again!
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
hmmm I was thinking of scaling the distance check to ctrlMapScale

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
all you had to do was just copy paste what i wrote, and fill the placeholders,
A command B > [A, B] remoteExec ["command", <targets>]
(_this select 0) addAction ["<t color='#FF0000'>REPAIR</t>", {vic2 setdamage 0}];
[_this select 0, ["<t color='#FF0000'>REPAIR</t>", {vic2 setdamage 0}]] remoteExec ["addAction"]
and for setVariable, pass true as third argument instead, don't remoteexec, essentially does the same thing, https://community.bistudio.com/wiki/setVariable look at alternative syntax
[Cc]? ๐
lol I tried! Thanks again @copper raven Like I said head bonks
How about regexFind that returns [[match pos1 start,match pos1 end],[match pos2 start,match pos2 end],...]?
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
Make sure you saved the mission everytime you modify description.ext
i did
i try to call it via: execVM CRM_fnc_showWarning.sqf; and it doesn't get found
๐ค
โฆno
why not
your function will be compiled to CRM_fnc_showWarning in mission namespace, so just <args> call/spawn CRM_fnc_showWarning
oof
do you execute BIS_fnc_endMission.sqf? nope
Thats in the ticket. I'll try to do all the things
Great to hear, Ded
This is just proof of concept telling me I can do all the regex things ez
also regexReplace would be nice (don't know if its in the list) 
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
so you renamed the file, but didn't change the filepath in the cfgfunctions?
Same except for that
it is :u
well, how does one reference groups?
well it depends how you have it setup, you can give them a variable in the editor
@polar anchor Might wanna read https://community.bistudio.com/wiki/Arma_3:_Functions_Library
yeah thx
I have a function that spawns any number of groups. the function returns an array of the spawned groups so I can "access" them at a later point (eg to delete them or give them new waypoints). the question is now, how to "access" those groups.
didn't you just answer your own question?
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
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.
correct
thx
if you do some (other) development, what you see is a "toString()" representation
just out of curiosity: is there a way to get a copy-pastable array of groups?
using setGroupId!?
give them a name in editor
what will you use for capture groups? \ or $?
STL's default is $
nope just wanted to check 
yeah is valid question :u
https://community.bistudio.com/wiki/count
Well what does the Alternative Syntax say?
no mention of hashmap there
thereforeโฆ?
Then it probably doesn't work ๐
count some hashmap sub elements
something like { _y # 0 == west } count forces
alright ๐
thx
but to be clear. _x would be the key and _y the value, which is an array
yep
๐
What's the easiest way to add the values of two arrays e.g. [1,1,1,1] to [3,5,6,4]
private _result = 0;
if (count _arr1 > 0) then { private _toAdd = _arr1 select 0; _result = _result + _toAdd; };
```etc ๐
apply? 
you mean like vector sum right?
the result should be [4,6,7,5]?
I mean like vectorAdd but for 4 dimensions ๐
apply then 
vectorAdd does it now no?
The result will be in UI screen coordinates, so anything is possible ๐
vectorAdd is only 2D and 3D
Probably not
I member Ded & KK arguing about it yeah
I think he might've done something. because he even was arguing about the performance with KK 
KK said it would be slower, but Ded tested it and said there wasn't much difference
well on dev vectorAdd just trims the array to 3
for now just do apply
or even for 
then I believe BIS_fnc_vectorAdd does it - yet somehow I doubt the perf? ๐
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 ๐
Why not use set (as you're only changing one index)?
to inline it I suppose?
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?
open it:
copyToClipboard loadFile "\a3\ui_f\hpp\definecommoncolors.inc";
you can just unpbo ui_f.pbo
and find it there
ty
use 3den Enhanced and open the Functions viewer ๐
Is this the best way to make a copy of an array? _a = _b apply {_x}
no
shallow copy: _a = _b + []
deep copy: _a = +_b
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?
Never
while [true] is incorrect
{True} ?
Also absolutely no point to [] spawn {sleep 15; twice if you wanted to do it in the same timing
use { } with while
also, all it would do is every cycle create two waiting threads, unlimited
hmm
(and maybe run out of memory, too)
And you put this into a trigger? Without spawn'ing?
Write first, run second, debug last
yeah i'm gonna give it a run after
Think* first actually ๐
Thinking is overrated
uninstall brain then
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?
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
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?
I argued about it with KK and made a working PoC. But I didn't fully implement it
@polar anchor You have posted the solution already
\A3\ui_f\data\map\gui\cfg\debriefing\endDeath_ca.paa this is the path
What are you trying to do?
iconPicture = "\A3\ui_f\data\map\gui\cfg\debriefing\endDeath_ca.paa";
where is that used?
descriptiom.ext
he wants to make it so that by default, arma 3 saves the file following that directory
at least that's what i think he's trying to say
saving isn't possible
overViewPictureLocked="\A3\Ui_f\data\Logos\arma3_white_ca.paa";
this works for example
well uhh
{
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;
};
};```
can't you just do that in Attributes -> General?
no need for the description.ext file
this doesn't
wait ok now i get what you're trying to make
i need to use it inside a notitifcation
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
3den Enhanced Mod
yw
@little raptor does regexFind really need a "returnAll" flag? doesn't really hurt to just always return all hits
I hate you for spelling it 3den btw
Should have been Eden or 3DEN ๐
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
isNil
yeah but why?
read the doc
i did
read it again
Tests whether the variable given by its name is nil or undefined, or whether the given expression evaluates to nil or Nothing.
there is more than just the description
(but the description already contains it)
Tests whether the variable given by its name
@polar anchor ^
Yo anyone here got some expierence with [how to make Item] and is willing to help me with [make item]? ๐ฎ
what are you talking about?
Been trying to put Atropine back into ACE cuz I kinda need it for Purposes but it flat out refuses to exist
how can you save R3F Logistics placed objects between sessions?
now also with case insensitive mode :3
https://robm.me.uk/2014/03/regex-o-modifier/
but it's not in every regex system
An explanation of the little-used โ but handy-to-know โ o modifier to Rubyโs regular expressions.
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.
Ah, so it won't return wookie booKie cookie but wookie booKie cookie separated?
and i is inoptimized of course ๐
o gets you slower creation of the patten, but faster execution.
Better when you run it over long texts
However in the current progression how long it takes to execute? Kinda curious
it takes one
I'm running unoptimized debug build. Maybe I can tell you in a few hours
one speed
I c

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
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;
};
};
};```
How did you do actually?
?
Because findDisplay does only detect currently shown display. You apparently need to launch it before
hint format ["%1", findDisplay 3000];```?
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 ?
Yes
You have to either add the things manually or use the %ALL thing to whitelist all items.
Got it. So with BIS_fnc_addVirtualWeaponCargo (and three others), right?
yes
Result:
0.0128 ms
Code:
"wookie boOkie cookie" regexFind [".ookie"]
Result:
0.686342 ms
Code:
"wookie boOkie cookie" regexFind [".ookie",0]
Ugh... excuse me what
Result:
0.0073 ms
Code:
"I'm a cookie clicker" regexMatch ".*cookie.*"
Result:
0.0128 ms
Code:
"wookie boOkie cookie" regexReplace [".oo/gio", "[$&]"]
Ugh... excuse me what
๐ w-whattttt
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
Wouldn't it make it slower?
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
What about other libraries?
not an option
What does Notepad++ use? 
omg this was so terrible to do ๐
I had to implement exceptions, with exceptions disabled
use SQF try/catch!
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?
This is for units/objects spawned after mission start. So Im wondering how it will work mid mission.
scripting commands exist
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
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.
KK, was asking to find out if someone had already done so to save time.
and if you do so, please let us know in #community_wiki so we can share the knowledge ๐
I can add notes to the pages themselves an I will ๐
plz no, we can use icons
Ah,
I can do so but ill talk with you guys in #community_wiki before I do
sure thing! thanks a lot
The end goal is to roll this with a HC system to result in pseudo caching.
[[Arma_3_Dynamic_Simulation]] 
id assume running it on machine who owns the ai is enough 
(mass-replaced!)
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?
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 
something like this?
this addEventHandler ["HandleDamage", {(_this select 2)/4}];
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
I did 
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?
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];
}
as to setting task state i can use modules as well, don't i?
no you put it in the event handler
no, use the bis_fnc
hmm, alright
you can create the task itself using modules tho
yeah
aight
also complete this part from the wiki (handleDamage):
params ["_target",..."_instigator"];
(_instigator getVariable ["hit_cnt", 0]) + 1]; random ] there
copy paste error 
Thank you
Are there classes / structs in arma scripting?
no
is there a script command to find out if a missile is air to air or air to ground?
some config value maybe you can look for
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?
no
but you can use setVariable to save an array of values when you store them
or use a for loop and pushBack the lbText to it
private
nil deletes a variable
private _var;?
private "_var";
ok thx
you mean to hard code the amount of elements of the listbox in a variable?
if you regularly access them that's the fastest way
_arr = [];
_lb setVariable ["lb_texts", _arr];
lbClear _lb;
{
_lb lbAdd _x;
_arr pushBack _x;
} forEach _someTextArray;
lbClear _lb;
_lb setVariable ["lb_texts", _someTextArray apply {_lb lbAdd _x; _x}];
better, no?
yeah
or maybe just use lbSize
yes
or use a for loop and pushBack the lbText to it
so wait, is there any performance improvement between this 2?
for "_i" from 0 to _elementsInListBox do {
}```
and
for "_i" from 0 to lbSize 7112 do {
}```
you can measure the performance of your code in debug console
gives you the exec time in ms
Is there a biki page explaining the relationship of
- altitude(seemingly ATL),
- object view distance,
- 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).
it doesn't explain why that happens
Ye, not really. I don't know basically anything of rendering & any of that, but have played around enough with different position types ๐
the zooming in Arma is just terribly buggy 
sometimes I zoom in on a tree and it gets lower quality, while those out of my view get better 
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.
will isEqualTo return true when comparing two arrays that have the same values but in different orders?
[1, 2, 3] isEqualTo [2, 1, 3]??
yeah that will return false
i edited it. confirm please
still false
rgr, thx mate
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
set
why even use hashmap here? just use an array, you're mapping to indices anyway
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
you're still using indices
hashmaps are not needed here (they're slower)
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
๐ค
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
hashmaps have unique indexes, not values?
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;
where player vote is unique would be the player unit as key, and the vote as value
hashmaps don't take object as keys
can't i just do:
_playersVotes insert [str _i, []];
}```?
i don't understand that
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
are groundweaponholders entities or objects?
a vehicle ๐คฃ
ah true! objNull risk.
is there a way to detect when a new group is created using the dynamic group system?
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
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
diag_log and systemChat are you friends
that code is crying for hashmaps so bad
i knowwwww lol leo was showing them to me a couple of days ago, just haven't gotten around to doing it yet.
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.
hashmap is still better
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?
(_array select _forEachindex) setPosATL [0, 0, 0];
(_array select _forEachindex) setDamage 1;
why not just delete them?
private _vehiclename = str _launcher + "vehicle" + str _forEachindex;
_vehicle setvehicleVarName _vehiclename;
is that needed?
i did that for debugging when I initially wrote the script. so I could better understand what things were where using your dev tools
first solution i see is looping allGroups, and checking for BIS_dg_reg flag in their namespace, but that's not very efficient
unsure if there is a better way 
waitUntil {
_launcher getVariable ["launcher_captured", false]
};
explain
why wait?!
you modify that variable yourself somewhere, so that means you know when exactly it will be true
you're spawning a new code for every launcher
that's bad 
- that ^
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
run the code there and then, instead of waiting, no need to do this bounce between two scripts
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",""]]
In ace arsenal you should be able to just click import
Trying to give it to a unit using a script. Will I have to give each item individually?
You should be able to just copy-paste the unit you gave the kit
so for the hashmaps I'd do something like... ["opforAttackHeli", "O_Heli_Attack_02_dynamicloadout_F"] as one of the map values? then i'd just do _map get "opforAttackHeli"?
yep
best to set these up globally at mission start in a variables file?
yea
@copper raven more like this then? listed before and after to show change
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
yep
value can be anything, keys don't support every single value type though, this is very useful: https://community.bistudio.com/wiki/HashMap
yeah I'm reading through this while writing them. just figuring out the limitations
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
like this?
https://sqfbin.com/agocuhesuxiyoxevemep
you would use createhashmapfromarray on those values too
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
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
that snippet above works for me. you will need to paste the full snippet you're using
i found the error. was a copy pasta error
probably you did something like:
createhashmapfromarray [...west...]
as is usual. missing ] in one of the arrays of arrays
Nice to see that HashMaps are going good :3
Hello Lou! I just found out, that I can use netIDs to create copy-pastable arrays of groups.
they are netIDs, that's it
works for me ๐
Heya everyone. I am messing around with CfgORBAT. The BIKI (https://community.bistudio.com/wiki/Arma_3:_ORBAT_Viewer#Texture_in_missonConfigFile) suggests using a trick with Preprocessor commands in order to get user texture file paths. I recall that a specific command was introduced that made it redundant. Anyone remember the name of the command?
getMissionPath ?
Exactly. Thank you!
@tough abyss If you get it to work with that, can you post the code in #community_wiki
So we can update the page?
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!
np
Sure will do. I will double check if it works in a PBO on dedicated as well (the true test!).
won't work in SP
(and you don't copy-paste groups, you copy-paste numbers)
will there be select for hashmaps also?
no
ok
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`
@pearl temple see how to use syntax highlight in pinned messages, thanks ๐
Your possible issue:
using isServer + player
Do you have to detach it first?
Thx @winter rose
But there is no error if I execute the commands in the debug console individually?
@grim ravine Sorry, mistype.. code edited ๐
@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 ^
@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.
playSound does not take any sound source, you are thinking of say or say3D
@winter rose Right you are! ๐
Will try the say3D command instead, thx.
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.
@faint oasis https://feedback.bistudio.com/T154260
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 ?
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
Try
deleteAT (_runners find _lurker);
instead of
_runners = _runners - [_lurker];
selectRandom _runners, not selectRandom [_runners]
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!
I'm level medium at scripting
then you should already be familiar with event handlers
yes but I can't get how to actually find the unit that destroyed the building
((player))
which event handler do you use?
BuildingChanged for detecting if a building is destroyed
not sure if MPKilled will help to find the unit
you have to add the event handler before it's destroyed
I'm not sure if map objects are global ๐ค
you may have to use "killed" if they're not
KP Liberation actually have a feature where it detects when a building is destroyed
I wish there is a way to view the map through eden
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
you don't need KP lib
just get the nearestTerrainObjects and add a killed/MPKilled EH to it
private _buildingARR= nearestObjects [_loc, ["House", "Building"], _area];
would this work?
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
sorry didn't quite understand that
by simulation you mean dynamic simulation and stuff right?
oh ok
getText(configOf _obj >> "simulation")
thanks
it should be house:
if (getText(configOf _obj >> "simulation") == "house") then {
//add EH
}
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
everyone has sqm, everyone see editor-placed markers (they are global)
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
it's "local" anyway (as in created on every machine) but synchronised because they have the same name
I switched to boost::regex afterall..
Better perf!
Result:
0.0065 ms
Code:
"wookie boOkie cookie" regexFind [".ookie"]
Result:
0.0048 ms
Code:
"I'm a cookie clicker" regexMatch ".*cookie.*"
Result:
0.0073 ms
Code:
"wookie boOkie cookie" regexReplace [".oo/gio", "[$&]"]
and named groups!
"wOokie boOkie cookie" regexReplace [".(?<test>oo)kie/gio", "[$+{test}]"]
wasnt there a command to get an unlocalized string from the config?
getTextRaw?
yep thanks :)
get3DENSelected is the command to get โcurrently opened attributes' objectsโ?
yes
yes I got it pretty thanks
I will also edit it to include || getText(configOf _obj >> "simulation") == "building"
There's no such simulation 
then how would I get the buildings
must make another EH right?
What do you mean buildings?
Houses are buildings
A house IS a building (and vice versa)
Am I saying it wrong?
'house' is the simulation used in arma for (most) buildings
so that code will cover what you're looking for
alright
it's just a name, like how static weapons use the simulation 'tank'
oh alright, yeah forgot about that lol
been playing the game for 1 month so its too much info pardon me
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
i've always done it this way
_runners = [p1, p2, p3];
_lurker = selectRandom _runners;
_runners = _runners - [_lurker];
Same problem with that which is why I tried a different method
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.
private _players = [objNull, objNull, objNull, objNull]; // put ur players here
private _lurker = (selectRandom _players);
private _runners = [];
{
if !(_x isEqualTo _lurker) then {
_runners pushBackUnique _x;
};
} forEach _players;
// Kill lurker and runners
_lurker setDamage 1;
{ _x setDamage 1 } forEach _runners;
this could also work
I don't think I said this but I want to keep the _lurker out of the _runners array entirely as I want to run some other scripts just for the _runners. With pushBackUnique won't the _lurker player still be included in the _runners array but just at the back?
No runners wont include the lurker, go try it
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
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
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
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;
private _findLurkerAndRunners = {
params [
["_allPlayers", [], [[]]]
];
private _lurker = (selectRandom _allPlayers);
private _runners = [];
{
if !(_x isEqualTo _lurker) then {
_runners pushBackUnique _x;
};
} forEach _allPlayers;
[_lurker, _runners];
};
private _players = allUnits;
([_players] call _findLurkerAndRunners) params ["_lurker", "_runners"];
``` example with allUnits as players
Am very curious what lurkers and runners are, in this context ๐คจ
Had a question of my own
Making a gamemode similar but different to Dead by Daylight but for arma. Those are the names of roles.
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) ?
the more AI you have, the more dumb they act
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.
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.
Idk I've never touched AI, they are pretty network intensive in a3
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)
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.
If you are looking to create atmosphere music and effects are the best way to go.
Thanks guys. I did this on a previous mission. Works great on hilly maps (vanilla maps), where you can break up the scenario physically for an infantry player. Ambient battle sound mods, scripted explosions, tracer modules, certainly did that trick. You are right.
Just experimenting with a different atmosphere here. Let me dig up an example video
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
^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.
you got a quantum computer?
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).
Very interesting! I have worked with event handlers in terms of zero damage by source of damage
That would set most computers on fire and burn your house down.
I'm very intrigued by this idea although I have no clue on how to change the direction of ammunition.
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.
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
_previousObject
addMissionEventHandler |#|["BuildingChanged", {
if (_this select 2...'
error generic error
}];'
Error Missing ]
well that's not the only error you got goin on
whats next?
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?
Wait
This
I mean is it even achievable?
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.
I have been trying to do this for the past two days
lets clean up your script first
Alright
But isn't _previousObject local? Shouldn't it function normally here?
well you never defined _previousObject ever
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
also BuildingChanged is no good for your needs. HitPart is better since it actually tells who fired the shot
Do buildings have parts?
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
I think it does work
place a building object and do getAllHitPointsDamage object and see if anything pops up
In its inti?
nah, just give it a variable, start the mission then run it from debug
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?
oh ok
that command gives [[hitpoints], [selection names], [values]]
all values are zero then
i think it would be. you'd need to apply it to all terrain objects that have the parent class of "building"
not sure how I would do that lol
well, you'd have to do a more specific subclass
https://community.bistudio.com/wiki/Arma_2:_CfgVehicles#Static_Class_Vehicles arma 2, but it still applies "House" would work
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
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?
well I'm not sure what _buildingARR is
if you didn't place the building yourself, they aren't part of mission objects
they are terrain objects
_buildingARR is the array name that that person gave the return for the command
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
I will need to check if _target is a building?
actually, you could do it differently too
here we go again
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
seems simple enough
how did you learn to use eventhandlers?
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
I have no idea how to use the eventhandlers by myself sadly
no videos about it at all
like I never considered hitpart as a solution to your problem until wipeout mentioned it
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
true, then check if shooter is AI. if not punish
using if then - typeOf _target == "buildingclass" && _shooter == player and forgoing the array
well why not check if the player was the one who shot?
that's better
need to check to see what his target is as well
Yes
That would check it?
player addEventHandler ["HitPart", {
(_this select 0) params ["_target", "_shooter"];
if (_target isKindOf "house" && _shooter == player) then {
//code
};
}];
Now I got how to use the EHs thanks to you
You saved the wall next to me from being banged
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.
Isn't there a way to compile arma's code?
Like when I make an sqf and stuff?
Other than reloading the mission
if you have a file in the mission folder, you can just call it directly from debug if you want
That's when I load the mission
oh i see what you mean
But when I want to check inti.sqf is it possible?
what you mean "check" it
you can rerun init.sqf with execVM yes
Compile
compileScript ["init.sqf"] ?
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
#arma3_scripting message
yes in debug
No I know about that
But I don't want to exec
Anyway got it
Thats not how the HitPart EH works
just run the compiler on it to see if the code is not wrong, OKโฆ
Here we go again
yeah looked at it again, no its not cause we didn't collect the hitparts lol
Aren't these the ones I sent previously?
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
You mean check if its damaged?
isplayer
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
};
}];
};
10kms radius?
Rip PC
idk tweak it to what you want lol
you do it during init
init.sqf
it takes a few second and it's done
Just joking lol
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
and worldSize / sqrt 2 for radius
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;
}];
with setVariable and getVariable
setvariable
setVariable

dang we took him out back and hit him with a machine gun
Hmm, never used it like that. Alright, appreciate it. Too easy
so it says type string, expected array at |#|nearestTerrainObjects
but where is the string? isn't that an array?
oh
has to be an array of types, not just single type
Hey!
here comes arma 3 dev
it doesn't seem to fire up
rip
systemChat format ["%1 shot %2", _shoot,_unit]; I added in the code
it should say something
you mean _shooter?
like you caused greater than 80% damage to the building and it didn't work?
what did you use to blow it up?
I hit it with a 125mm HE-FRAG-FS
russian T-14 round
maybe instead of isPlayer _shooter try _shooter == vehicle player?
ok
wait one
it worked
thanks man
again you saved the wall
from being demolished
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
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
ooooooh I see, fragmentation of the rounds hitting.
yes
they already warned about it
in the docmuentation
If simultaneous damage occured (e.g. via grenade) EH might be triggered several times.
so
it explodes
sending fragments
the explosion destroys the building
then the frags damage the building a bit
so it records both
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
arma 3 moment
maybe try the "hit" handler
no just "hit"
yes it will
anything wrong?
!code
```sqf
// your code here
hint "good!";
```
โ
// your code here
hint "good!";
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
so much hotter
I wouldn't say that about text but ok
yeah but have you seen that RED?
what the error
doesn't give one?
nope it doesn't fire up
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
it takes two hits to destroy the building
ok
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
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
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
I believe it was setVectorDirAndUp. If that doesn't work, ping Leopard, he knows.
_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?
Hit isnt that reliable. try damaged or handleDamage or hitPart
I tried dammaged
same thing
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
try isPlayer _instigator
ok
because remember, _instigator is who pulled the trigger, so we don't use vehicle player for that
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
we use HandleDamage
however keep in mind terrain objects may behave a bit different to editor placed
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];
};
}];
};
for testing you should remove that if condition
first you need to see if the EH triggers at all
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];
}];
};
You can't kill house if I am correct
Use https://community.bistudio.com/wiki/Arma_3:_Mission_Event_Handlers#BuildingChanged
we have gone full circle now lol
What is he trying to do? See if a plane destroys a building or something?
well
this
go back to the buildingChanged
lmao
it was the original idea before others suggested other handlers which sent you in a spiral lol
but now you know how to define local variables correctly lol
_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
reeeeeeeeeeeeeeeeeeeeeeeee
I may have found it
still gives me the same error
bruh
it says there is something wrong with line 8
its not even close, give me a sec to write something
Finally got to testing this and it still doesn't properly work. The "lurker" dies once about every 5 tries.
damit
forgot the "then"
All that code does is find a lurker and runners, nothing to do with dying
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
its gonna take a while to for me to figure out something for you and also search through all of KP's functions on the github. Why don't you ask him directly how he does it?
@hollow thistle
I did
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
he is one of the top guys in the community, if he didn't figure it out, its probably not possible
arma 3 dev where are you
not their job lol
extreme bruh moment
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
laughs in the shadows
cries with extreme pain
pain au chocolat ?
le fishe au chocolat
๐ค ๐ฅ
meanwhile i need to get back to troubleshooting this hud dialog problem I'm having for days
which i just solved...
i guess i just needed to look away from it for a little bit
well
_x = addMPEventHandler ["MPHit", {
anything wrong with this line of code?
oh god here we go
You could try writing a script that replaces map object with script spawned ones.
heyyyyooooo! he approves #arma3_scripting message
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.
and
how would I detect
if it was hit by a player
I assume the Hit or Dammaged or HitPart or HandleDamage will work on non terrain buildings.
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
that's normal for indirect damage
so just make a conditional to skip that _projectile for the count
how
i already found it. sec
