#arma3_scripting

1 messages · Page 43 of 1

still forum
#

wuht. we have that EH

#

ah no it was created?

#

I'm pretty sure we have a delete thing

winter rose
winter rose
#

heheheee, a new EH is coming

outer bay
#

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

pliant stream
#

caching: the best of both worlds

hallow mortar
real tartan
#

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 ... }];
sage heath
#

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

kindred zephyr
sage heath
#

oh then i cant fuckin script that XD

kindred zephyr
#

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

sage heath
#

just looked, no there isnt, however its a night mission anyways so

#

no bigge

#

was hoping it'd be darker

copper raven
meager granite
#

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

little raptor
meager granite
#

I scripted it to check actual damage on each EH and it doesn't seem so

#

Unless engine writes elsewhere, not visible through script

little raptor
#

I expect that it's like that yeah

meager granite
#

_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

meager granite
#

Its all in the same frame, yes

#

All EH fires return proper Number value: _new_damage

little raptor
#

Then I guess those mismatches are due to values being overwritten (or in other words not applied yet)

meager granite
#

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

little raptor
#

I always imagined it's due to some "sudden change in inertia" kinda thing... 😅
But yeah still makes no sense

granite sky
#

Maybe some sort of backwards-compatibility signalling?

humble tundra
#

How do one checks state of a door (or doors) on a vehicle?

warm hedge
crystal lagoon
#

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

humble tundra
crystal lagoon
#

I guess

#

Also, guard areas don't need to be set as repeatable, correct?

meager granite
novel basin
#

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 ^^

little raptor
#

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

novel basin
#

Thks

sage heath
#

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?

warm hedge
#

Not even sure what to help. What's unclear?

sage heath
#

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

warm hedge
#
abdul1 switchMove "Acts_JetsMarshallingStop_in";```
sage heath
#

abdul1 addAction ["Surrender" #{switchmove "Acts_JetsMarshallingStop_in"}];
missing ]
error is

sage heath
#

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

winter rose
#

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

sage heath
#

i want the first one

little raptor
sage heath
#

fr? wait where

little raptor
sage heath
#

oh

little raptor
#

and even if you fixed it the syntax is still wrong

sage heath
#

right...what would the correct one be?

winter rose
#

in the action code
you need to tell who is going to switch what action

sage heath
#

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

agile cargo
#

Is this list of selection names complete?

winter rose
grizzled cliff
#

the fastest way to store things now is to treat missionnamespace like a big hash and use unique variables and set/get variable

tough abyss
#

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?

hallow mortar
#

Do you mean that you want to choose a random unit type from a list, to spawn with createUnit?

tough abyss
#

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

hallow mortar
#
private _unitType = selectRandom ["type_a","type_b"];
_group createUnit [_unitType,_position, ...];```
tough abyss
#

thanks for confirming it/showing the correct way to do it

undone basin
#

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 ..?

tough abyss
undone basin
teal flare
#

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

little raptor
little raptor
teal flare
#

thanks for the help

velvet merlin
#

is there really no EH in A3 to catch seat changed within a vehicle for players/AI at this point?

granite sky
#

hmm, didn't GetInMan work?

granite sky
#

oh yeah, I thought there was something in there :P

modern meteor
#

Is there a way to disband or delete a certain unit from the squad AI?

winter rose
#

deleteVehicle to delete the unit

modern meteor
#

Could unit be set to the latest AI which has joined the group?

winter rose
#

you will have to store that value somewhere

modern meteor
#

or perhaps i could point at the unit ingame and select the option from a custom menu option?

winter rose
#

if you want to

modern meteor
#

not sure how i select the unit i am pointing at in a script?

granite sky
#

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.

modern meteor
#

I will give it a try. Thank you both

torpid mica
#

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 😦

modern meteor
#

has all the details about custom menus

willow hound
#

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.

digital hollow
winter rose
#

true that ^ I always forget about the group UI commands

humble tundra
#

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

copper raven
#

copyToClipboard loadFile "Searchlight\AL_searchlight\al_search_light_ini.sqf" in debug console

crystal lagoon
modern meteor
#

I got it working

hallow mortar
torpid mica
crystal lagoon
little raptor
#

guard areas?

crystal lagoon
#

Yeah, for guard waypoints

little raptor
#

dunno. never used them

granite sky
#

There is apparently createGuardedPoint as an alternative.

winter rose
#
count (units blufor select { isPlayer _x });
torpid mica
#

