#arma3_scripting

1 messages · Page 764 of 1

little raptor
#

ofc if you only want it to be the driver what you first wrote was best

modern meteor
#

should this code not simply add and remove the silencer of the the player?

    player removePrimaryWeaponItem "muzzle_snds_shield_black_m";
    hint "Silencer off";
}
else {
    player addPrimaryWeaponItem "muzzle_snds_shield_black_m";
    hint "Silencer on";

}
}
#

as a toggle

#

for some reason it does not but also does not give an error

little raptor
#

it doesn't execute at all

modern meteor
#

hm

#

but where is the {} wrong?

little raptor
#

outermost

modern meteor
#

ah

#

let me check

little raptor
# modern meteor let me check

what you wrap in {} becomes a code
a code never executes unless a command executes it
e.g. in {} forEach array, forEach executes the {}. or in if (bla) then {} then executes the {}

modern meteor
#

ah, i understand

#

thank you

#

i changed it to..

    player removePrimaryWeaponItem "muzzle_snds_shield_black_m";
    hint "Silencer off";
}
else {
    player addPrimaryWeaponItem "muzzle_snds_shield_black_m";
    hint "fuck";
}```
#

now it adds a silencer to the player but never removes it

#

if ("muzzle_snds_shield_black_m" in primaryWeaponItems player) then {

#

is this valid?

little raptor
#

but in is case sensitive

#

so it never succeeds

#

because what you have is all lowercase and the actual item class name most likely isn't

modern meteor
#

but the name of the item is all lowercase

little raptor
#

see what it gives you

little raptor
#

at least not always

#

depends how it was defined in config

modern meteor
#

now it works

#

primaryWeaponItems player => can i use this command to get the loadout of an AI unit in my group?

willow plume
#
if ("muzzle_snds_shield_black_m" in primaryWeaponItems player) then {    
    player removePrimaryWeaponItem "muzzle_snds_shield_black_m";
    hint "Silencer off";
}
else {
    player addPrimaryWeaponItem "muzzle_snds_shield_black_m";
    hint "fuck";
};

^ You were missing a ; in this code, in case that was breaking it

willow plume
little raptor
modern meteor
#

sorry, primary weapon attachments i meant

#

for a certain unit in my group

little raptor
#

yes

modern meteor
#

ok

#

an how?

#

in other words, how can i address a certain unit (eg F2) in a script?

little raptor
modern meteor
#

sorry, i meant without actively selecting it

#

if i understand correctly

#

_myUnitCount = count units player;

#

gives me an array with units in my group

#

now how can i access the 4th member in the player group from the array?

little raptor
modern meteor
#

primaryWeaponItems (units group - [player]) select 3;

#

tells me group not defined

still forum
#

But I noticed that Arma could drop that kind of request or trim it.
Arma should never drop anything, if it does its a bug

little raptor
#

I meant units group player...

#

fixed

#

but your code is still wrong

tough abyss
#

we discussed about that and we have a conclusion but it is interesting to have your pov too

still forum
#

no difference

#

both are serialized and sent mostly the same

tough abyss
#

ok thanks

still forum
#

maybe we finally need a compress/decompress command

tough abyss
#

that would be great

modern meteor
little raptor
willow plume
still forum
#

for like a dozen people sure

willow plume
#

Couldn't this already be done (kinda) using the HashValue command?

still forum
#

wat

willow plume
#

ohh wait nvm

#

the idea was [array of values] -> convert array to hash -> send through remoteExec to unhash function -> unhash the data -> run code

still forum
#

Yes, hashes inherently cannot be unhashed, that's like, the definition of a hash

copper flare
#

I am working on a shoothouse and I have nearly everything working except the final evaluation tally. Part of the final evaluation is to count targets hit, targets missed, and maybe save those numbers to do some math with them like time penalties.

I am using the pop-up target objects from Vanilla. I've broken them out into arrays named as "S1Shoot" and "S1 NoShoot" so I've got something like this already.

private S1Shoot = ["S1_01","S1_02","S1_03","S1_04","S1_05","S1_06","S1_07","S1_08","S1_09","S1_10","S1_11","S1_12","S1_13","S1_14","S1_15","S1_16","S1_17","S1_18","S1_19","S1_20","S1_21","S1_22"]
private S1NoShoot = ["NS1_1","NS1_2","NS1_3","NS1_4"];

According the forums on individual targets I can apparently using this line to return the state of an individual target where a returned value of 0 means the target is up and a returned value of 1 means the target is down:

private _state = _target animationPhase "Terc";

Where I am completely lost here is how to take that line, and work it into a "ForEach" Command to iterate through array ultimately returning values to count the number of targets up and number of targets downed.

modern meteor
#

forEach (units player - [player]) group player;

can someone tell me the correct syntax?

modern meteor
#

running a command for all units in the players group excluding the player.

little raptor
little raptor
modern meteor
#

Tyvm

copper flare
#

THanks

cold mica
#

I have been trying to set up this script for multiplayer yet it never works as intended. Here is how it is called:

weaponGod's init

[this] execVM "scripts\weaponDealer.sqf;

weaponDealer.sqf

params ["_weaponGod"];
[_weaponGod, "Miłosz the Weapon Dealer"] remoteExec ["setName", 0, this];
_weaponGod_actionId = _weaponGod addAction [
    "<t color='#FFC800'>Demand STG-44",
    {
        params ["_target", "_caller", "_actionID"];
        _target removeAction _actionID;
        _target globalChat "You have found me, stranger.";
        sleep 4;
        _target globalChat "Ah, I see you want the best.";
        sleep 2;
        _weapon = [_target, "rhs_weap_MP44",1] call BIS_fnc_addWeapon;
        isNil { _target selectWeapon _weapon; };
        sleep 3;
        _groundWeaponHolder = createVehicle ["GroundWeaponHolder", getPosATL _target, [], 0, "NONE"];
        _groundWeaponHolder addMagazineCargo ["rhsgref_30Rnd_792x33_SmE_StG", 6];
        _target action ["DropWeapon", _groundWeaponHolder, primaryWeapon _target];
        sleep 5;
        _theFlashbang = "ACE_G_M84" createVehicle (getPosATL _target);
        sleep 1;
        [_theFlashbang] call ace_grenades_fnc_flashbangThrownFuze;
        deleteVehicle _target;

    }
];

The issue occurs when the _target tries to select the weapon. It never does so so I try to force it with an isNil yet it still bypasses it and runs the rest of the script without selecting the weapon and dropping.

In singleplayer, the weapon is successfully selected and dropped. Running this script in the debug console on a dedi does work, but only when it is run in global execute.

Any advice is appreciated

little raptor
open fractal
cold mica
#

Where should I be calling the action in an MP environment? Server? Globally? Currently, it is in the init of a unit, meaning it should be global + JIP.

fair drum
orchid stone
#

do we have a command to take distinct elements from an array?

[1,1,2,3,3,3,3,4,4,5,5] becomes [1,2,3,4,5]

orchid stone
#

ahh ty

#

good enough for me, this will work

cold mica
digital rover
orchid stone
#

even cleaner

#

ty

limpid lake
#

automatically does it mid mission, hes sick

tough abyss
#

(pbo is obfuscated, we can not fix the error)

tranquil jasper
#

that kind of message is generated by arma itself so probably not, best bet is to just fix the issue or if you are not the creator let them know there's a problem so they can fix

tranquil jasper
#

^ This is slightly more than 2x as fast as arrayIntersect using the example dataset and the code performance checker on the ESC menu

#

worth considering if you need to do that operation a lot

granite sky
#

I get the arrayIntersect version as 4x faster.

open fractal
#

so just remotexec the ai command and call it a day I’d say

tranquil jasper
#

odd, I wonder why the discrepancy?

granite sky
#

I'd have expected arrayIntersect to be faster as it's a command, even if it's a dumb algorithm :P

tranquil jasper
#

Not sure why our systems say different things...I get 0.0022ms for 10k runs with arrayIntersect, 0.0009ms for 10k runs with pushBackUnique

granite sky
#

0.0024 vs 0.0099

tranquil jasper
#

yeah I wrote the test wrong, that's why

#

2x faster but you get no output 😅

granite sky
#

Oh yeah, diag_codePerformance doesn't complain about errors :P

haughty bone
#

Greetings everyone. I was wondering if any of you is familiar with extDB3 ? I am trying to work with it but am hitting a couple points that are confusing to me. I also am new to scripting in general. Which also doesnt exactly help 😅

#

I just have a couple questions when it comes to setting up the extDB3 and how to check if it can actually make a connection succesfully.

little raptor
#

SQF is never faster than engine

tranquil jasper
#

it was an error in the test

finite bone
#

Is there a way to remoteExec the createVehicle command and have it create a vehicle once in a multiplayer lobby? The createVehicleLocal does the job fine but I couldn't get that object be added to the curator list.

drifting portal
drifting portal
finite bone
#

Ye, I understand createVehicle is global hence I wanted a similar solution to (A) Create the vehicle and (B) Add it to the curator list

drifting portal
#

you know that adding an object to the curator list will crash the game?
jk
use

   [[_CreatedObject], {   
           params ["_object"];   
          { _x addCuratorEditableObjects [[_object], true]; } foreach allCurators;   
        }] remoteExec ["spawn", 2];   
#

create a vehicle with createvehicle, then replace the _CreatedObject with the variable storing the vehicle

#

pretty easy

finite bone
#

the problem is the createVehicle command itself is run inside a remoteExec'd sqf script

drifting portal
#

may you post the code?

finite bone
#

ye

#

Init:

[[_object_class],"\create_object.sqf"] remoteExec ["BIS_fnc_execVM",0,true];``` create_object.sqf: ```sqf
_my_obj_class = _this select 0;
/* other variables and code arguments and such */
_my_obj = _my_obj_class createVehicle _designated_position;```
finite bone
#

