#arma3_scripting
1 messages Β· Page 691 of 1
Hmm, but only applies when you use the designated methods with the array right?
as when I do
_a = [];
[_a] call {
params ["_b"];
_b = [1];
};
systemChat str(_a); //output == []
But had I used set / push-back then it would have changed. So the reference is only to the elements of the array passed, and not the actual array pointer?
don't think of sqf like other languages 
_b = [1]; //new array
set and pushBack modify the array by reference. that's why _a changes. because _b is a reference to _a
even if you did:
_a = [];
[_a] call {
params ["_b"];
_c = _b;
_c pushBack 1;
};
systemChat str(_a);
_a would change
in other words, when you did _b = [1];, you changed the reference
ah, was just about to clarify if it was because a new assignment would change the reference. Alright that makes sense and I got a bit wiser today π
Thanks for the clarification and help!
@wind hedge "Can you create a simple object using the vehicle's model instead of leaving no wreck on the crash site? It would be way more immersive like that"
It is possible, but not logical.
The script works only if vertical velocity is more that 50 m/s. It is enough to completely destroy the plane, and what could left after that is the only some small parts, and I don't have a proper geometry for it.
For velocities below 50 m/s the plane has a standard behaviour.
Im trying to learn how to script in arma but have a couple questions
1 how did you learn/what were some simpler scripts you made when you started scripting
2 I was looking at the scripting examples on the arma forum, and ive seen this other places to, but what does _x mean/do
wait when was that page changed? 
@barren pewter as for answers to your questions:
- most people start with a simple action script I guess. writing stuff like telling AI where to go is pretty simple too
- https://community.bistudio.com/wiki/Magic_Variables#x
How do I make a task to kill a group of units?
do you mean a briefing task, or detect when such group has been killed?
How can I have Civilians that spawn from Civilian Presence module join a custom group? [this] join grouName in the "Code On Unit Created" box but didn't work. they are still assigned to NULL-group
most likely because this is not the proper keyword?
detect when a group has been killed
@winter rose i've tried this, [this], but yea i'm not sure what the correct keyword to use.
did you read the doc?
units theGroup findIf { alive _x } == -1
that's good
taking a bit more performance, but way more human-readable, your code is valid
as of now when the group dies nothing happens
it is synced to the success state
Just tested out your condition, works just fine now
Thank you
I am having some trouble replacing a selected string in an edit box with a predefined text
if (_length < 0) then //Check if it was selected from right two left
{
_start = _start - abs (_length);
};
private _chars = _content splitString ""; //Split the whole string
_chars insert [_start + abs (_length) + 1, [_textNew]]; //Insert the new string behind the selected text
_chars deleteRange [_start, _start + abs (_length)]; //Delete the selected text
....join the string again.
Right now it's not properly replacing it.
deleteRange is [from,count] so you would want this wouldnt you?
_chars deleteRange [_start, abs (_length)];
Yes
As weird as it sounds. I just noticed that.
I thought it was startIndex, endIndex 
Thanks for your help connor π
for "_i" from _end to _start step -1 do
{
_chars deleteAt _i;
};
Gave me the hint that something is wrong with deleteRange (rather with the way I use it) π
anyone able to give me a point in the right direction to display the current ingame time via script?
Ah. tah
I use
[daytime, "HH:MM"] call BIS_fnc_timeToString```
hey, how do I add a scope to a weapon (without the player doing it manually)?
context, I'm wanting a weapon on the ground to have a certain attachment
I looked into addWeaponItem, etc, tho it fails to work for some reason
Is there a way to set a trigger when a unit is fired upon? I hate having snipers/mgs/ move around when setting an ambush or on overwatch, so I'd like to set them to disable ai or something so they stay still and just shoot- but I don't mind them trying to relocate/hide if they start taking heavy fire. I was searching around the wiki but I can't find anything resembling a "isBeingFiredAt". The idea would be hold/disable moving until "IsBeingFiredAt" and then re-enable it.
@next kayak Catch their combat mode (no EH, cycle needed), I think it is the only reliable way.
FiredNear is just for sounds, so it is useless for long ranges.
Also you can add MPHit EH in addition to combat mode.
Oh! I hadn't seen that list of event handlers before, looks like there's a "suppressed" EH as well that might fit the bill
Hmm, but that one looks very specific, might be too tedious lol
Heh, I didn't see the suppressed EH too π Seems like I can try to improve my campaign AI scripts now.
private _noAdminExists = isMultiplayer && {(allPlayers findIf {(admin (owner _x)) != 0}) == -1};
this doesnt cover self hosted "admin"
how to detect such for remote clients?
or you need to make a PV with VAR_IsHosted = isServer && !isDedicated; ?
Was about to suggest that.
Available to any admin (voted in / logged in) or server host
This might work
yes this is to detect the admin, but its local only
if (isServer) then
{
if (serverCommandAvailable "#kick") then
{
missionNamespace setVariable ["ww2_selfhosted",true,true];
}
else
{
missionNamespace setVariable ["ww2_selfhosted",false,true];
};
};
waitUntil {!isNil "ww2_selfhosted"};
// Periodically check if an admin is not logged in and force random select factions
// this is done in a loop over 60 seconds incase an admin did log in
// but disconnected before confirming their selection
while {serverTime < ww2_faction_init_timeout} do
{
sleep 0.1;
// if (ww2_faction_init_complete) then {breakOut "root"};
private _noAdminExists = isMultiplayer && {((allPlayers findIf {(admin (owner _x)) != 0}) == -1) && {!ww2_selfhosted}};
if (_noAdminExists || (!isNil "BIS_factionSelection")) exitWith {};
};```
if (serverCommandAvailable "#kick") then
{
missionNamespace setVariable ["ww2_selfhosted",true,true];
}
else
{
missionNamespace setVariable ["ww2_selfhosted",false,true];
};
Can be reduced to missionNamespace setVariable ["ww2_selfhosted", serverCommandAvailable "#kick", true];
I'd move the isMultiplayer check to the beginning of the file and just exit if it's single player. Then you can omit the check from the other conditions.
To self check the admin state of a local client, use
BIS_fnc_admin.
Got two questions about nearestObjects - i did try to find all vietnam bunkers ( Land_vn_b_trench_bunker_01_01 ) but with nearestObjects im getting the 02_01 and 03_01 too - how to prevent this? I guess this coming from the hint in the BIKI that the comparison is with isKindOf right?
And if i place the bunker in VR , i can attach a spawned laptop ( createVehicle 0,0,0 ) without any problems - but if i go to Cam Lao Nam, all Laptops are @ 0,0,0 and didnt attach - dont have any clue, why this happens
buildLaptop = {
params ["_building", "_counter"];
hint format["Building: %1 | Counter: %2", _building, _counter];
private _terminal = createVehicle ["Land_Laptop_device_F", [0,0,0],[],0,"can_collide"];
_terminal setVehicleVarName "terminal";
_terminal attachTo [_building, [-1.85,2,0.19]];
_terminal setDir 90;
[_terminal] execVM "Scripts\HackEX\hackex.sqf";
systemChat format["TerminalPos: %1", getPos _terminal];
private _marker = createMarker [format["Marker%1", _counter], getPos _terminal];
format["Marker%1", _counter] setMarkerColor "ColorRed";
format["Marker%1", _counter] setMarkerType "mil_warning";
};
buildLaptops = {
params ["_buildings", ["_amount", 20]];
_blds = [_buildings] call getObjects;
for "_i" from 1 to _amount do {
private _building = selectRandom _blds;
[_building, _i] spawn buildLaptop;
};
//{ _x spawn buildLaptop } foreach _blds;
};
getObjects = {
params ["_buildings"];
hint format["Buildings: %1", _buildings];
_pos = getArray(configFile >> "CfgWorlds" >> worldName >> "centerPosition");
_blds=nearestobjects [_pos,_buildings, 20000];
_blds;
};
[["Land_vn_b_trench_bunker_01_01"]] spawn buildLaptops;
try nearestTerrainObjects instead
But with nearestTerrainObject its only possible to search for keywords not the objectname?
_result = _result select { typeOf _x == "Land_vn_b_trench_bunker_01_01" };
I believe the others are inheriting from the 01_01
Thanks, i'll give that a try (filter out with typeOf)
@winter rose Works perfectly, tyvm! Now only the problem exists, that the laptops doesnt attach to that building like in VR - they did stuck on 0,0,0 - do you have any hint why this happens on Cam Lao Nam but not in VR? Is it not possible to attach objects to map content itself (in VR the bunkers are place as objects).
I believe it is possible, but I have no idea
try with vanilla assets/no mods/cdlc loaded?
No didnt try that, because in VR it works - so my only guess is, that something is different between placing objects in VR (this bunkers) or using the same bunkers on maps, where they are not placed in mission.sqm
no I mean, try to see if it is "usual behaviour" or "CDLC issue" ^^
ah this way - no, didnt try but ill give them a try
need a hand, unsure what im doing wrong,
initPlayerLocal.sqf
introSeq = [] execVM "introScript.sqf";
introScript.sqf
// Start with a silent black screen.
titleCut ["", "BLACK FADED", 999];
0 fadeSound 0;
// Spawn text effects.
_this spawn {
params[
["_missionName", "Operation | Storm"],
["_missionAuthor", "by M. Texas"],
//["_missionVersion", "Version 1.0"],
["_quote", "βThose who stand for nothing fall for anything.β β Alexander Hamilton"],
["_duration", 9]
];
// Starting quote as volume fades in.
titleText [_quote,"PLAIN"];
titleFadeOut _duration;
_duration fadeSound 1;
sleep (_duration - 2);
// New "sitrep style" text in bottom right corner, typed out over time.
[
[_missionName,"font = 'PuristaSemiBold'"],
["","<br/>"],
[_missionAuthor,"font = 'PuristaMedium'"],
//["","<br/>"],
//[_missionVersion,"font = 'PuristaLight'"]
] execVM "\a3\missions_f_bootcamp\Campaign\Functions\GUI\fn_SITREP.sqf";
// Fade from black, to blur, to clear as text types.
sleep 3;
"dynamicBlur" ppEffectEnable true;
"dynamicBlur" ppEffectAdjust [6];
"dynamicBlur" ppEffectCommit 0;
"dynamicBlur" ppEffectAdjust [0.0];
"dynamicBlur" ppEffectCommit 5;
titleCut ["", "BLACK IN", 5];
};
Problem im facing is on a dedicated host, the screen stays black and does not do anything.
and local now. Last night, worked fine.
do you have any error messages?
whats the difference between
car1 attachTo [car2];
//and
[car1,car2] call BIS_fnc_attachToRelative;
?
the function keeps the inclinations iirc
Its saying a [ is missing on line 30
line 30
] execVM "\a3\missions_f_bootcamp\Campaign\Functions\GUI\fn_SITREP.sqf";
yeah you commented out some arrays and left the , semicolon
.
// Start with a silent black screen.
titleCut ["", "BLACK FADED", 999];
0 fadeSound 0;
// Spawn text effects.
_this spawn {
params[
["_missionName", "Operation | Storm"],
["_missionAuthor", "by M. Texas"],
["_missionVersion", "Version 1.0"],
["_quote", "Those who stand for nothing fall for anything.β β Alexander Hamilton"],
["_duration", 9]
];
// Starting quote as volume fades in.
titleText [_quote,"PLAIN"];
titleFadeOut _duration;
_duration fadeSound 1;
sleep (_duration - 2);
// New "sitrep style" text in bottom right corner, typed out over time.
[
[_missionName,"font = 'PuristaSemiBold'"],
["","<br/>"],
[_missionAuthor,"font = 'PuristaMedium'"],
["","<br/>"],
[_missionVersion,"font = 'PuristaLight'"]
]; [] execVM "\a3\missions_f_bootcamp\Campaign\Functions\GUI\fn_SITREP.sqf";
// Fade from black, to blur, to clear as text types.
sleep 3;
"dynamicBlur" ppEffectEnable true;
"dynamicBlur" ppEffectAdjust [6];
"dynamicBlur" ppEffectCommit 0;
"dynamicBlur" ppEffectAdjust [0.0];
"dynamicBlur" ppEffectCommit 5;
titleCut ["", "BLACK IN", 5];
};
Ive updated it and now i get no error messages. However the text doesnt apear at all
!code
```sqf
// your code here
hint "good!";
```
β
// your code here
hint "good!";
your parameters arent being passed to "\a3\missions_f_bootcamp\Campaign\Functions\GUI\fn_SITREP.sqf"; also I believe theres already a function for this but w/e
you have
[
[_missionName,"font = 'PuristaSemiBold'"],
["","<br/>"],
[_missionAuthor,"font = 'PuristaMedium'"],
["","<br/>"],
[_missionVersion,"font = 'PuristaLight'"]
]; [] execVM "\a3\missions_f_bootcamp\Campaign\Functions\GUI\fn_SITREP.sqf";
it should be
[
[_missionName,"font = 'PuristaSemiBold'"],
["","<br/>"],
[_missionAuthor,"font = 'PuristaMedium'"],
["","<br/>"],
[_missionVersion,"font = 'PuristaLight'"]
] execVM "\a3\missions_f_bootcamp\Campaign\Functions\GUI\fn_SITREP.sqf";
I believe
anyone able to help me im trying to make it so only certain people with a set variable can open a door but im unsure whats wrong with it:
if ({player getVariable ['securitypass',0])==0}) then {this setVariable ["bis_disabled_Door_1", 1, false];}
seeing how you are using this I assume that you are using an init field
don't
Have you tried without the curly brackets around your condition?
wait so don't use an init field how come?
yeah i realised my issue with the curly brackets now i have
if ((player getVariable ['securitypass',0])==0) then {this setVariable ["bis_disabled_Door_1", 1, false];}
Hi there
When I load my mission in the editor, arma suddenly throws me this error, without any relation, file or script named. I have absolutely no idea where this is coming from, any ideas?
15:56:04 Error in expression < }; }; }; };>
15:56:04 Error position: <;>
15:56:04 Error Missing )
15:56:04 Error in expression < }; }; }; };>
15:56:04 Error position: <;>
15:56:04 Error Missing )```
any way to return the players currently selected "throw" weapon?
Also when on the server the mission will not show up with any slots?!
The only few things I changed are placing tripwire flares and some motorbikes but removing those did nothing.
see your rpt, it may have more details
when there is no details, it's usually in a CfgFunctions
looking at it with a buddy right now, possible mod issue with blastcore murr unsure yet, still checking
@willow hound π
is there a clean way to check if a player is indoor ? In a confined space ?
no
not really really, you can check if the player is within a building's bounding box, and/or use a lineIntersects to chexk if there is a roof above his head
buuut it would not be foolproof
the idea is to have a better local overpressure effect when using offensive grenades in a confined space
I guess even if not foolproof, could be doable
yep, did that for some rain effects π
like checking if in building first, and if yes checking for a line of sight between victim and 'nade (somehow meaning "in the same room")
wut
to see if the rain would hit the player or not
I was pretty sure that rain stops on the roof in A3 π€
anh
get it
Lou_fnc_isPlayerWet or something like that
i thought there might have been a soundcontroller but i was thinking of the 'houses' one
never worked with that
how is this working ? I see it's possible to define custom sound controllers
do houses even make a sound? 
looks more like an engine readable value for controlling sound sources more accurately
houses local density of object type βbuildingβ, derived from map <0;1>
Good day. From anim viewer I do have anim name and even path, but how do I force unit to play it? π€ I tried playMove and playAction with no luck so far.
path is useless
if the animation doesn't connect to the current animation, you'll have to use switchMove (or switchAction if it's an action) to get there
Thank you, that worked! π
If anyone may know, Is there anyway i can make AI only enter combat/alert if they're actually fired at, i've tried the vanila settings to not fire unless fired upon but the AI begins to shoot if they see the other person could shoot at them
set their AI to CARELESS, and trigger the AWARE/COMBAT mode with a suppressed event
Would that be possible with zeus or only editor?
I have no idea.
Im trying to setup up enemy ai that will attack one of six points randomly.
I was thinking about having a varible be set to random 6 and then have a if command for each value that syncs that enemy to one of the points. For a quick test i just set the varible to 1 and had
if (_myVar == 1) then {
opforSquadLeader1 synchronizeObjectsAdd [attack1];
};
I dont get any errors on game start but when the game starts he doesnt do anything. I also double checked to see if ai was enabled and it was. I probably made a really simple mistake because im new to scripting. Thanks ahead of time.
its far from foolproof.. balconies are a real problem
are they in a building or not?
is what I use.. it has a fairly reliable go at getting balconies and roof overhangs and deciding they are not in a building
you can convert the boundingboxreal 0 into a marker and do in marker or similar
Hi guys. Is it possible to get to know if map is open now? I have tried:
ctrlEnabled 51;
ctrlShown ((findDisplay 12) displayCtrl 51); - always true
ctrlEnabled ((findDisplay 12) displayCtrl 51); - always true
ctrlFade ((findDisplay 12) displayCtrl 51); - always 0
What else to try? π Thanks.
first of all, what is attack1?
second of all, syncing something to an AI doesn't mean he'll attack it.
it's utterly meaningless (syncing doesn't do anything in the game at all)
Exactly! Thanks ))
@blissful flower type utils 5 in debug console then search for whatever keyword you need like in this case map, many commands are explicit with names
or check the wiki for command groups too ^^
https://community.bistudio.com/wiki/Category:Command_Group:_Map
@little raptor Attack 1 is the cba Attack module. ai groups attack torwards the position of the module when it is synced to that group's leader. Ive used the module many times in simple missions that didnt involve scripting. Im sure there is a better way to do this, I was just trying to see if it was possible to do it with something I was more familiar with. How would you go about making them attack one of several positions?
What EH can I use to catch a bomb explosion? MPKilled/Killed doesn't work with it.
creating modules with scripts is a bit complicated:
https://community.bistudio.com/wiki/Modules#Spawning_a_Module_by_script
also I think syncing is uni-directional? I'm not sure. but using:
attack1 synchronizeObjectsAdd [opforSquadLeader1];
is safer
How would you go about making them attack one of several positions?
there are many scripting commands for commanding the AI.
you can for example give them waypoints:
_attackPositions = [_pos1, _pos2, _pos3, _pos4];
_group addWaypoint [selectRandom _attackPositions , -1];
there is no EH for that
you have to use a loop
Hm... What if I catch the projectile at Fired event? How can I catch the collision?
yes, you have to use a fired EH and use a loop like I said
the bomb has collided when it's dead
isTouchingGround/EPE is not for projectiles, right?
no
Sad, thanks. I need an exact time, to simulate some effects...
they can't "touch the ground"
yeah it's been requested several times before, but I don't think the devs are interested π
Hmm... I have an idea. How about to attach something to the bomb, and catch the Explosion event. or something? π
it can work, yes
catch killed for that other object
@little raptor does -1 in your script mean all of the data in the array?
no:
https://community.bistudio.com/wiki/addWaypoint
Since Arma 3 v1.90, -1 may be used for exact waypoint placement
Oh, thank you kind sir!
np
also in case you didn't notice:
selectRandom _attackPositions
it selects one of the attack positions randomly
Quick question if anyone knows, what produces the biggest Explotion in vanilla Arma?
GBU-12?
Is there a way to spawn just the explotion or would I have to go with ```sqf
CreateVehicle
?
you can create explosion effects
Would they do dammage?
I think so. But I think only small damage is possible?
I think this command gives them damage:
setParticleFire
Oh nice!
Thnx
btw
just found this:
https://forums.bohemia.net/forums/topic/216006-spawn-biggest-vanilla-explosion/
Just in case anyone else browsing here is interested
Ill read on it
this forums topic may interest you:
https://forums.bohemia.net/forums/topic/199056-need-to-make-a-small-explosion-on-trigger/?do=findComment&comment=3123988
Thank you!
Does anyone know how to make AI drive a vehicle after getting in?
"d" trim [" ", 0]; // Returns ""
Is that how it is supposed to work?
doesn't look like it in the biki
I know this is a noob question but here goes. How do I easily test changes of an addon I'm making? It's just an addon that changes the vanilla flashlight strength. But I'd rather not have to close the game and restart every time I make a change.
Thnx for that clue, I was making an oil-tower explosion and that was exactly what I needed to make a cool aftermath!
setPilotLight?
If you accept, that SOGPF is vanilla too - the biggest explosion is not the GBU anymore - its the 15'000 lb Daisycutter ( vn_bomb_15000_blu82_dc_ammo ) - and if you dont want that big explosion, have a look on the little sister ( vn_bomb_500_mk82_se_ammo ). Absolutely insane, as you see the airblast too on this explosions.
Can AI planes keep a desired altitude, without following the ground surface?
No, it doesn't work, the plane will follow the ground level
should follow sea level
also make sure you use only one type of the command, not both
looks like a bug to me 
Final height is
flyInHeight max flyInHeightASL
if you want it to fly low, make sure to lower the flyInHeight
Yeah, thanks. Already confirmed by dedmen in #arma3_feedback_tracker
Wasn't there a command added to set the icon of a diary entry? setDiarySubjectPicture
Is it possible to create another slot for clothing? (e.g. glasses, hats, nvgs slots) I want to make all my custom clothing barefoot and then have shoes as a different object.
@quick sigil Why not to create an action for it? Like "Select [loadout1]", "Select [loadout2]"
That would require making every single model with shoes
Impossible
So possible but only with engine changes?
Well if you really want to get creative, with a bit of inventory UI tweak (for boot selection/slot), and creating boots as placeable objects as well as an inventory item , then attaching to the characters' feet could maaaybe maybe maybe (like 5%[well, things tend to go wrong when pushing ur luck too much]) work. Not something I would invest time on though. Of course "boots" gotta be modelled properly, covering the actual uniform model's boots which would be a hassle on its own I'd believe.
openMap true;
hint "Choose where you want to be TP";
mapclick = false;
onMapSingleClick "clickpos = _pos; mapclick = true; onMapSingleClick """";true;";
waituntil {mapclick or !(visiblemap)};
_pos = [clickpos, 250, 1000, 3, 0, 20, 0] call BIS_fnc_findSafePos;
hint format ["%1",_pos];
player setPos [_pos select 0, _pos select 1];
hint 'TPing';
So i currently have that, i'm hitting a generic error in expression at the waituntil "OR".
(End goal being that it create local marker on friendly unit and TP the player around said unit in a kilometer radius
Any one could point me to my error ? ^^'
thanks c:
use map click EH plz
Try to spawn your code
Event handlers.. Should have checked that >.> XD
Generic error with waitUntil is often a "suspension is not allowed here" problem.
Mh ok, i guess i get why it's doing that then
And time to read the wiki for the EH c:
you can also do without public variables and only doing "on click = teleport + remove EH" π
Create EH when opening the map -> Teleport the player -> Delete EH ?
no:
add map click event handler that on click:
- teleports the player
- deletes itself
Q: is there a way to dynamically add action menus to an object, let's say, as the action is opening, a request/response event sequence?
or better yet, open a sub-action menu given a top level action...
addAction and scripting π
it seems like maybe BIS_fnc_createMenu is a starting point, but the docs seem, cryptic, undone
https://community.bistudio.com/wiki/BIS_fnc_createMenu
doc is a placeholder indeed
Well, thanks Lou and ansin π
Works like a charm :p
Now time to add a timer after death EH
my goal there is to present an unload captives menu.
currently I could piecemeal add actions to the vehicle.
but it seems more appropriate to iterate through loaded captives and present a comm menu if possible...
ooor not use the action menu at all and use an interface
action menu is ebol for lists π
meh a full on UI is kinda overkill. that's why I am π on the comm menu potentially.
if it depends on the amount of people in there, you may want to go simple combobox + OK button instead
I mean, what if you have 20 guys in the vehicle, you have multiple subpages?
honestly I don't know how many captives could be loaded, maybe, also depending on the vehicle cargo positions. will not be that terrible.
I just need an easy way to roll them up and present a comm menu. wrapping my brain around that approach.
one thing I know for certain, the current approach juggling loaded, unloaded, tracking action IDs, is UNWIELDY and CLUMSY putting it mildly.
@dreamy kestrel
Comms menu is probably more suitable for that. They are easy to make too
using showCommandingMenu, is there a hideCommandingMenu, or the engine just hides automatically?
ShowCommandingMenu "" will hide it
yessir studying the protocols there, seems like that's a strong fit
I don't think the array version exists on the wiki π€
I may have to write about that later.
could just stuff all the vehicle cargo position captives in there in a simple transform.
stupid question, how do I connect that with a specific vehicle?
I need something like "CursorOnVehicle" visibility perhaps, perhaps naming it something like "#vehnetid:mymenu_unloadcaptives"
or perhaps "PlayerVehicleCanGetIn" is appropriate here, i.e. unloading captives from a vehicle, that the player can also get into, might make sense.
How can you get the pointer / index of an (simple (one dimension)) array in forEach loops? Is that achieved with Hashmap? Or is that not possible and only be possible in a for loop?
Thanks - did overread many times the text " The index of the current element is accessible via _forEachIndex" π
It's not like I haven't had the BIKI entry open umpteen times already
All user menus have the tag #user
Open it with an action
is there an array.shuffle() method?
There's a bis function
Not sure how fast it is
thats alright, just have to shuffle a bunch of markers rarely
BIS_fnc_arrayShuffle?
I've used it many times, it works great...
fair enough; easy enough to proxy in then. thanks...
I use that to shuffle a CBA namespace (LOCATION) array feeding a CBA state machine. I have not measured it, but it seems fast enough for what it is doing.
re: showCommandingMenu, what is the script-string exactly? In the example it seems to want an associative ARRAY, ["expression", ...]?
which example?
not example, okay, in the notes...
https://community.bistudio.com/wiki/showCommandingMenu
ok
what is the script-string
it's a string, which contains a script
and not an array? I am confused...
and then, what happens if I would like to pass arguments? if I cannot I think I can workaround that, but I need to know that as well.
that page already showed one example
["Option-1", [2], "", -5, [["expression", "player sidechat ""-1"" "]], "0", "0", "\ca\ui\data\cursor_support_ca"]
you can't pass arguments to it
Have another question regarding offloading content to other scripts
I have a script from someone else, which loads the content of another script with call compile preProcessFileLineNumbers like this
_defaultValues = [] call compile preprocessFileLineNumbers ("defaultvalues.sqf");
In the defaultvalues.sqf there are three other arrays, which then returned back. Like this
_accounts = [];
_files = [];
_customCommands = [];
[_accounts, _files, _customCommands];
I have now my own function to offloading the arrays to this function and i want to load this into the defaultvalues.sqf .. but however i did integrate them, it doesnt work
My function file
_customCommands = [];
customCommands;
How to call this in defaultvalues.sqf? Did try with call, but doesnt work
_accounts = [];
_files = [];
_customCommands = ???
[_accounts, _files, _customCommands];
How to achieve that?
I have no idea what you mean 
If you wanna send your arrays back to defaultValues.sqf then this won't work without modifiying the original function.
Yes, that is what i want to do - but what do you mean with the original function? The other script only loads the defaultvalues.sqf and i want to offloading/outsourcing the _customCommands from defaultvalues.sqf to my_function.
is there a way to move smoke logic around?
I have a bunch of "cool stuff to find" things in a "waiting" area, until the player chooses his mission, then these arrays of objects get moved to the missions destination.
f.e. i have a downed helo and 2 pilots, but i also would like to have smoke
is there a way to move smoke logic around?
even if you moved it, since it gets activated at start the smoke won't move
you have to create the module where you want it
huh, maybe i can just copy the module and delete the old one
that works in zeus at least
params
or select
if this is what you mean:
from defaultvalues.sqf to my_function.
Another try ....
SCRIPT 1: The first codeblock with the call compile preProcessFileLineNumbers defaultvalues.sqf
SCRIPT 2: Codeblock 2 aka defaultvalues.sqf
SCRIPT 3: Codeblock 3
SCRIPT1 <-- pass [_accounts, _files, _customCommands] --- SCRIPT 2 <-- pass [_customCommands] -- SCRIPT 3
if you want to pass _customCommands from script 3 to script 2 there's no way but to modify script2, as R3vo said
@tough abyss here's an example:
script 3: return _customCommands
//bla bla bla
_customCommands
script 2:
params ["_customCommands"];
_accounts = [];
_files = [];
//blabla
script 1:
_customCommands = call compile preprocessFileLineNumbers "script3.sqf"; //return from script 3
[_customCommands] call compile preprocessFileLineNumbers "script2.sqf"; //pass the array to script 2
@tough abyss I recommend that you read about the lifespan of local variables:
https://community.bistudio.com/wiki/Variables#Local_Variables_Scope
is there an event handler for when someone talks in chat? and how can I check what channel a player is in?
I know there is one for people typing, dunno about chatting
yeah i found the one for typing
its exactly what I need except I need one for voice
well ive looked through all the event handlers and there isnt one, but could I have a "KeyDown" event handler for when someone holds push to talk?
what is the event handler for when a key is pressed?
isnt there one called "KeyDown"?
Am I using the DIK_KeyCode correctly? and how can I check what channel a player is in?
player addEventHandler ["onKeyDown", {
params ["", "_key"];
if ( keyName _key == "pushToTalk" && currentChannel player == 5 ) then {
//show microphone icon
};
}];
player addEventHandler ["onKeyUp", {
params ["", "_key"];
if ( keyName _key == "pushToTalk" ) then {
//remove microphone icon
};
}];
Thanks a lot for your explanation, but didn't have to do that now, was my mistake ... using underscores in the "tag" definitions of the CfgFunctions quite stupid idea ...
Looks like this now and above all, I don't have to edit a file that is not intended for it (the defaultvalues is, but not the one from the first code block).
/* Original File from other programmer, which i should not edit (aka Script 1 ) - got now here on _defaultValues select 2 the content of Script 3 */
_defaultValues = [] call compile preprocessFileLineNumbers ("defaultvalues.sqf");
/* Original defaultvalues.sqf file from other programmer, which i have to edit (aka Script 2) - doesnt matter if i want to outsource or not */
_accounts = [];
_files = [];
_customCommands = [] call tag_fnc_customCommands;
[_accounts, _files, _customCommands];
/* tag_fnc_customCommands (file fn_customCommands) aka Script 3 */
private _customCommands = [];
// return _customCommands to defaultvalues.sqf
_customCommands;
You can check the current channel with currentChannel π -> https://community.bistudio.com/wiki/currentChannel
oh sweet
also, arent there two types of key ID's? what about the type that the keyboard shortcut uses in addAction?
because right now im detecting when a player holds down caps lock, but its possible that they dont use caps lock to speak. so, how could I check whether or not they are pressing down whatever their push to talk key is instead of just checking for caps lock?
I found the command getPlayerChannel. The command returns the current channel when the player is speaking.
But you must check this periodically, when i understand correctly.
https://community.bistudio.com/wiki/getPlayerChannel
ohh cool
yeah that could work
nevermind
it says it doesnt work on dedicated server
currentChannel is client side too.
wait
You can use this client side, but not on the server.
so if this was in initPlayerLocal, then it would be fine?
yes, when the player is already speaking
ok
yea
ok well how do I make an event handler for when a player pushes their PTT key?
From the wiki page for addAction:
shortcut: String - (Optional, default "") One of the key names defined in bin.pbo (e.g. "moveForward"). Adding available shortcut will bind corresponding keyboard key to this action. Shortcut availability can be tested with inputAction command
ooooo
keyName exists
perfect
how does this code look?
player addEventHandler ["KeyDown", {
params ["", "_key"];
if ( keyName _key == "pushToTalk" && currentChannel player == 5 ) then {
//show microphone icon
};
}];
player addEventHandler ["KeyUp", {
params ["", "_key"];
if ( keyName _key == "pushToTalk" ) then {
//remove microphone icon
};
}];
well that's not going to work
very bad :P
Issue 1: it is not onKeyDown, it is keyDown
Issue 2: It is an ui event handler, not object event handler
There are more issues with your idea but thats next level.
the wiki says onKeyDown: https://community.bistudio.com/wiki/User_Interface_Event_Handlers#onKeyDown
can I not add a UI event handler to a player? what do I need to do instead?
read the first link too
i think this could work:
(findDisplay 46) displayAddEventHandler ["keyDown", {
if (inputAction "pushToTalk" isEqualTo 1) then {
private _channel = currentChannel;
// here your code
}
}]
the big red note is not an ad you know 
Oh wow it actually follows regardless of scrolling now haha, I liked it
ok
the reason they re written like that is due, these are the names used on config, but we remove the "on" prefix when we add by script.
well, as the name suggests
and findDisplay 46 returns the mission display
https://community.bistudio.com/wiki/Arma_3:_IDD_List
ok
but I dont quite get the reason for using findDisplay? why wouldnt it work like this:
46 displayAddEventHandler [ //....
instead of:
( findDisplay 46 ) displayAddEventHandler [ //....
why would we need to "find" it if we already know what the display we are using is?
https://community.bistudio.com/wiki/findDisplay Check return value
ohhh
not sure if the correct place, but Im looking for a simple to use database for a dedicated host, however I don't want the hassle of dealing with setting it up on a server.
Is there any options out there that are both easy to implement and can stay within the mission files??
46 is a number 
the syntax for displayAddEventHandler goes:
DISPLAY displayAddEventHandler ARRAY
"IDD_MISSION" is a string
If you include the rscdesignl.inc file, or whatever that file was named... you can do that too, without quotes that is
yeah mb
now IDD_MISSION is a variable 
it can be anything (but in this case undefined, unless you defined it yourself)
ok
then can you give me an example of what findDisplay would return?
i just wanna understand this
if you include that file you said 
ofc if you include
it returns a display
display is a GUI element
what if I did this:
_display = findDisplay 46;
hint str _display;
for example, when you pause the game, what you see is a display (display 49 in this case)
u basically find the display with the ID of 46
yeah, basically different layers of UI
IDs of displays are defined in config, with idd=46 for example.
yeah but what would this hint?
Display#46
it would say Display#46 if display is on
ok
anyone got ideas?
alrighty so heres my script updated for the display stuff. still not working?
( findDisplay 46 ) displayAddEventHandler ["KeyDown", {
params ["", "_key"];
if ( keyName _key == "pushToTalk" && currentChannel == 5 ) then {
//show microphone icon
};
}];
( findDisplay 46 ) displayAddEventHandler ["KeyUp", {
params ["", "_key"];
if ( keyName _key == "pushToTalk" ) then {
//show microphone icon
};
}];
Define not working in this context? Is there code in place of comments?
just pretend that the code there exists and works perfectly
how does the rest of it look
you can try a systemChat in there to see if it does 
sure
@past wagon did you seen that? -> #arma3_scripting message π
iirc inputAction didn't work in keyDown EH
yes I did seen that
currentChannel player is wrong
I saw what I needed to do
ok
shouldnt it return 5 if the user is in direct?
the command has no parameter like "player"
oh yeah
such command would already only work on local player by itself
yes
Why wouldnt it? Out of curiosity.
I think because it has an override feature:
capture key > override or not > do action
it does that in that order (action is done last)
but action is independent from checking the key to commit action.
but inputAction checks if an action key is pressed
yes but override part is about the commiting the action, unrelated to action key
easy to test anyways
I'm not 100% sure about what I said. You can test it.
yeah I know, just wondered the reason why u recall so ^^
if inputAction does not work in that context, is there a way to actually find out a way whether or not a button is actually stopped to be pressed, in a scenario of another display coming up front to the display the events are assigned?
cos keyUp in the event of another display going in (such as pressing ESC , and stop pressing the key, then close ESC) will result in keyUp event being missed.
@crude vigil looks like I was wrong
it does work
you need to use:
inputAction "action" > 0
not == 1
on short press it's not 1
I put this code in initPlayerLocal, and its not doing anything when I use PTT in direct chat:
waitUntil { !isNull ( findDisplay 46 ) };
( findDisplay 46 ) displayAddEventHandler ["KeyDown", {
params ["", "_key"];
if ( keyName _key == "Caps Lock" && currentChannel == 5 ) then {
hint "You are talking in direct channel";
//show microphone icon
};
}];
( findDisplay 46 ) displayAddEventHandler ["KeyUp", {
params ["", "_key"];
if ( keyName _key == "Caps Lock" ) then {
hint "";
//show microphone icon
};
}];
did I do keyName correctly?
you have to wait until display 46 exists
use waitUntil to find out!
isNull
oh yeah
#arma3_scripting message You might wanna pay attention to this and next line as I had mentioned there is an advanced issue apart from first two issues I had listed.
but looks good for the start
when is display 46 not null? because ive waited about a minute and still nothing
depends on where the code is being run
Im not really experienced with those initPlayerLocal stuff (mission related .sqf files) so cant say something accurate, I'd expect it to exist instantly.
are you sure it is stuck at waitUntil? put a systemChat below waitUntil
so you see the systemchat after waitUntil?
yes
put a systemChat str _this; line before params line, see if the action name is correct etc (ie. as you expect)
ok
wait a minute...
_name = keyName 28; // result is "Enter"
it gives name of the key
not the action name
does ur systemChat str _this return a value like "caps lock" etc?
lemme check
the name of capslock is capslock 
ok
let him check, thats how someone goes into debug practices
it is a long process to accept the need ^^
you're doing that for _key
no
yes u should also systemChat str keyName _key
_key is a number
we already know that 
lemme do systemChat str (keyName _key);
make sure you always practice what you are doing in here now
so now u know why it doesnt work
yep
the command doesnt do what u expect it to do
use inputAction like @brave creek said
yeah inputAction _key > 0.5
0
larger than 0.5? what does that mean
inputAction supports analog input too
doesnt matter in ur case, 0 or 0.5
why not this:
if ( keyName _key == "Caps Lock" ) then {
?
what if Im not using caps lock for voice chat?
when I short press a key it's ~0.06
so > 0
oh yeah
Hey, I just use what Bohemians are using, I dont question it, they know the engine better than me π
I think it matters for joystick etc stuff...
I use keyboard tho
you are a developer, you gotta love everyone equally regardless of input device type they use :(
look up inputAction on the wiki
u coded it in ur mind, u just didnt write it
_key is a number which is whatever key that is being pressed
happens π
ok
"pushToTalk"
if ( inputAction (keyName _key) > 0 ) then {
also , there is a pushToTalkDirect button as well, maybe u would like to handle it too
nah its whatever
what does keyName _key return again, remember?
"Caps Lock"
exactly
now check what inputAction takes
( findDisplay 46 ) displayAddEventHandler ["KeyDown", {
params ["", "_key"];
if ( keyName _key == "pushToTalk" && currentChannel == 5 ) then {
//show microphone icon
};
}];
( findDisplay 46 ) displayAddEventHandler ["KeyUp", {
params ["", "_key"];
if ( keyName _key == "pushToTalk" ) then {
//show microphone icon
};
}];```
Your old code, for you to remember.
wrong
it returns the name of the key 
read it again
I didnt say thats the final answer
the name
- what does keyName _key return again
- "Caps Lock"
- exactly
keyName _key returns "Caps Lock" , whats wrong with that...
Ok Trioxide, do you want Caps Lock as answer?
No
it's not always capslock 
For this context, it is >:C
Leo, Im just going slower for him to compare the values he is receiving
"Push To Talk"
yes
you want "pushToTalk"
not "Push to Talk"
is it equal to "Caps Lock" Obviously not
actionInput requires the action's name, not the key's
so
you don't even have to read the wiki description. just look at examples:
inputAction "leanLeft"
is leanLeft a key? no

actionKeys is the missing element here
retrieve the actionkeys, check if the _key in inside actionKeys
but u dont need it
you can do as Leopard linked
ofc > 0 not isEqualTo 1
I cant even remember what im trying to do
( findDisplay 46 ) displayAddEventHandler ["KeyDown", {
params ["", "_key"];
if ( inputAction "pushToTalk" > 0 && currentChannel == 5 ) then {
//show microphone icon
};
}]
if any key is pressed, you ll basically check if "pushToTalk" button is being pressed through inputAction, u dont need to check the key at all
hm?
for what?
ohhhhhh
you mean addon key config! π
I didn't know that! Thanks
that's actually very nice!
Is it going to work reliably for RMB actions as this ticket was quite a concern to me... Not sure if this feature is related at all.
https://feedback.bistudio.com/T83382
waitUntil { !isNull ( findDisplay 46 ) };
( findDisplay 46 ) displayAddEventHandler ["KeyDown", {
if ( ( ( inputAction "pushToTalk" > 0 or inputAction "voiceOverNet" > 0 ) && currentChannel == 5 ) or ( inputAction "PushToTalkDirect" > 0 ) ) then {
//show microphone icon
};
}];
( findDisplay 46 ) displayAddEventHandler ["KeyUp", {
if ( ( inputAction "pushToTalk" > 0 or inputAction "voiceOverNet" > 0 ) or ( inputAction "PushToTalkDirect" > 0 ) ) then {
//show microphone icon
};
}];
am I doing the condition with the parentheses correctly?
leaderboardRequestRowsGlobalAroundUser what on earth?! 
I think so
although it makes more sense if it is:
inputAction "pushToTalk" > 0 || inputAction "voiceOverNet" > 0 || inputAction "PushToTalkDirect" > 0
no lazy evaluation?
I think it's fast enough?
it is never enough
it can end up being slower 
99.5% cases will be using pushToTalk as it is default so :P
gotta check what voiceOverNet is
let me test:
inputAction "pushToTalk" > 0 || inputAction "voiceOverNet" > 0 || inputAction "PushToTalkDirect" > 0
0.0030 ms
inputAction "pushToTalk" > 0 || {inputAction "voiceOverNet" > 0 || inputAction "PushToTalkDirect" > 0}
0.0032 ms
inputAction "pushToTalk" > 0 || {inputAction "voiceOverNet" > 0 || {inputAction "PushToTalkDirect" > 0}}
0.0034 ms
huh
so not that much slower
0.0004 ms aint much
there are 2 
by 0.0002 ms π
depends on the used key, no? π¬
well I was going to say it too but he ll defend with "it will activate no matter what key is pressed"
and I got no plans to counter that
so I leave it here 
*attacks @little raptor from the left* "@crude vigil, pick right!"
My comment on the ticket applies to this too
Ah, thanks
I had that expectation already π
btw, activate or activated? π

the example says activated!
addUserActionEventHandler ["Reload", "Activated", { systemChat "reloading!"; }];
event: String - event name - see UserAction Event Handlers. Can be one of:
"Activate" "Deactivate" "Analog"
It is a surprise for release
guess who provided the information π
After CZ, amma go to Amsterdam to bulli Dedmen >:D
Ded?!
Hello, I'm searching for a quick way to change a group of units' side to east, I've googled it but it all seems a bit much for something that could be done in one line of code?
not really "one line of code", but you can create an opfor group and make those units join it yes
_units joinSilent createGroup east;
π
That's exactly what I'm refering to when I googled, Do I Have to place an additionnal unit to make a group
example is wrong
Nice
and _units are? :P
on it
@winter rose activate, deactivate, analog
unless you think I should change it
I can also change it into a StartsWith instead of a Equals. Then you can have all the variants π
fixed
you NINJA'D ME on my own ground??!
hm
only on addUserActionEventHandler
Did not expect this Lou.. Thought u are inactive for a while for that purpose.
there's more?!
got removeUserActionEventHandler π
Also simple question: what does the "_" do, as in "_x" "_units" "_group" "_obj"? I googled it a few months ago but it never really gave me a straight answer or an example
I also have to write dad jokes for tomorrow, it's an all-time job
it means "local variable"
No excuses
I'm not sure I understand
OHHHHH
isnt it more like https://community.bistudio.com/wiki/Variables
that's for the scope and all
but the naming of a variable is "identifier" yep
yes but he asked what _ is
-it means "local variable"
-I'm not sure I understand
links are there agrrr
I guess you meant what is a local variable? @tough abyss
Lou is just trying to make people check as many pages as they can
he ll make him read identifiers then make him jump to variables
β¦I get paid per view π
No, I wasnt sure what were "_x" used for. I thought you could use _x as in to say "all those things" or _units as in "all those units"
_x is a magic variable:
https://community.bistudio.com/wiki/Magic_Variables
I always thought it was paperview and didn't understand
the page already explains it
Magic variables are engine-maintained variables that serve a specific purpose within a given scope and are often used by the engine to push data to a given script or code fragment.
_x
Represents the current element during a loop with: apply, count, configClasses, configProperties, findIf, forEach, select.
Yeah I read that but I understand half of it
For a new starter, the definition does not feel clear
for example, when you loop over an array, you want to know what the current element is, and what is the iteration index
that's where _x and _forEachIndex magic variables come in handy:
{
if (_forEachIndex == 1) then {
_x setDamage 1
};
} forEach [_unit1, _unit2];
kills unit 2, not unit1
when you have a list, the _x will represent the item of that list
and the code will be executed for each item π
the https://community.bistudio.com/wiki/Introduction_to_Arma_Scripting page is coming but @willow hound is slow @ writing it

I liked the old one better 
I especially hate that it starts with creating a file 
I'd say show them what a script feels like
we need a quick example
some people already know programming and can pick it up in one look
plus it's called "Introduction"
I wonder how it feels not to know programming
Yea, personally I like to see a script similar to what I want. Look at it and learn what makes it work the way it does
Yep, the only thing you need to push someone from scripting is to introduce something other than scripting, people are already scared from it
Starting a page with file creation just feels like "Okay, I need a file for a script"
what next, introduce cfgFunctions? :P
I was writing a quick intro to sqf a long time ago
I'll see if I still have it and try to complete it
then I'll show it to Lou
maybe he'll like it
Even slower now that the exam season has picked up π¦
Yes, some already know programming, but many do not. Those with established knowledge can skip ahead as their skills allow.
My current plan for the rest of the page is splitting it into something like three sections along the lines of Beginner Scripting, Intermediate Scripting and Advanced Scripting and then list some concepts that readers at the specific level should familiarise themselves with (maybe also provide additional explanation for some of the trickier concepts) plus some example script case studies at each level.
let's skip to #community_wiki, I have ideas :p
Hey me again, I just tested your code and it doesnt seem to work.. I tried a single unit, I tried a group
I tried this
guardtower1 joinSilent createGroup east; guardtower2 joinSilent createGroup east;
and whatever this may be
setSide east forEach unit inAreaArray guardgobad;
basically i want units to go crazy, mentally deranged yea if a unit goes into a trigger area called guardgobad
I tried a single unit, I tried a group
well you did it wrong
if you want a whole group to join east:
(units guardtower1) joinSilent (createGroup east);
(hopefully the parentheses can help)
a single unit:
[_unit] joinSilent (createGroup east);
if im using ["Open", [false]] call BIS_fnc_arsenal; how do i populate the arsenal with weapons and gear i pick?
Is there any way to print something to console via dedicated server script?
diag_log
or what console do you mean?
@shadow knoll https://community.bistudio.com/wiki/Arma_3:_Arsenal
@cosmic lichen There is one console as I know - the one you call by pressing Esc or Ctrl-D π
What kind of text you wanna add there?
"rscdebugconsole_expression" this is the variable in profileNamespace which contains the last content added to the debug console
remoteExec, setVariable, profileNamespace. Guess that's all you need
@cosmic lichen"rscdebugconsole_expression" this is the variable in profileNamespace which contains the last content added to the debug console"
But if that text hasn't been added to console output, then it will not be there, right? π
I need script that can throw any kind of readable text into console - because copytoclipboard doesn't work in this case.
If you just wanna copy something you might wanna look into https://community.bistudio.com/wiki/Arma_3:_display3denCopy
Ok, thanks...
I think the most reliable way is to create a window displaying needed information.
whats the easiest way of checking if a unit is still executing a vehicle getOut animation, after giving a moveOut command?
unitReady maybe?
It could report not ready a bit longer than the anim tho, usually until unit gets into "get out spot" near the vehicle.
hm, i want to avoid that the unit runs to the "get out spot" in the first place.
since it's an animation, maybe the animation kind of command should be used? You could check what's the current animation for instance.
unitReady doesnt work when exiting a vehicle by moveOut, its remains ready all the time
hey i want to get into arma 3 moding
is ther any videos to help with that
ps : i already know c++
@tawny grove what do you mean by modding?
What is it you would like to do?
i guess animationState is the way to go then? Directly after moveOut command, get animState for the getOut anim name and then wait until animState returns something else.
those are all quite intense and different things
add logic and enteraction between the player and some static objects
for modes you need to first learn modeling
for terrains there is a number of tools and concepts to learn
like what ?
#arma3_terrain pinned messages got more info
important part will be to be able to look up stuff on your own
cant i just use a terrain i created in blender ?
focus on one thing first ... logic and interaction -> SQF scripting. Mods -> config.
π
there is arma scripting commands wiki page
cause i can use place holders for the other stuff
also if i make changes to my code
will have to restart the game to see the changes ?
depends how you work on it.
depends on what ?
some development can be done by restarting mission so that your changes get loaded
oh i see
Id check out what the wiki has to offer
i am checking it right now
also pinned messages on various topic channels can offer tips on where to look
ok got it
Sorry didn't notice your reply. Yes that's what I meant. π
although... does vehicle _unit return objNull or the vehicle while the unit is exiting the vehicle?
Use animStateChanged event handler if that is to happen too frequently
null iirc
alternatively as a crude solution you can just check time since the unit started leaving vehicle
just assume that unit exits all kinds of vehicles for 2s max...
Not so reliable
But you can check the animation and get how long it takes to finish
If you want to go with the time method
yeah that's even cooler
I thought you were asking! 
I was asking on behalf of X3KJ π€
Trying to make a storage system for players, maybe work off of their unit if possible (but can just work off faction if not possible)
does anyone have suggestions on how i'd do that or where to start looking?
what kinda storage system?
but store what exactly?
Merkava IIA
ground vehicles in general is what im attempting
you need to describe what you want to achieve a bit more
See, my joke of saying some specific vehicle actually was a good prediction π
yeah sorry im still a bit new to this in general
how exactly should it work?
ah
I think you want to let players drive up to sojme place, and despawn the vehicle they drive up, and then be able to spawn it back later again?
If im following now,
what im trying to-
yes
sorry for the confusion lol
well... you store the class name of the vehicle and any other its properties you want to be saved like damage or inventory
delete the vehicle
then you recreate the vehicle again with createVehicle and the data you've saved
also you will have to create some simple user interface for this
this is where the fun begins...
@novel delta for example:
fn_saveVehicle.sqf
_veh = vehicle player;
if (_veh == player) exitWith {};
MY_saved_vehicle = [
typeOf _veh,
damage _veh
];
fn_loadVehicle.sqf
_vehParams = MY_saved_vehicle;
if (isNil "_vehParams") exitWith {};
_vehParams params ["_type", "_damage"];
_veh = createVehicle [_type, _somePos];
_veh setDamage _damage
you can save it to profileNamespace so that data survives mission restarts if you want
also a good new modern way to serialize all that data is to use a hashmap
then it's also easier to implement backwards compatibility when you decide to update your code
How would you remove empty ammo counters after changing around pylons through script? Bombs/rockets used on default loadout now show 0. Would like to get rid of them completely because switching through them wastes time.
In addition to this: #arma3_troubleshooting message
There is a function called OT_fnc_getsave_server:
_data = profileNameSpace getVariable OT_saveName;
waituntil {!isNil "_data"};
server setvariable ["OT_Save",_data,true];
I'm trying to exec it locally (to run the script on my dedicated server):
remoteexec ["OT_getsave_server",2];
Assuming that it will set the OT_Save variable.
But remoteexec doesn't work in this case.
I can do server exec:
spawn OT_getsave_server;
and it works fine.
What could be a problem?
What would be the best way to hide everything on a unit say for their gear? Trying to take preview screenshots
are you sure your server allows remote execution?
Yes. Most of other functions work (can't say 100% for all, just noticed this problem)
@unreal scroll
_data = profileNameSpace getVariable OT_saveName;
waituntil {!isNil "_data"};
this is wrong
it never becomes true
also you don't have to wait for it
Hm... Then why it works?
probably because the var already exists
if it doesn't, it won't
It doesn't exist before. Above is the whole function body
then it doesn't work
No, it works π
it shouldn't
@unreal scroll is OT_saveName an array?
or a string?
if it's a string it shouldn't
It is an array. Can you explain why !isNil "_data" should never becomes true?
The array is very large, the process can get up to 10-15 seconds. So it is for a fail-safe purpose.
sqf is single threaded. what fail-safe?
it never moves forward until something is done
True π
"if it's an array your waitUntil is useless
it's always not nil"
I'm just checking that the data exists. The purpose is not the elements counting. No matter, does it contains something or just an empty array.
the data ALWAYS exists
_a = missionNamespace getVariable ["blabla", 1];
!isNil "_a"
go ahead and try it
do you even have blabla?
no
but it exists
The check is incorrect, unless _data gets updated in a higher scope (which is impossible as wait until would not allow any updates)
The _data variable is always what you assign to it and not a reference to somewhere in your missionNamespace
because you're giving it a default value
It is pretty much equivalent to
_data = 1;
Waituntil { _data != 1 };
Just that you're lucky and the variable in missionNamespace is already set
he's using an array
it already exists
because of default value, not because of luck
As I said, I've got it, thanks.
"Just that you're lucky"
No, I'm just too careful π
I always use such checks in missions, when manipulating objects.
"he's using an array
it already exists"
No, I just assumed that the script could get further, without having anything _data. Taking in account that it is single-threaded and we're not manipulating objects, it is nonsense, that is just a useless thing, not a real problem.
I am well aware of that
Wanted to show what happens when the variable ever was actually nil
It simply would remain that way forever and create a deadlocked script
"It simply would remain that way forever and create a deadlocked script"
Also I can type format C: π
Or put a chat-related command to a chat EH.
It is very easy do catch, and it is another thread of conversation - all we do some useless things from time to time.
The real problem - why the remoteexec doesn't work...
you can't suspend in fsm can you?
no
that's too bad... setFsmVariable could set _data otherwise π
i've seen some waituntil { !isnull _object } sort of stuff before, but i never encountered any problems requiring this myself. in what kinds of situations would this be useful?
did you put a diag_log at the beginning to check?
I think in init scripts when you don't know when the player will be created?
depends what _object is
@pliant stream "in what kinds of situations would this be useful?"
Missions, for example. It comes from here, it is written in auto mode π
Like waituntil {isNull _object}; - if it is supposed it should be destroyed.
"did you put a diag_log at the beginning to check?"
Trying currently π
what you're describing is orthogonal to my question
he is specifically asking about the !isNull object tho, not waitUntil 
right. in what situations does an object value change from being null, to being non-null? if the engine is to be considered remotely sound, it should be never
I can only imagine 2 things:
- init
- an object being created on another machine and checking its status on this machine (which is stupid
)
i have dynamically spawned units spawn inside vehicles, and they need to exit and finish the exit animation and then continue to run some other init code, once per "unit lifetime". Not sure if that counts as frequent.
nope
but doesn't mean you can't use it! π
what happens if you add multiple eventhandlers of the same type to a unit by script? I know you where limited to 1 EH when using config defined EH for a long time - not anymore - but i'm unsure about "addEventhandler" side of things ?
you can have multiple event handlers and get back a handle for removing it. which handler's return value is used i'm not sure off the top of my head
never
if it were to happen i suspect it would be when you create an object on machine A, send a reference to it to B, B checks it for null, but the packets propagating information about the object being created are delayed
That cannot happen
these updates are guaranteed to arrive in the order they were sent then?
the network packets are ordered.
a remoteExec with a object reference cannot arrive before the objects creation
@little raptor The functions didn't called at all.
how did you define the function?
class CfgFunctions, as all others.
you said it yourself:
function called OT_fnc_getsave_server
but
remoteexec ["OT_getsave_server",2];
Thanks, sorry for it, need to rest ))
How do I get a UAV pilot unit out of a vehicle?
moveOut script command says "Does not work for UAV crew"
doGetOut also doesn't seem to do much.
The unit is dead I want to get it out to put a new one in
worked! awesome
now just need to spawn B_UAV_AI. both createUnit and createAgent, the unit is there for half a second and then becomes null
why not just use createVehicleCrew?
your UAV is bugged 
even this works for me:
_gr = createGroup west;
_u1 = _gr createUnit ["b_uav_ai", [0,0,0], [], 0, "NONE"];
_u2 = _gr createUnit ["b_uav_ai", [0,0,0], [], 0, "NONE"];
_u1 moveInAny dr;
_u2 moveInAny dr
(tried it on Darter)
@still forum are you trying that in MP?
YE
debug console local
wow I typed script ingame.
apparently text box didn't have focus.. The typing selected the Respawn button and instantly confirmed 
oof that worked now
I tried to add them to my player group
that somehow deleted them
creating a new group works
side driver T1 == CIV
why is the driver of my UAV now a civ :U
what command did you use?
createUnit or createVehicleCrew?
Yours
join command on the driver unit doesn't work π
it seems like it left the group it as soon as I did moveInAny.
The group i created the unit in is now empty
btw did you use this?
#arma3_scripting message
I changed it a bit
I was creating two separate groups before 
Yes.
_gr = createGroup west;
_u1 = _gr createUnit ["b_uav_ai", [0,0,0], [], 0, "NONE"];
_u1 moveInAny dr;
its a single seater
I now re-did with createVehicleCrew.
Works now.
driver..... WHAT
Driver in vehicle was in blufor group, but side of the driver was still CIV.
Now all of the sudden the drivers group is grpNull. Without doing anything, the driver left its group and is now not in any group
what the hell is going on
it's probably an agent
try this:
teamMember driver T1
if it's not null it's an agent
(it should be, because units can't not have groups in Arma; only agents can)
weird, AnimChanged EH does trigger before there is a detectable change with command "animationState"
Can anyone explain the difference what makes AnimChanged different to AnimStateChanged?
["anim player=","amovpercmstpsraswrfldnon"," time=",1.572]
["anim player=","amovpercmstpsraswrfldnon"," time=",1.589]
["anim player=","amovpercmstpsraswrfldnon"," time=",1.606]
["anim player=","amovpercmstpsraswrfldnon"," time=",1.623]
["anim player=","amovpercmstpsraswrfldnon"," time=",1.64]
["anim player=","amovpercmstpsraswrfldnon"," time=",1.656]
["anim player=","amovpercmstpsraswrfldnon"," time=",1.672]
["EH: AnimChanged to","amovpercmevasraswrfldf"," time=",1.672]
["EH: AnimStateChanged to","amovpercmevasraswrfldf"," time=",1.672]
["anim player=","amovpercmevasraswrfldf"," time=",1.688]
["anim player=","amovpercmevasraswrfldf"," time=",1.705]
<snip>
["anim player=","amovpercmevasraswrfldf"," time=",2.176]
["anim player=","amovpercmevasraswrfldf"," time=",2.193]
["anim player=","amovpercmevasraswrfldf"," time=",2.21]
["EH: AnimChanged to","afalpercmstpsraswrfldnon"," time=",2.21]
["EH: AnimChanged: Falling detected"]
["EH: AnimStateChanged to","amovpercmstpsraswrfldnon"," time=",2.21]
["anim player=","amovpercmstpsraswrfldnon"," time=",2.226]
["anim player=","amovpercmstpsraswrfldnon"," time=",2.243]
["anim player=","amovpercmstpsraswrfldnon"," time=",2.26]
<snip>
["anim player=","amovpercmstpsraswrfldnon"," time=",2.427]
["anim player=","amovpercmstpsraswrfldnon"," time=",2.444]
["anim player=","amovpercmstpsraswrfldnon"," time=",2.461]
["anim player=","amovpercmstpsraswrfldnon"," time=",2.478]
["EH: AnimStateChanged to","afalpercmstpsraswrfldnon"," time=",2.478]
["EH: AnimStateChanged : Falling detected"]
["anim player=","afalpercmstpsraswrfldnon"," time=",2.495]
["anim player=","afalpercmstpsraswrfldnon"," time=",2.512]
["anim player=","afalpercmstpsraswrfldnon"," time=",2.529]
["anim player=","afalpercmstpsraswrfldnon"," time=",2.546]
yes
"State" π
animChanged will trigger when the unit wants to change animation
basically when you say: "I want to play animation X", it'll trigger
it won't trigger for animations that are just connections/interpolations to that animation
ah good to know, thanks
are you sure it's alive?! π€£
@little raptor BTW, I've found the cause of another issue with the remoteexec (#arma3_troubleshooting message)
As I supposed, it comes from inattention too, and it was the missed brackets inside the CBA PFH.
It didn't generate any errors. Need to keep in mind that CBA functions don't throw errors even from incorrect syntax...
depends where the function was executed
On dedicated
if you used per frame EH it won't
(or in general, all EH's don't throw errors afaik)
IM using inidbi2 to have an auto-save feature in a mp mission im creating. Currently i have the server run a script called 'autosave.sqf' that completes an auto-save of player data every 90 seconds. However, i want to change this to a save on disconnect. is this possible?
@tough abysshttps://community.bistudio.com/wiki/Arma_3:_Mission_Event_Handlers#HandleDisconnect
right, would it be worth doing and will it have a fail chance? would it be a better idea to implement a button for players to press to save data instead of this?
not sure if its true or not but ive been told it can be buggy on mp??
It should works well, but consider the situation when you don't want to save the game at this moment, and just quit.
hmm
From my experience in coop campaigns the most reliable and logical way is to have one or more players as some kind of game masters, who can save the game.
that would be me. However, i also want to account for accidental disconnects / crashes. Hence why i have an auto save system currently in place. I just wanted to know if i could do it reliably for a player who has disconnected or crashed.
currently data saves every 2min 30 seconds.
it is. I gave up on it now π
"i also want to account for accidental disconnects / crashes"
Good point.
Yes, you could do it. You make a persistent mission, isn't you? Then you should already have a working save system.
Then just do the loadout/character save on disconnect.
I would check if the player is alive and in safe place. Care of your lives π
Also you can add something for fail-safe saving, like that: https://youtu.be/N2w3T3DA7eA
If yu're interested, you can visit my discord channel (https://discord.gg/5Jw7ks4), I can suggest you some of fail-safe features/save algorithms.
I am still confused, need clarification... when you create a trigger object attached to a target object, when the position of the target changes, does that in effect change the position of the trigger?
I'm looking for ideas - i'm currently trying to get rid of this annoying game breaker by myself, as it seems no fix is coming: https://feedback.bistudio.com/T154778
My workaround works mostly OK in stopping the "slide of death" as well as the damage you would receive - but sometimes the glitched state exits on its own before i can confidently say that its in fact in a glitched state. And when that happens you receive a huge amount of damage from a very small fall. Does anyone have a better idea how to detect and intercept this glitched state faster than just comparing height numbers?
https://www.sqfbin.com/imaqibawupuwesemuyuw
if anyone wants to try with the anti-glitch -> see pbo.
Doesn't seem to me like a fix is coming for that
my entire collection of walls, trenches and other fortifications is basically unusable on certain maps (i'm guess it depends on terrain grid size or something), as you constantly get into glitched state and die... so i have to do something, otherwise i might as well throw the towel on the whole fortification thing.
I was plagued as player with the same bug when i still played Arma Exile. Died so many times and was raging like crazy π
My hacky noob attempt to get rid of it.
We run this in a loop (via Exile Thread system every second) and it stops it from happening, using it for more than one year now and so far iam not aware of any downsides.
_fs = ["afalpercmstpsraswrfldnon","afalpercmstpsnonwnondnon","afalpercmstpsraswpstdnon","afalpknlmstpsraswrfldnon","afalpknlmstpsnonwnondnon"];
_player = player;
_playerpos = getPos _player;
if ((animationState _player) in _fs) then
{
_f = _playerpos select 2;
if (_f < 0.1) then
{
_player setvelocity [0,0,0];
};
};
Hey y'all,
Can someone tell me what the issue is on the following line?
dep_unit_init = "[_this] execVM (selectRandom ["Scripts\enemyAK12.sqf","Scripts\enemyRPK.sqf","Scripts\enemyRPG.sqf","Scripts\enemySniper.sqf"])";";
From the DEP settings.sqf to add an init to each unit created.
The example shows this: dep_unit_init = "[_this] execVM ""unitinit.sqf"";";
It tells me it's missing a right bracket and a semicolon. It's probably quote and semi colon placement issue but I'm not sure what's the correct format
From a simple look, you should notice that there are 11 quotation marks.
Then, you should ask, how can SQF understand nested strings?
dep_unit_init = "[_this] execVM (selectRandom ['Scripts\enemyAK12.sqf','Scripts\enemyRPK.sqf','Scripts\enemyRPG.sqf','Scripts\enemySniper.sqf']);";
or
dep_unit_init = "[_this] execVM (selectRandom [""Scripts\enemyAK12.sqf"",""Scripts\enemyRPK.sqf"",""Scripts\enemyRPG.sqf"",""Scripts\enemySniper.sqf""]);";
//You can keep nesting strings with 2^x formula. (ie. " , "" , """", ...)
Nevermind, I figured it out!
Thanks!
I did the following and worked:
dep_unit_init = "[_this] execVM (selectRandom [""Scripts\enemyAK12.sqf"",""Scripts\enemyRPK.sqf"",""Scripts\enemyRPG.sqf"",""Scripts\enemySniper.sqf""]);";
Thanks a lot β€οΈ Sorry i'm kinda bad
SrgFatCat3522 β Today at 2:57 AM
I am trying to start and return to the same location. I want the trigger to only fire when I return. I am using this script in the init of a trigger to create a trigger for the return. Hope that makes sense. It doesn't work. can anyone help? thx How to use SQF syntax highlighting in Discord
// _trg = createTrigger ["EmptyDetector", getmarkerPos [mark1]]; _trg setTriggerArea [5, 5, 0, false]; _trg setTriggerActivation ["CIV", "PRESENT", true]; _trigger synchronizeTrigger [completetrg]
I know I can use "daytime >" but I am trying to spawn the trigger . thx
!code
```sqf
// your code here
hint "good!";
```
β
// your code here
hint "good!";
I'll write one when I get up! 
@austere hawk give this a try:
player addEventHandler ["AnimStateChanged", {
params ["_unit", "_anim"];
_isFalling = _unit getVariable ["T_falling", false];
if (_anim select [0, 4] == "afal" && !_isFalling) then {
_unit setVariable ["T_falling", true];
_unit setVariable ["T_fallParams", [getPosASL _unit #2, 0, velocity _unit # 2]];
systemChat "falling";
onEachFrame {
private ["_params", "_v0"];
_v = velocity player;
if (_v#2 < -6) then {
_params = player getVariable ["T_fallParams", []];
_params set [1, _params#1 + diag_deltaTime * accTime];
_params params ["_y0", "_dt", "_v0"];
_y1 = getPosASL player #2;
_dy = _y1 - _y0;
_dy_expected = -0.5 * 9.81 * _dt^2 + _v0 * _dt;
if (_dy > _dy_expected*2/3) then {
_v set [2, _v0];
_params set [1, 0];
player setVelocity _v;
}
}
}
} else {
if (_isFalling && {isTouchingGround _unit}) then {
_unit setVariable ["T_falling", false];
systemChat "not falling";
onEachFrame "";
}
}
}];
it's for testing. don't actually use it. if it works I'll clean it up and make it into a mod
cheers! from a handfull of tests - yours seems to prevent dieing, but you can still be stuck for an awefully long time, including the problem of sliding sideways along
idk if you have tested the repro mission yet, but if you run at an angle towards the other side of the "trench", you slide sideways and then die (without intervention). You seem to stop the death, but not the sliding for several seconds. When running straight (from position 2 to 3 in pic), you dont slide normally, you are just stuck a long time in midair. Running diagonally (e.g. pos 1 to 4) results in the sliding on bottom of trench.
If you manually execute velocity [0,0,20] while falling, your script stops reduce downwards acceleration when going into negative z direction again, its a bit arkward - BUT i havent czeched what actually happens if you "legitimately" exit a flying vehicle that travels upwards.
czechBox
So anyone know if theres a way to get a returnvalue from a function (Like in C# when using a method) ?
I am reading this rn https://community.bistudio.com/wiki/Function
But cant seem to find anything
last variable in the function will be returned
_myFunction = {
dostuff;
doStuff;
//return
"uwu"
}
is there a way to reverse-browse through a hashMap ? Something like "get" but on values instead of keys ? Lots of programming languages make it possible, I wonder if ArmA can do such a thing. According to documentation, the only way to do so is by iterating on all values and existing loop when wanted value is found
which is not very optimal
but working nonetheless
Niice, thank you!
create a hashmap, where values are the keys and keys are values π then you can most optimally browse
no its not a multimap.
that is actually not a bad idea π€ very unoptimal when done on the flight, but with a "cache" sort of thing, might be very usefull π€
choose a better strategy so you dont have to search through it in the first place...
i store some objects in a hashmap for some data. But i also store the key as local var on the object (in case i dont want to use object name as key)
what I'm doing could really benefit from a multimap, as reverse searches are relevant
however reverse searches can be avoided or made very rare
so iterating the hashMap in these rare cases should be a problem
what exactly are you trying to achieve?
plus, it's not a matter of milliseconds, so no problem if it's slow
basically, a whitelist
storing a whitelist as a hashMap of steamID:nickname
when checking if a given player is whitelisted, the steamID is used
the nickname is used only when admin want to add/remove offline people from/to the whitelist
why does BIS_fnc_findSafePos sometimes return position way beyond the maximum distance (maxDist parameter)?
nvm, I guess that was some kind of default pos..
sorry this is probably super basic and easy to solve but im using this addaction to run a script for an arsenal with specific gear player addaction ["<t size='1.4' shadow='2' color='#AABEA5'>Armory</t>", "vanillaArsenal.sqf", [], 1, true, true, "","([base] findIf {player distance _x < 50}) > -1"]; i already have the arsenal made but every time i use the addaction i made it gives me a whole new addaction to use the arsenal and it also never goes away.
[player,((itemCargo player) + _availableHeadgear + _availableGoggles + _availableUniforms + _availableVests + _nvgoggles + _mainattachments + _seconattachments + _miscshit)] call BIS_fnc_addVirtualItemCargo;
[player,(magazineCargo player + _magazines)] call BIS_fnc_addVirtualMagazineCargo;
[player,((weaponCargo player) + _gunz)] call BIS_fnc_addVirtualWeaponCargo;```
is there a magic variable that I can diag_log a line of script ? __LINE__ or __FILE__
well i dont want that second action to pop up in the first place
my original addaction goes away when i leave a certain radius and i want the script to be executed through that one and not give me another one
what is vanillaArsenal.sqf?
also ([base] findIf {player distance _x < 50}) > -1, why?, just player distance base < 50
thats the sqf for all the gear in the arsenal
sorry im still new to this and thats just what i got
where are you calling addAction from ? object init field ? init.sqf ? initPlayerLocal.sqf ?
init.sqf
there is your problem
that's causing my current addaction to to give me another addaction when i interact?
can you paste the contents of that sqf file?
which one?
the arsenal one, or is it what you sent in your initial message?
i sent the main part of it in the intial the rest of it was just the gear i was including
look at the functions on the wiki
they all have arsenal action parameter which defaults true, so you need to pass false instead
thanks i will look again
yeah I didn't think about that case. I'll π¨πΏ
I think it can be "fixed" too
Does the setobjectscale command work in MP yet? Thanks. I was running it on server, but it would not run.\
it works in MP
Hi there. Anyone knows, how https://community.bistudio.com/wiki/addForce 's "force" translates into SI units?
Is it not in Newtons?
iirc it was
if one can confirm, please tell us in #community_wiki
that whitelist will have at most a couple hundred entries?
iterating it won't be that hard.
And you can always make a second hashmap for the reverse, as long as its not too big which it doesn't seem to be, you don't really care about the memory usage
more like at most a dozen entries π€£
not to worry about memory
it was more of a code quality/readability matter than a performance matter
Good day. How do I spawn an entire group of units like the one I see in the Editor? "Recon Squad", "Fire Team", etc.?
You might wanna go for https://community.bistudio.com/wiki/BIS_fnc_spawnGroup
don't forget to flag created groups for autodeletion when empty
you'll avoid strange problems of units not spawning after a while for no apparent reason on long duration/persistent missions
So what happened with the diag_setTerrainHeight commands that were in the diag.exe. Where they planned to come to stable or is it still being worked on? You could reshape terrain with scripting commands.
No. They'll never come to stable
afaik
Damn.,
Imagine the trolling with scripters tho, making a massive crater to ruin airbase. LOL.
I'm also quite surprised (and excited) at the most recent script commands. Stuff that was missing for long are now coming to the engine, like HashMaps, modded keybinds (CBA might like this very much), some more physx stuff (cruise control, unlocking brakes for towing), etc
I wonder why so much stuff, now that A3 is very close to no-support
oh and regex manipulation stuff too
that's cool
Totally agree. I feel lucky to jump in when, for example, hashmaps added, makes a lot of stuff much easier.
Thank you.
Because I'd be bored otherwise
Fair enough π