thank you very much 🙂

winter rose
#

keep forgetting about that one

humble tundra
copper raven
#

huh? you never sent it here

humble tundra
#

...

#

I love how my phone is synchronized with my computer now.

copper raven
#

sqfbin next time pls meowsweats

#

so im guessing you just don't see the action or?

humble tundra
#

Give me a minute

humble tundra
copper raven
torpid mica
#

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

frank cedar
#

@grizzled cliff, why do thing that spawn and execvm is for noobs?

#

Is there any alternatives for polling cycles?

carmine egret
#

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?

odd kestrel
#

There are multiple handlers you could chose, compare sides of the units, lots of possibilities, some may work better or worse.

torpid mica
#

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
odd kestrel
#

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.

humble tundra
odd kestrel
#

@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.

keen stream
#

CBA Events?

queen cargo
#

just no ... just fucking no ...

glossy raft
#

soon to be reimplemented btw

frank cedar
#

@queen cargo, so it is better to use spawned cycles?

queen cargo
#

there are tons of better ways doing it

#

it all depends on what you want to have in the end

frank cedar
#

for example I want to periodically check some parameters and spawn units (items) in nearby houses

queen cargo
#

how often is periodically

frank cedar
#

Is there any better method than using loop with nearObjects["Houses"] ?

#

3-7 seconds

queen cargo
#

you already could be in the range where a spawn with a sleep is better then a trigger etc.

frank cedar
#

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...

raw meteor
#

Is the size of a rope segment a engine defined parameter?

warm hedge
#

IIRC defined in CfgNonAIVehicles

raw meteor
# warm hedge 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

warm hedge
raw meteor
#

so it is define in class ropes as well but the size is staying the same

warm hedge
#

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

raw meteor
#

my question is. can you changed the size of an individual rigid rope segment

warm hedge
#

You don't, rope do

#

Or, perhaps if you make a new rope class

raw meteor
#

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

warm hedge
#

Well since not sure why you want that can't really tell

raw meteor
#

for the project im working on i need a rigid segment that swings thats 1.5m long

warm hedge
#

Hm

#

If so, you're making a Mod right? Trying to mess around with CfgVehicles?

raw meteor
#

yes

warm hedge
teal flare
warm hedge
#

Is _player defined properly?

teal flare
#

in the player init:
[this, 500, 1] spawn cbrn_fnc_chemDetect;

warm hedge
#

What exactly is the full error?

teal flare
#
private _objects = |#|nearestObjects [_player, ["CBRNCase_01_F...'
Error inarea: 0 elements provided, 3 expected
(The file path) line 13```
granite sky
#

_payer

teal flare
#

that was me typing out the error, my apologies

granite sky
#

Copy-paste from the RPT.

teal flare
#

and if, hypothetically, I didn't know where that was?

granite sky
teal flare
#

even if it hasn't crashed?

granite sky
#

yeah, it's misleading.

#

RPT is just a continual log.

#

If you have -nologs then it won't write much. Don't use -nologs.

teal flare
#

now where do I find it in this 3914156 line file?

granite sky
#

search for error in, or remove all your shitty mods so that it's shorter :P

teal flare
#

unfortunately not my server so I cant choose the mods, i'll try find it

granite sky
#

Hmm. Does the code work on localhost then?

teal flare
#
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

granite sky
#

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.

teal flare
#

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```
granite sky
#

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.

teal flare
#

I keep neglecting event scripts, my fault

granite sky
#

This feels like a good time to start :P

teal flare
#

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.

granite sky
#

Just text-edit the sqm.

#

Format is pretty intuitive.

teal flare
#

ah alright will do

teal flare
granite sky
#

Well yeah, because initPlayerLocal runs once on each client.

teal flare
#

Okay cool

#

Thank you so much, I usually dont ask for help for fear of being belittled but you've been very helpful!

granite sky
#

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.

teal flare
#

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

fair drum
#

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

hallow mortar
#

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

fair drum
#

alright ill take a look

#

so "zaslehPoint" means suppressor?

#

nope, i see it on non suppressors too

hallow mortar
#

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.

fair drum
#

oh I see we are talking about two different things, thats my bad cause i edited it after i put in my find

hallow mortar
#

You could check for the value of the audibleFire property in the ammoCoef subclass in its itemInfo. That should be mostly reliable.

fair drum
#

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?

hallow mortar
#

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

copper raven
#

101 is silencers

