#arma3_scripting
1 messages · Page 43 of 1
maybe just not documented 📖
heheheee, a new EH is coming
I'm curious to know if it's possible to switch scenarios using a script? My original plan was to use BIS_fnc_endMission or a similar command to instantly end the mission so I can quickly load a new one myself (multiplayer zeus), but I figured I'd check if there were any existing solutions to this
caching: the best of both worlds
is the a way to added respawn event handler persist after respawn on entity passed to script ?
// initPlayerLocal.sqf
[player] execVM "script.sqf";
// script.sqf
params [["_unit", player]];
_unit addEventHandler ["Respawn", { ... code ... }];
ok so, im playing around with setAperture to recreate my tunnel sequence, problem is...i cant get it to work how i want it to (ie like sog tunnels), i want it to be dark, but you can wear nods or use a flashlight
SOG probably use occluders, setApperture its just a part in the grand scheme of things
oh then i cant fuckin script that XD
yes, you cant just script it sadly, there need to be either occluded by objects or be closed interior objects in shadow lods. There is a couple of tricks to do it. Your easier bet is to take a look at Cytech, which is the only recent mod that use occluders for custom interior darkness. I wouldnt discard the possibility of a mod that has only occluding tools available somewhere on the workshop, but i dont know of its existence.
As far as making "believable", combining apperture, PP effects and HDR setting might give you soemthing ok-ish but not night like
just looked, no there isnt, however its a night mission anyways so
no bigge
was hoping it'd be darker
it should be persistent by default
Sorry @still forum but I want to bother you again. If you have a minute, can you have a glance at why HandleDamage is hardcoded(?) to do damage to HitHead and overall damage (and not actually do anything, returned EH value does nothing), before doing expected walk through all affected body parts and properly working as expected?
Not that I want this fixed, but I'd like to have an idea for this behaviour so I can account for it
Reminder, HandleDamage applied to local unit does 2 false fires
Visible in this log, HitHead, overall damage, result of EH doesn't count, then it properly walks through all hit points and overall damage.
How to test:
player removeAllEventHandlers "HandleDamage";
player addEventHandler ["HandleDamage", {diag_log [diag_frameNo, _this]; (_this select 2) / 2;}];
```Then teleport player few meters into the sky to have fall damage and view the RPT.
```sqf
player setDamage 0;
player setPosWorld (getPosWorld player vectorAdd [0,0,3]);
RPT will looks like:
Line 1: HitHead damage (EH return ignored)
Line 2: Total damage (EH return ignored)
Line 3: Total damage
Line 4+: All hit points
removeAllEventHandlers is optional, removing BI-added EH shouldn't matter
Well if it triggers twice then it's not ignored but overwritten, right?
I scripted it to check actual damage on each EH and it doesn't seem so
Unless engine writes elsewhere, not visible through script
I expect that it's like that yeah
_saved_damage in my screenshot is previous EH returned value, _current_damage is return of damage/getHitIndex commands
[!] shows mismatch between return of the commands and previous HandleDamage fire return
But in the same frame right?
Its all in the same frame, yes
All EH fires return proper Number value: _new_damage
Then I guess those mismatches are due to values being overwritten (or in other words not applied yet)
Either that or these 2 questionable fires not actually applying the damage
Whatever the case, it is still a mystery why engine even does these 2 fires at all
@south swan just tested that removing HitHead hit point leaves only 1 questionable EH fire
Feels like engine is hardcoded to do these
Thus my question to dedmen
Also no _source on that ignored overall damage
Lots of questions
I always imagined it's due to some "sudden change in inertia" kinda thing... 😅
But yeah still makes no sense
Maybe some sort of backwards-compatibility signalling?
How do one checks state of a door (or doors) on a vehicle?
Is there a way to set up trigger areas without them eating frames by constantly checking if the condition is met?
Specifically, I'd like to do guard areas, but an option for other kinds would also be good
Might reduced the checking time. By default it is .5 seconds
no