Yes exactly

drifting portal
#

there is no point in having this then so you must change it

finite bone
#

I replaced createVehicle with createVehicleLocal

drifting portal
#

your end goal is to do what exactly?

finite bone
#

just so it will execute once locally and probably have it added to the curator list KMAO

drifting portal
#

hmm but the problem is players won't see the vehicle the zeus is editing

#

and every player will have their own version of the vehicle

finite bone
#
  1. Create a vehicle based on the object class passed
  2. Have it editable by zeus
    all while running globally for players in remoteExec
drifting portal
#

yes, but you are creating it only local for the zeus here, which means the players playing won't be able to see what the zeus is doing

hallow mortar
#

...why does this script have to be remoteExec'd to all players?

drifting portal
#

it will not be on their screens

hallow mortar
#

Also you don't need BIS_fnc_ExecVM, you can just use execVM

drifting portal
#

why would you give zeus an editable object that other players can't see?

hallow mortar
drifting portal
#

yep

#

I'm trying

#

to relay that to him

finite bone
#

so my only way is to have it created first in the init file and then pass it to the remoteExec'd script?

hallow mortar
#

I'm not sure exactly what that means but I think the answer is no

drifting portal
#

you just want a vehicle that can be seen being edited by zeus by everyone on the server right?

finite bone
#

yes

drifting portal
#

yes

#

createVehicleLocal does the opposite of that

finite bone
#

yea i learnt it the hard way xd

drifting portal
#

it gives every player a vehicle that is only visible to them on their side

#

yep so

#

no need for remoteExec here

#

do

#

init :

[_object_class] execVM "\create_object.sqf";

create_object.sqf:

_my_obj_class = _this select 0;
/* other variables and code arguments and such */
_my_obj = _my_obj_class createVehicle _designated_position;
/* BELOW adds object to curator interface*/
   [[_my_obj], {   
           params ["_object"];   
          { _x addCuratorEditableObjects [[_object], true]; } foreach allCurators;   
        }] remoteExec ["spawn", 2];   
#

because

#

the command is global

#

locally executing it will still give a global effect

finite bone
#

ah ok ty

drifting portal
#

try it and give feedback

#

because I have not checked if it works

orchid stone
#

anyone ever run into an issue where sound sources created with createSoundSource cannot be heard after respawn?

#

it could be the complexity of the sounds coming through as well. i'm not really finding much on when could stop a sound source from playing (the same function works on different maps for me)

#

for the curious, this is my script. it's not doing much

#include "script_component.hpp"
if (!isServer) exitWith {};

private _logic = param [0, objNull];