hallow mortar
#

I would love to find where that's documented. I couldn't find it in the cfgWeapons reference or the Weapon Config Guidelines

proven charm
#

hashmaps are handy if you need to fetch a value via key

frank mango
#

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??
willow hound
#

What does player getVariable ["isPilot", false] return?

sage heath
#

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?

frank mango
#

regardless of the role being set to a pilot or not

willow hound
copper raven
#

it doesn't iterate better or faster

willow hound
sage heath
winter rose
frank mango
#

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??

winter rose
#

no idea what you are trying to do tbh

frank mango
#

shift-click marker/waypoint
BUT only for some players, specifically Pilots

finite sundial
frank mango
#

this setVariable ["isPilot",true,true];

finite sundial
#

All you really need to accomplish your goal is:

if (player getVariable ["isPilot",false]) then {
    [player] onMapSingleClick {_shift};
};
sage heath
#

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]; 
};}];```
willow hound
# frank mango I have no any idea. What is or isnt supposed to do what. Looking at the biwiki ...

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.

willow hound
little raptor
#

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

vestal viper
#

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

little raptor
#

No. It's an exponent

vestal viper
#

Yeah both files have e-

little raptor
# vestal viper this one doesn't

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

vestal viper
#

It works for first aircraft but doesnt for second.

little raptor
#

It should work for both

vestal viper
#

Thats what I dont get. Everything is exactly the same but still it doesnt.

little raptor
#

See if you get the message

vestal viper
#

Trigger or sqf?

hallow mortar
#

If after, what happens if you remove the first one and only do the second?

vestal viper
vestal viper
hallow mortar
hallow mortar
#

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.

vestal viper
#

Aaha. Let me fix that and run it again

hallow mortar
#

Yes, but don't forget to change the wp2 script as well (and in init.sqf, change _wp2 to refer to wp2.sqf)

vestal viper
#

Both aircraft dont move

hallow mortar
#

Did you remember to change back the previous, incorrect, change in the trigger itself?

vestal viper
hallow mortar
#

Yes

vestal viper
#

Isnt this correct now since it is referring to local variable?

#
rec = [] spawn _wp2;```
hallow mortar
#

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.

hallow mortar
# vestal viper

This change - don't do it. Only the data array as I described before.

vestal viper
#

so it should remain wp1 = compile preprocessFile "wp1.sqf"; instead of _wp1 = compile preprocessFile "wp1.sqf";

hallow mortar
#

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.

vestal viper
#

Alright. Lemme fix and try again...

hallow mortar
#

That was half my fault, I should've paid attention and not said that was right before.

vestal viper
#

OH MY GOD IT WORKS!

#

Setting it to local will still make it work on dedicated right

#

@hallow mortar

little raptor
#

that's just the first thing that came up when I googled but I'm sure you can find more reliable sources

hallow mortar
vestal viper
#

But thank you so so much

#

🥮 Here's a cake

#

BTW is this a new update that caused this?

vestal viper
#

All 10 of them

pliant stream
little raptor
#

I did? think_turtle

#

well technically it could

#

but yeah I meant hundreds of MB

#

not few MBs meowsweats

hallow mortar
# vestal viper Cause Last year I did a black hawk down op that used 10 helis and I used global ...

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.

vestal viper
#

Arma....A mystery

hallow mortar
#

Well......."using the same name for a global variable will overwrite whatever was previously in it" isn't really a mystery :U

velvet flicker
#

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?

stable dune
#

If you want nearEntities without animals use
"CAManBase"

velvet flicker
#

I ripped out all my privates because I thought it was a scope issue

modern meteor
#

Is there a way to limit the distance where the friendly squad AI attacks an enemy?

velvet flicker
#

**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?)

hallow mortar
#

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.

velvet flicker
little raptor
modern meteor
#

thank you

manic kettle
#

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

cold mica
#

just make sure to player enableSimulation true when the action is interrupted or complete

manic kettle
#

o.o that works?

cold mica
#

it should

manic kettle
#

yeah it does, thanks

cold mica
#

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?

stable canyon
#

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.

winter rose
winter rose
# cold mica Any advice, code wizards?

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
winter rose
stable canyon
#

Thank you.

cold mica
hallow mortar
stable canyon
#

So

#

If I have

#

class CfgSounds

#

and

#

class CfgSentences

#

Then it won't work?

#

Or is it just stuff like having CfgSounds twice?

hallow mortar
#

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.