Hey guys
How are you ?
I have a big problem on my server :/
For almost all players, sometimes, after 10 minutes of play, they get kicked out of the game and have the following error:
x (285) out of range <0.256)
while searching I found the error in this post
https://community.bistudio.com/wiki/Talk:arma.RPT
but nothing tells me how to solve this problem :/
anyone how to fix it? thanks in advance ^^
depending on what sort of condition you're checking there are typically better options
the fastest option, if available, is event handlers (for stuff like units getting killed, getting in vehicles, etc.). see this page for the list of EHs:
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers
they "eat" 0 frames because they're not being checked constantly. they execute when the event happens
another options is using scheduled loops instead of triggers. they too won't eat frames (unless you run slow commands), but they might lag behind if there's too many scripts in the scheduler
ask in #arma3_troubleshooting
Thks
ok so im planning to add a self action to an ai character im planning to basically remote control, and i need to script an addAction to activate a certain animation
this is the code switchmove "Acts_JetsMarshallingStop_in"
abdul1 is the variable name, can anyone help me?
Not even sure what to help. What's unclear?
wait
ik why
i wrote it wrong, wait one
lemme test something
ok nvm
so initially i wrote
abdul1 addAction ["Surrender" {switchmove "Acts_JetsMarshallingStop_in"}];
and this is wrong
so...im stumped
abdul1 switchMove "Acts_JetsMarshallingStop_in";```
abdul1 addAction ["Surrender" #{switchmove "Acts_JetsMarshallingStop_in"}];
missing ]
error is
right...but i need it to be toggle-able basically
he's not gonna surrender right away
its basically a leg chase, so at first i run, then at the end of that, i trigger the animation
i dont wanna use radios because...its a little clunky
so what exactly do you want to do 🤨 ?
you want an action that triggers an animation → you have it
do you want the action to trigger the guy to run away? that's unclear
i want the first one
but this doesnt work
missing comma
and wrong syntax
fr? wait where
where the # symbol is...
oh
and even if you fixed it the syntax is still wrong
right...what would the correct one be?
this one
in the action code
you need to tell who is going to switch what action
abdul1 addAction ["Surrender", {abdul1 switchmove "Acts_JetsMarshallingStop_in"}];
so...this? from my understanding
yep
it works
thanks everyone!
actually one last question
nvm disregard figured it out
most likely, but you can check yourself in the editor
the fastest way to store things now is to treat missionnamespace like a big hash and use unique variables and set/get variable
is it possible to put a local variable in the commas where you input what unit you would like to spawn and then have it choose between what type of unit to spawn?
Do you mean that you want to choose a random unit type from a list, to spawn with createUnit?
yes
is there a limit of it not reading variable names?
i am simply asking as i am not able to run arma right now or for a while
private _unitType = selectRandom ["type_a","type_b"];
_group createUnit [_unitType,_position, ...];```
thanks for confirming it/showing the correct way to do it
Greetings everyone. I was hoping someone could point me in the direction of a script that locks players out of vehicles until theyre a certain rank ..?
using vanilla ranks or something else?
Yeah just the vanilla ones. Like more vehicles unlock as they promote.
just remembered why nearestObject doesn't work, radius is only 50 meters.
i'll just add all the objects to an array and sort by distance
use nearestObjects then
i'll just add all the objects to an array
if you already have the objects then obviously that's what you should've done
I dont already have them, I was going to get them by checking their classname against allmissionobjects, that is if (nearestObjects [player, ["classname"], 500]) select 0; doesn't work.
thanks for the help
is there really no EH in A3 to catch seat changed within a vehicle for players/AI at this point?
hmm, didn't GetInMan work?
oh yeah, I thought there was something in there :P
Is there a way to disband or delete a certain unit from the squad AI?
yes, [unit] join grpNull
deleteVehicle to delete the unit
Could unit be set to the latest AI which has joined the group?
you will have to store that value somewhere
or perhaps i could point at the unit ingame and select the option from a custom menu option?
if you want to
not sure how i select the unit i am pointing at in a script?
cursorObject. cursorTarget also works most of the time :P
But if you attach the action to the unit with addAction then you don't need that.
I will give it a try. Thank you both
hey can somebody tell me how i can create an Folder/Submenu in the interaction menu as well as an Submenuentry? Haven´t found something about that 😦
If you are talking about the scrollwheel interaction menu (i.e. addAction): When chosen, the Open Folder action has to create (i.e. addAction) all the actions that are in the folder (and remove itself). Similarly, all actions that are in the folder have to be removed (i.e. removeAction) to leave the folder.
If it's already in your group then groupSelectedUnits would be good.
true that ^ I always forget about the group UI commands
I have an init script in a helicopter:
null = [this] execVM "Searchlight\AL_searchlight\al_search_light_ini.sqf";
Works fine in Editor Single player mode and hosted MP, but not on my dedicated.
FYI this is ALIAS Searchlight script
Hints welcome
are you able to sqfbin the script?
copyToClipboard loadFile "Searchlight\AL_searchlight\al_search_light_ini.sqf" in debug console
Is this something that needs to be tied to a trigger area, or could I maybe use a blank area marker on the map for it?
Thank you
I got it working
Would fully adding/removing them really be necessary? Should be able to toggle a bool variable that's referenced in the actions' condition to show
no. it's purely scripted
thank you :). How can i count all the players of a give side?
i already tried:
_NOPlayers = {player && playerside == WEST} count Units;
Sorry, I mean in regard to guard areas specifically. I should have been more specific.
guard areas?
Yeah, for guard waypoints
dunno. never used them
There is apparently createGuardedPoint as an alternative.
player is an object, you cannot use it in a && bool check
playerSide is local player's side
count units is… well, counting
count (units blufor select { isPlayer _x });
thank you very much 🙂
even better: playersNumber
https://community.bistudio.com/wiki/playersNumber
keep forgetting about that one
Did a test but led to nowhere. Took a break.
huh? you never sent it here
You wanted me to paste the code here?
...
I love how my phone is synchronized with my computer now.
On my phone. 😁
Give me a minute
No, I don't
the script adds the action on the server machine only
what is the best Way to kick a player when he friendly fires?
Eventhandler "Hit"?
I want to make a script that warns a Player for friendly firing (shooting another player) once and when he does it again he gets kicked
@grizzled cliff, why do thing that spawn and execvm is for noobs?
Is there any alternatives for polling cycles?
anyone know how i could setup a trigger for when a radio tower is destroyed i can allow a unit to access supports for air support?
You can have a client side event handler that tracks team kills and passes client information to the Server once your limit is reached. You could then use server command kick to remove the player.
There are multiple handlers you could chose, compare sides of the units, lots of possibilities, some may work better or worse.
and how would the kicking work?
[_killer, "Kick"] call BIS_fnc_MP; doesn´t seem to work
addMissionEventHandler ["EntityKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
//hint format ["%1,%2", _unit, _killer];
"Eigenbeschuss ist verboten" remoteExec ["hintC", _killer]; // Works fine the killer gets a hintC
Remote execute on the Server from the client event handler for example.
You will need to define a server command password for this in the config.
That's what I guessed. Thank you very much for your time 🙏
@torpid mica Also, I forgot to mention that I had issues in the past with the unit object returned by the event handlers with ACE medical. I am not sure if they ever resolved the issue, although I do not believe so considering how their system works.
CBA Events?
just no ... just fucking no ...
soon to be reimplemented btw
@queen cargo, so it is better to use spawned cycles?
there are tons of better ways doing it
it all depends on what you want to have in the end
for example I want to periodically check some parameters and spawn units (items) in nearby houses
how often is periodically
you already could be in the range where a spawn with a sleep is better then a trigger etc.
I mean loot spawning system, loot is not localized anywhere, but it could be in every house, so I think using spawned "while" is good solution
but if exists better solution it would be interesting...
Is the size of a rope segment a engine defined parameter?
IIRC defined in CfgNonAIVehicles
so are rope is defined in both class rope & cfgnonai but the segment of rope always stay the same size if i had a p3d of rope that was 1m (in model) it would not just be 1 segment it would how many the default rope needs
you can see the segment size on all of these is the same even tho the model size is not
Oh I misremembered, it is CfgVehicles
https://community.bistudio.com/wiki/Arma_3:_Ropes
so it is define in class ropes as well but the size is staying the same
Well, I ain't sure what exactly is your question but the size (aka length) of a rope can be longer or shorter depends on the situation
my question is. can you changed the size of an individual rigid rope segment
the best way i can tell you is if you look at the pic above im trying to make a 1 segment rope that is 1.5m long (with a custom p3d rope) but every time i try the segments are all 0.5m
Well since not sure why you want that can't really tell
for the project im working on i need a rigid segment that swings thats 1.5m long
yes
Then head to#arma3_config , this channel is for in-game scripts
Can anyone help me with why on line 13 the nearestObjects is returning an error "0 elements provided, 3 expected"
https://pastebin.com/XQ8Y5j4T
Is _player defined properly?
in the player init:
[this, 500, 1] spawn cbrn_fnc_chemDetect;
What exactly is the full error?
private _objects = |#|nearestObjects [_player, ["CBRNCase_01_F...'
Error inarea: 0 elements provided, 3 expected
(The file path) line 13```
_payer
that was me typing out the error, my apologies
Copy-paste from the RPT.
and if, hypothetically, I didn't know where that was?
even if it hasn't crashed?
yeah, it's misleading.
RPT is just a continual log.
If you have -nologs then it won't write much. Don't use -nologs.
now where do I find it in this 3914156 line file?
search for error in, or remove all your shitty mods so that it's shorter :P
unfortunately not my server so I cant choose the mods, i'll try find it
Hmm. Does the code work on localhost then?
private _objects = nearestObjects [_player, ["CBRNCase_01_F>
6:14:04 Error position: <nearestObjects [_player, ["CBRNCase_01_F>
6:14:04 Error inarea: 0 elements provided, 3 expected
6:14:04 File C:\(Filepath), line 13```
no unfortunately not
For more context, it was working when I used player instead of _player, and didn't pass it through as a param, just called the function in the player's init, but this then meant the player setVariable ["cbrn_exposure", _exposure + 1] added an amount of exposure equal to the player count, so I moved away from that method.
I had done that assuming would player would be purely local
well, issue is that those init functions are executed everywhere.
So any time a player joined, it'd fire your function again on each client.
But I don't see where this error is coming from.
Maybe diag_log the call parameters.
nearestObjects will throw that particular error if the first parameter is a number, so I suspect your old call without player is still active.
diag_log returned all the players as expected, except there is a random "500" thrown in there halfway through. Perhaps I had accidentally pasted this code into an object at some point? How would I go about finding it?
for reference:
6:34:15 B Alpha 1-1:1
6:34:15 B Alpha 1-1:2
6:34:15 B Alpha 1-1:3
6:34:15 B Alpha 1-2:1
6:34:15 B Alpha 1-2:2
6:34:15 B Alpha 1-3:8
6:34:15 500
6:34:15 B Alpha 1-4:1
6:34:15 B Alpha 1-4:2```
lol
You could write the sqm without binarizing and find it, but mapping that to the editor may be tricky.
You're kinda doing it wrong here though. If you want some piece of code to run locally for each player, you should be firing it from initPlayerLocal, not editor script boxes.
I keep neglecting event scripts, my fault
This feels like a good time to start :P
in the case of our random object, I could probably make the script add everything to an array, remove the players then teleport it to my pos.
ah alright will do
does this solve the issue of any time a player joins, it fires the function again on each client?
Well yeah, because initPlayerLocal runs once on each client.
Okay cool
Thank you so much, I usually dont ask for help for fear of being belittled but you've been very helpful!
The fancy alternative is that the server watches for player connections and remoteExecs to the client, but there are a lot of gotchas when dealing with player objects.
They're initially local to the server and then moved to the client.
Well the elusive 500 id isn't in the sqm so thats cool
I'll still look
Ah, its the init of a group itself
what config property can I grab to filter out suppressor attachments in an array of all compatible weapon items?
answer:
_itemClassArray = _itemClassArray select {
private _config = (configFile >> "CfgWeapons" >> _x);
!("muzzle_snds_H" in ([_config] call BIS_fnc_returnParents apply {configName _x}))
};
might require CBA
I wouldn't necessarily rely on that, a mod muzzle attachment could very well not inherit from muzzle_snds_H
It should be possible to identify a muzzle attachment by whether it has a muzzleEnd property inside its itemInfo subclass
alright ill take a look
so "zaslehPoint" means suppressor?
nope, i see it on non suppressors too
Oh sorry, suppressors specifically, not just muzzle attachments. My mistake.
There might not be a way to 100% reliably detect that; most of the things you'd look for could also be done by non-suppressors.
oh I see we are talking about two different things, thats my bad cause i edited it after i put in my find
You could check for the value of the audibleFire property in the ammoCoef subclass in its itemInfo. That should be mostly reliable.
say I want to filter through all of CfgWeapons universally and pick out things that players can select in the arsenal. what config entry do I check for that? scope?
Probably scope and also look out for the baseWeapon property; weapons with a different weapon as their baseWeapon are considered subvariants and not shown
For more detailed information on configs you should probably check with #arma3_config
_x >> "itemInfo" >> "type"
101 is silencers
I would love to find where that's documented. I couldn't find it in the cfgWeapons reference or the Weapon Config Guidelines
101 is muzzle devices in general, ACE uses it
hashmaps are handy if you need to fetch a value via key
Been told to use this, in order to allow my player pilots, with the pilot variable to be able to use the waypoint system.
But I get an error upon load
if (player getVariable ["isPilot",false] call BIS_fnc_inString) then {
[player] onMapSingleClick {_shift};
};```
Error:
```Error in expression <g] isEqualTypeAll "") exitWith {[[_find,_string], "isEqualTypeAll", ""] call (mi>
16:19:02 Error position: <_string], "isEqualTypeAll", ""] call (mi>
16:19:02 Error Undefined variable in expression: _string
16:19:02 File /temp/bin/A3/Functions_F/Strings/fn_inString.sqf..., line 25
16:19:02 Error in expression <F/Strings/fn_inString.sqf"
if !([_find,_string] isEqualTypeAll "") exitWith {[[>
16:19:02 Error position: <_string] isEqualTypeAll "") exitWith {[[>
16:19:02 Error Undefined variable in expression: _string
16:19:02 File /temp/bin/A3/Functions_F/Strings/fn_inString.sqf..., line 25```
What is the issue??
What does player getVariable ["isPilot", false] return?
so the final thing i need to finish my mission is...i need a way to play a video (which is the credits) how do i switch to the outro phase and play a video?
false
regardless of the role being set to a pilot or not
And is false a valid input for BIS_fnc_inString? Look at https://community.bistudio.com/wiki/BIS_fnc_inString if you don't know.
it doesn't iterate better or faster
I've never tried, but I think if there is an outro, it starts automatically after the end of the mission (see https://community.bistudio.com/wiki/Eden_Editor:_Scenario_Phases).
For the video: https://community.bistudio.com/wiki/BIS_fnc_playVideo
iirc scen phases are..broken, i think
you can use in to check for string in string btw
I have no any idea. What is or isnt supposed to do what.
Looking at the biwiki has added to my confusion tbh.
Is that even the right function for what I'm trying to do??
no idea what you are trying to do tbh
shift-click marker/waypoint
BUT only for some players, specifically Pilots
do you ever use setVariable to define isPilot?
Yes.
this setVariable ["isPilot",true,true];
All you really need to accomplish your goal is:
if (player getVariable ["isPilot",false]) then {
[player] onMapSingleClick {_shift};
};
so coming off kjw’s script on fade in and out i wanna make sure that this occurs to just the person interacting with this script is that how this already works? if not how to do i do so?
this addAction ["YourAction",{
[] spawn
{
titleText ["", "BLACK OUT", 2];
sleep 3;
player setPosATL (getPosATL tplocation);
titleText ["", "BLACK IN", 2];
};}];```
Well, false is not a valid input for BIS_fnc_inString: As documented on the Wiki, the syntax for BIS_fnc_inString is [searchTerm, searchText, caseSensitive] call BIS_fnc_inString, and false call BIS_fnc_inString clearly does not match that pattern. That is the cause for the error message that you shared in the beginning.
But, as you discovered when you looked at the Wiki, BIS_fnc_inString is very likely not the right tool to accomplish your goal in the first place, so we probably don't even have to deal with that error at all. This is why you should always start by consulting the Wiki when you are having trouble with a command or function - it could be that it is not the right tool for the job or that you are using it wrong.
The script contains no remote execution (i.e. it only runs on the machine of the player who activated the action). The only command with global effect is setPosATL, and that only affects one object (in this case the player who activated the action).
In conclusion: The fading and teleporting only affects the player who activated the action.
nice! and thank you
No
Hashmap iteration is slower
The only reason to use hashmaps is when you want to find something in a container that has many elements. In that case hashmap will give you a better performance
But keep in mind that hashmaps use more memory too
A hashmap with a few million integer elements could be several GBs, but an array version could only be a few hundred MBs
Hi. Can anyone help with unitplay function?
MY plan is to have three aircraft takeoff and drop off infantry. For the first aircraft, unit play works great. However when I try run unitplay for the second aircraft, it doesnt work.
I pretty much did the same thing I did for the first aircraft but unitplay works for the first one but not for the second one.
I am using tr1, tr2 for the aircraft.
this one works
this one doesn't
Trigger:
Ive tried re capturing, putting down a new aircraft but nothing seems to work
No. It's an exponent
Yeah both files have e-
Those scripts makes no sense. Since you're changing the wp1 and wp2 variables (which were the functions you were calling). You can change them to _wp1 and _wp2 in those scripts to make them local variables
But in any case the code looks fine as far as I see
It works for first aircraft but doesnt for second.
It should work for both
Thats what I dont get. Everything is exactly the same but still it doesnt.
Put a systemChat "tr2 works"; at beginning of the second one
See if you get the message
Trigger or sqf?
Huh? Why would that be?
Before or after changing the unitPlay data arrays to be local variables?
If after, what happens if you remove the first one and only do the second?
Nothing
When I run the local variable, even the first one stops moving
Did. Nothing happened
That change can't have that effect if done correctly. What exactly did you do?
Add _ in trigger.
Well, you haven't changed the unitPlay data arrays to be local variables, you've just told the game to look for the script in a local variable (that doesn't exist)
_wp1 = [ ... ]; // The data array is a local variable rather than global now
[tr1,_wp1] spawn BIS_fnc_unitPlay // You also have to change other references to it
The problem we are trying to resolve is that both the script (wp1 = compile preprocessFile ...) and the data array (wp1 = [ ... ]) are saved as global variables named wp1 - or rather, they're saved as the same variable, one overwriting the other, which causes chaos.
Aaha. Let me fix that and run it again
Source?
Like this?
Yes, but don't forget to change the wp2 script as well (and in init.sqf, change _wp2 to refer to wp2.sqf)
Both aircraft dont move
Did you remember to change back the previous, incorrect, change in the trigger itself?
This one?
Yes
Isnt this correct now since it is referring to local variable?
rec = [] spawn _wp2;```
No, because that's where you want to refer to the script (which is still, and must be, a global variable), not the data array (now contained in a local variable and not accessible in the trigger's scope)
Oh wait, I read what you put earlier wrong. The reference to the script when you do preprocessFile should not be changed. That's wrong.
This change - don't do it. Only the data array as I described before.
so it should remain wp1 = compile preprocessFile "wp1.sqf"; instead of _wp1 = compile preprocessFile "wp1.sqf";
Yes. You don't want the script to be a local variable because then it's only available in the local scope where it was defined (in init.sqf). The script reference should be a global variable.
The data array is only used in the local scope and not outside it, so it can be a local variable, and making it a local variable removes the conflict with the script.
Alright. Lemme fix and try again...
That was half my fault, I should've paid attention and not said that was right before.
OH MY GOD IT WORKS!
Setting it to local will still make it work on dedicated right
@hallow mortar
you can verify it in Arma itself
but anyway, as you know, an ideal hashmap can simply map to memory. that alone would tell you that for 64bit hashes you'd need thousands of terabytes of RAM 😉
https://stackoverflow.com/questions/22502412/why-does-a-hash-table-take-up-more-memory-than-other-data-structures
that's just the first thing that came up when I googled but I'm sure you can find more reliable sources
Local in this case is about scope (https://community.bistudio.com/wiki/Variables#Scopes) not network locality.
I would be careful about how this trigger is activated though. In multiplayer it may be possible for more than one player to activate it, which would be bad.
I have had that problem where someone spawned a bunch of stuff via radio.Now I use an area trigger activated by opfor outside ao. So only I can activate
But thank you so so much
🥮 Here's a cake
BTW is this a new update that caused this?
Cause Last year I did a black hawk down op that used 10 helis and I used global variables and they still worked.
All 10 of them
Sure it might take up a bit more memory but your claim of 3 orders of magnitude is simply ludicrous.
Nothing's changed about this in a very long time. It's always been wrong to overwrite variables while you're trying to use them, and it's always been best practice to use local variables for things that don't need to be global.
Using global variables would be functionally fine (but not a brilliant plan) as long as the script and array variables had different names. That was the core of the issue; changing to local variables happens to solve it and make sure it won't happen again.
Last time you probably just used different names for them and accidentally avoided the issue.
Arma....A mystery
Well......."using the same name for a global variable will overwrite whatever was previously in it" isn't really a mystery :U
Maybe a second pair of smarter eyes can help me here...
params ["_obj"];
_ensure_team = {
params ["_team_name", "_side"];
_cur_groups = allGroups;
_old_team = (_cur_groups findIf { groupId _x == _team_name});
_team;
if( _old_team == -1 ) then {
_team = createGroup _side;
_team setGroupId [_team_name];
}else{
_team = (_cur_groups select _old_team);
hint str _team;
};
hint str _team; <------------------ OUTPUT: B Blue Team
_team;
};
_players = _obj nearEntities ["man", circles_team_assign_range];
_players = _players call BIS_fnc_arrayShuffle;
_green_team = ([circles_team_assign_green_name, independent] call _ensure_team);
_blue_team = ([circles_team_assign_blue_name, west] call _ensure_team);
hint str [_green_team, _blue_team]; <------------------ OUTPUT: [any,any]
Am I doing something apparently wrong with the way I am returning my variable here?
If you want nearEntities without animals use
"CAManBase"
I ripped out all my privates because I thought it was a scope issue
Is there a way to limit the distance where the friendly squad AI attacks an enemy?
Solution: change _team; to _team = NULL (Improperly declared, so it only existed in the scope of the if statement
**Question: ** [_this] remoteExec ["my_func", 2]; calls on the server, from what I understand. Does this mean it will run only once? (not for each client?)
It will run only once if only one client remoteExecs it. If every client runs the remoteExec, the server will receive that many remoteExecs and will execute the command or function that many times.
Not possible?
Thank you, glad you emphasized that!
no
thank you
is there a way to freeze the player in place? As if they were performing an action
context: I want to create a holdAction. But i need the player to start in the holdAction... It doesnt seem thats possible so i'm figuring out a way around it by playing an animation and making them wait with a progress bar
you can player enableSimulation false
just make sure to player enableSimulation true when the action is interrupted or complete
o.o that works?
it should
yeah it does, thanks
I have a function that is supposed to notify players when the countdown timer is over. Here is the code.
init.sqf
waitUntil {(!isNull player) && (time > 0)};
/// Setup Timer
[900] call SESO_fnc_setupTimer;
fn_setupTimer
params ["_endTime"];
// Server Only
if (isServer) then {
[_endTime, true] call BIS_fnc_countdown;
};
// Players Only
if!(isDedicated) then {
while { ([true] call BIS_fnc_countdown) } do
{
if ([0] call BIS_fnc_countdown <= 5) then {
["SetupOverNotif"] call BIS_fnc_showNotification;
};
sleep 1;
};
};
What is happening:
The countdown timer appears and correctly counts down to 0 from _endTime
What is supposed to happen:
The countdown timer appears and correctly counts down to 0 from _endTime. Around 5 seconds in, the player should get a notification stating the timer is over.
Any advice, code wizards?
Hey, amateur scripter here.
I have two different description.ext's that are responsible for two different things. Any way to have them merged into one description.ext?
I have attempted this and one part of it does not initialise the way it's supposed to.
// Players Only
if!(isDedicated) then {
```should be```sqf
// players Only
if (hasInterface) then {
The countdown timer appears and correctly counts down to 0 from _endTime
yes
the script runs on every machine "all at once"; the countdown does not have time to be broadcast.
also, your code does "while the countdown is active, show the notification every second if the timer < 5"
so:
- wait until the timer is active, then
- wait until it remains 5s
only one description.ext can exist, so have a main one
copy-paste at your own risk as two different declarations cannot coexist (e.g two CfgSounds)
Thank you.
Got it, waitUntil instead of while and for loops. Forgor those exist. Thanks!
You can use #include to split bits into their own files if that helps you keep track of things. What Lou said about only having one of any declaration class still applies though; things in an #include'd file behave exactly like they're in the main file.
So
If I have
class CfgSounds
and
class CfgSentences
Then it won't work?
Or is it just stuff like having CfgSounds twice?
You can have more than one different type (otherwise a lot of things would be impossible...). You can't have two of the same one, they conflict.
Makes sense.
I am just asking because I am having a slight issue with it where it seems to work but when I then use a trigger to activate a audio file, the trigger doesn't work despite being set up correctly.
With no evidence that there is something wrong in the description.ext.
If you can see the sound in the trigger's Sounds dropdown in its Attributes, select it and click the play button next to the dropdown to test it. If you can't see it in the dropdown, there's a major problem. If you can see it but nothing happens when you test it, try restarting the Editor and do it again
are the two files big?
ez merge:
class CfgSounds
{
class sound1
{
// ...
};
};
```&```cpp
class CfgSounds
{
class otherSound
{
// ...
};
};
```=```cpp
class CfgSounds
{
class sound1
{
// ...
};
class otherSound
{
// ...
};
};
{
gameType = Sandbox;
minPlayers = 1;
maxPlayers = 25;
};
respawn=3;
respawnDelay=5;
respawnOnStart=-1;
showCompass = 1;
showMap = 1;
showGPS = 1;
showWatch = 1;
showPad = 1;
showRadio = 1;
author = "MAJ.GEN Alastor";
onLoadName = "AREA 52, CHEYENNE MOUNTAIN";
loadScreen = "r3.jpg";
onLoadMission = "SGSOC OPERATION";
overviewText = "SG Deployment";
overviewPicture = "r3.jpg";
class CfgSounds
{
class intro
{
name = "intro"; // Name for mission editor
sound[] = {\sound\intro.ogg, 3, 1.0};
titles[] = {0, ""};
};
};
class CfgSentences
{
class ConversationsAtBase
{
class Briefing
{
file = "brief.bikb";
#include "brief.bikb"
};
};
}; ```
The file path should be a string
Ah yes.
whats the most efficient way to write this sqf _cursorTarget = cursorObject; if (isNull _cursorTarget) then { _cursorTarget = cursorTarget; };
Maybe _cursorTarget = [cursorTarget, cursorObject] select isNull cursorTarget;
Not gonna be much different though.
TBH John's solution is worse IMO, since it evaluates both cursor commands regardless is null or not
I don't really see Quicksilver's solution is bad enough
Just some lines, if we want make it shorter just compile into a function
worst thing about mine is that it evaluates cursorTarget twice :P
Ye
Still works out slightly faster in the branch-taken case.
Hm, really?
Yeah, but slower in not-taken.
So depends how common the cases are.
Man, cursorTarget is really wide.
Is there any way to check that player is looking at the sky using screenToWorld?
lineIntersectsSurfaces + eyePos + eyeDirection doesn't hit anything, I guess?
Unless you just mean "looking upwards"
Yeah lineIntersectsSurfaces, ty
its good for things like nametags ... cursorobject is very sensitive, if you look at someone you have to be looking at the right part of them.. if your cursor is over their gun, it detects the gun instead of them
you'd think that screenToWorld might tell you, but trying it now I'm really not sure what it's doing.
cursorObject and cursorTarget seem close but not identical for houses, like one's using a different LOD or a slightly different view point.
but then for units, cursorTarget is working with something like a bounding sphere.
Huh, unless the unit's inside a house, and then cursorTarget is doing the geometry too.
iirc cursortarget also is subject to _unit disableAI "CHECKVISIBLE"
hmm, I think there's a bug with cursorTarget actually. I can find spots near a target unit that return objNull while areas much further away return the unit.
yea its good for medium/far units
thats why i still use it
player doesnt need super precision to still get nametags
Cursortarget would "target" objects even when you have obstructed view in some cases, no? Unlike cursorobject
I remember seeing some claim like this when I was looking for a script to trigger stuff when you see something through your binos
It looks like it does is a line trace first, and if it doesn't hit a valid target then it does the bounding sphere check on units.
Except in the case where the line trace hits something invalid more than ~300m away but not sky then it returns objNull without doing the bounding sphere check.
Might be the difference between the line trace distance and the bounding sphere check distance that matters.
I'm running into a weird issue. I'm using the supply drop (Virtual) support module, and have some script in the crate init field.
I want it to create a respawn condition once it lands and stops moving and as such have some code in the crate init field like the following
altNew = round (getPos _this select 2);
waitUntil {sleep 2.5; altOld = altNew; altNew = round (getPos _this select 2); altNew == altOld};
respawnPos = getPos _this;
marker = createMarker [format ["respawn_west_%1_%2_%3", round (respawnPos select 0), round (respawnPos select 1), round (respawnPos select 2)], respawnPos];
Because of the waitUntil function that escapes once the altitude of the crate is the same after 2.5 consecutive seconds, the init script is being carried out until shortly after it lands.
When the helicopter drops the crate, it deploys with the parachute, the init script seems to be executed, at which point the crate falls from the parachute like a brick to the floor, and after a moment or two teleports back into the air connected to the parachute.
The respawn position is created where it first hits the ground which means that the crate with the parachute can then drift a long way off from this position.
I was wondering if there's a way to ensure it remains connected to the parachute while executing the crate init field, or a better means by which to create the respawn position?
Thanks!
it's recommended to not use getpos but instead use getposATL etc
fair point, I'll go about changing it
I don't see why the init script would affect the crate/parachute connection.
The script does nothing to either of them.
I don't know but it seems to? I think it's the way the support module itself may work? Perhaps it executes the init field then attaches it to the parachute?
Did you try it without an init field?
Just did, works fine without an init field. I have a video of the problem but unsure if allowed to post it?
eh, here it is
so it creates the respawn point where it first touches the ground, but because it then teleports and reattaches itself to the parachute, it can drift a fair ways away from that respawn point.
Hello, simple question. What the command to move the currently selected unit to the cursor position on screen?
{ _x setPos (getPos cursorObject) } forEach (groupSelectedUnits player) perhaps, didn't test it
screenToWorld is possibly useful there.
but then you may have to figure out what it's doing with the sky :P
When you say "currently selected unit", do you mean selected in zeus, the command bar or what?
screenToWorld version of honger's code then:
{ _x setPosATL screenToWorld [0.5, 0.5] } forEach (groupSelectedUnits player);
It's a forEach because you can select multiple units.
and you have to execute it through console, not sure if there is a way to add an option to the command menu to execute that
I mean there probably is but I haven't tried doing anything like this yet 
Otherwise it is "beaming" the unit 😉
well yeah, insta-change of unit placement is a way of moving lol
move the currently selected unit to the cursor position on screen
can be read two ways 😁
Also you can just do the move-to-point with the command menu?
Yea, but if the cursor is over another unit it always swaps to select unit
Which is annoying
you can open your map and move unit by pointing on map
nah
CQB
orders in world
I just want to have a reliable move command via menu
It's annoying if the cursor changes to "select unit"
Unless there is a way to deselect this ingame
only through overriding the default command menu I believe, All-In-One Command Menu does something similar
not sure if it fixes unit selection but makes it easier to let your units heal themselves on move, otherwise it's annoying as the option constantly fades away
One annoying thing. When I sent the unit to location and it arrives there it shows Reads below the name. If I select all my units in a next step, it somehow ignores the unit which I've just sent to the location. Any solution for that?
I should add that this is the case when the other units follow the leader.
So only the unit which just went to the location has Ready status
assign them to a team (give a color) and use a team shortcut to select your group
so instead od ~ it's Ctrl + 1 to Ctrl + 5 or something
I've been trying to experiment a little and thought that I might be able to use attachTo to attach the arsenal to the parachute at the beginning of the init field, however it doesn't seem to be working.
I've added this to the beginning of the init field which is executed when the crate is released.
sleep 1;
nearTarget = nearestObjects [_this, [], 100, false];
hint format ["%1",nearTarget];
_this attachTo nearTarget select mynumber;
And tried it changing mynumber from 0 through to the length of the array returned in nearTraget but with no luck.
The hint output is attached, I'm just wondering if there's something obvious I may be doing wrong?
i have a problem with kicking a player from my (pc hostet) Server. I can use the kick command in the chat but using: serverCommand format ["#kick %1",_id]; won´t work. No error message, nothing happens
Did you assign a command password?
no i used #login just before
It’s all explained on the Biki page I linked you earlier.
Dedicated server instance locally?
You will need to define a command password which is a different password in your server cfg.
It is required for usage of ‘serverCommand’.
Check the Biki page I linked you here, it’s all explained in depth there.
ok thanks 🙂
How to use the /o flag with regex? Do you create a variable for the regex pattern and append /o at the end to create an optimized regex pattern that you can re-use, saving performance?
did you try?
_this attachTo [nearTarget select mynumber];
I'll boot it up and give it a whirl now
and how you create array neartarget? edit. no matter now 😄
holy shit this worked
This is the pertinent bit of code, I think perhaps the select 0 object is the arsenal itself, and the parachute is the select 1.
sleep 1;
nearTarget = nearestObjects [_this, [], 100, false];
hint format ["%1",nearTarget];
_this attachTo [nearTarget select 1];
No. It probably only gives better performance for regexReplace.
can you use https://community.bistudio.com/wiki/setObjectTexture on weapons?
{
_x setUnitPos "MIDDLE";
}forEach (groupSelectedUnits player - [player]);
Trying to change the Position of a unit but nothing happens. What am I doing wrong?
Thank you
Why am I getting two missionFlow fsms when I'm only executing it once?
//diag_activeMissionFSMs
[["fn_feedbackMain","Check_Sudden_Dea",-0.995],["missionFlow","Tank_Objective",-0.995],["missionFlow","Tank_Objective",-0.995]]
answer: FSMs in the root folder are automatically run on init - no need to execFSM
i have an Array which contains many Subarrays. In these subarray there is an information i want to sort all the subarrays by. ho can i do this?
something like this: [[position, name, size, prioBlu, prioOpf],[position, name, size, prioBlu, prioOpf]] and i want to sort by prioBlue or prio Opf. how would i do that?
are prioBlu and prioOpf numbers?
yes they are
these are just placeholders, since the value can change after some time
_sortedArray = [
_array,
[],
{
_x params ["_pos","_name","_size","_prioBlu","_prioOpf"];
_prioBlu //must return string, number, or array
},
"ASCEND"
] call BIS_fnc_sortBy
Hello
Need help with an Task Script
Basically, i want to have a Task activate after 3 previous tasks have been sucessfully completed.
Those 3 previous tasks work fine.
But whenever i start the mission i get the error message dor the 4th Task:
"triggerActivated task1a_sucess |#|&& task1b_sucess && task1c_sucess;
Error &&: Type Object, expect Bool, code"
The 3 previous tasks are all about eliminating specific enemies.
For example: Task 1a is: to destroy 3 vehicles and its script is:
!alive Vehicle1 && !alive Vehicle2 && !alive Vehicle3;
And that works fine
Thanks for any help or advice !
["task1","task2","task3"] findIf {!(_x call BIS_fnc_taskCompleted)} == -1
!alive Vehicle1 && !alive Vehicle2 && !alive Vehicle3;
[vehicle1, vehicle2, vehicle3] findIf {alive _x} == -1
gotta start using arrays my dude
Thank you !🙏
The error is gone now.
But the task still isnt popping up...
should have told you, you should be using the task system to do this stuff (which is what my code uses), not triggerActivated stuff. Are you using the task system?
You mean the Task modules ?
Ive been using those in combination with triggers
okay, and you are naming your tasks in the Task ID box?
Yes
I select one unit from my squad via F4 and execute the following script:
{
_x setBehaviour "STEALTH";
} forEach (groupSelectedUnits player - [player]);
But for some reason it is putting the whole team into stealth mode. Why?
setBehavior
Sets individual unit behaviour on every unit in a group.
pm me pictures of your modules and triggers. its hard to help with editor based stuff here instead of raw scripting.
is there a command to do it for one individual unit?
setCombatBehaviour
you still sure you want to use groupSelectedUnits? that is for high command mode
nah, that's hcSelected
oh i read that wrong
my objective is to use the script on one selected unit
This works. Thank you!
no
are FSMs in the root folder automatically executed?
edit: they are it seems
iterating over array or hashmap is both very similar (hashmap slightly slower, hashmap is multiple arrays internally, like 6+).
What hashmap does better is find operations.
HashMap needs more memory
can't reuse. See https://community.bistudio.com/wiki/Arma_3:_Regular_Expressions
Sorry reading slower than replying, Leo already answered
hey guys, trying to make a mission for my players were they assault and destroy an islands power plant, which then will turn the lights off for the rest of the deployment. Does anyone happen to know of an easy way to go about doing this?
_myLamps = position powerPlant nearObjects ["Lamps_base_F", 100];
{
_x switchLight "OFF";
} forEach _myLamps;
Or you need get correct class in "Lamps_base_F"
Depends which all lamps you want shutdown
Well tested that "streetLamp" return empty array (wo knowing which lamp you have on street),
But. Don't know is that better or not.
And I pasted wrong, tested on off and sended ON, my bad.
Does anyone have experience with createSimpleObject from .p3d 's? Specifically in applying the different types of textures ( https://community.bistudio.com/wiki/Texture_Map_Types ) to the object?
setObjectTexture is mentioned on https://community.bistudio.com/wiki/createSimpleObject
Does anyone have experience with communication menus? I have a .sqf with code to move a selected AI from my squad to a certain position. I am now trying to call the sqf from a communication menu but nothing happens.
mymod_fnc_showGameHint = {
MENU_COMMS_2 =
[
["Submenu", true],
["Move Select", [2], "", -5, [["expression", "[groupSelectedUnits player - [player], screenToWorld [0.5, 0.5], 3] execVM ""MoveSelected.sqf"""]], "1", "CursorOnGround", "\a3\Ui_f\data\IGUI\Cfg\Cursors\iconCursorSupport_ca.paa"]
];
showCommandingMenu "#USER:MENU_COMMS_2"
};
["Special Menu1","Menu_key1", "Menu Key1", {_this call mymod_fnc_showGameHint}, "", [DIK_U, [false, false, false]]] call CBA_fnc_addKeybind;
what is that dangling }?
Sorry, forgot to copy the first line
what does your sqf code contain?
Have to paste in two messages
sec
params ["_allUnits", "_pos","_radius"];
if (count _allUnits == 0) exitWith {};
_units = _allUnits select {(vehicle _x == _x)};
_fnc_move =
{
// Remove units from JBOY Array
jboy_FastMovers = []; // Remove team from array used by jboy_haulAss eachFrame code
{
_unit = _x;
_unit setVariable ["formationMembers",[],true];
_unit setVariable ["blueMoveCompleted",true,true];
_unit setVariable ["formationLeader",player,true];
{_unit enableAI _x;} forEach ["SUPPRESSION","AUTOCOMBAT","COVER","AUTOTARGET","TARGET"];
_unit forceSpeed -1;
_unit setAnimSpeedCoef 1;
} forEach (groupSelectedUnits player - [player]);
// Start Move
params ["_unit", "_pos", "_watchPos"];
if (vehicle _unit != _unit) exitWith {};
_unit setVariable ["my_CurrentOrder", "360"];
_unit doFollow player;
sleep 0.1;
doStop _unit;
sleep 0.2;
_unit moveTo screenToWorld [0.5, 0.5];
_unit setUnitPos "up";
_unit setCombatBehaviour "AWARE";
_unit disableAI "AUTOTARGET";
_unit disableAI "AUTOCOMBAT";
_unit setUnitCombatMode "BLUE";
_time = time + 100;
_failed = false;
waitUntil {sleep 1; moveToCompleted _unit || {_failed = time > _time || !alive _unit || currentCommand _unit != "STOP" ||
_unit getVariable ["my_CurrentOrder", "360"] != "360"; _failed};
};
// End of the Move
if (_failed) exitWith {};
_unit setUnitPos "MIDDLE";
_unit setCombatBehaviour "STEALTH";
_unit enableAI "AUTOTARGET";
_unit enableAI "AUTOCOMBAT";
// Rest of End move
_time = time + 600;
waitUntil {sleep 2; time > _time || !alive _unit || currentCommand _unit != "STOP" || _unit getVariable ["my_CurrentOrder", "360"] != "360"};
_unit doWatch objNull;
// Add units to JBOY Array again
{
_unit = _x;
_unit setVariable ["formationMembers",[],true];
_unit setVariable ["blueMoveCompleted",true,true];
_unit setVariable ["formationLeader",player,true];
{_unit enableAI _x;} forEach ["SUPPRESSION","AUTOCOMBAT","COVER","AUTOTARGET","TARGET"];
_unit forceSpeed -1;
_unit setAnimSpeedCoef 1;
} forEach (units group player);
[units group player] call startFastUnits;
player groupChat (selectRandom ["Single move done!"]);
// doStop _unit;
};
_count = count _units;
if (_count == 0) exitWith {};
{
_unit = _x;
_unitAngle = (_forEachIndex + 1) / _count * 360;
_formPos = _pos vectorAdd [_radius * sin _unitAngle, _radius * cos _unitAngle, 0];
_watchPos = _pos vectorAdd [100 * sin _unitAngle, 100 * cos _unitAngle, 0];
[_unit, _formPos, _watchPos] spawn _fnc_move;
} forEach (groupSelectedUnits player - [player]);
startFastUnits
doesn't seem to be defined
also you should put some systemChats in your code to see where it stops working
start with those exitWiths
it runs fine in the console
only problem is that nothing happens when i try to start it from the command menu
not sure why
your menu is incomplete as far as I see
it doesn't have a header
you only have 1 element in it
menus must start with a header
sorry, it has one
let me edit
so the menu is working and the code runs fine in the console. But when i execute the code from the command menu then nothing happens
Not even an error
I see nothing wrong if that's your exact code
Not it actually has an error. Undefined variable _allunits. Line 3
Weird thing is, that the code runs fine in the console
But it gives this error from the command menu
the execVM part looks correct 
you mean this is what you run?
[groupSelectedUnits player - [player], screenToWorld [0.5, 0.5], 3] execVM "MoveSelected.sqf"
yea
["Move Select", [2], "", -5, [["expression", "[groupSelectedUnits player - [player], screenToWorld [0.5, 0.5], 3] execVM ""MoveSelected.sqf"""]], "1", "CursorOnGround", "\a3\Ui_f\data\IGUI\Cfg\Cursors\iconCursorSupport_ca.paa"]
i select a unit
open the menu
and select 1
I mean in console
well run this
the whole code doesn't have _allunits defined either
nothing happens from console
hmm, it did not give an error in the console
where do i have to define it?
it doesn't because it runs unschd
it does have the error
it just doesn't show it
oh, i did not know it
either way if this doesn't run or give you an error anymore the only explanation is that your file doesn't exist
you said it doesn't give an error tho
this one
well if you use this the variable is defined
maybe you didn't save your script or something
this one defines _allunits?
it passes it to the code
the code defines it
so it shouldn't be giving you any errors
this is really weird
no error
as I said
where are you even checking for error? rpt?
if so you're looking at old errors
editor
issuing the command to grp
and then it pops up on screen
just be be sure
what exact code are you using for the menu?
The full line of this i mean
that exact thing
different to this?
no
so basically the same full line?
anyway that script is a huge mess
yes
everything is exactly as you posted
ok
and I already told you it doesn't have any errors just by looking at it
then you're doing something wrong yourself. I can't tell you what 
think i tried everything
yea, i check again
Thank you for your help though!
Much appreciated
I've got a quick question about drawIcon3D
can this be used server-side so it doesn't need to be created to every player?
no, it is UI-related
How do I end function, which I would normally do with return? I found exit, but it doesn't seem to be working
Put a variable at the very end of the function
I don't care to return anything, only to kill the script in this case
Will break only break out of one scope?
Ill try exitWith, thanks!
I figured it out!
Solution: use scopeName <someString> at the scope you want to break, and when you want to break that scope, use breakOut <someString>
for awhile i had a script that would crash servers on the first restart of the leap year Feb 29
pain in the ass but it was too complicated to deal with so i just left it
gonna try converting the date to number, then add after conversion, the change it back to date
figured it out doing this
params [["_min", 0, [-1]]];
private _dateNumber = dateToNumber date;
private _year = date select 0;
/*
private _isLeapYear = (
_year % 400 == 0 or
(_year % 4 == 0 && _year % 100 != 0)
);
private _daysInYear = [365,366] select _isLeapYear;
*/
// no need to compensate for leap year as numberToDate already takes year into account
// conversion from min to unit number (365 days = 1.0, 366 = 1.00274)
private _delta = _min / 60 / 24 / 365;
private _dateNumber = _dateNumber + _delta;
if (_dateNumber > 1) exitWith { false };
// return
numberToDate [_year, _dateNumber];
Does anyone know a way to spawn a vehicle in via script with a certain camo/skin already applied. Just trying to streamline vic spawning with zeus intervention to just change the vic skin/camo
And sounds real sad but where can i find the class/define term for camo's
Many thanks mate
You can also use the Garage and export the appearance. Might be helpful.
Ah great suggestion mate - Appreciate it
recsavedSlotMoney = (player getVariable ["HALs_money_funds", 0]);
hint str recsavedSlotMoney;
recsavedSlotMoney = createhashmap;
if (vehicleVarName _x != "") then { recSavedSlotMoney set [vehicleVarName _x, recsavedSlotMoney]};
publicVariable "recsavedSlotMoney";
profileNamespace setVariable ["PlayerMoney", recSavedSlotMoney];
_savedPlayerMoney = recsavedSlotMoney player;
Hey I am trying to make Hal's Simple Shop money persist over sessions of the same mission.
This is what I have so far for attempting to save the money value, the first time trying this. I am really new to this form of scripting so a lot of this stuff wont look right probably but maybe it gets the point across of what I am trying to achieve.
This is running on the client?
Not a good idea to store anything in the client's profilenamespace as it is prone to get abused.
It will be running on the mission's folder itself. Regardless, it is something I am creating for a campaign me and my friends are planning to do. I'd appreciate it if you could help me out
having problems with locking a gate in arma. I call this _LeftGate SetVariable[Format["bis_%2_Door_%1",_i,_OpenStatus], 1, true]; this locks and unlocks when needed
then I call _LeftGate animate [Format["Door_%1_rot",_i], 0]; this closes the gate.
without closing the Gate it locks.
How do I close the gate then lock it?
Will say3D allow for AI to detect the player if it is played from them?
no, afaik
is there any other way to do that (i.e make the player "speak" to the point ai can hear)
So I found this from 2 years ago, what did this person mean by wrong operator? Can't seem to figure it out.
reveal
no idea, and they have edited their message so most likely fixed
So I'd need my own logic 
perhaps coughing shouldnt reveal players 
Hello, I need your help pls. I am calling a .sqf from a custom communication menu:
Communication Menu:
#include "\a3\editor_f\Data\Scripts\dikCodes.h"
mymod_fnc_showGameHint = {
MENU_COMMS_2 =
[
["Submenu", true],
["Move Selected", [2], "", -5, [["expression", "[units player - [player], screenToWorld [0.5, 0.5], 3] execVM ""\AI\MoveSelected.sqf"""]], "1", "CursorOnGround", "\a3\Ui_f\data\IGUI\Cfg\Cursors\iconCursorSupport_ca.paa"]
];
showCommandingMenu "#USER:MENU_COMMS_2"
};
\AI\MoveSelected.sqf:
_selected = groupSelectedUnits player - [player];
player groupChat (selectRandom ["a"]);
if (count _selected == 0) exitWith {};
player groupChat (selectRandom ["b"]);
.....
When I now select a unit from my AI squad ingame via F2 and then open the custom menu and execute the order, the full code does not get executed. I prints "a" in the chat but this is where it stops. It almost feels like that the count is 0 but I selected a unit ingame in advance. Any idea why the full code does not get executed?
hmm so it turns out its not fixed. tested the saved money value using hint str and it saves the money, adding it is not working since it thinks I have no money, probably goes wrong somewhere in
if (_money == -1) then {
*Edit
Here's a fix if someone from 2 years from now looks for it
if (_money >= -1) then{
im new to scripting, would anybody want to help and let me know how to make a survivable heli crash
so "there is an issue somewhere"
figured it out, wasnt too hard, just had to use the brain
if (_money == -1) then {
[player, _money] call HALs_money_fnc_addFunds;
} else {
[player, 4000] call HALs_money_fnc_addFunds;
};
```it's the _logic_ that is inverted
if money is not defined, add -1 money, else add 4000
anyway
allowDamage can help you
the selection seems to get emptied before execVM runs. Swap to call-ing the intended code instead, that seems to work 🤷♂️
Than you. Just to be clear, you suggest to use call in the code for the command menu, right?
[arguments] call MY_fnc_name
I will give it a shot. Thank you!
I'm trying to find where flagpole gets it's flag texture but cannot find it in config, anyone knows?
i see a bunch of bohemia flagpoles setting their flag texture in "init" EventHandler
i.e. sqf class Flag_FD_Green_F: FlagCarrier { author = "Bohemia Interactive"; ... displayName = "Flag (FD - Green)"; hiddenSelectionsTextures[] = {"\A3\Structures_F\Mil\Flags\Data\Mast_mil_CO.paa"}; hiddenSelectionsMaterials[] = {"\A3\Structures_F\Mil\Flags\Data\Mast_mil.rvmat"}; class EventHandlers { init = "(_this select 0) setFlagTexture '\A3\Data_F\Flags\flag_fd_green_CO.paa'"; }; };
and hidden selection seems to be non-flag part of the pole 🤷♂️
https://community.bistudio.com/wiki/flagTexture/https://community.bistudio.com/wiki/getForcedFlagTexture may work for already placed flags
yep that's it! thx 🙂
Just to confirm before I do something very silly,
player is just a local pointer to the object that the player is, right? Don't think I explained that best, but all it is is another word for the object being controlled by the local computer?
I feel like I need the silly context for this, but I'm gonna tentatively say "yes".
I tried to call the intended code via:
["Move Selected", [10], "", -5, [["expression", "[units player - [player], screenToWorld [0.5, 0.5], 3] call ""\AI\MoveSelected.sqf"""]], "1", "CursorOnGround", "\a3\Ui_f\data\IGUI\Cfg\Cursors\iconCursorSupport_ca.paa"]
But receive an error: "Error call: Type string, expected code"
no. it doesn't get emptied
it does on my machine 🤷♂️
as the error says you're providing a string
oh he's doing groupSelected in the sqf file
yeah that won't work
@modern meteor get the selected units in the command menu
spawn did the same. Call worked.
Can you paste the code you use to call?
I know
as in:
["Move Selected", [10], "", -5, [["expression", "[groupSelectedUnits player - [player], screenToWorld [0.5, 0.5], 3] call ""\AI\MoveSelected.sqf"""]], "1", "CursorOnGround", "\a3\Ui_f\data\IGUI\Cfg\Cursors\iconCursorSupport_ca.paa"]
just make a function...
MY_fnc_name = compile preprocessFileLineNumbers "file.sqf"; // this part goes outside the command menu
[blabla] call my_fnc_name // this part is inside the command menu expression
Like this?
MY_fnc_name = compile preprocessFileLineNumbers "\AI\MoveSelected.sqf";
#include "\a3\editor_f\Data\Scripts\dikCodes.h"
mymod_fnc_showGameHint = {
MENU_COMMS_2 =
[
["Submenu", true],
["Move Selected", [2], "", -5, [["expression", "[units player - [player], screenToWorld [0.5, 0.5], 3] call MY_fnc_name"]], "1", "CursorOnGround", "\a3\Ui_f\data\IGUI\Cfg\Cursors\iconCursorSupport_ca.paa"]
];
showCommandingMenu "#USER:MENU_COMMS_2"
};
change MY_fnc_name to your function name
I just choose a function name?
Like this?
Test = compile preprocessFileLineNumbers "\AI\MoveSelected.sqf";
#include "\a3\editor_f\Data\Scripts\dikCodes.h"
mymod_fnc_showGameHint = {
MENU_COMMS_2 =
[
["Submenu", true],
["Move Selected", [2], "", -5, [["expression", "[units player - [player], screenToWorld [0.5, 0.5], 3] call Test"]], "1", "CursorOnGround", "\a3\Ui_f\data\IGUI\Cfg\Cursors\iconCursorSupport_ca.paa"]
];
showCommandingMenu "#USER:MENU_COMMS_2"
};
@modern meteor this would work. Both your variants with compile preprocessFileLineNumbers would work as well. The point about renaming is: MY_fnc_name is too generic and non-descriptive. Test is even worse. The convention is to go for TAG_fnc_functionName usually, with "TAG" being your unique short tag you mark all your functions with to prevent collisions with other people's code. And "functionName" being, well, function name. Preferably short and descriptive. R47_fnc_moveSelected would work, for example.
Thank you artemoz. Testing it now and report back.
It's working now. Thank you all for your help.
just setVariable publicly -- making sure it won't set it for all players 😅
yeah that's fine.
thank god for that
Note the undocumented behaviour of setVariable that it transfers on respawn.
but not on selectPlayer.
That's good, need it to remain like that lol
Is it possible to use IP verification in script commands to block certain people from accessing the server?
I don't think so. You could block by steam UID though.
How can a player's regional affiliation be determined by steam UID?
there are MODs for this
That's not undocumented behaviour of setVariable, it's the respawn system that copies all variables from the old object to the new object.
it can't, but banning the UID is way more efficient than banning a range of IPs since the latter can be bypassed easily with a vpn
You could certainly describe it like that. It's not documented anywhere related to respawning either though, as far as I can tell.
if I add an eventhandler to player, is it bound to the current unit or is it transferred dynamically to other units if player changes his unit through selectPlayer?
I'm fairly sure EHs aren't transferred with selectPlayer.
On the grounds that I assumed they weren't and no bugs showed up :P
Some EHs are transferred with respawns but I think those are all documented.
player is a local variable to the client, so I think player is exactly the unit that the client controls.
alright, so I have to add new EH every time player switches to another unit, thx
I have some syntax issues. How do I add screenToWorld [0.5, 0.5] to the following?
["Rush", [5], "", -5, [["expression", toString {[player, "HandSignalPoint"] spawn AI_CommandDispatcher}]], "1","\a3\Ui_f\data\IGUI\Cfg\Cursors\iconCursorSupport_ca.paa"]
If you really need to filter based on IP, place your Arma server behind a firewall.
You'll have to be more specific, where do you want to add it? What is that array used for?
It's part of the custom command menu and my objective is to see a crosshair when I select the option. Similar to this one:
["Move", [2], "", -5, [["expression", "[units player - [player], screenToWorld [0.5, 0.5], 3] execVM ""\AI
\CircleStand.sqf"""]], "1", "CursorOnGround", "\a3\Ui_f\data\IGUI\Cfg\Cursors\iconCursorSupport_ca.paa"],
What's AI_CommandDispatcher?
sqf which monitors the player's hand signal
player, "HandSignalPoint"
Baiscally my problem is that I don't know how to fit in screenToWorld [0.5, 0.5] when I use toString in the command
You want it to point at a particular position?
Yes, exactly
I think that's a bit more than a syntax problem.
Oh, I can't see a cursor on a ground when I use the the ToString command?
toString is just converting code -> string because some functions only take a string.
What parameters can AI_CommandDispatcher take?
[player, "HandSignalPoint"]
Yes, but could it take anything else?
Maybe think of it this way: Ignoring the command menu stuff, how would you make the player point in a specific direction?
This AI_CommandDispatcher function may or may not have that capability. We wouldn't know.
I just want to see the crosshair when i select the option
Do you know how to write SQF code that accepts parameters?
Well, I don't think this has anything to do with screenToWorld but your command menu syntax is missing a parameter there...
you missed isActive in that one.
Like this:
["Rush", [5], "", -5, [["expression", toString {[player, "HandSignalPoint"] spawn AI_CommandDispatcher}]], "1","\a3\Ui_f\data\IGUI\Cfg\Cursors\iconCursorSupport_ca.paa"]
should be something like this:
["Rush", [5], "", -5, [["expression", toString {[player, "HandSignalPoint"] spawn AI_CommandDispatcher}]], "1","cursorOnGround","\a3\Ui_f\data\IGUI\Cfg\Cursors\iconCursorSupport_ca.paa"]
What does it do though? No idea :P
screenToWorld [0.5,0.5] does not, in itself, generate a crosshair. All that does is determine what world position is directly under the centre of your screen. Actually doing something with that position requires more code, which is presumably contained in AI\CircleStand.sqf in your example code.
is there a way to get a Grouptype of any Group e.G. you have an array with allGroups and you want to find a Infantry or CAS Group? is that possible?
crosshair is that icon, \a3\Ui_f\data\IGUI\Cfg\Cursors\iconCursorSupport_ca.paa
there is a bis fnc for that
can you tell me which? wasen´t able to find anything 😦
idk. probably something like getGroupType? 
I had copied part of it to my own code:
https://pastebin.com/pjMEHrvr
I used it for getting the group icon tho
i could probably use the setVariable/getVariable when Spawning a group to give it an attribute thats says what kind of group it is....
and using that together with isKindof should give pretty reasonable results...
wat? isKindOf?
and plus you don't spawn all groups yourself
and even if you do not all groups are created using a template. you can just do createGroup _side and add random units to it.
so either way you have to do something like this if you want to support all groups
yeah thats right... 😦 but since all of them are spawned using my scripts i probably could change all the scripts to just give that attribute and use that together with your code. Youre right
can i just put this function in an random script? or do i have to define it anywhere else?
yes. it's local. but if you want to use it in many places just define it as a global function
but keep in mind that that function is meant for giving you the group icon
you can just change the "_type" variable to whatever else you want
yes i will 🙂 thank you very much. If i need more help I will contact you
Thank you guys. I will have another look and see if i can find a solution.
if i understand it correctly you run this code for every group and it "just" outputs an Grouptype for that group in form of an icon... if i would change it to text then it would work fine for me
yeah you just run _grp call _fnc_getGroupType and it gives you its _type
thanks mate 🙂
I still have no idea where I got that from tho 
I think spectator function maybe...
yeah I guess that was where
Hey ,
Can I change the attachment point of the rope?
I mean if I create a rope between the rod and the player and if I want to connect the end point that is attached to the player, attach it to the other pole?
That is, Can I build a fence from ropes and poles 🤔😁
No, I only need one rope between the two poles, but I want the first installation rope between the player and pole 1, and the player moves to the second pole and unhooks the rope from himself and attaches the rope to the second pole.
I'm gonna guess yes
have you tried simply detaching the rope from the player and attaching it to the pole?
Well, cannot attach wo creating helper, because rope don't attach if object do not have transport vehicle.
So currently using ace helpers here.
Those work but it only attached to helper but helper doesn't attach to my pole.
Cannot send you my code, so , I will get back to this tomorrow when I have some content to this one.
Trying to figure out why some of my scripted area markers display as transparent/translucent on the map.
https://imgur.com/a/MHUqUqD
getAssignedCuratorLogic player addEventHandler ["CuratorObjectPlaced", {
params ["_curator", "_object"];
_marker = createMarker [format ["markers_%1", hashValue _object], _object];
_marker setMarkerShapeLocal "RECTANGLE";
_marker setMarkerSizeLocal ((0 boundingBoxReal _object) select 1);
_marker setMarkerDirLocal getDir _object;
_marker setMarkerColorLocal "ColorGrey";
_marker setMarkerBrush "SolidFull";
}];
did you try manually setting setMarkerAlpha?
no effect on
allMapMarkers apply {_x setMarkerAlpha 1}
then I guess it's hardcoded 
speaking of hardcoded things, is the inventory weight hardcoded -- i.e unable to be script modified at all? (don't want to use setMass for compatibility with ACE and such)
Not sure what you mean by inventory weight.
Container maximum? Unit maximum? Item weights?
this
sum of the weight of all inventory items
but obviously you cant add to that atm without taking up inventory space afaik
I think that's just adding config mass values of the items.
you can only change the weight coefficient that impacts your stamina script-wise, everything else is config with certain numbers of mass
i would imagine so however being able to modify to simulate items with weight being in the inventory without taking up that space would be very useful (at least for me)
and thats with setMass isnt it
or am i getting you confused
setmass is for physx
ya in base game it influences players stamina drain according to biki
maxLoad I would imagine but that just returns maximum load soldier can carry
Relevant commands:
_unit setUnitTrait ["loadCoef",<number>]; // lower is more
(backpackContainer _unit) setMaxLoad <number>; // server exec
_currentWeight = loadAbs _unit;```
I could use loadCoef to figure out how much extra weight the item would have in the inventory? i.e
configtomass _item/(loadAbs player + configtomass _item)``` or something similar?
or am i chasing something that probably isnt a good idea
in fact no if its a coef theres no guarantee its scaling the same as mass does ffs
It's fine if I lose the hashValue. I guess that's too expensive? O_o
probably because the hash contains #
thats a special marker for user placed markers, that set the channel and who placed it
hmm. base64 can't have # in it? Can have + or / though...
Maybe put the hashValue as text on each one and then it should be pretty obvious what it's tripping on.
Hey guys, hoping someone may see an easy solution to a problem here. I have an SQL service that connects with my Arma servers through extDB3. Recently I added the ability to save and retrieve loadouts from the SQL, such that when you connect to the server, or respawn, you get assigned your saved loadout, and whenever you disconnect from the server, or get killed, your loadout gets saved (so that it persists over server connections and deaths).
The problem I am running into is that when you spawn with the "Select a spawn location" UI from vanilla Arma, it seems that "kills" your unit (that you never actually see), and the first spawn counts as a respawn. Further, this "killing" of your unit happens before the "PlayerConnected" code runs.
so, when you connect to the server, the server kills your default unit with a default loadout, and then triggers saving of that default loadout because you "died".
I'm not sure of a clean solution to this.
Pretty niche problem, but if someone has a smart solution, I'd love to be enlightened. Here are my basic eventhandlers (with some of the isPlayer checking/etc stripped out)
params ["_newEntity", "_oldEntity"];
diag_log "extDB3: Player respawned, retrieving their loadout";
_uid = getPlayerUID _newEntity;
_rawLoadout = "extDB3" callExtension format["0:PTF:getLoadout:%1", _uid];
_loadout = (((parseSimpleArray _rawLoadout) select 1) select 0) select 0;
_newEntity setUnitLoadout _loadout;
}];
_id = addMissionEventHandler ["EntityKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
diag_log "extDB3: Player died, saving their loadout";
_uid = getPlayerUID _unit;
_loadout = getUnitLoadout _unit;
_result = "extDB3" callExtension format["0:PTF:saveLoadout:%1:%2", _loadout, _uid];
}];
_id = addMissionEventHandler ["PlayerConnected", {
params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
diag_log "extDB3: Player connected, retrieving their loadout";
_unit = _uid call BIS_fnc_getUnitByUID;
_rawLoadout = "extDB3" callExtension format["0:PTF:getLoadout:%1", _uid];
_loadout = (((parseSimpleArray _rawLoadout) select 1) select 0) select 0;
_unit setUnitLoadout _loadout;
}];```
maybe # is wrong character, don't remember what exactly
Eventually occurred to me to try it: "_USER_DEFINED #0/0/3"
so I'm gonna guess that it doesn't like the /
@still forum From our convo yesterday with gamma.
Would this code work as an EH to detect a player's gamma when they close settings menu?
_gammaHandler = call {
findDisplay 5 displayAddEventHandler ["Unload",{_this spawn
{
params ["_display", "_exitCode"];
private _gamma = parseNumber (ctrlText _display displayCtrl 109);
};}];
};
findDisplay 5 will be displayNull when its not currently open
not sure if unload might be too late to read values
you missunderstood
it says it should run in unscheduled
meaning NOT to use spawn, exactly like you are doing at _this spawn
Well, there's a danger that the control is destroyed before Unload triggers on the display. I don't know the order there and apparently neither does the wiki.
I'm 99.99999% sure that with your spawn there it will not work
the display will be gone by the time the code runs
Is there a way to save a variable specific to a player or unit, from the server side? Maybe something similar to missionnamespace...
I'm thinking I could make something like "did this player run this code yet? - if no, skip and set to true"
is there a script to get the weapon classname of the vehicle you are currently in?
I remember using something like that a bit ago to figure out a tank's cannon's classname but I may be wrong
remoteExec to run code on the players machine
@still forum I'm thinking I could just make a server-side array of "respawnedPlayers", and when they respawn, check if they're "in" the array, and if not, add them and skip the rest of the eventhandler.
Might clear my issue
@still forum
if I want to have an array of UID's in a global array, is it okay for me to add them as private variables?
globalPlayerArray = []
//loop this a buncha times
myPrivateLoop = {
_uid = 1234
if (_uid in globalPlayerArray) {
// do stuff
}
else { globalPlayerArray append _uid }
_uid = 5678
if (_uid in globalPlayerArray) {
// do stuff
}
else { globalPlayerArray append _uid }
}
globalPlayerArray = {"1234","5678"}
would that work? or would it get screwed up because it's looking for the private variable in there?
I'm not sure what you're trying to do there but the syntax is very wrong.
Even if is not SQF, it doesn't make any sense... 
Those aren't private variables, but anyway that wouldn't cause a problem.
Aside from the syntax issues, some of this code is redundant or logically flawed. For example, you don't need to write out an individual statement for each UID:
_flaggedPlayers = [1234,5678];
{
if (_x in globalPlayerArray) then {
// ...
} else {
globalPlayerArray pushBack _x;
};
} forEach _flaggedPlayers;
...but I'm not sure why the flow here is what it is. If a flagged player is in the global array, you do code. If they aren't, you add them to it. But then on the next loop they are in it so they get the code run on them - why not just do it the first time? And then you explicitly set the global array yourself anyway, so why bother having the loop add them? I think you need to have another think about what you're trying to achieve here.
wasn't writing anything in any specific syntax, just writing garbage pseudocode off my phone lol
Yeah sorry the code should be split up into 4 different blocks, it's not all being executed in the same place, was just restricted by phone typing
Well, it's not safe to modify an array from multiple machines.
Would all be done from the server
via missioneventhandlers
I'll update my code here in a sec with what it actually looks like
startedPlayers = [];
_id = addMissionEventHandler ["EntityKilled", {
params ["_unit", "_killer", "_instigator", "_useEffects"];
_uid = getPlayerUID _unit;
if (_uid in startedPlayers) then {
diag_log "extDB3: Player died, saving their loadout";
_loadout = getUnitLoadout _unit;
_result = "extDB3" callExtension format["0:PTF:saveLoadout:%1:%2", _loadout, _uid];
} else {
_uid append startedPlayers;
};
}];
Basically point of function is to prevent the main code in EntityKilled missioneventhandler from firing for the first time an entity is killed, since Arma technically kills off the fake unit the first time you spawn in the mission
Hey so I've got some questions about what's the easiest way to detect if a vehicle takes damage
https://community.bistudio.com/wiki/damage
and
https://community.bistudio.com/wiki/getDammage
don't seem to work if its only indirect damage so auto canons not using ap rounds or apers mines wont be detected
I have read through this https://community.bistudio.com/wiki/Arma_3:_Damage_Description and think I could possibly use https://community.bistudio.com/wiki/getAllHitPointsDamage to just check all of the vehicles damage points but that would massively complicate things and I'd rather keep this as
my code works, thank zeus!!!
You can use EventHandler
I am running a script locally, but I want it to spawn a smoke effect that every player can see. I thought I could accomplish this via remoteExec, but other players are reporting that they can't see it. Is there a way to do what I'm trying to do?
create_smoke = {
params ["_OBJ"];
_PS = "#particlesource" createVehicleLocal getPos _OBJ;
_ps setParticleCircle [0, [0, 0, 0]];
_ps setParticleRandom [0, [0.25, 0.25, 0], [0.2, 0.2, 0], 0, 0.25, [0, 0, 0, 0.1], 0, 0];
_ps setParticleParams [["\Ca\Data\ParticleEffects\FireAndSmokeAnim\SmokeAnim.p3d", 8, 3, 1], "", "Billboard", 1, 8, [0, 0, 0], [0, 0, 1.5], 0, 10, 7.9, 0.066, [1, 3, 6], [[0.5, 0.5, 0.5, 0.15], [0.75, 0.75, 0.75, 0.075], [1, 1, 1, 0]], [0.125], 1, 0, "", "", _OBJ];
_ps setDropInterval 0.3;
_ps;
};
_smoke = [_this] remoteExec ["create_smoke", 0]; <-----Spawns a smoke effect, only I can see it :(
Most likely create_smoke is not defined elsewhere
I think I'd suggest to remoteExec'ing call instead, with the function
was worried that was going to be the answer lol
so i assume it would be this https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#HandleDamage
How do you mean?
Lemme try to write psuedo code on my phone lol
If you have fingers like mine, than I so appreciate your sacrifice on my behalf
[_this, {fnc to create particles}] remoteExecCall ["call"]```Perhaps it is better to use remoteExecCall instead, mayb not
Super gracias!
@velvet flicker
its better make the function in its own file, put it in the library and remote execute that function instead of remoteExec'ing a block of code over the network
[_this] remoteExecCall ["circ_myFunction"]
the reason why your players didn't see it in your previous remoteExec attempt is that you created the function on that client, but that function doesn't exist everywhere else yet. You need to declare the function in the function library so that all clients can use it.
You're not putting variables into an array, you are putting values, and values cannot be private so that question doesn't make sense
if you need to do anything reliably avoid the scheduler
thats all im arsed to say right now :P
need to go study for an art history test
how do I detect whether player is holding breath (while aiming)? So far I found the SoundPlayed EH but since the "breath held" sound is not played every time my eventhandler doesn't happen always on that action
(findDisplay 46) displayAddEventHandler ["KeyDown", {
params ["_Disp", "_Key", "_bShift", "_bCtrl", "_bAlt"];
if(cameraView == "GUNNER") then{
if(_Key in (actionKeys "holdBreath")) then{ hint "Holding breath"; };
};
FALSE
}];
(findDisplay 46) displayAddEventHandler ["MouseButtonDown", {
params ["_Disp", "_Btn", "_xPos", "_yPos", "_bShift", "_bCtrl", "_bAlt"];
if(cameraView == "GUNNER") then{ hint "Holding breath"; };
}];
Untested, but I would do something like this
I got these camera follow scripts but both seem to be choppy, anyone know a better method?
G_HALO_spCamMove = [] spawn{
waitUntil{
_PosPWV = getPosWorldVisual G_PDROP_Plane;
_CamPos = vectorNormalized [sin G_PDROP_Theta, cos G_PDROP_Theta, sin G_PDROP_Phi];
_CamPos = _PosPWV vectorAdd (_CamPos vectorMultiply G_PDROP_zRad);
G_PDROP_Cam setPosWorld _CamPos;
_vDir = _CamPos vectorFromTo _PosPWV;
_vUp = vectorNormalized ((_vDir vectorCrossProduct [0,0,1]) vectorCrossProduct _vDir);
G_PDROP_Cam setvectorDirAndUp [_vDir, _vUp];
FALSE
};
};
G_HALO_spCamMove = [] spawn{
waitUntil{
_CamPos = vectorNormalized [sin G_PDROP_Theta, cos G_PDROP_Theta, sin G_PDROP_Phi];
G_PDROP_Cam camSetTarget G_PDROP_Plane;
G_PDROP_Cam camSetRelPos (_CamPos vectorMultiply G_PDROP_zRad);
G_PDROP_Cam camCommit 0.10;
waitUntil{camcommitted G_PDROP_Cam};
FALSE
};
};
this would detect holding the breath button while aiming, so that would be enough
however when player holds breath he does that only for a certain amount of time, after X seconds unit will always try to take breath again and weapon sway goes up, wonder if I could detect this too
nothing in eventhandlers tho so I guess I'll stick to just holding the button for now
is there a way to add a permanent holdAction to a certain object? Currently adding holdAction using 3den enhanced attributes
yup
yeah gonna have to manually script it, thank you
Yeah thats what I was asking
Script worked without issue 😅 happy to have that one done.
inputAction "holdBreath" for input. I'm not sure if getWeaponSway is accurate while ADS.
this would detect just the button press and correct effect but f.e. ignore that player is exhausted, unit has to breath again and hold breath action is technically interrupted?
I'm not sure exactly how those interact tbh. you're probably here already: https://community.bistudio.com/wiki/Category:Command_Group:_Stamina_System
yeah I went through all wiki entries about stamina or sway and there's nothing about getters/setters/whatever for holding breath sway and how does the hold breath sequence work so you hold breath and take breath while constantly holding the hold breath button
I am trying to fix a script I found so it works in MP, the following is triggered on a single client:
* a small object is created using createVehicle (obj is then owned by that client?)
* particle effects are attached, using remoteExec.
* object is moved by setVelocity (it spawns a while-loop that triggers it continuously)
the issue i have is that setVelocity only works on the client that triggers the action, other clients see the object standing still.
if i remoteExec setVelocity it works, but the wiki says that the command have a global effect so it should not be needed.
what am i missing?
I'm not changing the simtype, so it should be enabled. Object is spawned next to the player and travel a few 100 m tops
Simulation type is more complex than enabled/disabled. There are several different simulation types which have different update rates. For example, static building objects typically have low simulation rates, while physics objects update much faster.
i see, the object created in this case is this one:
_proj = "B_9x21_Ball" createVehicle _CrPos;
Bullets have strange behaviours and are usually designed to have one copy of themselves on each client, rather than one global object. You're probably running into a manifestation of that.
ok, is there a good "dummy"-object that can be used in his case? something small and invisible
Use a physics object like a tin of beans or something and make it invisible with hideObject/hideObjectGlobal (note server exec requirement for -Global)
ok, i will try that
that worked much better! however it seems the script leveraged the fact that the bullet disappears when it hits something and used that as one of its condition to check when it has arrived.
any way to delete the can "on collision" in a good way? like a EH
There's the EpeContact* events. Not used them myself though.
that one did not trigger for me unfortunately, used a simple can from CUP. maybe that object dont work with physX stuff specifically.
Any idea what could be causing a frame loss when moving? Like, I go from 80 FPS stationary to 40FPS jogging and 35 FPS when sprinting.
It has to be some script or misconfigured thing. It only happens on this mission I`m working on... But I can't pinpoint what is causing it exactly
neither can we! remove some animation- or speed-related scripts and find out 🙂
that or despawning/respawning scripts, etc
i have had that issue on specific terrains, even when completely empty of stuff. could be worth checking
Doesn't seem to be the map... It's defiantly something in the mission .sqm itself
ok, best to backup the mission and start removing stuff until it goes away
yep, I'm doing that
at the moment it doesn't look like it's something specific, but the more i remove, the better it gets. The strange thing is that only affects players when they are moving/sprinting
it sounds like some mod or script is messing with you then, hard to tell which from here
probably lol
Yes, it's the Northen Fronts mod.
I wonder, is there a way to get a performance log of the functions running?
Is there any ways to make the TAB key useable while in a dialog or display?
Specific intended use case: I want to both open and close my inventory menu with the tab key. (making a keybinds mod for myself)
Problem: tab seems to be reserved only for selecting the next menu item while in displays or dialogs and will not be recognized as a bound key. This is a feature that I do not and have not ever used in the inventory.
can you use preprocessor commands like #include in a .FSM? I want to include some macros in my mission flow FSMs for debugging
addUserActionEventHandler [
'holdBreath',
'activate',
{player setvariable ['holding_breath',true]}
];
addUserActionEventHandler [
'holdBreath',
'deactivate',
{player setvariable ['holding_breath',false]}
];```
I have a very simple helmet and vest randomization script. Except, it's randomizing even when I hit the arsenal
//Loadout Array
_S3SpawnVest = selectRandom ["OPTRE_MJOLNIR_MkVBArmor","OPTRE_MJOLNIR_MkVBArmor2","OPTRE_MJOLNIR_MkVBArmor3","OPTRE_MJOLNIR_MkVBArmor4","OPTRE_MJOLNIR_MkVBArmor5","OPTRE_MJOLNIR_MkVBArmor6","OPTRE_MJOLNIR_MkVBArmor7","OPTRE_MJOLNIR_MkVBArmor8","OPTRE_MJOLNIR_MkVBArmor_Default","OPTRE_MJOLNIR_MkVBArmor_Default2","OPTRE_MJOLNIR_MkVBArmor_Default3","OPTRE_MJOLNIR_MkVBArmor_Default4","OPTRE_MJOLNIR_MkVBArmor_Default5","OPTRE_MJOLNIR_MkVBArmor_Default6","OPTRE_MJOLNIR_MkVBArmor_Default7","OPTRE_MJOLNIR_MkVBArmor_Default8","OPTRE_MJOLNIR_MkVBArmor_Default9","OPTRE_MJOLNIR_MkVBArmor_Default10","OPTRE_MJOLNIR_MkVBArmor_Default11"];
_S3SpawnHeadgear = selectRandom [
"OPTRE_MJOLNIR_MkVBHelmet",
"OPTRE_MJOLNIR_MkVBHelmet_UA",
"OPTRE_MJOLNIR_MkVBHelmet_UA_HUL",
"OPTRE_MJOLNIR_Commando",
"OPTRE_MJOLNIR_Commando_HUL3",
"OPTRE_MJOLNIR_Commando_HUL3_UA",
"OPTRE_MJOLNIR_CQB",
"OPTRE_MJOLNIR_CQC",
"OPTRE_MJOLNIR_Pilot",
"OPTRE_MJOLNIR_Pilot_UA",
"OPTRE_MJOLNIR_Pilot_UA_HUL3",
"OPTRE_MJOLNIR_Operator",
"OPTRE_MJOLNIR_Scout",
"OPTRE_MJOLNIR_EOD",
"OPTRE_MJOLNIR_Security",
"OPTRE_MJOLNIR_ODST"
];
//Unit Init
_this addVest _S3SpawnVest;
_this addHeadgear _S3SpawnHeadgear;```
class EventHandlers: EventHandlers
{
init = "(_this select 0) execVM ""OPTRE_MJOLNIR_Units\data\scripts\spartan_3.sqf""";
};```
Is that fixable?
Or just a cause of the randomization
Hello ^
I've got a quick question, is there a way to remove or change the 502 number on the sentinal via a script? [picture link]
https://cdn.discordapp.com/attachments/547250110359142402/1070256088399753236/image.png
They are set up as separate textures as if to allow them to be changed, but they aren't enabled as hiddenSelections, so unfortunately it's not possible to actually do it
The numbers on the Shikra and Black Wasp are configured as hiddenSelections, so I'm going to make an FT ticket about this and hopefully it can be fixed.
perhaps setPlateNumber
no guarantee though
I tried that and unfortunately not
ah welp
then "no" ^ 😄
Ah welp there was an attempt
My only thought is to figure out some display or other that is present in the Arsenal but not in the scenarios that you want this to work in (or vice versa) then just throw a check in for that at the start of the script. Maybe something like..
private _display = findDisplay xxx; // "xxx" here being the display ID for whatever display this is, perhaps the arsenal display itself if(!isNull _display)exitWith{}; //the rest of your script follows
This would exit your randomizing script before it ran IF the display in question is currently loaded
@frank cedar you'd use CBA's per frame handler, as long as your checks are quick
rolleyes
Hi, I wonder if there is a script way to check that an object is currently playing a say3d sound?
Are these group eventhandlers already implemented in Arma? For example:
_group addEventHandler ["CombatModeChanged", {
params ["_group", "_newMode"];
player removeEventHandler [_thisEvent, _thisEventHandler];
}];
Yes, they were added in 2.10, which is the current stable version
I tried the following but it does not work:
units player - [player] addEventHandler ["CombatModeChanged", {
params ["_group", "_newMode"];
player removeEventHandler [_thisEvent, _thisEventHandler];
}];
It is a group event handler and must be added to a group. You can't use it on an array of units, you have to use it on a group.
Even if it was a unit EH (it is not), you would need to use a forEach to add it to each unit in an array, not just point it directly at the array.
I see. Not sure how to do this though.
group player addEventHandler [ ...```
Oh okay. I'll give it a try. Thank you!
Sorry, one more question. Is this the right way to delete an event handler?
player removeEventHandler ["FiredMan", 0];
That's the correct syntax for the removeEventHandler command, yes. You'll need to be sure that the provided index is the correct index, though - mods or other scripts could add their own EHs, so hardcoding an index isn't the best way. You should save the correct EH index when you add it, so you can refer to it when it's time to remove it.
"You should save the correct EH index when you add it, so you can refer to it when it's time to remove it."
Not sure how I would do this. How can I give an EH a specific index and refer to it later when I want to delete it?
The EH index is automatically assigned when it's added. The addEventHandler command returns the index of the EH it just added.
As for saving and referring to it: https://community.bistudio.com/wiki/Variables
If I understand this correctly I can assign a specific EH to a variable?
The EH index, returned by addEventHandler (https://community.bistudio.com/wiki/addEventHandler), is a number. Numbers are one of the many types of data you can save in a variable. It's up to you to remember which EH the index belongs to; naming the variable something obvious is a good way to do this.
I got it now, thank you. How would I remove a EH if I assigned a variable to it (for example EH1)?
player removeEventHandler ["EH1", 0];
Like this?
No
private _EH1 = player addEventHandler ["whateverEH",{}];
//and later
player removeEventHandler ["whateverEH",_EH1];```
Got it, thanks. Is there also a way to find out which EHs are currently active during a mission? I would like to check if other mods added some EHs.
I don't think there is. But it is not even a concern since you can add one as much as you want
That's a point
//my code EH1
private _EH1 = player addEventHandler ["FiredMan", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
{
_x setUnitCombatMode "GREEN";
} forEach (units player - [player]);
group player removeEventHandler ["CombatModeChanged",_EH2];
player removeEventHandler [_thisEvent, _thisEventHandler];
}];
//my code
//my code EH2
private _EH2 = group player addEventHandler ["CombatModeChanged", {
params ["_group", "_newMode"];
player removeEventHandler ["FiredMan",_EH1];
player removeEventHandler [_thisEvent, _thisEventHandler];
}];
//my code
Getting an error of undefined variables _EH1 and _EH2
They aren't defined in it
Oh, then I misunderstood. I thought they are defined as the event handlers?
They are defined as private local variables, which means they only exist in the script scope where they were defined, not in other scopes (such as the EH code scope).
You would want to save them as global variables rather than local in order to use them like this.
Ah, I see. Will do that. Thanks
https://community.bistudio.com/wiki/Variables#Scopes
I keep linking the documentation because it's really useful to read it
use get/setVariable
Thank you
also for the latter EH, you're adding it to the group, but then trying to remove it from an object instead
hm
group player removeEventHandler ["CombatModeChanged",_EH2];
I thought this is the correct way to remove it
No?
That is. In EH2 you have this:
player removeEventHandler [_thisEvent, _thisEventHandler];```
Which won't work
ah
should be like this?
group player removeEventHandler [_thisEvent, _thisEventHandler];
Seems likely
tk u!
it would be better to use the group's reference directly though
group player addEventHandler ["CombatModeChanged", {
params ["_group", "_newMode"];
// do stuff
_group removeEventHandler [_thisEvent, _thisEventHandler];
}];
as player may have changed group in the meantime 🙃 🙂
Good point. I will do this. Tks
since we can't save or bookmark messages on Discord I'll just leave this answer so I can find that again later lol
bookmark bot incoming
Hello.
Using this code to open and close doors of my Chinook. Nothing new there. 😉
this addAction [""Open Doors"", ""CH47I_01 animateDoor ['Door_L_source', 1, false]; CH47I_01 animateDoor ['Door_R_source', 1, false];""]; this addAction [""Close Doors"", ""CH47I_01 animateDoor ['Door_L_source', 0, false]; CH47I_01 animateDoor ['Door_R_source', 0, false];""]
but, looking to have only the open action present when doors are closed and close when doors are open.
is it possible?
Next would be to lock and unlock helicopter so players can't get in or out. I failed to achieve the correct code here. 
dumb question, not sure but does a spawn clean itself up when there is no more code to run? Can't find an answer to that online.
it isss
look at https://community.bistudio.com/wiki/addAction
there is a condition thing, which you can fill with toString { /* your code */ }
yes
it becomes scriptNull and is ditched 🙂
Gotcha ty.
why does the parachuted soldiers die when they touch ground, i have this problem only with IFA
That smells like an IFA problem rather than a scripting problem
They probably get hit by part of the plane?