_logic spawn {
    private _sound = _this getVariable "SoundEffect";

    _eval = format ["getText(_x >> 'sound') == '%1'", _sound];
    _soundref = configName((_eval configClasses(configfile >> "CfgVehicles")) # 0);

    createSoundSource [_soundref, position _this, [], 0];
};
orchid stone
#

... i think it's the respawn screen... on the wiki it says...

"For some unknown reason if at the moment of command execution the player is in first person view and is inside a vehicle, the sound created is greatly attenuated."

does the respawn screen put players in some sort of pseudo vehicle when they first connect?

orchid stone
#

i guess a trigger with setSoundEffect is a better answer to this problem

drifting portal
#

is creating and deleting a trigger after its use a good practice? (The trigger won't be running for long)

fair drum
#

I like to. Less objects.

drifting portal
#

Have you noticed any impact from doing this?

orchid stone
#

generally it's good practice to dispose of objects when you're done with them

#

i say that from a general programming point of view (not as an arma scripting expert/authority - which im not)

drifting portal
#

Where are my arma 3 experts/ authorities I miss them

orchid stone
#

Not sure what you mean, but you should make sure your stuff is cleaned up. Especially things that run in loops (even more so with infinite loops - like a repeatable trigger that never gets deleted). One trigger maybe won't matter, but it's bad practice.

drifting portal
open fractal
#

i can proclaim myself an expert

drifting portal
open fractal
#

this is below my pay grade

drifting portal
ebon citrus
ebon citrus
#

is there a method for rejecting updates for Units?

#

as in, rejecting network replication updates sent by the server

#

i have a scenario with possibly hundreds of agents at once and im thinking that it might cause issues when the server population increases

#

so i was thinking of fetching updates for only the agents which are within actual render-distance

#

although, i think this might work more in the way where the server pushes updates to the clients from the networking point of view

#

so if i can stop the inflow of data and also hide the said agent on the local client until the agent is within render distance

prisma wharf
#

how would I add a loop to a play3D script

#
class CfgSounds
{
    sounds[] = {};
    class music1
    {
        name = "music1";
        sound[] = {"\sounds\pa.ogg", 1, 1};
        titles[] = {0,""};
    };

    class music2
    {
        name = "music2";
        sound[] = {"\sounds\generator.ogg", 1, 1};
        titles[] = {0,""};
    };
};
#

what i have so far

ebon citrus
#

there already are no agents present when players arent present, but sometimes ýou dont want to send the network updates of an agent to a client that is 5km away from that agent just because another player is nearby that agent

#

but wait...
Each client have it is own dynamic simulation manager, all script commands do affect the local simulation manager.
this would lead me to believe that they are local effect?

#

well, this is easily tested

#

just by disabling the player's ability to trigger dynamic sim and then dynsiming the agents

#

need to try that when i get home

drifting portal
#

thats why I mentioned it

ebon citrus
#

needs to be tested

#

although im pretty sure dynamic simulation wont block packets

#

but we SHALL see

#

i might be wrong

#

nope, here it says then
To achieve best results it is suggested to manage dynamic simulation on one place - ideally on server.

#

so who knows

#

we need Dedmen in here

#

Does dynamic simulation disable simulation of far objects client-side or server-wide or both?

drifting portal
ebon citrus
#

im alrady optimizing my mission to the extent where the agents are not present when there are no players around, so that part doesnt benefit me at all

drifting portal
ebon citrus
#

no

#

If client B is 200m away from Agent A and client C is 5km away from Agent A, i want A to be enabled and behaving for B, but not C

drifting portal
#

nope

#

dynamic simulation doesn't do that

ebon citrus
#

but Arma 3 sends positional updates for players (for obvious reasons) even on units they would not be interested in

drifting portal
#

so yeah you need a better way

ebon citrus
#

I dont need this part of Arma 3 for my scenario

#

so i was wondering if there was an engine commmand or similar to discard pushes made by the server concerning certain units

drifting portal
#

the closest person I know about knowing something about such a thing is @hollow thistle

orchid stone
#

I'm actually not sure your question is about dynamic simulation or even scripting at this point

drifting portal
#

no he is doing a splendid idea

#

but its execution is too far from my level

#

he needs someone high tier lol

orchid stone
#

Not saying its a bad idea. But that's really not even about simulation ranges, but what the server packages in each frame to clients

drifting portal
#

Yep

#

He wants to selectively send packets

#

A manager

ebon citrus
#

there's probably an internal time-condition to keep the packets-per-second limited to some reasonable range

drifting portal
#

I would have tagged dedmen if its not for the rules

#

Yeah per frame is a bit too much on the bandwidth innit

ebon citrus
#

could be, depending on server performance

drifting portal
#

Have 60 players, server just dies

ebon citrus
#

rather it would be the server Dossing the clients

#

the client end would probably freeze

#

not the server

drifting portal
#

Well say its a crappy server that runs like 20 fps

#

Its not going to ddos but its going to die

ebon citrus
#

yeah, but if it runs at 20fps, then that's perfectly reasonable

#

20 updates per second is reasonable

drifting portal
#

Yes

ebon citrus
#

but if youre swapping between 20 updates per second and 3600 updates per second

#

then that's just unreasonable

#

anyway, BI has this part handled which is evident from the server-traffic

orchid stone
ebon citrus
#

but returning to topic, there doesnt seem to be a way of discarding updates of a particular agent server side

orchid stone
#

There is good info there

ebon citrus
#

the server doesnt need to update clients of the information it processes on every frame

#

that would be silly

orchid stone
#

It talks about each frame in that link

drifting portal
ebon citrus
#

so when the server needs to send packets, how many packets does it send before it moves to the next frame

orchid stone
#

No it contains the definition and flow of each frame.

ebon citrus
#

not how many packets it sends every frame

orchid stone
#

Ctrl f, then type "frame"

ebon citrus
#

this post from 2009

#

with no source

#

yikes

#

ok, lets go over some basics

orchid stone
#

No, I sent the Biki article with a lot of info

ebon citrus
#

if you have the cycle-time, you would really want to run your physics simulation at a higher framerate

#

but you dont want to send updates of that physics simulation on every frame

#

so you send updates to clients, for example on every 3rd frame if you simulate at 60 cycles per second

#

that's when you get 20 updates per second

#

then on the client-end, you interpolate between the updates sent by the server

#

and do some prediction as to where the unit would be moving if it continued moving in the same way

#

and bam

#

you have fluid movement and fluid simulation without running some ridiculously high update-rates from server to client

#

downside is that the position isnt always super precise and if packets fall behind or theyre not handled correctly in order, you get rubberbanding and what we usually call "desync"

orchid stone
#

That's a nice wall of text, but you're talking about achieving this with the internal scripting engine

#

Soooo

ebon citrus
#

also, this topic is INCREDIBLY old

distant egret
#

It does? Updates are send less the further you are away as client

ebon citrus
#

i would not be surprised if things have changed since then

#

ah, it was already dealt with

#

my bad

warm hedge
#

Ey what?

drifting portal
#

He has cometh

ebon citrus
#

there was a discord nitro scam bot

#

but someone dealt with it already

drifting portal
#

POLOX may you also please help us here

ebon citrus
#

im not sure if polpox knows

warm hedge
#

Ah log says so. It was a automated process

#

And what is the topic?

drifting portal
ebon citrus
drifting portal
ebon citrus
#

either by some internal logic or by simply discarding all updates of specific objects

#

i'd be able to do the logic myself

warm hedge
ebon citrus
#

ok, simply put, i want to tell the server not to send updates from a specific object to a specific client

drifting portal
#

He basically wants units updates to be sent to the players that are close to the units only not players that are far away

warm hedge
#

I... don't think I can say I know it

ebon citrus
#

some combination of createVehicleLocal and publicvariable?

#

but vehicles are not agents

#

and i have specifically agents

warm hedge
#

What kind of server side objects you don't want to sync?

ebon citrus
#

agents

warm hedge
#

And is that even necessary? Do you have a LOT of agents that would kill the performance?

ebon citrus
#

i have A LOT

drifting portal
#

He has the nato altis invading force

warm hedge
#

Ah... notlikemeow

orchid stone
#

I'm still confused why there is doubt the server doesn't do this per the previous info sent (albeit old)

ebon citrus
#

i have from 1200 to 2400 agents server-wide

warm hedge
#

Perhaps just enableSimulation in server side?

ebon citrus
#

because some clients are close to the agents and the updates are relevant, but some clients are so far away that the updates are just spam

#

i understand that from the design nature of arma there comes a need to keep every player on the server updated on every object and agent, but i would like there to be a way of changing this behaviour if the scenario calls for it

#

since it's not strictly necessary to all scenarios

#

just even a command to tell the server "Dont send updates of this object to this client"

#

and then being able to reverse that change

warm hedge
#

Hmm. I don't think I can solve it, or I can tell it is even possible or not

ebon citrus
#

i dont think that should be awfully difficult to solve

#

if there are the necessary people working on the game anymore

#

I'm certainly not a big person and my request is not big, so it would most likely never be added

#

but one can always hope

drifting portal
ebon citrus
#

this would be a huge help to people trying to optimize their missions for LARGE amounts of units

drifting portal
#

Yep

ebon citrus
#

well, i dont know how RV4 works internally on that department

#

but if it's well designed, it would not be a big deal

drifting portal
#

Well I think its either dedmen or killzone kid or veteran29 who might have an idea about this

ebon citrus
#

whatever way you use to collect updates or determine the receiver of the updates, in that method check if the receiver of the update is paired with the target of the update in this ignore list/hashmap/whatever data structure you prefer and if so, ignore the update

#

there, done

#

then a method of removing pairs from this ignore-"list"

ebon citrus
#

and im not looking for a ban right now

drifting portal
#

Yep lol

#

I tagged veteran29

#

Already

ebon citrus
drifting portal
#

This would have greatly helped in my biggest mission that I have made, darn

orchid stone
#

I'm also wondering about the performance impact of evaluating and filtering through each entity in the update rather than just taking it from the server (client or server)

#

Tbh, I'm not even convinced it's a good idea

ebon citrus
#

we're comparing peas and planets here

ebon citrus
drifting portal
#

Its a stupid idea but did you try enablesimulation false on a client in a server?

orchid stone
#

Oof. Ok well bed time then

#

I didnt come here to argue lol

#

Good luck

drifting portal
ebon citrus
orchid stone
drifting portal
#

Come on elon just bought Twitter chill guys

ebon citrus
orchid stone
#

Well, that the documentation is wrong, and that it is necessary to circumvent the server updates with something in the scripting engine, and so much more

ebon citrus
orchid stone
#

But honestly. You're being a bit confrontational about it for some reason, and I have no skin in the game. So I'm just gonna let ya go

#

Have a good night

ebon citrus
#

it IS necessary to block engine updates from script engine in this case

#

and so much more

ebon citrus
#

just launching baseless assumptions

orchid stone
#

I dont think that's fair to say when I provided documentation related to how the server determines what is a necessary update and what isnt

ebon citrus
orchid stone
#

Ok this is childish now

#

I'm done for real

ebon citrus
#

ok, go sleep

#

good night, sleep tight

#

My case still stands

#

In my humble opinion, there should be a way to ignore network updates of specific objects to specific clients

#

this should probably be a BI forum post at this point rather than a discord discussion

drifting portal
#

we should have created a thread

ebon citrus
#

cant create threads

cyan dust
drifting portal
#

and you can add comments without using comment command

#

that very slightly affects performance

#

in-line can be directly called, in-file needs a set of commands to be called

#

but overall in-file are easier to deal with

#

more clean code

#

it depends if you have access to mission files too

cyan dust
#

Thank you. Any other opinion?

drifting portal
#

well

#

please do check this

#

and

#

check this

#

when you do execVM repeatedly for a file, you will make the game read it each time, which is slow

#

so you can for example do

My_fnc_Cool = compile preprocessFileLineNumbers "myScript.sqf";

and whenever you want to use it you can do

call My_fnc_Cool; //or spawn My_fnc_Cool;, depends on your use case
#

more efficient

#

do that when you want to run the same sqf file more than one time, if one time just use execVM

cyan dust
#

Sorry, there is a little misunderstanding, I know how funcs work and how to write and use them, it's just that I walked functions-as-files route from day one (the first thing I saw in tuts and examples I guess), and now was struck by question why would I do that in the first place? A good question indeed, because I have no answer to that, it's just how it is. I was asked why don't I just write them as global variables inside one large sqf file instead of building 'functions' folder tree - no answer to that either. I tried biki - it just says 'well, you can do that or that' without explaining the difference. That's how I ended up here (=
Now I do know that functions-as-files are compiled firsthand and that it is compileFinal, is that it? Anything else maybe? Why would one prefer functions-as-fiels over inline code variables then?

#

Maybe I underestimate these advantages?

still forum
cyan dust
drifting portal
still forum
#

Thats just a preInit eventhandler, you could add your own eventhandler and compile your scripts there, before init.sqf and others

drifting portal
#

you can write them all in a single sqf file

#

then execute that sqf

#

so that they become global variables

#

that you can execute in game

#

it just depends on your use case

winter rose
#

and that's "bad" 😄

drifting portal
#

if you have a 1000 line function however

cyan dust
still forum
#

Bad organization when everything is just thrown together in the same bucket.
Bad modability (CfgFunctions you can replace single functions if you want to mod something, if its all in one large file not so much)

winter rose
#

they may be local only if you f-up
they may be overwritable if you f-up
they may become illegible if you f-up (or keep them piled-up)
etc 🙂

cyan dust
still forum
#

no performance difference

cyan dust
still forum
#

Well unless SQF bytecode maybe, depending on how the compilation happens.
But if you are thinking about putting your scripts into a single file, you are not thinking about bytecode

cyan dust
#

Thanks, everybody,

drifting portal
#

If you are really persistent

#

About putting everything in one place

#

Put only small functions in one place

#

Give large functions their own files

#

They deserve it

winter rose
#

why persist in going the bad way when the good way is shown 😛

drifting portal
#

A single missing ; will disable a lot of functions potentially

cyan dust
drifting portal
#

Good practice is always good

winter rose
#

Gotta know what you're doing instead of blindly following 'good practice'
I concur! 👍

#

yes but "why" is important 🙂

drifting portal
#

Bad practice is only worth it if you going to ensure it will be fun

#

And worth it

winter rose
#

we spoke with Zeus this year, and we agreed on that
"you should not inline things"
yeah… """but why?"""

so you know and don't blindly follow indeed - or repeat the same "bad practice" in a different way 🙂

ebon citrus
#

There is no reason to otherwise than for testing

#

i dont care what CBA says

#

also, i think the security aspect of CfgFunctions needs to be brought up too

drifting portal
drifting portal
ebon citrus
#

as in, you cant replace CfgFunctions scripts from runtime

#

or so im told

little raptor
#

You can recompile functions in missions

#

If you enable it

ebon citrus
#

they can be recompiled if you enable it, exactly

#

but an inline function can be replaced just by assigning the function variable again

#

as such, much more prone to exploit

#

but i am me, i put my functions religiously in CfgFunctions

rapid swallow
#

Hello, who has a script for the infantry spawn during the spawn trigger so that the infantry fills in the houses on the first and second floors

pulsar bluff
#

how you put your functions is really irrelevant. whichever way is more efficient for your workflow (and the workflow of anyone else you want working on the project) is best

#

inline functions should perform a tiny bit better since they are located in a namespace with less data

#

so your getVariable would produce a result tiny bit faster

ebon citrus
still forum
#

so your getVariable would produce a result tiny bit faster
You mean namespace with fewer values == faster? No thats not quite how hashtables work. Adding more values might even make the lookup faster, if you get over the threshold to get more buckets allocated.

little raptor
#

not related to what QuikSilver said

#

but because CfgFunctions also create _scriptName and _scriptNameParent variables... 😅

#

basically these lines:

private _fnc_scriptNameParent = if (isNil '_fnc_scriptName') then {'BIS_fnc_GC'} else {_fnc_scriptName};
private _fnc_scriptName = 'BIS_fnc_GC';
scriptName _fnc_scriptName;
still forum
#

Can you disable them with CfgFunctions entry?
initFunctions has a check for different header "types" so I assume there's also one without that?
Never actually tried to do that

little raptor
#

¯_(ツ)_/¯

cyan dust
little raptor
#

yeah it was also documented on the wiki 🤣

#

I read the file meowsweats

versed widget
#

is there a way to check currentweapon of the vehicle in gunners position like cannons and such, i tried currentweapon gunner vehicle player but it returns the gunner side arm

little raptor
#

gunner vehicle player gives the gunner itself...

#

I don't think it's possible to know which vehicle weapon they have selected tho thonk

#

@versed widget use currentWeaponTurret

versed widget
#

thanks that will do

leaden ibex
#

Hey everyone, I am trying to figure out, if it's possible to add a music track into the SOG "player", using mission side scripts.
Anyone has any idea if it's possible? I would normally script it to the heli, but the SOG has such a nice menu for it

tidal ferry
#

Is it possible to check the status of animateSource?

little raptor
tidal ferry
modern meteor
#

Hi, my AI squad members have a laser/light combo attached to their rifle. Is there a way to activate their laser or light via script?

tough abyss
#

wait lol

#

hive mind lol

winter rose
modern meteor
#

Many thanks guys

#

Hmm, it looks like the AI cannot switch between laser and lights mode on an attachment

#

I am using a laser/light combo where I as a player can press a button to switch between modes but it seems for the AI it can only activate one mode with the attachment. Is that correct or am I doing something wrong?

#

Just for clarification, I try to switch between light and laser for the AI in my squad. Those units have a laser/light combo equipped on their rifle.

winter rose
#

laser/light combo is not a vanilla equipment, so maybe the mod is doing something special here

modern meteor
#

oh, i see. i guess in this case it is not possible to alter the function of the attachment from laser to light.

hallow mortar
#

It might be possible by calling the function the mod uses to switch, but it might take a bit of investigation to figure out what that is

obtuse prawn
#

hello there, i have this command:
**this setUnitLoadout (missionConfigFile >> "CfgRespawnInventory" >> selectRandom ["UA1", "UM1","UE1", "UE2", "UE3", "US1"]); **
I want the AI to execute this command on it's init, when they respawn, so AI will be like changing classes.
And i also want to make so that this only work for one side (the other side, will have other classes to select).
Can someone help me on how to do this?

modern meteor
hallow mortar
#

It could be mentioned somewhere in the config of the weapon or the attachment. Alternatively, you might be able to find it by just browsing all the functions added by the mod (or any of its dependencies) using the function viewer.

#

Keep in mind there's no guarantee this will result in finding something that works. It's only a possibility.

modern meteor
#

Ok, thank you. I'll give it a try.

little raptor
obtuse prawn
ebon citrus
#

Whether it be a local server or dedicated

#

You can check with isServer

#

Otherwise it runs for every client and the server

#

The init field runs on every device where the object gets initialized

tough parrot
tough parrot
#
_unit = "I_Soldier_AR_F" createUnit [[9142.09,21661,9.53674e-007],createGroup[resistance,true]];
sleep 10;
selectPlayer _unit;

Is this supposed to work for taking control? It is not working for me. It works if I console myself into an editor placed unit.

copper raven
modest temple
#

A mod a group I'm in using has a vehicle that doesn't have a cargo variant. So I made one you can spawn in as a composition on a dedicated server


this removeWeaponTurret ["LIB_M2", [0]];

this setObjectTexture [2, ""];

this lockturret [[0],true]; 

getPos this nearestObject "Building" attachTo [this];

this lockCargo [4, true];
this lockCargo [5, true];
#

this is the init of the car

#

it works

#

The attach to attaches a box in the back to make it look like a cargo vehicle

#

how would I modify this, to allow it to work it multiple boxes if I wanted to decorate it further

#

I can't just name the boxes because then it wouldn't work on a multiplayer server if more than one was spawned at ones, right?

tough parrot
#

is EachFrame supposed to target 50hz sim rate in all cases or does it use graphic rate in some cases?

tough parrot
little raptor
#

it literally runs every frame

willow hound
little raptor
tough parrot
little raptor
willow hound
little raptor
tough parrot
little raptor
tough parrot
tough abyss
#

Is there any way to get the view distance defined in graphical user config instead of viewDistance command ?

little raptor
#

no

dry valley
#

would i need to know how to script/code to create a particle system? or is it doable by tweaking some template and making 2d images or 3d model parts?

little raptor
#

also now sure what you mean by "particle system"

dry valley
#

like.. if a plastic box is shot at, or whatever object. it destructs, and delete the original object "source of particles" and sprays/bursts its "part1, part2 etc.p3d" on the floor.

#

basicly an explosion of premade parts if its 2d billboards or 3d models..

#

allready made the models, but atm it doesnt matter if it bursts cubes, just so i could tweak something to make it fit the item.

little raptor
#

no need for scripting

dry valley
#

so just in the config.cpp and CfgCloudlets?

little raptor
#

yeah. I think some stuff should be added to CfgAmmo too

#

I don't remember very well

dry valley
#

hmm

little raptor
dry valley
#

ok, well thanks for your time. appreciated

open fractal
#

this might be a dumb question but is it possible to add a keyDown event handler that works in the arsenal? I'm not quite up to speed on GUI stuff and the event handler doesn't fire for display 46 while in the arsenal. I see a bunch of controls get added to Display # -1 but adding an event handler to findDisplay -1 does not seem to produce results.

#

Should I assume that if I want something similar I need to modify the function itself?

copper raven
#

arsenalOpened scripted EH gives you the display

open fractal
#

i skimmed that page but didnt see it gives the display

#

thank you

granite sky
#

The example doesn't use it but it's in the table.

open fractal
#

eyess yep there it is _display

lapis ivy
#

Hello. I have a condition:

a3a_var_started && (([east,0] call BIS_fnc_respawnTickets) < 1 or ([west,0] call BIS_fnc_respawnTickets) < 1);

Activation:

"SideScore" call BIS_fnc_endMissionServer;

But, for some reason, when the tickets run out, the game sometimes gives a defeat to the team that is the winner.
How can I do this in one trigger to add points to the winning team without creating a second trigger?

copper raven
copper raven
lapis ivy
#

I need something like this...

if ([east,0] call BIS_fnc_respawnTickets) then (west addScoreSide 9990) or if ([west,0] call BIS_fnc_respawnTickets) then (east addScoreSide 9990);
open fractal
#

oh wow the scripted event handler did exactly what I needed.

[missionNamespace, "arsenalOpened", {
    private _display = _this # 0;
    _display displayAddEventHandler ["KeyDown", {
          //stuff
        } 
    }];
}] call BIS_fnc_addScriptedEventHandler;

Should I go through the effort of removing the event handler after the arsenal is closed?

#

disregard I got it in the state that I want it

finite bone
#

I have this code: sqf { _bodyPart = ["Head", "RightLeg", "LeftArm", "Body", "LeftLeg", "RightArm"] selectRandomWeighted [0.47,0.69,0.59,0.55,0.61,0.58]; _dmgType = selectRandom ["backblast", "bullet", "explosive", "grenade"]; if (typeOf _x != "VirtualCurator_F") then { [_x, _damage, _bodyPart, _dmgType] call ace_medical_fnc_addDamageToUnit; _tip = selectrandom ["04","burned","02","03"]; [_x,[_tip,200]] remoteExec ["say3d"]; } else { [_x] call ace_medical_treatment_fnc_fullHealLocal; }; } forEach (_nearentity);

When I run it - I get this following error in the server log without any damage being done to the player:
[ACE] (medical) ERROR: addDamageToUnit - badUnit [Z1,0.01,"RightLeg","grenade"] [local false] Here Z1 is the variable name of the player.

copper raven
lapis ivy
copper raven
#

IDK, that's what BIS_fnc_endMissionServer uses

lapis ivy
#

Understood. Thank you.

lapis ivy
drifting portal
#

if you read the biki

#

it will tell you the difference

#

between endmisison and endmissionserver

drifting portal
#

in config viewer in eden editor

tidal ferry
#

Hey, is there any way to access 3den Editor comments from within a scenario? E.g. writing comments in 3den Editor which are visible to Zeus

drifting portal
#

well that requires a script

open fractal
#

and _damage is not defined

finite bone
#

the _damage is defined in the code above it

#

I fixed the typo of forEach (_nearentity)

open fractal
#

are you running this on the server?

#

if (isNull _unit || {!local _unit} || {!alive _unit}) exitWith {ERROR_2("addDamageToUnit - badUnit %1 [local %2]", _this, local _unit); false};

#

if the unit isn't local then it will give you this error

#
[_x, _damage, _bodyPart, _dmgType] remoteExecCall ["ace_medical_fnc_addDamageToUnit",_x];
#

this will call the function on the player's machine

#

if you have code that affects a player unit expect it needs to be run local to the player

#

still check the documentation

finite bone
#

ah ok

open fractal
#

ace devs are doing you a favor by giving you an error code, you can always open up github and ctrl+F to find why it's happening

#

badUnit being the error code in this case

drifting sky
#

In A3, isn't there a way to get the index of the current event handler?

open fractal
#

_thisEventHandler

drifting portal
#

are there functions for this type of stuff?

copper raven
drifting portal
#

I thought

#

there was a way

#

to create keys

#

using a function

#

is it not possible to create a key?

drifting sky
#

What's with "BIS_fnc_findSafePos" sometimes returning only the first element of a position instead of an array?

drifting sky
#

I was using it in an attempt at a foolproof way of finding a totally empty position. It seemed to work in A2, but in A3, in sometimes returns just the first element in a position array, instead of a whole array.

#

Anybody have advice for finding an empty position with 100% success? Devoid of any map or editor objects, or objects spawned in during the game, including vehicles, men, and buildings.

pulsar bluff
#

you are sure there are empty positions available?

tough parrot
drifting sky
#

yes

tough parrot
#

I tested a mod a while back that turns a backpack into a tent. I had no problem with the placement unless there was no actual place to fit it.

drifting sky
#

it only happens like 1 out of a hundred times

tough parrot
drifting sky
#

How come the "fired" event handler sometimes has a "_thisEventHandler" of "any", thus causing an error?

little raptor
little raptor
#

If you pass an object as center it could be returning the object (when it doesn't find a safe pos)

ebon citrus
proven charm
#

you can decide what it returns when no pos is found by using the parameter #8

#

or param #9 if you start counting from one 🙂

raw oyster
#

ugh so one of the mods we use (R3F Logistics) that has been dead for a bit is now broken... yay. With our unit so dependent on it for our logistics system I may need to just make a new one. Can anyone point me in the right direction of scripting a gui with a money system that spends money when a vehicle or object is created. Pretty advanced ik it's just never attempted something like this on this scale, and any help is appreciated.

steel fox
raw oyster
steel fox
#

Not at my computer so I can't check for you rn. But can't you just look through the code for a bit and try to find where a detach somewhere and see what's broken?

#

Logs might even be telling you exactly what is wrong.

raw oyster
#

Will try we haven't touched anything besides the normal config, and even then we haven't touched it in months. It just started out of the blue.

#

It also does it randomly one op a player can drop items, and the next he can't, but someone else can

steel fox
#

If R3F hasn't changed you might have changed a mod or setting and created an incompatiblity

raw oyster
#

Hmm ok

#

That's prob most likely it will just have to dive into the modlist

steel fox
#

Be sure to also start checking logs next time it happens. (Some people do disable logs for better performance so keep that in mind and turn em back on)

raw oyster
#

5:41:47 Scripting function 'advlog_fnc_detach' is not allowed to be remotely executed
5:41:47 User Comm. Jonah (76561198133665042) tried to remoteExec a disabled function

little raptor
#

not the function itself

raw oyster
#

how do I allow it?

little raptor
#

CfgRemoteExec or something like that

#

google it

raw oyster
#

how can I apply it here?

#

nvm I see what you mean

#

you chads ty for the help @little raptor @steel fox

plush prism
raw oyster
#

it wound up being a mission side error

plush prism
#

👍

raw oyster
#

We had to put this in our description

class CfgRemoteExec
{
    class Functions
    {
        /*
        Operation modes:
            0 - remote execution is blocked
            1 - only whitelisted functions / commands are allowed
            2 - remote execution is fully allowed, ignoring the whitelist (default, because of backward compatibility)
        */
        mode = 2;

        /*
        JIP:
            0 - JIP flag can not be set
            1 - JIP flag can be set (default)
        */
        jip = 1;

        class BIS_fnc_someFunction
        {
            /*
            Allowed targets:
                0 - can target all machines (default)
                1 - can only target clients, execution on the server is denied
                2 - can only target the server, execution on clients is denied
                Any other value will be treated as 0.
            */
            allowedTargets = 0;

            //Override the global setting (defined in class Functions) for this function:
            jip = 0;
        };
    };

    class Commands
    {
        mode = 1;

        class setDir
        {
            allowedTargets = 2;
            jip = 0;
        };
    };
};
#

might be something to put in a doc to do for setup we have been using r3f logistics for nearly a year, and never had to do that till now

little raptor
raw oyster
#

oh?

#

I mean once I put it in it stopped all the bugs on the server

little raptor
raw oyster
#

ah

little raptor
#

class BIS_fnc_someFunction
that was just an example and no such function exists

raw oyster
#

ight ty

grave jungle
#

I managed to get it working using an even simpler example.

#

I managed to get it working. No $PBOPREFIX$ was needed, nor was the P drive~!!!

drowsy geyser
#

hey, do i need to remoteExec setAnimSpeedCoef
if i want to "freeze"a specific player ?

drowsy geyser
#

yes thank you, i see that is says GA but its LE so i guess it needs remoteExec?

digital rover
#

Yes

hallow mortar
#

Setting animSpeedCoef to 0 might have strange effects. You should also consider attaching the player to a static object or disabling simulation on them (note: disabling simulation might make them immune to damage)

ebon citrus
grave jungle
# little raptor did I say it was?

someone told me it was not optional, but it does appear to be optional. I was able to use the "file" attribute at the FUNCTION level to specify the location of my functions as files individually.

#

also, the name of the folder in which the addon resides seems to be irrelevant

#

👍 thank you for the help

grave jungle
#

umm I just got my P drive working, so far as I can tell I think it's useful to: 1) enable you to recompile functions in-game 2) have all assets pre-unpacked to make loading times faster

#

not sure what else it's really needed for

little raptor
# grave jungle not sure what else it's really needed for

it's not really needed for scripting. but for model and terrain making it's a must have, otherwise some tools can't find the assets you use
you can recompile functions if you simply put them in a mission folder and build your scripts in that mission

#

that's how I personally make my mods

marsh drift
#

Could someone help me out? Im not good at coding. The function for open my doors/hatches (vehicle) is not working properly. If I turn out or in nothing is gonna happen but if i open the door manually (from outside per user action) it is opening but will close immediately after it opens.

fn_openHatches.sqf

params["_v"];

_v = _this select 0;

while{alive _v} do{
    
if (isTurnedOut (_v turretUnit [8])) then {
        if (_v animationPhase "door_left" < 0.5) then {
            _v animateSource ["door_left",1];
        };
    } else {
        if ((_v animationPhase "door_left") >= 0.5) then {
            _v animateSource ["door_left", 0];
        };
        
sleep 0.5;
 
};
};

Config:

class AnimationSources: Animationsources
class door_left
{
    source = "user";
    animPeriod = 1;
    initPhase = 0;
};

model.cfg:

class Animations
{

class Rotation 
    {
        type = "rotation";
        memory = 1;
        minValue = 0;
        maxValue = 1;
        angle0 = 0;
        angle1 = 1;
    };

class door_left: Rotation

    {
                type            = "rotation";
                source          = "door_left";
                selection       = "door_left";
                axis            = "door_left_axis";
                memory          = 1;
                sourceAddress   = "clamp";
                minValue        = 0;
                maxValue        = 1;
                angle0          = 0;
                angle1          = -3.05;
    };

};

class UserActions 
{
            
    class Open_Door_Left 
    {
        displayName = "Open Left Door";                
        position = "door_knob_left";                
        radius = 3;
        onlyForPlayer = 0;
        condition = "this animationPhase 'door_left' < 0.5";
        statement = "this animate ['door_left', 1]";
}; ```
little raptor
wicked roostBOT
#
How to use SQF syntax highlighting in Discord

```sqf
// your code here
hint "good!";
```

// your code here
hint "good!";
little raptor
#

(also please edit your message, don't make a new one)

marsh drift
#

uh sry yes

little raptor
#

also don't do it that way

#

you're keeping a while loop always active

#

you can just run that script when the user opens the hatch

#

for example, you can add TurnIn and TurnOut event handlers to your vehicle:

class EventHandlers {
  class JakeEatsASteak {
     TurnIn = "[_this#0, 0] call jake_fnc_turnInOutTank1";
     TurnOut = "[_this#0, 1] call jake_fnc_turnInOutTank1";
  };
};

jake_fnc_turnInOutTank1:

params ["_vehicle", "_phase"];
_vehicle animateSource ["door_left", _phase];
#

ofc you only need the function if you need to do more than animation

#

if that animation is all of it no need for that small function

#

just do:

class EventHandlers {
  class JakeEatsASteak {
     TurnIn = "_this#0 animateSource ['door_left', 0]";
     TurnOut = "_this#0 animateSource ['door_left', 1]";
  };
};
grave jungle
#

I could build a UI but that seems like overhead... binding to custom keys also seems inflexible and non-robust

grave jungle
#

comms seems interesting..

little raptor
#

I recommend comms menu

south swan
#

radio trigger, some object with addAction, links in diary on the map...

grave jungle
#

yep that seems good

#

Leopard

#

so then the admin would press 0, 9 and see the custom script commands I've got

#

only thing would be how to pass parameters into it

#

I'll read your suggested Wiki articles.

little raptor
#

@marsh drift also if you want to customize script to handle all doors for different turrets, you can do:

params ["_vehicle", "_turret", "_phase"];
private _anim = call {
  if (_turret isEqualTo [8]) exitWith {"door_left"};
  if (_turret isEqualTo [9]) exitWith {"door_right"};
  //etc.
};
_vehicle animateSource [_anim, _phase];
class EventHandlers {
  class JakeEatsASteak {
     TurnIn = "[_this#0, _this#2, 0] call jake_fnc_turnInOutTank1";
     TurnOut = "[_this#0, _this#2, 1] call jake_fnc_turnInOutTank1";
  };
};
marsh drift
#

aahh ok im understanding this right now. I have added emissive light rvmats and im doing it the same way with hide/unhide and while loop... So i can use it the same way here?

class JakeEatsASteak 
{
     TurnIn = "_this#0 animateSource ['door_left', 0]";
     TurnOut = "_this#0 animateSource ['door_left', 1]";
     isLightOn = "";  ?
};```
#

what do you mean with customize? I have another door and a front hatch

little raptor
little raptor
#

based on the turret path

little raptor
#

and what is your current script?

marsh drift
#

config

class Eventhandlers: Eventhandlers
{
    class lightstoggle
    {
        init="if (local (_this select 0)) then {[(_this select 0), """", [], nil] spawn jzra_sb_fnc_lightToggle;}";        
    };
};

class CfgFunctions
{
    class jzra_sb
    {
        class scripts
        {
            file = "\jzra_sb\scripts"; // file path will be <ROOT>\My\Category\Path\fn_myFunction.sqf";
            class lightToggle
            {
                file = "\jzra_sb\scripts\fn_lightToggle.sqf"; // file path will be <ROOT>\My\Function\Filepath.sqf";
            };
        };
    };
};

fn_lightToggle.sqf


params["_v"];
_v = _this select 0;

while{alive _v} do{
    
if (isLightOn _v) then { _v animate ["lights_hide",1,true]; } else { _v animate ["lights_hide",0,true]; };
sleep 0.01;
 
};

little raptor
# marsh drift config ```cpp class Eventhandlers: Eventhandlers { class lightstoggle { ...

well looping is very bad.
but anyway afaik there's no event handler for lights
idk if there's a native engine solution for that, but if there isn't, you can use user action event handlers.
see:
https://community.bistudio.com/wiki/addUserActionEventHandler
for example, create a post init function that does this:

if (missionNamespace getVariable ["jake_headlights_action_EH", -1] != -1) exitWith {}; //don't add the EH if it was already added

_EH = addUserActionEventHandler ["headlights", "Deactivate", {
  _v = vehicle player;
  if (isLightOn  _v) then {
    _v animate ["lights_hide",1,true];
  } else {
    _v animate ["lights_hide",0,true];
  };
}];

jake_headlights_action_EH = _EH;
#

ofc it only works with player controlled vehicles...

#

you can ask in #arma3_config to see if there's a better solution. I personally don't know of any, but I'm not a model maker either blobdoggoshruggoogly

marsh drift
#

thank you for all of this will try it out now 😄

little raptor
drifting sky
#

However, now my problem is the method I was using in A2 to force AI to fire their grenade launcher, isn't working in A3. _unit selectWeapon _muzzle; _unit fire [_muzzle,_muzzle,_mag]; Any suggestions?

south swan
#

[aaaa, "GL_3GL_F"] call BIS_fnc_fire;
aaaa forceWeaponFire ["GL_3GL_F", "Single"]; both seem to work in my (limited) testing

drifting sky
#

I'm going to try that. But also, right now I'm setting the velocity of the projectile to get it to go where I want them to shoot it. Is there any simple way to get Ai to fire upon a specified position?

south swan
#
_unit fire [_muzzle, _mode, _magazine];``` seems to work (at least to some extent) for me 🤔
little raptor
#

if not that then try forceWeaponFire

drifting sky
wooden torrent
#

:)

#

make them shoot at a grass cutter

south swan
#

given that official tracers module spawns an agent, disables its animation and just rotates the entire model...

drifting sky
#

I can't get them to successfully shoot at invisible targets. Also, the ones built into arma 3 block both bullets and unit movement, so they're useless.

wooden torrent
#

like i said

#

grass cutter, helipad (invisible)

drifting sky
#

grass cutter?

little raptor
#

it's a decal

open fractal
#

invisible helipads are seen and used by AI. It's better practice to use createVehicleLocal and hideObject if you absolutely need an object

#

or check the box in the editor to hide it

drifting sky
#

can either of those objects have a side so that ai automatically can detect them and fire upon them on their own?

little raptor
#

no

#

they're empty objects

open fractal
#

you can set your own variable to them

wooden torrent
wooden torrent
#

what's the point of it

drifting sky
#

It's a separate question related to my suppression system, which I haven't mentioned yet.

#

I've got an awesome suppression system I was using in A2, but it uses invisible targets with a side that AI can detect and fire upon on their own.

#

Tried using CBA invisible targets, but they don't seem to work.

wooden torrent
#

I think CBA or ACE3 have a suppression module already

drifting sky
#

Mine's better. Presuming I can get it to work in A3.

#

Ok, so I've got them to shoot smoke grenades like this: isNil { _unit setVariable ["SMOKE_EVENT_CONSTANTS",[_vel,_vv] call func_VEC3_scale]; _unit addeventhandler ["fired",{ (_this select 6) setVelocity ((_this select 0) getVariable "SMOKE_EVENT_CONSTANTS"); player sideChat format["shooter: %1, projectile: %2, event handler: %3", (_this select 0), (_this select 6),_thisEventHandler]; }]; _unit selectWeapon _muzzle; [_unit, _muzzle] call BIS_fnc_fire }; However there's a problem. They don't fire the nade immediately, meaning the fire event is capturing other projectiles apart from the intended smoke grenade.

south swan
#

filter by ammo/magazine? params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; so _this select 4/5

drifting sky
#

Oh my god, nade rounds are absurdly bouncy.

open fractal
drifting sky
#

I want control over the size of the area they fire upon

#

also over the length of time they're firing

open fractal
#

you can give each unit a random pos within a radius to fire upon

#

yeah looks like time is always going to be random

drifting sky
#

is the fourth element of the position parameter its size?

#

also, will they fire grenades and rockets?

#

my A2 version they fire anything they got, grenade rounds, hand grenades, rockets. The works.

south swan
#

i don't think doSuppressiveFire takes 4-element arrays, docs ask for PositionASL. I believe they meant "assign a different targets with random offsets from the center to different units". Also i don't think bots would use everything, at least in my (limited) testing grenadier was only shooting his rifle. And with the rifle mags removed he refused to shoot;

drifting sky
#

I really need to find a way to get invisible targets to work correctly.

lapis ivy
#

Tell me, is it possible to make it so that the players in the north of the Arma 3 game have the same nickname in Discord, Team Speak and in the game itself? Something like a white list, but I need to implement a discord.

#

My players use out-of-game communication between themselves, although we use TFAR. I can't find these players in my Discord channel because their username is different from their in-game and Team Speak nicknames

hallow mortar
#

An automatic integration between Discord and Arma is not something I've ever heard of and I think it's unlikely to be possible.
As a Discord server admin, you could change the players' server nickname to match their ingame name, after asking them.
Or just ask people to use the same name.

cold flower
#

You could just enforce your rules and tell them to conform

Sounds like an organizational issue

lapis ivy
#

This does not work. There are rules, but it is not always possible to track everyone. I'm thinking about the procedure for registering and manually adding player names to the white list of the server.

open fractal
#

Possible? Yes, but it would be much more effort than just enforcing your rules as the above said

lapis ivy
#

But I would like to know if there is a discord bot that can do this?

open fractal
#

that can do what, precisely?

lapis ivy
#

Add player names to whitelist

open fractal
#

yes

cold flower
#

He wants to automate name recognition across all three platforms. TS, Discord and Arma

open fractal
#

you can make a bot to add names to a list pretty easily

open fractal
#

it's getting that data from elsewhere that's the hard part

cold flower
lapis ivy
#

Oh, I'm glad it's possible!

lapis ivy
#

The fact is that a lot of people come every day.

cold flower
#

Then I really don't know what to tell you

You could find a bot that enforces or changes names on Discord and maybe extract the data. You could do a server whitelist that looks for specific names

But you're going to end up making people pissed no matter the decision you decide

lapis ivy
#

Why will they be angry? They violate the rules of the game project, and the rules have long indicated everything and they are.

cold flower
#

Because your people are not following the rules and want to do what they want

lapis ivy
#

There are problem players everywhere, this must be accepted as a fact. My task is to minimize their number. Thanks for the reply, I'll try to come up with something.

open fractal
#

The only way I can think to do that is by requesting steam id's from discord users and pulling profile name data from the server to be sent back to the bot. On the other hand, you can require users to submit their arma profile name upon joining your server and turn off the ability to change nickname. One of these is the better choice.

#

You can make them having permissions to join your discord server/game contingent on them providing you this data if it's that important. This is not something that should involve arma scripting. @lapis ivy

#

you can either sacrifice dozens or more hours of your time coming up with an "automatic" system that needs upkeep or enforce your rules.

rich rover
#

So I’m trying to make a wave combat scenario for some people and I’m struggling at keeping the wave part of it. I have the teams set up and the tutorial I watched gave me a script that I put into a trigger synced to a show/hide module, but the OPFOR still all spawn in at once

open fractal
#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

```sqf
// your code here
hint "good!";
```

// your code here
hint "good!";
lapis ivy
#

Do not quite understand. That is, can you make it so that when a player connects to the server, his nickname in my discord server will automatically change to the one he has in the game?

open fractal
#

it's not worth it dude

#

just enforce your rules

#

you're thinking of what teamspeak does with plugins. discord is not teamspeak.

lapis ivy
#

It's a pity, of course, I'm just familiar with one project where they have automated registration. BUT, they don't have Discord, they use site registration.

open fractal
#

literally

lapis ivy
#

OK I understood. Thank you.

open fractal
#

just take away the ability to set nicknames

#

it's that simple

#

you don't need anything that automatically updates

#

make a google form or a python bot or something

rich rover
#
//({ alive _x } count units W1G1 == 0) && ({ alive _x } count units W1G == 0) && ({ alive _x } count units W1G3 == 0) && ({ alive _x } count units W1G4 == 0) && ({ alive _x } count units W1G4 == 0) && ({ alive _x } count units W1G4 == 0) && ({ alive _x } count units W1G5 == 0);
#

This is my code

#

W1G1 stands for the Wave and Group

#

The units have this as their variable names too

open fractal
#

you might want to stop getting your advice from that youtuber

#

this code is fucked

rich rover
#

And I think the video is already 4 years old?

open fractal
#

literally don't know what they're doing and giving advice, like me but worse

rich rover
#

So is there a better way?

open fractal
#

let me decipher that mess and go from there

rich rover
#

Alright

south swan
#

looks like a trigger/whatever condition "if all members of all groups are dead", i suppose?

rich rover
#

Yep

open fractal
#

yeah

#

it's done in like the worst way though

#

im sorry it's really not that bad i'm just offended by that code for whatever reason

#

are the variables units or groups

south swan
#

i'd call that a surprise effect

rich rover
#

Or groups

#

Not very sure on the difference

open fractal
#

and you want the condition to be that they're all dead?

rich rover
#

Yep, once the first wave dies, the second wave spawns

#

Then repeat

open fractal
#

can you send all the trigger statements

rich rover
#

That's the only trigger

open fractal
#

yeah but what's in the activation field

rich rover
#

Nothing I believe

open fractal
#

so the trigger fires and then what?

rich rover
#

It is synced to a show/hide module

open fractal
#

oh

#

oh

#

how are the units spawned

rich rover
#

They're originally hidden, then once the trigger is done, the second synced show/hide sets the wave to show

#

And you're supposed to repeat this for every wave

open fractal
#

are there specific units that you placed down or did you just place a group from the editor

rich rover
#

It's a modded group, each group has their leader synced to the show/hide

open fractal
#

what do you mean modded group

rich rover
#

But yes, they're technically from the editor

#

It's a mod

open fractal
#

did you place down a pre-made group or not

rich rover
#

Yes

open fractal
#

what mod is it?

rich rover
#

COXHOUND

open fractal
#

if I had that addon downloaded I'd just write a script to spawn the group but we can stick with your hideObject method

rich rover
#

Oh, I'm fine removing it

#

tbf, I feel like it's more work keeping it

open fractal
#

I'll dm you because i got a plan

rich rover
#

Ok

open fractal
#

no crossposting on this server

rich rover
#

Yep

#

I only transferred here because it seemed better

south swan
haughty bone
#

greetings everyone. I am trying to work on a simple create a unit on top of a specific marker. I have placed this marker in my mission. Which is called spawnmarker_01. However it throws back an error at me. This is my code: ```_spawnPos01 = getMarkerPos "spawnmarker_01";
_createAttackGroup = createGroup [west, true];
_unit = "B_Soldier_lite_F" createUnit [position _spawnPos01 , group _createAttackGroup];

if (alive _unit) then{
//move unit to waypoint marker 01

// move unit to waypoint marker 02

// move unit to attack marker 01
};``` and the error i get thrown back at me is: Error position: Type Array, expected Object,Location. I am not sure as to what i am doing wrong here.

#

could it be because i am using Empty markers that dont show up on the map when i start the mission?

winter rose
#

you are getting marker pos, then are getting the pos of the pos

haughty bone
#

ahh i see. so it should just be _spawnPos01

winter rose
#

bingo!

haughty bone
#

ofcourse. makes sense.

#

thank you!

granite sky
#

That code's also using the wrong createUnit. That one doesn't return a unit reference.

#

and similarly to the position, group _createAttackGroup should just be _createAttackGroup

haughty bone
#

yea i saw that and changed it aswell. It spawns the unit now and now i can go further with the if statement which is throwing an error now

granite sky
#

Probably because it's using the wrong createUnit so _unit is nil.

haughty bone
#

which is saying: undefined variable in expression: _unit

granite sky
#

yes.

#

You want the standard syntax, not the alt.

haughty bone
#

_unit = group player createUnit ["B_RangeMaster_F", position player, [], 0, "FORM"]; this one?

granite sky
#

yes.

haughty bone
#

got ya thank you!

#

so what does the "FORM" do ? I thought it was part of the rank string but it doesnt seem to be?

elfin comet
#

I'd venture to bet that it deals with the formation of the group

south swan
haughty bone
#

yea looks like it indeed. am just reading through the wiki to make more sense of it

elfin comet
haughty bone
#

i am going to see if it's the case by testing something right now

grave jungle
hallow mortar
#

Depending on how your script is structured, you could use https://community.bistudio.com/wiki/admin on the server to instruct admin clients to create the menu (i.e. remoteExec a function on admin clients), or use https://community.bistudio.com/wiki/serverCommandAvailable on the client to determine whether it's an admin. Alternatively, if it's only for use on a server you control, you can keep a list of admin Steam IDs and check whether the client is one of those, which would allow access for admins other than the logged-in admin.
If you use a method other than Steam ID whitelisting, bear in mind that admin status can change mid-mission, so if you'd like the script to account for that you'll need to check multiple times over the course of the mission - otherwise only the admin who was logged in at mission start will have the option.

#

Also keep in mind that the communication menu may not be available to players in spectator mode or Zeus, whereas a custom GUI & keybind will be.

grave jungle
#

^^^ pin that +100

#

I will do whitelisting since it is the simplest for me to personally accomplish. I am the admin and it's just for my own streaming and fun

opal zephyr
#

Hi, I need to accurately get the unit name of the local player even in mp on a dedicated server. I don't have access to this kind of server to test if just using "player" works. I've seen some stuff online that suggests it can work in certain scenarios, but my general understanding was that "player" doesnt work in mp.

My goal is for the player to press a button and then I get a list of all the units in their group.

Any help is greatly appreciated!

granite sky
#

player works fine, if there is a local player (client for example). name player would give you their name.

opal zephyr
#

name player would give me like their profile name? Where as player would give me the unit name right?

granite sky
#

However in multiplayer name always returns profileName

#

There's no difference for MP apparently.

opal zephyr
#

hmm

granite sky
#

player is the object. It converts to the object's name (if any) in debug console output but in script it's still an object.

opal zephyr
#

so if it returns profileName, can I still use that for like "units" as the type parameter?

granite sky
#

hmm, I guess str _unit is potentially something else.

#

No, you have to keep the object to use it for commands that require an object as input.

opal zephyr
#

So "player" would not work in a multiplayer setting is what you're saying

granite sky
#

No...

#

My goal is for the player to press a button and then I get a list of all the units in their group.

#

units player works fine for this. Then you can do units player apply { name _x } or units player apply { str _x } depending on which you want.

open fractal
#

player works in multiplayer, it just does a very specific thing. check the wiki page for player, it returns the player unit belonging to the machine executing the command

#

if the script is not executed local to the player unit you want then use another method

opal zephyr
#

Thanks for the help, ill look into it some more

left coral
#

Hi I'm new here there's a way to move whit acceleration an object to point A to point B?

tacit glen
#

Does anyone know the display IDD or even if there is one for being in the virtual arsenal, im trying to get a keybind to trigger when the users presses enter in the VA and it isnt working for display IDD 46?

granite sky
#

actually came up yesterday if you search for "arsenal"

#

"arsenalOpened" has a display parameter.

#

@left coral setVelocityTransformation probably.

#

You can also use setVelocity or even addForce for increasingly manual control but I suspect that's not what you're after.

tacit glen
open fractal
#

relatable

still forum
# lapis ivy Tell me, is it possible to make it so that the players in the north of the Arma ...

If you make a Discord Bot you can do anything you want.

I have a system that connects our website accounts with TeamSpeak, Arma, Discord.
It can see names on all platforms and could enforce same name everywhere if we wanted to (but we don't bother).
If you have time and know programming theres little stuff you can't do 😄

Every player has a account in our system, and the server has a discord bot and a teamspeak bot to interface with both.
And Arma I could make but didn't have any need to do so, so far it can only read the logs.

The discord bot could change their nickname, the teamspeak bot could poke/kick them if they join with wrong account, Arma side could also kick if name doesn't match.
But so far I didn't bother, telling people to be reasonable mostly works fine

ebon citrus
#

Can we have renaming players in mp environment, please?

still forum
#

no

left coral
#

Hi I'm new here there's a way to move whit acceleration an object to point A to point B? I Find that i can use KeyFrameAnimation to move the object, but it need to start when the player reach certain point (like a spot on the map) , there's a way to combine the start of the animation whit a trigger on the terrain?

ebon citrus
ebon citrus
#

And yes, you can use triggers. If youre going to use 3den keyframes, then a better place is #arma3_editor

lapis ivy
still forum
#

No. Would need alot of time to make it adjustible and I don't have that time

digital rover
#

Does setVelocityTransformation velocity interpolation in MP work for static objects? Or only for physx objects

winter rose
#

you can fake it by attaching them to other velocity-friendly objects

tough abyss
#

Is it scheduled to make findIf command compatible with hashmaps in the next Arma update?

little raptor
tough abyss
#

for stuff

little raptor
#

a hashmap already does finding

winter rose
#

use case plz (or no effort will be made this way)

little raptor
#

if you want to iterate through values use forEach

tough abyss
#

yeah but still less efficient than findIf

winter rose
#

use case please

tough abyss
#

what do you mean by case?

winter rose
#

a case where it would be useful

tough abyss
#

I don't have such case, it was just a random question

little raptor
winter rose
tough abyss
#

I was aiming to use it but as it is not available, I have chosen another way to do it

little raptor
#

if you want findIf convert to array first blobdoggoshruggoogly

winter rose
#
{
  if (_condition) exitWith { _result };
} forEach _hashMap
drowsy geyser
#

is it possible to have multiple drawIcon3D in a single Draw3D missionEventHandler ?

little raptor
#

@drowsy geyser here's an example 👆

drowsy geyser
#

i need to display different icons on different objects and i guess it wouldn't be good performance wise if i added multiple missionEventHandlers for all the objects?

little raptor
#

though performance is not the only concern here

#

you shouldn't add too many event handlers, because event handler IDs are limited

#

because numbers in SQF are floats, and any ID greater than ~16.7M becomes meaningless

drowsy geyser
#

okay thank you, i noticed fps drop after i added like 7 missionEventHandler

little raptor
drowsy geyser
#

yes some of them

little raptor
#

they're slow

#

for drawing, use ASLtoAGL getPosWorldVisual _obj
or unitAimPositionVisual for units

drowsy geyser
#

i just looked im using these getPosWorldVisual/modelToWorldVisual

little raptor
#

ok they're good

little raptor
#

there's probably something else wrong here

granite sky
#

Maybe if they were drawing something huge :P

winter rose
#

you shouldn't add too many event handlers, because event handler IDs are limited
because numbers in SQF are floats, and any ID greater than ~16.7M becomes meaningless

I'd say you have another problem before you reach that value 😄

little raptor
#

well IDs are always incremental and don't reset 😛

#

even if you delete all of them you still run out meowsweats

drowsy geyser
little raptor
#

but you said 7 EHs? were you drawing more than 1 obj per EH?

drowsy geyser
#

idk here an example (sry for bad scripting)

allBatteries = (allMissionObjects "Land_BatteryPack_01_battery_black_F");
{_x setVariable ["batteryEmpty",false,true];
} forEach allBatteries;


batteryIcons = addMissionEventHandler ["Draw3D", {    
      {     
      if (!(_x getVariable ["FlashActive",true])) then {    
     alphaText = linearConversion[1.9, 2, player distance _x, 1, 0, true];           
        drawIcon3D [getMissionPath "images\BatteryIcon.paa", [1,1,1, alphaText], _x modelToWorld[0.04,0,0.02], 3, 3, 0, "SPACE", 0, 0.04, "LCD14","center",true,0,-0.02];  
              };    
      }forEach allBatteries;    
}];
ebon citrus
little raptor
#

I'd say maybe getMissionPath is the thing slowing it down

#

no it's fast thonk

#

alphaText
don't use global var

#

I guess as John Jordan said maybe your icon is too big thonk

#

also you can just not draw if alpha is 0

granite sky
#

How many batteries is this?

drowsy geyser
little raptor
#

and you were doing 7 EHs? i.e 50 * 7 = 350?

granite sky
#

oh, the alpha 0 optimization is looking pretty strong here.

#

actually maybe do inAreaArray on the things first...

drowsy geyser
granite sky
#

If you don't care about stuff >2m away, pre-cull it.

little raptor
ebon citrus
#

Or jsut look for batteries within 2m inside the EH

#

Eliminates inAreaArray and makes it a bit more dynamic

little raptor
#

not outside

ebon citrus
#

nearEntities or whatever was the fast one

little raptor
#

it's already dynamic

little raptor
ebon citrus
#

The array doesnt include nrw added batteries

little raptor
#

or static objects

ebon citrus
#

I dont remember

#

NearestObjects

#

There are 100 of them

#

Read the dock and pick one

granite sky
#

oh wait, is the allMissionObjects inside the EH...

little raptor
#

the game would probably be at 1 FPS at that point...

ebon citrus
#

Tbh, i just recommend looking for the items within 2m raidus inside the EH

little raptor
#

oh it's just 2m?

#

then yeah nearestObjects is fast enough

ebon citrus
#

Much faster than iterating and measuring area distance over an array of 50 objects

granite sky
#

Oh, inAreaArray is surprisingly fast. Probably not much different there.