stable canyon
#

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.

hallow mortar
#

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

winter rose
#

ez merge:

class CfgSounds
{
  class sound1
  {
    // ...
  };
};
```&```cpp
class CfgSounds
{
  class otherSound
  {
    // ...
  };
};
```=```cpp
class CfgSounds
{
  class sound1
  {
    // ...
  };

  class otherSound
  {
    // ...
  };
};
stable canyon
#
{
 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"
        };
    };
};    ```
hallow mortar
#

The file path should be a string

stable canyon
#

Ah yes.

pulsar bluff
#

whats the most efficient way to write this sqf _cursorTarget = cursorObject; if (isNull _cursorTarget) then { _cursorTarget = cursorTarget; };

granite sky
#

Maybe _cursorTarget = [cursorTarget, cursorObject] select isNull cursorTarget;

#

Not gonna be much different though.

warm hedge
#

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

granite sky
#

worst thing about mine is that it evaluates cursorTarget twice :P

warm hedge
#

Ye

granite sky
#

Still works out slightly faster in the branch-taken case.

warm hedge
#

Hm, really?

granite sky
#

Yeah, but slower in not-taken.

#

So depends how common the cases are.

#

Man, cursorTarget is really wide.

tranquil jacinth
#

Is there any way to check that player is looking at the sky using screenToWorld?

granite sky
#

lineIntersectsSurfaces + eyePos + eyeDirection doesn't hit anything, I guess?

#

Unless you just mean "looking upwards"

tranquil jacinth
#

Yeah lineIntersectsSurfaces, ty

pulsar bluff
# granite sky Man, cursorTarget is really wide.

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

granite sky
#

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.

pulsar bluff
#

iirc cursortarget also is subject to _unit disableAI "CHECKVISIBLE"

granite sky
#

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.

pulsar bluff
#

yea its good for medium/far units

#

thats why i still use it

#

player doesnt need super precision to still get nametags

jade acorn
#

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

granite sky
#

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.

lime frigate
#

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!

proven charm
#

it's recommended to not use getpos but instead use getposATL etc

lime frigate
granite sky
#

I don't see why the init script would affect the crate/parachute connection.

#

The script does nothing to either of them.

lime frigate
granite sky
#

Did you try it without an init field?

lime frigate
#

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.

modern meteor
#

Hello, simple question. What the command to move the currently selected unit to the cursor position on screen?

jade acorn
#

{ _x setPos (getPos cursorObject) } forEach (groupSelectedUnits player) perhaps, didn't test it

granite sky
#

screenToWorld is possibly useful there.

#

but then you may have to figure out what it's doing with the sky :P

modern meteor
#

hmm

#

still not sure how to do it

granite sky
#

When you say "currently selected unit", do you mean selected in zeus, the command bar or what?

modern meteor
#

no sorry, the unit which i select via the command menu

#

eg via F2, F3, F4, etc

granite sky
#

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.

jade acorn
#

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 staresmile

modern meteor
#

Ok, I replaced setPos with DoMove

#

This seems to be working

granite sky
#

oh, that sort of move :P

#

picked the wrong ambiguity

modern meteor
#

Otherwise it is "beaming" the unit 😉

jade acorn
#

well yeah, insta-change of unit placement is a way of moving lol

winter rose
#

move the currently selected unit to the cursor position on screen
can be read two ways 😁

granite sky
#

Also you can just do the move-to-point with the command menu?

modern meteor
#

Yea, but if the cursor is over another unit it always swaps to select unit

#

Which is annoying

jade acorn
#

you can open your map and move unit by pointing on map

modern meteor
#

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"

jade acorn
#

right

#

now it makes sense

modern meteor
#

Unless there is a way to deselect this ingame

jade acorn
#

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

modern meteor
#

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

jade acorn
#

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

lime frigate
# lime frigate I'm running into a weird issue. I'm using the supply drop (Virtual) support modu...

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?

torpid mica
#

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

odd kestrel
torpid mica
#

no i used #login just before

odd kestrel
#

It’s all explained on the Biki page I linked you earlier.

torpid mica
#

since it´s locally hosted

#

it worked in the chat

odd kestrel
#

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.

torpid mica
#

ok thanks 🙂

tepid vigil
#

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?

golden cargo
lime frigate
golden cargo
#

and how you create array neartarget? edit. no matter now 😄

lime frigate
lime frigate
little raptor
brazen lagoon
modern meteor
#

{
   _x setUnitPos "MIDDLE";
}forEach (groupSelectedUnits player - [player]);

Trying to change the Position of a unit but nothing happens. What am I doing wrong?

modern meteor
#

Thank you

fair drum
#

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

torpid mica
#

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?

fair drum
torpid mica
#

yes they are

#

these are just placeholders, since the value can change after some time

fair drum
#
_sortedArray = [
    _array,
    [],
    {
        _x params ["_pos","_name","_size","_prioBlu","_prioOpf"];

        _prioBlu //must return string, number, or array
    },
    "ASCEND"
] call BIS_fnc_sortBy
inner otter
#

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 !

fair drum
inner otter
fair drum
inner otter
fair drum
#

okay, and you are naming your tasks in the Task ID box?

inner otter
#

Yes

modern meteor
#

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?

fair drum
modern meteor
#

oh

#

i see

fair drum
# inner otter Yes

pm me pictures of your modules and triggers. its hard to help with editor based stuff here instead of raw scripting.

modern meteor
#

is there a command to do it for one individual unit?

granite sky
#

setCombatBehaviour

fair drum
granite sky
#

nah, that's hcSelected

fair drum
#

oh i read that wrong

modern meteor
#

my objective is to use the script on one selected unit

modern meteor
fair drum
#

are FSMs in the root folder automatically executed?

edit: they are it seems

still forum
#

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

still forum
#

Sorry reading slower than replying, Leo already answered

velvet knoll
#

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?

stable dune
#
_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

stable dune
#

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.

acoustic abyss
modern meteor
#

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;


modern meteor
#

Sorry, forgot to copy the first line

little raptor
#

what does your sqf code contain?

modern meteor
#

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]);
little raptor
#

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

modern meteor
#

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

little raptor
#

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

modern meteor
#

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

little raptor
#

I see nothing wrong if that's your exact code

modern meteor
#

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

little raptor
#

the execVM part looks correct blobdoggoshruggoogly

modern meteor
#

very odd that it triggers the variable error

#

but not when i run it from console

little raptor
#

you mean this is what you run?

[groupSelectedUnits player - [player], screenToWorld [0.5, 0.5], 3] execVM "MoveSelected.sqf"
modern meteor
#

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

little raptor
modern meteor
#

ah

#

let me check

#

i mean the whole code in the sqf which i run from console

little raptor
modern meteor
modern meteor
#

where do i have to define it?

little raptor
#

it doesn't because it runs unschd

#

it does have the error

#

it just doesn't show it

modern meteor
#

oh, i did not know it

little raptor
modern meteor
#

the error is the undefined variable it seems

#

as you said

little raptor
modern meteor
#

thats what i thought initially

#

see above

little raptor
#

maybe you didn't save your script or something

modern meteor
little raptor
#

it passes it to the code

#

the code defines it

#

so it shouldn't be giving you any errors

modern meteor
#

this is really weird

little raptor
#

I'm pretty sure the problem is elsewhere

#

but let me test once

little raptor
#

as I said

#

where are you even checking for error? rpt?

#

if so you're looking at old errors

modern meteor
#

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?

modern meteor
little raptor
little raptor
#

no

modern meteor
#

so basically the same full line?

little raptor
#

anyway that script is a huge mess

little raptor
#

everything is exactly as you posted

modern meteor
#

ok

little raptor
#

and I already told you it doesn't have any errors just by looking at it

modern meteor
#

yea

#

well then i don't know

little raptor
#

then you're doing something wrong yourself. I can't tell you what blobdoggoshruggoogly

modern meteor
#

think i tried everything

#

yea, i check again

#

Thank you for your help though!

#

Much appreciated

spiral temple
#

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?

winter rose
#

no, it is UI-related

velvet flicker
#

How do I end function, which I would normally do with return? I found exit, but it doesn't seem to be working

warm hedge
#

Put a variable at the very end of the function

velvet flicker
#

I don't care to return anything, only to kill the script in this case

warm hedge
#

Ah

#

Misreaden I guess. exitWith or break (IIRC) would do

velvet flicker
#

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>

pulsar bluff
#

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

fair drum
#

gonna try converting the date to number, then add after conversion, the change it back to date

fair drum
#

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];
cloud sundial
#

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

cloud sundial
#

And sounds real sad but where can i find the class/define term for camo's

cloud sundial
cosmic lichen
#

You can also use the Garage and export the appearance. Might be helpful.

cloud sundial
plush belfry
#
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.

cosmic lichen
#

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.

plush belfry
proud carbon
#

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?

sullen sigil
#

Will say3D allow for AI to detect the player if it is played from them?

sullen sigil
plush belfry
#

So I found this from 2 years ago, what did this person mean by wrong operator? Can't seem to figure it out.

winter rose
sullen sigil
modern meteor
#

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?

plush belfry
chrome crow
#

im new to scripting, would anybody want to help and let me know how to make a survivable heli crash

winter rose
plush belfry
winter rose
#

if money is not defined, add -1 money, else add 4000

#

anyway

south swan
modern meteor
#

Than you. Just to be clear, you suggest to use call in the code for the command menu, right?

south swan
#

[arguments] call MY_fnc_name

modern meteor
#

I will give it a shot. Thank you!

proven charm
#

I'm trying to find where flagpole gets it's flag texture but cannot find it in config, anyone knows?

south swan
#

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 🤷‍♂️

sullen sigil
#

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?

granite sky
#

I feel like I need the silly context for this, but I'm gonna tentatively say "yes".

modern meteor
# south swan `[arguments] call MY_fnc_name`

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"

south swan
#

it does on my machine 🤷‍♂️

little raptor
little raptor
#

yeah that won't work

#

@modern meteor get the selected units in the command menu

south swan
#

spawn did the same. Call worked.

modern meteor
little raptor
little raptor
little raptor
modern meteor
#

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"
};
jade acorn
#

change MY_fnc_name to your function name

modern meteor
#

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"
};
south swan
# little raptor as in: ```sqf ["Move Selected", [10], "", -5, [["expression", "[groupSelecte...

@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.

modern meteor
#

Thank you artemoz. Testing it now and report back.

#

It's working now. Thank you all for your help.

sullen sigil
granite sky
#

yeah that's fine.

sullen sigil
#

thank god for that

granite sky
#

Note the undocumented behaviour of setVariable that it transfers on respawn.

#

but not on selectPlayer.

sullen sigil
#

That's good, need it to remain like that lol

last rain
#

Is it possible to use IP verification in script commands to block certain people from accessing the server?

granite sky
#

I don't think so. You could block by steam UID though.

last rain
willow hound
jade acorn
granite sky
jade acorn
#

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?

granite sky
#

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.

last rain
jade acorn
#

alright, so I have to add new EH every time player switches to another unit, thx

modern meteor
#

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"]
willow hound
willow hound
modern meteor
granite sky
#

What's AI_CommandDispatcher?

modern meteor
#

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

granite sky
#

You want it to point at a particular position?

modern meteor
#

Yes, exactly

granite sky
#

I think that's a bit more than a syntax problem.

modern meteor
#

Oh, I can't see a cursor on a ground when I use the the ToString command?

granite sky
#

toString is just converting code -> string because some functions only take a string.

willow hound
#

What parameters can AI_CommandDispatcher take?

modern meteor
#

[player, "HandSignalPoint"]

willow hound
#

Yes, but could it take anything else?

granite sky
#

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.

modern meteor
#

That's not necessary

#

The code works fine

granite sky
#

blinks

#

I give up.

modern meteor
#

I just want to see the crosshair when i select the option

willow hound
#

Do you know how to write SQF code that accepts parameters?

granite sky
#

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

hallow mortar
#

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.

torpid mica
#

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?

little raptor
torpid mica
#

can you tell me which? wasen´t able to find anything 😦

little raptor
#

idk. probably something like getGroupType? meowsweats

little raptor
torpid mica
#

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...

little raptor
#

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.

little raptor
torpid mica
torpid mica
little raptor
#

yes. it's local. but if you want to use it in many places just define it as a global function

little raptor
#

you can just change the "_type" variable to whatever else you want

torpid mica
#

yes i will 🙂 thank you very much. If i need more help I will contact you

modern meteor
#

Thank you guys. I will have another look and see if i can find a solution.

torpid mica
#

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

little raptor
torpid mica
#

thanks mate 🙂

little raptor
#

I still have no idea where I got that from tho meowsweats

#

I think spectator function maybe...

#

yeah I guess that was where

stable dune
#

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.

little raptor
stable dune
#

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.

digital hollow
#

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";
}];
little raptor
digital hollow
#

no effect on

allMapMarkers apply {_x setMarkerAlpha 1}
little raptor
#

then I guess it's hardcoded think_turtle

sullen sigil
#

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)

granite sky
#

Not sure what you mean by inventory weight.

#

Container maximum? Unit maximum? Item weights?

sullen sigil
#

sum of the weight of all inventory items
but obviously you cant add to that atm without taking up inventory space afaik

granite sky
#

I think that's just adding config mass values of the items.

jade acorn
#

you can only change the weight coefficient that impacts your stamina script-wise, everything else is config with certain numbers of mass

sullen sigil
#

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)

sullen sigil
#

or am i getting you confused

jade acorn
#

setmass is for physx

sullen sigil
#

ya in base game it influences players stamina drain according to biki

jade acorn
#

maxSoldierLoad or something like that

#

that's what i thought about

sullen sigil
#

maxLoad I would imagine but that just returns maximum load soldier can carry

hallow mortar
#

Relevant commands:

_unit setUnitTrait ["loadCoef",<number>]; // lower is more
(backpackContainer _unit) setMaxLoad <number>; // server exec
_currentWeight = loadAbs _unit;```
sullen sigil
#

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

digital hollow
still forum
#

probably because the hash contains #

#

thats a special marker for user placed markers, that set the channel and who placed it

granite sky
#

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.

eager prawn
#

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;
}];```
still forum
granite sky
#

Eventually occurred to me to try it: "_USER_DEFINED #0/0/3"

#

so I'm gonna guess that it doesn't like the /

warm swallow
#

@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);
};}];
};
still forum
#

findDisplay 5 will be displayNull when its not currently open

#

not sure if unload might be too late to read values

warm swallow
#

This was in the wiki

#

so I put it inside a call {};

still forum
#

you missunderstood

#

it says it should run in unscheduled

#

meaning NOT to use spawn, exactly like you are doing at _this spawn

warm swallow
#

ohhhhh inside

#

if im only getting a variable than it shouldn't matter, right?

granite sky
#

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.

still forum
#

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

eager prawn
#

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"

plush belfry
#

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

still forum
eager prawn
#

@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

eager prawn
#

@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?

granite sky
#

I'm not sure what you're trying to do there but the syntax is very wrong.

warm hedge
#

Even if is not SQF, it doesn't make any sense... meowsweats

hallow mortar
#

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.

eager prawn
eager prawn
granite sky
#

Well, it's not safe to modify an array from multiple machines.

eager prawn
#

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

mortal latch
#

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

eager prawn
#

my code works, thank zeus!!!

velvet flicker
#

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 :(
warm hedge
#

Most likely create_smoke is not defined elsewhere

velvet flicker
#

Ah that makes sense

#

Thanks, that fixed it!

warm hedge
#

I think I'd suggest to remoteExec'ing call instead, with the function

mortal latch
warm hedge
#

Lemme try to write psuedo code on my phone lol

velvet flicker
#

If you have fingers like mine, than I so appreciate your sacrifice on my behalf

warm hedge
#
[_this, {fnc to create particles}] remoteExecCall ["call"]```Perhaps it is better to use remoteExecCall instead, mayb not
velvet flicker
#

Super gracias!

fair drum
#

@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.

still forum
grizzled cliff
#

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

jade acorn
#

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

gaunt tendon
# jade acorn how do I detect whether player is holding breath (while aiming)? So far I found ...
(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
  };
};
jade acorn
#

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

plush belfry
#

is there a way to add a permanent holdAction to a certain object? Currently adding holdAction using 3den enhanced attributes

jade acorn
#

set hideOnUse as false

#

ah wait, hold action, mb

plush belfry
jade acorn
#

removeCompleted set to false

plush belfry
#

yeah gonna have to manually script it, thank you

eager prawn
#

Script worked without issue 😅 happy to have that one done.

digital hollow
jade acorn
digital hollow
jade acorn
#

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

scenic shard
#

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?

granite sky
#

What's the simulation type of the object?

#

Also how far does it move?

scenic shard
#

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

hallow mortar
#

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.

scenic shard
#

i see, the object created in this case is this one:
_proj = "B_9x21_Ball" createVehicle _CrPos;

hallow mortar
#

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.

scenic shard
#

ok, is there a good "dummy"-object that can be used in his case? something small and invisible

hallow mortar
#

Use a physics object like a tin of beans or something and make it invisible with hideObject/hideObjectGlobal (note server exec requirement for -Global)

scenic shard
#

ok, i will try that

scenic shard
#

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

granite sky
#

There's the EpeContact* events. Not used them myself though.

scenic shard
#

that one did not trigger for me unfortunately, used a simple can from CUP. maybe that object dont work with physX stuff specifically.

agile cargo
#

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

winter rose
#

neither can we! remove some animation- or speed-related scripts and find out 🙂

#

that or despawning/respawning scripts, etc

scenic shard
agile cargo
scenic shard
#

ok, best to backup the mission and start removing stuff until it goes away

agile cargo
#

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

scenic shard
#

it sounds like some mod or script is messing with you then, hard to tell which from here

agile cargo
#

probably lol

agile cargo
#

Yes, it's the Northen Fronts mod.

#

I wonder, is there a way to get a performance log of the functions running?

ripe hemlock
#

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.

fair drum
#

can you use preprocessor commands like #include in a .FSM? I want to include some macros in my mission flow FSMs for debugging

pulsar bluff
woeful kiln
#

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

versed belfry
hallow mortar
#

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.

winter rose
#

no guarantee though

hallow mortar
#

I tried that and unfortunately not

winter rose
#

ah welp
then "no" ^ 😄

versed belfry
#

Ah welp there was an attempt

ripe hemlock
# woeful kiln Is that fixable?

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

cedar kindle
#

@frank cedar you'd use CBA's per frame handler, as long as your checks are quick

jade abyss
#

rolleyes

copper nova
#

Hi, I wonder if there is a script way to check that an object is currently playing a say3d sound?

modern meteor
#

Are these group eventhandlers already implemented in Arma? For example:

_group addEventHandler ["CombatModeChanged", {
    params ["_group", "_newMode"];
    player removeEventHandler [_thisEvent, _thisEventHandler];
}];
hallow mortar
#

Yes, they were added in 2.10, which is the current stable version

modern meteor
#

I tried the following but it does not work:

units player - [player] addEventHandler ["CombatModeChanged", {
    params ["_group", "_newMode"];
    player removeEventHandler [_thisEvent, _thisEventHandler];
}];
hallow mortar
#

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.

modern meteor
#

I see. Not sure how to do this though.

hallow mortar
#
group player addEventHandler [ ...```
modern meteor
#

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];
hallow mortar
#

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.

modern meteor
#

"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?

hallow mortar
modern meteor
#

If I understand this correctly I can assign a specific EH to a variable?

hallow mortar
#

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.

modern meteor
#

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?

warm hedge
#

No

private _EH1 = player addEventHandler ["whateverEH",{}];

//and later

player removeEventHandler ["whateverEH",_EH1];```
modern meteor
#

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.

warm hedge
#

I don't think there is. But it is not even a concern since you can add one as much as you want

granite sky
#

It's a concern for EHs with a return value.

#

HandleDamage for example.

warm hedge
#

That's a point

modern meteor
#
//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

warm hedge
#

They aren't defined in it

modern meteor
#

Oh, then I misunderstood. I thought they are defined as the event handlers?

hallow mortar
#

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.

modern meteor
#

Ah, I see. Will do that. Thanks

hallow mortar
copper raven
#

use get/setVariable

modern meteor
#

Thank you

copper raven
#

also for the latter EH, you're adding it to the group, but then trying to remove it from an object instead

modern meteor
#

hm

#

group player removeEventHandler ["CombatModeChanged",_EH2];

#

I thought this is the correct way to remove it

#

No?

hallow mortar
#

That is. In EH2 you have this:

player removeEventHandler [_thisEvent, _thisEventHandler];```
Which won't work
modern meteor
#

ah

#

should be like this?

group player removeEventHandler [_thisEvent, _thisEventHandler];
hallow mortar
#

Seems likely

modern meteor
#

tk u!

winter rose
#

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 🙃 🙂

modern meteor
#

Good point. I will do this. Tks

jade acorn
still forum
#

bookmark bot incoming

humble tundra
#

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. notlikemeow

frigid oracle
#

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.

winter rose
winter rose
frigid oracle
proven charm
#

why does the parachuted soldiers die when they touch ground, i have this problem only with IFA

hallow mortar
#

That smells like an IFA problem rather than a scripting problem

proven charm
#

yeah

#

actually I think they die when they exit the plane

granite sky
#

They probably get hit by part of the plane?

proven charm
#

maybe

#

IFA has its own paradrop WP, so i might have to use that

#

also sometimes the paratroopers ignore the vehicle exit commands. like "moveOut" etc