#arma3_scripting

1 messages Β· Page 648 of 1

little raptor
#

I think they are. Because some functions are stored in the uiNamespace. And if they have preStart = 1, that means that the uiNamespace exists
That's just what I think

cosmic lichen
#

Yes, diag_log uiNamespace returns "namespace"

#

so that's not it

little raptor
warm hedge
#

How did you throw _this into the script?

past mist
#

@atomic crow you passed a boolean (true\ false) value to the first parameter (that is defined to get a number).

#

how are you calling the function?

pale ridge
#

so i want to have array with random numbers:
[0,0,random 1 or 0,random 1 or 0,random 1 or 0,random 1 or 0], what's the best way to do this?

winter rose
willow hound
#

Well, looks like your conversion from Boolean to Number doesn't work...

#

What does your MAIN_SETTINGS_TYPE macro look like?

still forum
#

SQL injection, fun

atomic crow
#

its quiet large to post it here.
And yeah nah maybe.. the asyncCall function was renamed before posting it here haha

tough abyss
#

Just out of curiosity, whats the best way to go about shading a map to limit the focus on to a specific area? Do I just use the rectangle markers in the editor?

winter rose
tough abyss
#

Any chance you know what it is called?

willow hound
#

Cover Map

tough abyss
#

10 4

#

Its not very dark though

#

Wondering how to make it pitch black

limber panther
#

hello everyone, i need help with a script. In multiplayer game i placed a noticeboard with addaction script. When player uses it, the script executes an sqf file. In that file i need a script that would give the player who executed it extra score. The point of this is to prevent player from getting negative score during the game and getting flagged as teamkiller. I've tried this:
player addPlayerScores [1000000, 1000000, 1000000, 1000000, 1000000];
as well as this
_player addPlayerScores [1000000, 1000000, 1000000, 1000000, 1000000];
but it didn't work. I have also tried putting this
this addPlayerScores [1000000, 1000000, 1000000, 1000000, 1000000];
into init of every single playable unit but it also didn't work. Any ideas please?

normal abyss
#

You'd want to pass a param through for (_this select 1)

limber panther
#

Could you please write the whole script for me?

willow hound
limber panther
#

understood but can you send me what should it look like? i'm not a pro in scripting i don't understand it so it's difficult to me to combine more commands into one script

winter rose
limber panther
winter rose
#

yep!

limber panther
#

appreciate it, i often struggle with scripts in arma, may i send you a pm next time i'll need help again?

winter rose
#

use this channel first, it is here for that πŸ˜‰ I also might not be available, while others are!

limber panther
#

ok thank you i was just asking for a permission to write you a message, some people hate receiving unrequested messages

winter rose
limber panther
#

by the way are you familiar with mcc?

winter rose
#

nope

limber panther
#

that's pity, i've got one more script that doesn't work but it's related to mcc

exotic flax
#

tip: don't use MCC, it breaks a lot

limber panther
#

i've already heared about it but nobody ever told me what exactly it does and so far it has benefits to me

#

haven't encountered any problem yet

limber panther
ashen warren
#

hi guys, Looking to optimize my coding a bit. Is there a way to have this command done by using a compileFinal PreprocessFileLineNumbers

_eventForShotFiredNear = player addEventHandler ["FiredNear", {_this execVM "shotFiredNear.sqf"}];

#
_FiredNear = compileFinal preprocessFileLineNumbers "shotFiredNear.sqf";

_eventForShotFiredNear = player addEventHandler ["FiredNear", {_this call _FiredNear}];

I'm a summing it would look like this?

willow hound
little raptor
#

never ever put a scheduled code like that (without checking whether the last code is done) in an event handler

#

{_this call _FiredNear}

#

not defined in that scope

ashen warren
#

? I guess I don't understand how it its "scheduled"

little raptor
#

_this execVM "shotFiredNear.sqf"

#

execVM is scheduled

ashen warren
#

thats why i was hoping to move away from that to using Call. Was hoping to have this in ram if i understood this correctly

#

if i am completely off point on what I thought. then I guess I was taught wrong weeks ago

little raptor
#

hm? about what?

ashen warren
#

well techically half of this mod i'm putting together is basically rereading files off of the disk and not saving it in ram

#

unless my friends translation was incorrect

little raptor
#

yeah that's bad
not just reading but recompiling

willow hound
#

And the solution is making it a function krtecek

ashen warren
#

part of the mod is basically pulling an array of data from a large list in the worst portion so yea. about over 1000 classnames being sorted every second

little raptor
#

over 1000 classnames being sorted every second
you might wanna do something about that too

ashen warren
#

well. Looking into that as well

#

hoping to put the array function that runs once then can get passed down to the loop

little raptor
#

I mean what's the point of that loop?
and there's also global variables

ashen warren
#

well its a dynamic situation mod (adaptive music mod on the workshop). runs and checks for weather/player activity every second

#

it works but poorly optimized

little raptor
ashen warren
#

well I wanted to do a switch command

#

cause techically it runs about 30 different if statements

little raptor
#

if + exitWith is faster

ashen warren
#

don't believe that will work on this

little raptor
#

and yet switch does?!

ashen warren
#

its a bunch of if else statements

little raptor
#
call {
  if (_isRaining && {_someHeavyCondition}) exitWith {};
  if (... && {... && {... && {...}}}) exitWith {};
}
little raptor
ashen warren
#

example of a portion. most of it follows the same example

    //If there was no fight before or music ended, new games
    if(currentMusicState != "combat" || isMusicCurrentlyPlaying == 0) then
    {
        currentMusicState = "combat";
        if(vehicle player != player) then
        {
            //Fight in the vehicle
            _selecter = floor(random count _movingFastTracks);// Track02_SolarPower
            playMusic (_movingFastTracks select _selecter);
            duration = (_movingFastDurations select _selecter);
            currentTrack = (_movingFastTracks select _selecter);
           
            if(debugging == 1) then
            {
                hint format ["Changed music to InVehicleFightMusic Trackname: %1", (_movingFastTracks select _selecter)];
            };
        }
        else
        {
            //Fight on foot
            wasInCarBefore = 0;
            _selecter = floor(random count _combatTracks); //Track07_ActionDark
            playMusic (_combatTracks select _selecter);
            duration = (_combatDurations select _selecter);
            currentTrack = (_combatTracks select _selecter);
           
            if(debugging == 1) then
            {
                hint format ["Changed music to NormalFightMusic Trackname: %1", (_combatTracks select _selecter)];
            };
        };
        2 fadeMusic Volume;
        isMusicCurrentlyPlaying = 1;
        durationSinceTrackWasStarted = 0;
    };
little raptor
#

I don't see why you think it won't work

#

_selecter = floor(random count _combatTracks); //Track07_ActionDark
playMusic (_combatTracks select _selecter);

#

selectRandom

#

_combatTracks
_combatDurations
_tracks = [["name", duration]];

ashen warren
#

idk why i decided to put an older version. this is actually what a if statement for one of the on foot detections is now. not the one above.


//These tracks will play when player enters fog area.
_fogTracks = "'fog' in getArray(_x >> 'parameters')" configClasses (configFile >> "CfgMusic");

            if(fog >= 0.3) then
            {
                //playing fog music
                wasInCarBefore = 0;
                _selecter = configName selectRandom _fogTracks;
                playMusic _selecter;
                duration =  getNumber (configFile >> "CfgMusic" >> _selecter >> "duration");
              
                if(debugging == 1) then
                {
                    hint format ["Changed music to Fog Music Trackname: %1", (_selecter)];                
                };

            };

little raptor
#

why do you even need the duration?

ashen warren
#

keep from overlaping

#

it happens

#

also for fading

little raptor
#

are you familiar with music event handlers?

ashen warren
#

I guess not particularly with music event handling. just the one specific way

ashen warren
#

this is using a playmusic though

little raptor
#

so?

#

you're using playMusic too

ashen warren
#

this is the portion that requires duration

if(durationSinceTrackWasStarted > duration - 5) then
{
    2 fadeMusic 0;
};
if(durationSinceTrackWasStarted > duration - 2) then
{
    isMusicCurrentlyPlaying = 0;
};

Yea playMusic _selecter;

little raptor
still forum
little raptor
#

isMusicCurrentlyPlaying == 0
use bool

#

isMusicCurrentlyPlaying = false
!isMusicCurrentlyPlaying

ashen warren
#

Well... I guess I will have to go and rewrite a good percentage of this thing

#

if not all of itwut

solar chasm
#

Does the init field disallow comments?

I've commented successfully in sqf (both line and block), but when pasting a script into an init field in the editor, comments seem to return an error.

I've mainly tried // single line comments, and even tried adding a trailing semicolon, just in case.

TIA.

spice thistle
#

Hello,
I would like to share with you a question I have.
I don't know if it's a miss-understanding from me or if there is a bug in the function playSound3D but when I specify an offset in MP, the player on which the command is executed works well but all other players will start the sound from offset 0.
Anyone facing the same issue ?

winter rose
solar chasm
#

Thanks @winter rose
I might just forgo comments then (unfortunately). One of the things about the comment syntax is that it is easily parsed when reading through code, and I feel like just putting quoted test might make the file too busy.

solar chasm
#

Follow up, bug-chasing question - I'm getting a blank "Init:" dialogue when I try loading my code into the init box of an object. I'm used to seeing an additional dialogue that indicates what's throwing the error (usually with a |#| or similar indication of where it popped up), but that's not appearing.

I've isolated the ~30 line stretch that is throwing whatever error, and am not seeing anything on a couple passes ... is there something specific that blank dialogue implies, or just a general / unspecific error?

winter rose
#

…you have a 30+ lines init? o_o

solar chasm
#

Yeah. It's Pandemic's immersive HALO jump script. I'm digging into it to customize it for our unit a bit.

winter rose
#

if it is MP, it will be executed by each and every client machine, players joining in progress included

solar chasm
#

Ah. Yup, MP. Well I know we've used it successfully in the past w 20+ players. Does that include if it is baked into the map, so is generated prior to anyone spawning? That's generally what we do for jumps.

#

(I'll admit, I'm one of those Arma coders that knows just enough to get into trouble. My background is BASIC and LOGO from the 80s.)

fair drum
#

there a big difference between titleText and cutText?

robust hollow
#

you can only define layers in cutText (avoids conflicts with other mods), titleText always appears above cutText layers, and the titleText layer hides when the esc menu is open so it might be linked to display 46 somehow, not entirely sure on that part.

tropic thunder
#

Looking for some geometry help here.... Lets say I have two points, p1 and p2 and an edge e1 between these points. Now lets say I have a third point, p3. How can I tell if a line from the player position to p3 intersects e1? (ie that p3 is "behind" e1 from the perspective of the player)?

tropic thunder
#

Unfortunately I think all of those are just checking intersections with game objects, not intersections with other vectors

jade abyss
#

That was the part i was unsure about

tropic thunder
#

Appreciate the help though πŸ‘

jade abyss
#

I guess, cheap way is getting the Angles of p1+p2 against each other, then the angle to P3

#

If P1 == "negative" of P2 + angle to P3 != angle from p1->p2 == done

tropic thunder
#

Ah finding if p3 is between p1 and p2

solar chasm
#

is there a scripting function command that allows one to set garage options (cosmetics, etc) on vehicles spawned with createVehicle? I've been looking at the wiki and not finding anything.
(For example, spawning a MBT and making sure it has applicable camo netting on it; or a Rosomak, and adding armored stand-off slats)

#

Ofc, as soon as I posted this, found the 'vehicle customization' link on the wiki. Digging into it now, but any advice appreciated.
Edit - aaaaaand it looks like those are functions to be used in config files, not scripting commands...

fair drum
#

how do i figure out the attach point coordinates on a unit to say attach something to his hip area?

copper raven
spice thistle
robust hollow
#

sounds like a bug

spice thistle
#

Thank you for your response Connor, I will try submiting a bug report

half moon
#

I have a function which would need to be run when there's a certain goggle in the goggle's slot. Now I have manual ace-interaction to do this check, but I'd like it to be automatic, but I'm not really sure how to go with this.

#

Oh btw this is within an addon.

spice thistle
hollow thistle
half moon
#

[]spawn {
while ({alive _unit && _gogglesCurrent in odensbags_Array && (_unit getVariable ["murshun_cigs_cigLitUp", false])}) do
{
call pvmod_odens_under_lip;
};
sleep 10;
};
};

#

this is what I came up with

#

but it says it misses { from the last line

#

dunno if there's a better way to post code around here

finite sail
#
/* your code */
hint "good!";
#

see

#

pinned post

cosmic lichen
finite sail
#

that ^^^

half moon
#
/* your code */
[]spawn {
    while ({alive _unit && _gogglesCurrent in odensbags_Array && (_unit getVariable ["murshun_cigs_cigLitUp", false])}) do
        {
        call pvmod_odens_under_lip;
        };
        sleep 10;
        };
};
#

Cheers lads

cosmic lichen
#
[] spawn
{
  while ({alive _unit && _gogglesCurrent in odensbags_Array && (_unit getVariable ["murshun_cigs_cigLitUp", false])}) do
  {
    call pvmod_odens_under_lip;
    sleep 10;
  };
};
#

I guess that's more like it?

half moon
#

Cheers, I'll try it. Dunno if it works though even if written properly. Just something I thought of after 2 minutes of googling.

pliant stream
#

a snus mod? 🀣

half moon
#

It is haha πŸ˜„

#

But yeah the code doesn't work 😦 Doesn't give any errors but it's not launching the "under_lip" function.

cosmic lichen
#

Probably because _unit and _gogglesCurrent are not available inside spawn {};

#
[_unit, _gogglesCurrent] spawn
{
  params ["_unit", "_gogglesCurrent"];
  while {alive _unit && _gogglesCurrent in odensbags_Array && (_unit getVariable ["murshun_cigs_cigLitUp", false])} do
  {
    call pvmod_odens_under_lip;
    sleep 10;
  };
};```
wet hill
#

Hi, anyone knows the script to knock down people in multiplayer (with ACE unconscious effect)?

lusty canyon
#

is there a script way to make any object/equipment thermal masked? or is it config only rvmat like

hiddenSelectionsMaterials[] = {"\A3\Characters_F_Exp\BLUFOR\Data\H_HelmetB_TI_tna_F.rvmat"};
real tartan
#

createVehicleCrew creates vehicle crew corresponding to vehicle's faction. however, I need to create driver/gunner for drone but with different faction.

#
    private _vehicle = createVehicle ["I_UGV_01_rcws_F", [0,0,0], [], 0, "NONE"];
    _vehicle engineOn true;

    if ( isNull (driver _vehicle)) then 
    {
        private _driver = _group createUnit ["O_Pilot_F", [0,0,0], [], 0, "FORM"];
        _driver assignAsDriver _vehicle;
        _driver moveInDriver _vehicle;
    };

    if ( isNull (gunner _vehicle)) then 
    {
        private _gunner = _group createUnit ["O_crew_F", [0,0,0], [], 0, "FORM"];
        _gunner assignAsGunner _vehicle;
        _gunner moveInGunner _vehicle;
    };
limber panther
#

Hello everyone! Is here any volunteer interested in making a favour for me? I'd like to have a script, that will work as a spike strips in game. Haven't found anything already done among scripts or workshop mods. After googling possibilities, my idea is following: Player takes a laser designator and points the laser on the ground where the spike strip should appear. (There can be also limitation on distance how far from the player can it be) Then, using a trigger, player will use radio alpha (example) to execute the script (activate trigger). Now should appear something on the road (for example flattened barbed wire fence). When any vehicle drives over it, the vehicle should get something damaged. It can be either wheels or fuel tank. Damaging wheels may result in crash, damaging fuel will cause leak and fast drainage of the fuel leading to a safe stop. But it doesn't really matter. After all of this there should also be a way how to remove the spawned item. This is my idea but it can be done also a different way. Is here anyone able to create such a thing for me? Thank you
(by the way it's meant to be used in multiplayer on dedicated server)

willow hound
limber panther
finite sail
#

might want to put an occasional newline in the text while you're about it

next kraken
#

hi guys, is it possible to make linebreaks in that hint command ? tried <br> but it doesnt work;-(

#

hint formatText ["%1%2%3", "line1", "<br/>", "line2"];

#

?

solar chasm
#

@fair drum I need to get my eyesight checked, because I had looked at that and missed the method for calling it from an init field! Thank you!

brave jungle
#

Is it possible to set the main menu world using playScriptedMission? Wanting to have the same world loaded everytime.

winter rose
brave jungle
#

Yeah butttt

#

I have a custom rscDisplayMain

#

And I wanna use the same map, as it makes this design sort of well... work

#

is the best representation

winter rose
#

make a mod? 😬

brave jungle
#

Yeah I am

#

But I want it to load the same world everytime

winter rose
#

but then you might be able to force the loaded terrain - just that if you leave e.g Altis, it will come back to Altis

brave jungle
#

im gussing thats how its loaded as I don't see a loadWorld command

#

Thats what im after πŸ˜„

#

I mean I don't see in the configs anywhere to force the world load on startup so im guessing its done in the engine. My next idea was to use that command and then I could just use a premade pbo everytime

winter rose
#

I believe it can be a config setting, but then I have no idea how (#arma3_config may know)

brave jungle
#

Okay i'll switch, cheers

drifting sky
#

Arma2OA: Is there a gold standard for detecting when AI led groups get (chronically) stuck, and for a way of unstucking them?

winter rose
#

stuck, as in…?

drifting sky
#

stop moving for ever

#

not following waypoint

winter rose
#

when does it happen?

if they are totally immobile, you can maybe check unitReady and if false, if they are at the exact same location 10s later, teleport them somewhere close for the pathfinding to rework

drifting sky
#

I think it mainly happens after contact with the enemy

fair drum
solar chasm
#

Doh.

#

Fat fingers on mobile phone

drifting sky
#

or possibly when a vehicle is destroyed in their group

#

hard to tell what the cause is really

solar chasm
#

@robust hollow that's was a thank you for you - had missed how to call that function from an init!

drifting sky
#

I was hoping there was an all purpose solution for detecting why an ai group has stopped following its waypoint

#

can a MOVE waypoint ever be prematurely cancelled?

next kraken
little raptor
drifting sky
#

is there a way specifically to detect that

little raptor
#

in A2 no (not that I know of)

#

in A3 kinda

hot lichen
#

you could check if the units are fleeing

drifting sky
#

already have fleeing disabled

polar saffron
#

hi how can I make the independent faction go from ally to enemy in the middle of the mission?

fair drum
#

what classifies something as an "entity", because I can find some of the objects from mods I'm placing in allmissionobjects "all" but not in entities "all"

little raptor
fair drum
#

ah okay. well its definitely not living lol

little raptor
#

well not necessarily "living"
but I don't think stuff like buildings and props count as entities

spiral temple
#

I may need a little help. I have the coordinates [-0.999994, 0.00356055, 0], which should be the dir vectors, but how I can get the actual direction in °? sadly I dont own the original mission.sqm anymore, so I have to deal with that problem... 😦

little raptor
#

gives you an angle that can be used with setDir (if I understood you correctly)

spiral temple
#

oof... I see a lot of re-script... better redesign all objects πŸ˜„

little raptor
#

what do you want to do again?

spiral temple
#

Exile Traders, currently I have them set in the way Exile Eden export them, but I need real coordinates X, Y, Z, Dir

winter rose
#

you can also play with sin and cos

little raptor
#

he means atan2 πŸ˜›

winter rose
spiral temple
#

I had trouble to understand that in my a-level class, but completely forget that on university lol

#

anyway, thanks for your help guys πŸ˜‰

young dome
#

Hey all, I've come across a weird thing when building a mission where after using the Fade Effect function, a music track that's triggered to play 15 seconds or so afterwards does not play, or at least is not audible whilst the SFX and environment are.
I have a trigger, and in it's activation field theres a fade out effect:

 [0,"BLACK",3,1] spawn BIS_fnc_fadeEffect;

And then another trigger is linked to that to fade back in after a couple seconds:

[1,"BLACK",3,1] spawn BIS_fnc_fadeEffect

Then on another trigger delayed to run 15 seconds after the fade in trigger, theres another trigger that will activate and it does activate, all the AI waypoints that are activated by that trigger do work, but the music that's meant to play during said trigger is not audible. I use 3den enhanced, so the music is simply chosen from a checkbox, but I've tried calling the music in the activation script and it doesn't work there either.
Looking at the optional parameters for BIS_fnc_fadeEffect, theres nothing that would appear to fix this, the closest is fadeout music but i don't really want a track to play whilst it fades out.
Is there a fix for this or should I workaround this by trying a fade out/fade in effect that doesnt affect audio?
For the record, yes, the music IS added correctly. It plays perfectly fine before the fade function, but doesn't work afterwards.
If this is better off in #arma3_scenario or some other channel just let me know

winter rose
#

nope it's here, no worry

little raptor
#

it's probably still running in the background

#
Music_fadout_handle = [0,"BLACK",3,1] spawn BIS_fnc_fadeEffect;
terminate (missionNamespace getVariable ["Music_fadout_handle", scriptNull]);
[1,"BLACK",3,1] spawn BIS_fnc_fadeEffect
drifting sky
#

Okay, I figured out one of the main reasons AI groups are getting stuck. Crewmen bail out of a disabled vehicle. And then just sit there next to the vehicle forever.

young dome
# little raptor try terminating the script

Hmm, doesn't seem to work. The scripts run with no errors in syntax or anything, but it's same thing. I've also tried naming and terminating the fade in effect as well, both in the trigger where the music's supposed to play, and in a separate trigger that activates a couple seconds before the music, but no change in either case.

little raptor
young dome
#

Eh, a little out of my reach. The problem is just with the fade out effect i.e [1,"BLACK",3,1], whilst [0,"BLACK",3,1] is fine. I can just do with the fade in effect as its passable. Thank you for the help though!

little raptor
#

reset the music volume back to the default value

young dome
#

Woah, adding that in before the fade in function made it work! Thank you! No clue as to why though, perhaps the fade out function fades the music to 0 but the fade in doesnt change it back for some reason?

little raptor
#

yeah

#

that was probably why

winter rose
#
_BIS_fadeDuration fadeSound 0;
_BIS_fadeDuration fadeMusic 0;
_BIS_fadeDuration fadeSpeech 0;
// vs
_BIS_fadeDuration fadeSound 1;
_BIS_fadeDuration fadeSpeech 1;
young dome
#

yeah, thats honestly a bit weird, did BI not expect people to use fade in after using fade out? Anyway, thanks a lot!

limber panther
#

hi @winter rose may i ask you a question? i've asked here in this chat already some time ago but nobody helped so i'm wondering that maybe you could know the answer

limber panther
#

i'm afraid i don't, what is it?

winter rose
limber panther
#

that's brilliant! i had no idea that such a thing exists!

cerulean cloak
#
[
    Mort_1,
    target_0,
    "",
    15,
    6,
    [1,3]
] spawn BIS_fnc_fireSupport;

I'm trying to get a mortar with variable name Mort_1 to fire on target target_0 however, it's not working and I'm getting this <spawn> private _fnc_scriptNameParent = if (isNil '_fnc_scriptName') then {'BIS_fnc_fireSupport'} else {_f in the output of the debug console

robust hollow
#

because it is returning the spawned script

cerulean cloak
#

How do I fix it?

robust hollow
#

is there a log in your rpt file saying why it isnt working?

astral tendon
#

I am having a little dilemma here, is it better make a public variable and store a array information into it or to make a variable to a object?
Example:

//Make a variable for the awacs selection
private _VehicleVariable = ("RTG_AWACS_N" + (str (floor random 100000)));
_Vehicle setVariable ["AWACS_Number",_VehicleVariable, true];

// or

///add to the vehicles available as a awacs
RTG_AWACS_AvailableVehicles = RTG_AWACS_AvailableVehicles + [_Vehicle];
//add it to all players
publicVariable "RTG_AWACS_AvailableVehicles";

of course I am aiming at multiplayer reliability and its planed to be updated during mission.

robust hollow
#

that is basically the same thing, just saved to a different namespace

cerulean cloak
#

Can't find anything for firesupport in the RPT

astral tendon
robust hollow
#

if the value only needs to exist until the object is deleted then sure save to the object, otherwise i'd just do publicvariable

winter rose
astral tendon
#

There is a possibility that the object can die in mid mission.

cerulean cloak
#

Absolutely, I tried it myself with the arty computer and it works just fine.

astral tendon
#

So I was thinking update that if the object dies and remove from the array or delete the variable

astral tendon
#

Whats the difference? performance?

little raptor
#

yes

#

and you didn't answer why you want to do that?

astral tendon
#

Because I need those variables to be used by the clients to check how many awacs there is in the mission so they can select one.

little raptor
astral tendon
#

Thats the issue, It will be up to the mission maker how many he will put on the mission, that is something I don't have control so I am preparing for the worst

astral tendon
little raptor
#

remoteExec a function

little raptor
#

so that they won't make unnecessary calls to the server

little raptor
#

publicVariable

#

you have to make a framework for that
something like:

fnc_addVeh = 
{
...
_id = available_vehs pushBack _veh;
number_of_vehs = _id+1;
publicVariable "number_of_vehs";
...
};
fnc_takeVeh = 
{
...
available_vehs = available_vehs - [_veh]; //or you can use deleteAt 0 and give them the first veh from the pool
number_of_vehs = count available_vehs;
publicVariable "number_of_vehs";
...
};

etc.

astral tendon
#

Seems like you are making just more data to run around the server
seens about the same as

RTG_AWACS_AvailableVehicles pushBack _Vehicle;

//add it to all players
publicVariable "RTG_AWACS_AvailableVehicles";

Since I am just saving the object into a array

little raptor
#

how does that even compare?

#

and what I say merely sends numbers

astral tendon
#

Because this will be executed from the server, yours is sending two information, the vehicles and the index to select

little raptor
#

no mine is merely asking the server to select one for me

#

and even if you did send both the vehicle and the index, it's a one time thing

#

you wouldn't be sending the whole array to every client in the network when something changes

astral tendon
#

Thats the problem, I need a list of available vehicles, thats why I was sending a array

#

The two ideas was to either save it as a array or to mark the vehicles in the mission with the setvariable and then checked by the player

severe vapor
#

I am looking to make a scenario where there is an item on a dead body and if the player retrieves this item it activates a trigger. I was thinking of putting it in the condition of a trigger and limit the area so its not checking all player inventories all the time. I'd like to do something like this in the condition:
this && { return "JLTS_intel_trackingFob" in items _x;} foreach _thisList;
I tried to assign the "output" of the loop to variable and then put the condition after and I also tried to return that. I haven't been able to find a good example of more complicated checks like this in the condition field and this is very different then the java I'm used to. Appreciate the help.

winter rose
#

see findIf for performance πŸ™‚

astral tendon
#

@little raptor What about:

_Available_AWACS = (missionNamespace getVariable "Available_AWACS") + [_Vehicle];
missionNamespace setVariable ["Available_AWACS",_Available_AWACS, true];

Or is just as bad the same as :

RTG_AWACS_AvailableVehicles pushBack _Vehicle;

//add it to all players
publicVariable "RTG_AWACS_AvailableVehicles";
robust hollow
#

does the same thing, just with more commands

astral tendon
#

Thing is multiplayer reliability

robust hollow
#

dont know what you mean by that.

astral tendon
#

Like, not being heavily effected by ping or sending too much data trough the network.

winter rose
#

you could restrict the refresh rate?

#

but if you want to send an objects' array, you will send an object's array πŸ€·β€β™‚οΈ unless you want to work an overly complicated server-send client-update system just for this

astral tendon
#

the only time when the array will be updated is when the object is added, dies or is deleted, or the client can even just check locally if the object is null or is dead and remove it from the array on hes side, so the server only adds to the array.

high marsh
#

I want parameters to be available to admins of a server when skipLobby is enabled. So that they can change the parameters if they want. Possible?

robust hollow
#

in the server.cfg with a restart, sure. or you could use the config paramaters as a base for your own parameter system in game (which i do).

high marsh
#

Actually didn't think about that second option. That works. I would really rather have them be able to do it on the fly versus having to restart. https://community.bistudio.com/wiki/serverCommandAvailable can check privy for admin status right?

#

(dumb question), yes

severe vapor
severe vapor
fair drum
#

any way I can speed this up? it takes about 10 ms when I put down 6 objects (this will eventually be hundreds) that classify as such.

        {
            if (_x isKindOf "TG_TiberiumGreen" || _x isKindOf "TG_TiberiumBlue" || _x isKindOf "TG_TiberiumRed" || _x isKindOf "TG_TiberiumPurple") then {

                _tiberium_fields pushBackUnique _x;
            };
        } forEach allMissionObjects "House_F";

I eventually want to run it on a loop that updates every x amount of time but don't want it to smash the servers/sp client

#

can't use entities since it isn't one

winter rose
#

you could try to use typeOf in array instead

fair drum
#

yes they are now that I'm looking through it. doesn't decrease much though. let me try something with typeOf

sullen sigil
#

would here be where i ask about configs

fair drum
sullen sigil
#

that'll be the one

#

ty, hard to tell where to be with so many channels

fair drum
# winter rose you could try to use `typeOf` `in` array instead

looks like they are about the same...

//isKindOf method with 1500 objects = 30-40 ms

//typeOf method
private _tiberium_nodes_active = [];
private _tiberium_classes = [

    "TG_TiberiumBlue_1",
    "TG_TiberiumBlue_1_Medium",
    "TG_TiberiumBlue_1_Seedling",
    "TG_TiberiumGreen_1",
    "TG_TiberiumGreen_1_Medium",
    "TG_TiberiumGreen_1_Seedling",
    "TG_TiberiumPurple_1",
    "TG_TiberiumPurple_1_Medium",
    "TG_TiberiumPurple_1_Seedling",
    "TG_TiberiumRed_1",
    "TG_TiberiumRed_1_Medium",
    "TG_TiberiumRed_1_Seedling"
];

{
    if (typeOf _x in _tiberium_classes) then {

        _tiberium_nodes_active pushBackUnique _x
    };
} forEach allMissionObjects "TG_Tiberium";

// 1500 objects 30-40 ms
#

is a 30-40ms delay huge if I have to run that script every 10 seconds or so?

winter rose
#

no

winter rose
fair drum
#

i think i might do some sort of nearObjects style of method instead. might be faster than iterating through the allmissionobjects every time

winter rose
#

well, if you only need the close ones, yes
it might be faster

astral tendon
#

I have this command

///get targets that the unit got in the radar
_UnitTargets = ConnectedAWACS targets [true, 0];


//remove targets that are not in the radar but highly know for the AI and remove non air targets
_AcurateTargets = [];
{
    if (((driver ConnectedAWACS) getHideFrom _x distance2D (unitAimPositionVisual ((ConnectedAWACS targets [true, 0]) select 0)) < 1)and (_x isKindOf "air")) then {_AcurateTargets = _AcurateTargets + [_x]};
} forEach _UnitTargets;

It works when ConnectedAWACS is a plane that is flying, but if is a ground vehicle with a radar it does not work and getHideFrom is inaccurate

This script is suppose to check the knowledge of the unit of a target about its position since there is no way to check what targets are on the unit radar

#

And the ground unit can actually see the target in the radar if I check with Zeus.

little raptor
past wagon
#

hey guys

#

i need some help making a script, and I dont know much about coding

#

i am making a battle royale game and everything is finished except for the loot system

#

i want to put down a bunch of supply crates and have the loot randomly generate when the game starts

limber panther
#

Anyways hi everyone! Is there a way to change mine effects? When i lay down a mine as a player i want it to be detonated by vehicle only and the explosion should only damage wheels or fuel tank. I don't want any exploding cars or dead/injured players.

#

Anyone has any idea? It can be a general rule (script) for all mines and explosives or whatever since i don't need these things for anything else

limber panther
#

In other words, is there a simple way (simple script) that would define all landmine explosions non lethal, damaging only certain parts of vehicles? Can be defined for one specific type of landmine or any landmine, doesn't really matter

#

Note: it's meant for multiplayer game

past wagon
#

i dont wanna use a mod, i wanna keep it all vanilla

tidal swallow
#

I have a quick question. I have a bomb defusal script. There are four laptops in game (each has their own variable name), the script randomly chooses the computer to be the code holder and wire color coder. After that there is a phone suitcase with it's own variable name that acts as a bomb (makes sense). What I don't understand. I get an action to defuse the bomb, but I don't get an option on laptops to get code (these are exact actions that should pop up). I tested the script in 3den editor singleplayer and multiplayer (LAN) and it works, but it does not work on dedicated server. What am I missing here?

tough abyss
#

Since in eden and lan, you are the server

#

Dedicated,you and the server are two different entity

tidal swallow
tidal swallow
tough abyss
tough abyss
tidal swallow
#

will do

tough abyss
# tidal swallow why 😳

I don't have a scientific evidence behind it, but normally people avoid variable names that might be used by the server such as null for example. Not too sure if "server" is in that list.

#

Like it doesn't hurt to use another safe choice so u know.... why not right

tidal swallow
#

thats true

#

thanks for the heads up

#

will look into it :D

tough abyss
#

No probs mate :D happy to help. Hope the code will work out for you

tidal swallow
#

same πŸ‘€

drifting sky
#

In a scheduled environment, is it possible to make sure it isn't interrupted in between two or more commands?

robust hollow
drifting sky
#

thanks

#

do you know if there is a performance penalty for doing that?

robust hollow
#

nothing more than the usual side effects/rules/whatever of unscheduled code

still forum
#

there is yes, but nothing you could measure in scheduled πŸ˜„

#

the performance penalty being the isNil command call and additional scope.
not more than a if..then..

cunning oriole
#

Is it possible to say called a python script todo something totally different and not in arma from inside sqf?

#

like instead of

execVM "test.sqf";

do

execVM "test.py";
exotic flax
#

not directly

warm hedge
#

Never

hollow thistle
#

look into Pythia

warm hedge
#

(Maybe via extensions, but yeah)

exotic flax
#

Pythia is basically: "I have some SQF stuff, but want to have Python "

warm hedge
#

Huh, didn't know that

cunning oriole
#

right cheers

#

oh shit Pythia is quite neat

still forum
#

πŸ˜„

ripe sapphire
#

hi guys, how are you

#

is it possible to change the value of multiple arrays to string in a forEach?
here my script

_va1= ["Exocet", "Firewall", "ijo"];  
_va2= ["Itsdren", "Phoenix", "merah"];  
_vas= [_va1, _va2];  
{     
//--- Format the text    
 _name = _x select 0;    
 _chara = _x select 1;  
 _color = switch (_x select 2) do {
        case "ijo": { "<t color='#90EE90'>" };
        case "merah": { "<t color='#ff0000'>" };
    }; 
 _text = format ["%1 as %2%3</t>", _name, _color, _chara ];    
 _x deleteRange [0,2]; 
 _x set [0, _text]; 
 _x = _x joinString "";
} forEach _vas;  
#

that didnt work lol

#

it worked up to set but i guess you cant change the value of _x itself?

cosmic lichen
#

no, _x cannot be changed

ripe sapphire
#

i see, i tried manually adding _va1 = _va1 joinString "";, and it worked turning it into a string

#

however i have a lot of variables that need to be converted and doing this one by one would be pain lol

#

any ideas?

cosmic lichen
#

Since your original idea was to change _x

still forum
#

this looks very much like you want apply

#

and your forEach _vas also.... uh.. doesn't look correct to me

#

ah no it is correct, confusing script :u

ripe sapphire
#

ok i am reading it but im still confused how to utilize it as still it doesnt modify the original array?

austere granite
#

@exotic flax that's not really it honestly, its still super useful but its by no means just using python instead of sqf for example
t. Only person that actually released mods using pythia? πŸ˜„

finite sail
#

no

#

i have it installed beause its a dependency

#

of.........

#

7erra editing extensions

#

but tbh, it's not loaded right now as I'm getting used to Leopards tools

little raptor
#

but as others said, you can just use apply

#
_array  = _array apply {call some_fnc_modifyX};
#

or in your script:

_va1= ["Exocet", "Firewall", "ijo"];  
_va2= ["Itsdren", "Phoenix", "merah"];  
_vas= [_va1, _va2];  
_vas = _vas apply {     
//--- Format the text    
 _name = _x select 0;    
 _chara = _x select 1;  
 _color = switch (_x select 2) do {
        case "ijo": { "<t color='#90EE90'>" };
        case "merah": { "<t color='#ff0000'>" };
    }; 
 _text = format ["%1 as %2%3</t>", _name, _color, _chara ];    
 _x deleteRange [0,2]; 
 _x set [0, _text]; 
 _x = _x joinString "";
 _x //or you could end it here with: _x joinString ""
};
ripe sapphire
#

_va1 stays unchanged?

little raptor
#

_va1 changes too

#

because of _x deleteRange [0,2];

#

you're deleting the first two elements

ripe sapphire
#

yes but it doesnt change into a string?

little raptor
#

no

ripe sapphire
#

it still a array consisting of 1 string

#

i need to change it to a string

little raptor
#

put another params after that 🀷

#

doesn't modify the original
but you still get what you wanted

#
_vas params ["_va1", "_va2"];
ripe sapphire
#

ahhh got it thats the command i was looking for, cause manually resetting va1= _va1 joinString, va2 etc would be a pain

#

thanks a lot! πŸ‘

little raptor
#

np

past mist
#

so, I noticed some units placed in the editor, when equipped with certain vests/backpacks, even if their loadout is set to be empty, they spawn with items inside. Any way to block this behaviour?

winter rose
past mist
#

not vanilla units unfortunately

#

but this seem to happen with a lot of mods

#

CUP is one of them with medic backpacks spawning with medical stuff inside

exotic flax
#

If you use respawns, download 3den Enhanced and use the "keep loadout on respawn" (or however it's called) to fix that

past mist
#

well, this does happen even in single player without respawns

exotic flax
#

In that case you may have a mod which messes it up

little raptor
#

@past mist for example CFP (community factions project) has so many intrusive randomizations

past mist
#

so, looking at the classes, i see that maybe the problem is from respawnLinkedItems respawnMagazines and so on

exotic flax
#

What's in your mission.sqm?
Does it have a script to overwrite the loadouts?
And are the backpacks the "base" ones, and not the filled ones?

past mist
#

backpacks are not an issue right now

#

my main issue is the vest

#

atm I'm trying to spawn some units without rifles/ammunitions at mission start

#

I removed that from their loadout

#

the moment I run the mission they are all with weapons and gear

past mist
exotic flax
#

...

#

If you set custom loadouts in 3den, this will be transformed in a script which you should see in the mission.sqm

past mist
#

oh

#

lemme check

exotic flax
#

And even then certain mods do their own thing, so they could be the reason as well

past mist
#

I guess the best way to do this is to run a script after every unit has spawned to override the loadout once for all

#

I save the unbinarized mission and took a look at it, I can see the values being set to the classes

#

at this point tho, I'm thinking, as this is set at unit classes level, can't I just use vanilla classes and then change their loadout to what I need? Would it work?

exotic flax
#

Of course, that's how I always do it

#

Makes it easier when mods change in the future, and I don't want to have a broken mission because of it

past mist
#

nice

#

thanks again!

past wagon
#

can you add a script in the initServer.sqf file that adds loot to supply crates?

winter rose
#

yes

past wagon
#

how would I do that?

#

is there a wiki page I can go to?

winter rose
#

carefully

past wagon
#

what is the

#

ummm

past wagon
#

does it have to be a vehicle

#

or does any storage crate work?

winter rose
#

click the link πŸ™„

past wagon
#

kk

winter rose
#

Commands used to manipulate a vehicle's (or ammo box) inventory
πŸ˜‰

past wagon
#

ok nice

#

great, thats a start

#

i have like 60 supply boxes

#

and i need their loot to be random (from a list)

winter rose
#

okay

past wagon
#

should i get all the item names for everything that I want to spawn in the crates?

winter rose
#

classnames would be nice

past wagon
#

ok

#

i think there is a wiki page that lists them

#

do you know where I can find that?

winter rose
#

yes

#

on the wiki

#

search for A3 assets

past wagon
#

ok

median abyss
#

Can you force a variable to be final? Without using compileFinal.

winter rose
#

you can always define a description.ext var and use getMissionConfigValue

median abyss
#

Kinda weird that we cant make a code block final, without having it as a string (in one way or another) πŸ˜›

winter rose
past wagon
#
hgun_ACPC2_F
9Rnd_45ACP_Mag

hgun_P07_F
16Rnd_9x21_Mag

hgun_Pistol_heavy_02_F
6Rnd_45ACP_Cylinder

hgun_Rook40_F
30Rnd_9x21_Mag

arifle_Katiba_F
30Rnd_65x39_caseless_green

arifle_MX_Black_F
30Rnd_65x39_caseless_black_mag

SMG_01_F
30Rnd_45ACP_Mag_SMG_01

srifle_DMR_03_F
20Rnd_762x51_Mag

SMG_03C_TR_black
50Rnd_570x28_SMG_03

arifle_AK12_F
30Rnd_762x39_AK12_Mag_F

arifle_SPAR_01_blk_F
30Rnd_556x45_Stanag

SMG_05_F
30Rnd_9x21_Mag_SMG_02

srifle_DMR_06_hunter_F
10Rnd_Mk14_762x51_Mag

sgun_HunterShotgun_01_F
2Rnd_12Gauge_Slug

These are all of the weapons that I want to spawn in the crates. I want each weapon to spawn with two respective magazines.

winter rose
past wagon
#

thats a good question

#

I think i need to make an array

#

how do arrays work?

median abyss
past wagon
#

i dont want them to be completely random

#

if an AK-12 spawns in, i want a couple of AK-12 mags to go with it

median abyss
past wagon
#

ok nice

#

first I need to make an array

#
private _weaponArray 
#

what do I do after that? how do I list the items?

past wagon
#
private _weaponArray = [];
winter rose
#

that's an array, yes

past wagon
#

alright

#
private _weaponArray = [hgun_ACPC2_F, 9Rnd_45ACP_Mag];

I added two items. is that correct?

#

@winter rose

winter rose
#

Nope

past wagon
#

didnt think so

winter rose
#

A classname is a string

past wagon
#

ok

#

do i need to define it then?

#
private _weaponArray = ["hgun_ACPC2_F", "9Rnd_45ACP_Mag"];
#

@winter rose

winter rose
#

So it seems

past wagon
#

ok how do I define it?

winter rose
#

you just did

past wagon
#

oh

#

ok

little raptor
#

no you need to follow what we taught you before in #arma3_editor
you need [weapon, mag] pairs

past wagon
#
private _weaponArray = [["hgun_ACPC2_F", "9Rnd_45ACP_Mag"], ["hgun_P07_F", "16Rnd_9x21_Mag"], ["hgun_Pistol_heavy_02_F", "6Rnd_45ACP_Cylinder"], ["hgun_Rook40_F", "30Rnd_9x21_Mag"], ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], ["arifle_MX_Black_F", "30Rnd_65x39_caseless_black_mag"], ["SMG_01_F", "30Rnd_45ACP_Mag_SMG_01"]];
#

can I add more items to the array just like that?

#

@little raptor yeah, I think thats what I did. does it look good?

little raptor
#

no

past wagon
#

oof

little raptor
#

for one, you're missing a [ at start

past wagon
#

oh yea

little raptor
#

for second missing ] at end

past wagon
#

yea i fixed it now

#

anything else?

little raptor
#

I don't think so

past wagon
#

ok thanks

#
private _weaponArray = [["hgun_ACPC2_F", "9Rnd_45ACP_Mag"], ["hgun_P07_F", "16Rnd_9x21_Mag"], ["hgun_Pistol_heavy_02_F", "6Rnd_45ACP_Cylinder"], ["hgun_Rook40_F", "30Rnd_9x21_Mag"], ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], ["arifle_MX_Black_F", "30Rnd_65x39_caseless_black_mag"], ["SMG_01_F", "30Rnd_45ACP_Mag_SMG_01"], ["srifle_DMR_03_F", "20Rnd_762x51_Mag"], ["SMG_03C_TR_black", "50Rnd_570x28_SMG_03"], ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], ["arifle_SPAR_01_blk_F", "30Rnd_556x45_Stanag"], ["SMG_05_F", "30Rnd_9x21_Mag_SMG_02"], ["srifle_DMR_06_hunter_F", "10Rnd_Mk14_762x51_Mag"], ["sgun_HunterShotgun_01_F", "2Rnd_12Gauge_Slug"]];

All done

#

those are the weapons at least

little raptor
#

I can't believe you literally just typed all of that meowsweats

past wagon
#

no ididnt

little raptor
#

there is something called automation using the config.
you can support custom mods too (RHS, CUP)

past wagon
#

i copy pasted

#

well

little raptor
#

still counts as typing!

past wagon
#

it wasnt that bad

#

took like a minute

#

and i typed it here in discord

#

now i need to make an item array

#

brb

#
private _weaponArray = [["hgun_ACPC2_F", "9Rnd_45ACP_Mag"], ["hgun_P07_F", "16Rnd_9x21_Mag"], ["hgun_Pistol_heavy_02_F", "6Rnd_45ACP_Cylinder"], ["hgun_Rook40_F", "30Rnd_9x21_Mag"], ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], ["arifle_MX_Black_F", "30Rnd_65x39_caseless_black_mag"], ["SMG_01_F", "30Rnd_45ACP_Mag_SMG_01"], ["srifle_DMR_03_F", "20Rnd_762x51_Mag"], ["SMG_03C_TR_black", "50Rnd_570x28_SMG_03"], ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], ["arifle_SPAR_01_blk_F", "30Rnd_556x45_Stanag"], ["SMG_05_F", "30Rnd_9x21_Mag_SMG_02"], ["srifle_DMR_06_hunter_F", "10Rnd_Mk14_762x51_Mag"], ["sgun_HunterShotgun_01_F", "2Rnd_12Gauge_Slug"]];
#

what if I wanted to edit the quantity of magazines per gun

#

how would I do that?

hollow thistle
#

add it as 3rd indice of the array?

little raptor
#

or just make it a random number

past wagon
#
private _itemArray = [["Binocular"], ["FirstAidKit"], ["Medikit"], ["muzzle_snds_L"], ["optic_Arco_blk_F"], ["optic_Aco"], ["optic_Hamr"], ["optic_ACO_grn"], ["optic_MRCO"], ["muzzle_snds_acp"], ["optic_Holosight_blk_F"], ["HandGrenade"], ["SmokeShell"], ["U_B_FullGhillie_ard"], ["V_TacVest_oli"], ["H_HelmetB"], ["H_HelmetB_camo"], ["B_AssaultPack_rgr"], ["B_Carryall_mcamo"], ["V_PlateCarrier1_rgr"]];
#

alright so now i have these two arrays

#

i need to have it select one item from each array and add it to a loot crate

#

and i need it to do that like 60 times for 60 different loot crates

#

@little raptor do you know what I should do?

past wagon
#

thats what I was thinking

#

also selectRandom

#

if i did:

selectRandom _weaponArray

then would it select a random item in the array?

#

for example,

["hgun_ACPC2_F", "9Rnd_45ACP_Mag"]
#
crate1 addWeapon selectRandom _weaponArray;
crate1 addMagazine selectRandom _weaponArray;
past wagon
#

i dont know

little raptor
past wagon
#

i am new to scripting

#
private _weaponArray = selectRandom _weaponArray
#

then what do I do?

little raptor
#

what do you see wrong with that?

past wagon
#

with what I just put?

little raptor
#

yes

past wagon
#

oh

#
private _weaponArray = selectRandom _weaponArray;
#

then what do I do next?

little raptor
#

that's what you saw?!

past wagon
#

yea it was missing the ;

little raptor
#

anything else?

past wagon
#

idk

#

its the same thing you used

little raptor
#

_weaponArray = selectRandom _weaponArray
select a random element from the _weaponArray and assign it to a variable called _weaponArray

#

do you see it now?

past wagon
#

well I dont know what it does

#

i was just copying what you wrote

little raptor
#

I even spelled it out for you.

past wagon
#

ok

little raptor
#

so what's wrong with it?

past wagon
#

so it is taking a random element from _weaponArray and assigning it to a variable?

#

i need a new name for a variable

little raptor
#

yes

past wagon
#

how about....

#

weapon

little raptor
#

you're overwriting the variable

past wagon
#

i understand

#

i understand that making the variable name the same thing as the array name is a bad idea

#

i just didnt know that the second _weaponArray was a variable name

little raptor
#

I mean weapon

past wagon
#

should I just call the new variable that?

little raptor
#

let me ask you this instead. what's the point of _?

past wagon
#

i dont know

little raptor
#

It makes the variable local
in other words, the variable gets deleted when your script ends.
so it's not accessible to other scripts

past wagon
#

ok

#

by other scripts, you mean other .sqf files in the mission?

little raptor
#

any code that runs besides this

#

from anywhere

past wagon
#

so any other lines of code in the same .sqf file?

little raptor
#

not necessarily

past wagon
#

ok

#

so do i want to make it local or not local?

little raptor
past wagon
#

ok i see

#

so i am guessing it is best to make it global?

#

well

#

idk

little raptor
#

is it a temporary variable?
do you need it somewhere else?

past wagon
#

only in this mission

little raptor
#

wrong answer
It is a temporary variable
you only need it in this script
so it should be local
I'm not sure how you plan to use _weaponArray , so it could either be global or local

#
_weapon_and_mag = selectRandom _weaponArray;
#

an example

past wagon
#

ohhh

#
private _weapon_and_mag = selectRandom _weapon;
#

what about the private?

little raptor
#

private makes the variable local to its current scope { }:
with private:

_a = 1;
if (true) then {
  private _a = 2;
};
_a //it is still 1

without:

_a = 1;
if (true) then {
  _a = 2;
};
_a //_a is 2

you can think of it as if private creates a new variable inside { }. even if the variable with the same name exists outside { } it won't be affected

past wagon
#

ok

#

that makes sense

#

i think i understand

#

so I just want:

_weapon_and_mag = selectRandom _weaponArray;
little raptor
#

probably
depends on where you're using that

past wagon
#

do you know what I am trying to do with the weapon array?

little raptor
#

yes

#

I'm helping you learn what you're doing

past wagon
#

i want to add it to storage crates

#

yea

#

so now that the variable _weapon_and_mag = one weapon and one magazine (chosen at random), how do I add it to a crate?

little raptor
#

it's an array

#

it's holding two elements for you: the weapon (1st element) and the mag(2nd element)

past wagon
#

yea

little raptor
#

so you have to "pick" them

past wagon
#

but that is what the selectRandom does, right?

little raptor
#

no select random picks a random element

#

you don't want a random element

#

for example, if you used selectRandom and you wanted to get the weapon, you could get the mag instead of weapon

#

its random

past wagon
#

oh

#

i thought that the way I made the array made it so that it selected the mag AND the weapon

#
private _weaponArray = [["hgun_ACPC2_F", "9Rnd_45ACP_Mag"], ["hgun_P07_F", "16Rnd_9x21_Mag"], ["hgun_Pistol_heavy_02_F", "6Rnd_45ACP_Cylinder"], ["hgun_Rook40_F", "30Rnd_9x21_Mag"], ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], ["arifle_MX_Black_F", "30Rnd_65x39_caseless_black_mag"], ["SMG_01_F", "30Rnd_45ACP_Mag_SMG_01"], ["srifle_DMR_03_F", "20Rnd_762x51_Mag"], ["SMG_03C_TR_black", "50Rnd_570x28_SMG_03"], ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], ["arifle_SPAR_01_blk_F", "30Rnd_556x45_Stanag"], ["SMG_05_F", "30Rnd_9x21_Mag_SMG_02"], ["srifle_DMR_06_hunter_F", "10Rnd_Mk14_762x51_Mag"], ["sgun_HunterShotgun_01_F", "2Rnd_12Gauge_Slug"]];
#

the mag is inside the brackets with the weapon

little raptor
#

no
you simply "organized" them to be in pairs

past wagon
#

so it wont select a pair?

little raptor
#

it does select a pair

past wagon
#

give me an example

#

an example of what it might select

little raptor
#
_array = [1,2,3,4,5,6,7];
selectRandom _array //could be any of 1-7 numbers
past wagon
#

ok

little raptor
#

now another example:

#
_array = [[1,2], [3,4], [5,6]];
selectRandom _array //can be one of [1,2] or [3,4] or [5,6]
```in other words, every element itself is also an array
past wagon
#

yea

#

but look

#

thats what im saying

#

my array has the weapon grouped with it's respective mag

little raptor
#

can you explain to me what your _weapon_and_mag array can be now?

past wagon
#

weaponArray?

#

oh

#

the variable

little raptor
#

give me an example of what it might be

past wagon
#
["hgun_Rook40_F", "30Rnd_9x21_Mag"]
little raptor
#

exactly

past wagon
#

so will it then choose between those?

#

or will it be BOTH

little raptor
#

so when you selectRandom on this array, what do you get?

past wagon
#
"30Rnd_9x21_Mag"
#

or

"hgun_Rook40_F"
little raptor
#

bravo

#

so you can't do it randomly

past wagon
#

but when we selectRandom on the large array, wouldnt we get both?

#

wouldnt we get one of the smaller arrays? or would it narrow it down to one item?

little raptor
#

you get both
but you get ["hgun_Rook40_F", "30Rnd_9x21_Mag"]
so you can't select random one of them
one is a weapon, one is a mag
so this is wrong

past wagon
#

yea

little raptor
past wagon
#

so if I want it to give me a random pair (weapon + respective magazine), what would I do differently?

little raptor
#

nothing
you already have a random pair

past wagon
#

but I want it to be a random pair

#

i dont want a random item

#

a random pair

little raptor
#

it is a random pair

past wagon
#

ok

little raptor
#

["hgun_Rook40_F", "30Rnd_9x21_Mag"]

#

does it not look like a pair to you?!

past wagon
#

so now that i have the random pair, what would I do to get that added to a crate?

#

no it does

#

thats what I was saying

#

i just got a little confused

little raptor
past wagon
#

im confused

little raptor
past wagon
#

oh

#

i get it now

#

am i selecting from an array, config, or string?

#

_weapon_and_magazine is an array, right?

little raptor
#

yes

past wagon
#

ok

little raptor
#

the first syntax is what you want

Syntax:
array select index
Parameters:
array: Array
index: Number - Index 0 denotes the first element, 1 the second, etc. If index has decimal places it gets rounded down for fractions less than or equal .5, otherwise it gets rounded up.

past wagon
#

ok

#

wait

#
private _weaponArray = [["hgun_ACPC2_F", "9Rnd_45ACP_Mag"], ["hgun_P07_F", "16Rnd_9x21_Mag"], ["hgun_Pistol_heavy_02_F", "6Rnd_45ACP_Cylinder"], ["hgun_Rook40_F", "30Rnd_9x21_Mag"], ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], ["arifle_MX_Black_F", "30Rnd_65x39_caseless_black_mag"], ["SMG_01_F", "30Rnd_45ACP_Mag_SMG_01"], ["srifle_DMR_03_F", "20Rnd_762x51_Mag"], ["SMG_03C_TR_black", "50Rnd_570x28_SMG_03"], ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], ["arifle_SPAR_01_blk_F", "30Rnd_556x45_Stanag"], ["SMG_05_F", "30Rnd_9x21_Mag_SMG_02"], ["srifle_DMR_06_hunter_F", "10Rnd_Mk14_762x51_Mag"], ["sgun_HunterShotgun_01_F", "2Rnd_12Gauge_Slug"]];

_weapon_and_mag = selectRandom _weaponArray;

_weapon = Select _weapon_and_mag 0;

_mag = Select _weapon_and_mag 1;
#

how is that?

#

wait

little raptor
#

close
read this

Index 0 denotes the first element, 1 the second, etc.

past wagon
#

fixed it

little raptor
#

good

#

but still wrong

past wagon
#

lol

little raptor
#

can you tell what is wrong

past wagon
#

is Select not supposed to be capitalized?

little raptor
#

no

#

sqf is not case-sensetive

past wagon
#

ok

#

first do I need to create the variables?

little raptor
#

no
array select index

past wagon
#
private _weaponArray = [["hgun_ACPC2_F", "9Rnd_45ACP_Mag"], ["hgun_P07_F", "16Rnd_9x21_Mag"], ["hgun_Pistol_heavy_02_F", "6Rnd_45ACP_Cylinder"], ["hgun_Rook40_F", "30Rnd_9x21_Mag"], ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], ["arifle_MX_Black_F", "30Rnd_65x39_caseless_black_mag"], ["SMG_01_F", "30Rnd_45ACP_Mag_SMG_01"], ["srifle_DMR_03_F", "20Rnd_762x51_Mag"], ["SMG_03C_TR_black", "50Rnd_570x28_SMG_03"], ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], ["arifle_SPAR_01_blk_F", "30Rnd_556x45_Stanag"], ["SMG_05_F", "30Rnd_9x21_Mag_SMG_02"], ["srifle_DMR_06_hunter_F", "10Rnd_Mk14_762x51_Mag"], ["sgun_HunterShotgun_01_F", "2Rnd_12Gauge_Slug"]];

_weapon_and_mag = selectRandom _weaponArray;

_weapon_and_mag select 0;

_weapon_and_mag select 1;
little raptor
#

what's different between selectRandom and select?

Syntax:
selectRandom array

Syntax:
array select index

past wagon
#

there is no =?

little raptor
#

= means save the variable

#

you want to save it

past wagon
#

ok so should I put it back the way it was?

little raptor
#

yeah but also look at the syntaxes I posted

#

tell me the difference

past wagon
#

i dont see the difference

#

the array, then "select", then the index

#

that is what I put for "select"

little raptor
#

is it?
_weapon = Select _weapon_and_mag 0;

past wagon
#
private _weaponArray = [["hgun_ACPC2_F", "9Rnd_45ACP_Mag"], ["hgun_P07_F", "16Rnd_9x21_Mag"], ["hgun_Pistol_heavy_02_F", "6Rnd_45ACP_Cylinder"], ["hgun_Rook40_F", "30Rnd_9x21_Mag"], ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], ["arifle_MX_Black_F", "30Rnd_65x39_caseless_black_mag"], ["SMG_01_F", "30Rnd_45ACP_Mag_SMG_01"], ["srifle_DMR_03_F", "20Rnd_762x51_Mag"], ["SMG_03C_TR_black", "50Rnd_570x28_SMG_03"], ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], ["arifle_SPAR_01_blk_F", "30Rnd_556x45_Stanag"], ["SMG_05_F", "30Rnd_9x21_Mag_SMG_02"], ["srifle_DMR_06_hunter_F", "10Rnd_Mk14_762x51_Mag"], ["sgun_HunterShotgun_01_F", "2Rnd_12Gauge_Slug"]];

_weapon_and_mag = selectRandom _weaponArray;

_weapon = _weapon_and_mag select 0;

_mag = _weapon_and_mag select 1;
little raptor
#

good

#

now it's fixed

past wagon
#

ok

#

so now I just need to add it to a crate

little raptor
#

yes,
but let's say you have hundreds of crates
do you want to copy paste all of that?!

past wagon
#

no

#

thats what I was worried about lol

little raptor
#

good
well, you can put all of the crates in a variable:

_crates = [crate_1, crate_2, ...., crate_100];

and iterate over the array using forEach

{
  _crate = _x; //_x means current element that forEach is iterating on
  _weapon_and_mag = selectRandom _weaponArray;

  _weapon = _weapon_and_mag select 0;

  _mag = _weapon_and_mag select 1;
  _crate addWeaponCargoGlobal [_weapon, 1];
  _crate addMagazineCargoGlobal [_mag, 1];
} forEach _crates;
past wagon
#

ok

#

but wait

#

i dont want all the crates to have the same contents

#

is that what forEach does?

little raptor
#

for even more advanced way:
if the naming is consistent, you can even ditch the array:

for "_i" from 1 to 100 do {
  _varName = format["crate_%1", _i];
  _crate = missionNamespace getVariable [_varName, objNull];
  ...
};
little raptor
#

do you know what iteration means?

past wagon
#

not really

#

kind of

little raptor
#

it goes through the array one by one

past wagon
#

ok

little raptor
#

and does what the code says

#

in { }

past wagon
#

so it repeats the code for each and every crate

#

forEach

little raptor
#

yeah kinda
not "repeat"
executes the code for every element

past wagon
#

yes

#

now do I need to go into the editor and name all of my crates?

little raptor
#

maybe
you could even automate the creation of them

past wagon
#

well

#

i already have the locations that I want to place the crates

little raptor
#

good

past wagon
#

so I am going to go place them down now

#

what do I need to name them?

#

_crate?

little raptor
#

what was the lesson about _?

past wagon
#

ohh

#

i can name them all the same thing if I put a _

little raptor
#

no

past wagon
#

oh

little raptor
#

if you put _ at the beginning, then the name becomes local and other scripts cant see it
(altho the editor probably returns an error for you)

past wagon
#

ok

#

so I want to name them all crate?

#

the editor wont let me name them all the same thing

little raptor
#

well actually, didn't you say you have the positions already?

past wagon
#

yea

#

i know where I am planning to put them

little raptor
#

in an array?

past wagon
#

i dont have the coords

#

nah i just mapped it out with markers

little raptor
#

well you can name them something easy.
I think if you name one "crate" and then copy-paste it, the editor automatically gives it names like "crate_1", etc.

past wagon
#

yea

#

and that will be ok?

#

i will just name them crate1, crate2, crate3, etc.

exotic flax
#

Or, if part of a mod, make an unique object and find all of them on the terrain

past wagon
#

im not using mods

little raptor
#

are they from a specific class?

#

like are they all identical?

past wagon
#

yes

little raptor
#

then no need to name them either

past wagon
#

ok

little raptor
#
_crates = allMissionObjects "class";
past wagon
#

ok

#

that makes it easier

little raptor
#

class is the className of the object

past wagon
#

yea

#

i will have to get that

little raptor
past wagon
#

Box_EAF_Wps_F

#
private _weaponArray = [["hgun_ACPC2_F", "9Rnd_45ACP_Mag"], ["hgun_P07_F", "16Rnd_9x21_Mag"], ["hgun_Pistol_heavy_02_F", "6Rnd_45ACP_Cylinder"], ["hgun_Rook40_F", "30Rnd_9x21_Mag"], ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], ["arifle_MX_Black_F", "30Rnd_65x39_caseless_black_mag"], ["SMG_01_F", "30Rnd_45ACP_Mag_SMG_01"], ["srifle_DMR_03_F", "20Rnd_762x51_Mag"], ["SMG_03C_TR_black", "50Rnd_570x28_SMG_03"], ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], ["arifle_SPAR_01_blk_F", "30Rnd_556x45_Stanag"], ["SMG_05_F", "30Rnd_9x21_Mag_SMG_02"], ["srifle_DMR_06_hunter_F", "10Rnd_Mk14_762x51_Mag"], ["sgun_HunterShotgun_01_F", "2Rnd_12Gauge_Slug"]];

{
_weapon_and_mag = selectRandom _weaponArray;
_weapon = _weapon_and_mag select 0;

_mag = _weapon_and_mag select 1;

_crates = allMissionObjects "Box_EAF_Wps_F";

_crates addWeaponCargoGlobal [_weapon, 1];
_crates addMagazineCargoGlobal [_mag, 1];
} forEach _crates
#

is that good?

little raptor
#

what happened to what I said?

past wagon
#

what

little raptor
drifting sky
#

do you have to enclose a condition in {} to allow lazy evaluation?

past wagon
#

do I still need forEach?

little raptor
#

what do you think?

past wagon
#

yea

#

i do

finite sail
#

@drifting sky , yes

finite sail
#

πŸ™‚

past wagon
#
private _weaponArray = [["hgun_ACPC2_F", "9Rnd_45ACP_Mag"], ["hgun_P07_F", "16Rnd_9x21_Mag"], ["hgun_Pistol_heavy_02_F", "6Rnd_45ACP_Cylinder"], ["hgun_Rook40_F", "30Rnd_9x21_Mag"], ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], ["arifle_MX_Black_F", "30Rnd_65x39_caseless_black_mag"], ["SMG_01_F", "30Rnd_45ACP_Mag_SMG_01"], ["srifle_DMR_03_F", "20Rnd_762x51_Mag"], ["SMG_03C_TR_black", "50Rnd_570x28_SMG_03"], ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], ["arifle_SPAR_01_blk_F", "30Rnd_556x45_Stanag"], ["SMG_05_F", "30Rnd_9x21_Mag_SMG_02"], ["srifle_DMR_06_hunter_F", "10Rnd_Mk14_762x51_Mag"], ["sgun_HunterShotgun_01_F", "2Rnd_12Gauge_Slug"]];

{
_weapon_and_mag = selectRandom _weaponArray;

_weapon = _weapon_and_mag select 0;
_mag = _weapon_and_mag select 1;

_crates = allMissionObjects "Box_EAF_Wps_F";

_crates addWeaponCargoGlobal [_weapon, 1];
_crates addMagazineCargoGlobal [_mag, 2];
} forEach _crates
#

@little raptor does that look good?

drifting sky
#

k. thanks

little raptor
past wagon
#

ok

drifting sky
#

what about the first condition? Does it need to be enclosed in {}?

little raptor
#

no

#

if you enclose it in {} it becomes a code

#

{true} is a code

past wagon
#

@little raptor can i have

_crates addMagazineCargoGlobal [_mag, 2];

to have more than one mag in the crate?

drifting sky
#

define "a code"

little raptor
#

{ }

#

typeName { }

#

try the in debug console or something

finite sail
#

a code == collection of statements and commands that follow rules of syntax to do something

little raptor
#

in sqf code is a data type

finite sail
#

yeah but that just leads to the question, what is a datatype

little raptor
#

type of data?!

finite sail
#

hehe

drifting sky
#

okay, what's the connection between code being a data type and lazy evaluation?

pure aspen
#

Is there a way to make a unit only visible through Thermals that is executed by zeus enhanced. I was able to find a Script for a Mission File, however I can't find a way to do this through just zeus enhanced interface

little raptor
#

the && || operators act on it and execute it

#

@drifting sky

#
Parameters:
    a: Boolean - Test condition or variable that returns Boolean.
    b: Code - Code that returns Boolean. It is not evaluated if a returns as false.
Return Value:
    Boolean```
little raptor
#

but yes

past wagon
#

well what is the problem?

#

i dont see it

little raptor
#

follow your logic 🀷

drifting sky
#

Do both (or,and) as well as (||,&&) allow lazy evaluation? I notice the wiki only mentions lazy evaluation on the former.

#

nevermind

#

missed it

little raptor
#

they're just alternative names for them

past wagon
#
private _weaponArray = [["hgun_ACPC2_F", "9Rnd_45ACP_Mag"], ["hgun_P07_F", "16Rnd_9x21_Mag"], ["hgun_Pistol_heavy_02_F", "6Rnd_45ACP_Cylinder"], ["hgun_Rook40_F", "30Rnd_9x21_Mag"], ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], ["arifle_MX_Black_F", "30Rnd_65x39_caseless_black_mag"], ["SMG_01_F", "30Rnd_45ACP_Mag_SMG_01"], ["srifle_DMR_03_F", "20Rnd_762x51_Mag"], ["SMG_03C_TR_black", "50Rnd_570x28_SMG_03"], ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], ["arifle_SPAR_01_blk_F", "30Rnd_556x45_Stanag"], ["SMG_05_F", "30Rnd_9x21_Mag_SMG_02"], ["srifle_DMR_06_hunter_F", "10Rnd_Mk14_762x51_Mag"], ["sgun_HunterShotgun_01_F", "2Rnd_12Gauge_Slug"]];

{
_weapon_and_mag = selectRandom _weaponArray;

_weapon = _weapon_and_mag select 0;
_mag = _weapon_and_mag select 1;
} forEach _crates

_crates = allMissionObjects "Box_EAF_Wps_F";

_crates addWeaponCargoGlobal [_weapon, 1];
_crates addMagazineCargoGlobal [_mag, 2];

#

do i still need forEach?
@little raptor

#

ohh

little raptor
#

yes
can you explain the flow of the script to me?

past wagon
#

ok

little raptor
#

as in say in english what it does

little raptor
past wagon
#
  1. Select weapon + mag
  2. Select the weapon and make the variable _weapon
  3. Select the mag and make the variable _mag
  4. Select all of one container type and set it to _crates
  5. Put one weapon and 2 mags into each crate of that type
drifting sky
#

last question: Is there any reason to use lazy evaluation on simple conditions, or would that in fact degrade performance? example of simple condition: (a<5)

little raptor
past wagon
#

ok

#

it does it for each crate

#

but wait

#
private _weaponArray = [["hgun_ACPC2_F", "9Rnd_45ACP_Mag"], ["hgun_P07_F", "16Rnd_9x21_Mag"], ["hgun_Pistol_heavy_02_F", "6Rnd_45ACP_Cylinder"], ["hgun_Rook40_F", "30Rnd_9x21_Mag"], ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], ["arifle_MX_Black_F", "30Rnd_65x39_caseless_black_mag"], ["SMG_01_F", "30Rnd_45ACP_Mag_SMG_01"], ["srifle_DMR_03_F", "20Rnd_762x51_Mag"], ["SMG_03C_TR_black", "50Rnd_570x28_SMG_03"], ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], ["arifle_SPAR_01_blk_F", "30Rnd_556x45_Stanag"], ["SMG_05_F", "30Rnd_9x21_Mag_SMG_02"], ["srifle_DMR_06_hunter_F", "10Rnd_Mk14_762x51_Mag"], ["sgun_HunterShotgun_01_F", "2Rnd_12Gauge_Slug"]];

_crates = allMissionObjects "Box_EAF_Wps_F";

{
_weapon_and_mag = selectRandom _weaponArray;

_weapon = _weapon_and_mag select 0;
_mag = _weapon_and_mag select 1;

_crates addWeaponCargoGlobal [_weapon, 1];
_crates addMagazineCargoGlobal [_mag, 2];
} forEach _crates

is this better?

#

wait

#

no

little raptor
past wagon
#

@little raptor I think it is something wrong with _crates and forEach

past wagon
#

is it completely fixed though?

little raptor
#

no

past wagon
#

ok

#

i really dont know

little raptor
#

_crates addWeaponCargoGlobal [_weapon, 1];

#

what's wrong with it?

past wagon
#

i dont see anything wrong with it

#

i understand what it does

#

and it looks like it should work to me

past wagon
#

oh

little raptor
#

explain the command

#

Syntax:
vehicleName addWeaponCargoGlobal [weaponName, count]
Parameters:
vehicleName: Object - vehicle to add the weapons to
[weaponName, count]: Array
weaponName: String - weapon name. See the topic Category:Weapons for reference about possible values.
count: Number - number of weapons to add.

past wagon
#

is it only for vehicels?

#

thats what i thought at first

little raptor
#

vehicle = object

past wagon
#

but you told me to use it

#

wait

#

does a crate count as a vehicle/object?

little raptor
#

yes

past wagon
#

ok

#

so thats not the problem

little raptor
#

no

#

look at the paramters

past wagon
#

ok

#

weaponName is a string

#

but in the array, it is also a string

#

so it already has quotations

little raptor
#

no

past wagon
#

so thats not the problem, right?

#

is it?

little raptor
#

no

past wagon
#

ok

little raptor
#

_crates addWeaponCargoGlobal

#

that's where the problem is

#

do you see it now?

#

what is _crates?

past wagon
#

oh

#

every single container of that type

little raptor
#

_crates is an array

past wagon
#

oh

#

yea

little raptor
#

does that command support arrays?

#

no

past wagon
#

no

#

so how do I fix it?

little raptor
past wagon
#

ohhh

#

i forgot about _crate = _x

#
private _weaponArray = [["hgun_ACPC2_F", "9Rnd_45ACP_Mag"], ["hgun_P07_F", "16Rnd_9x21_Mag"], ["hgun_Pistol_heavy_02_F", "6Rnd_45ACP_Cylinder"], ["hgun_Rook40_F", "30Rnd_9x21_Mag"], ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], ["arifle_MX_Black_F", "30Rnd_65x39_caseless_black_mag"], ["SMG_01_F", "30Rnd_45ACP_Mag_SMG_01"], ["srifle_DMR_03_F", "20Rnd_762x51_Mag"], ["SMG_03C_TR_black", "50Rnd_570x28_SMG_03"], ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], ["arifle_SPAR_01_blk_F", "30Rnd_556x45_Stanag"], ["SMG_05_F", "30Rnd_9x21_Mag_SMG_02"], ["srifle_DMR_06_hunter_F", "10Rnd_Mk14_762x51_Mag"], ["sgun_HunterShotgun_01_F", "2Rnd_12Gauge_Slug"]];

_crates = allMissionObjects "Box_EAF_Wps_F";

{
_weapon_and_mag = selectRandom _weaponArray;

_weapon = _weapon_and_mag select 0;
_mag = _weapon_and_mag select 1;

_x addWeaponCargoGlobal [_weapon, 1];
_x addMagazineCargoGlobal [_mag, 2];
} forEach _crates

is this better?

#

@little raptor

little raptor
#

lol 🀣

#

_crates = _x

#

?

past wagon
#

cmon man

#

idk

#

lol

little raptor
#

you're changing _crates to _x

#

but it works

#

just remove that line

past wagon
#

ok

#
private _weaponArray = [["hgun_ACPC2_F", "9Rnd_45ACP_Mag"], ["hgun_P07_F", "16Rnd_9x21_Mag"], ["hgun_Pistol_heavy_02_F", "6Rnd_45ACP_Cylinder"], ["hgun_Rook40_F", "30Rnd_9x21_Mag"], ["arifle_Katiba_F", "30Rnd_65x39_caseless_green"], ["arifle_MX_Black_F", "30Rnd_65x39_caseless_black_mag"], ["SMG_01_F", "30Rnd_45ACP_Mag_SMG_01"], ["srifle_DMR_03_F", "20Rnd_762x51_Mag"], ["SMG_03C_TR_black", "50Rnd_570x28_SMG_03"], ["arifle_AK12_F", "30Rnd_762x39_AK12_Mag_F"], ["arifle_SPAR_01_blk_F", "30Rnd_556x45_Stanag"], ["SMG_05_F", "30Rnd_9x21_Mag_SMG_02"], ["srifle_DMR_06_hunter_F", "10Rnd_Mk14_762x51_Mag"], ["sgun_HunterShotgun_01_F", "2Rnd_12Gauge_Slug"]];

_crates = allMissionObjects "Box_EAF_Wps_F";

{
_weapon_and_mag = selectRandom _weaponArray;

_weapon = _weapon_and_mag select 0;
_mag = _weapon_and_mag select 1;

_x addWeaponCargoGlobal [_weapon, 1];
_x addMagazineCargoGlobal [_mag, 2];
} forEach _crates

so this should work?

little raptor
#

yes

past wagon
#

how does it know that _x is the new _crates?

#

oh

little raptor
past wagon
#

because forEach _crates

#

do I just put this into initServer.sqf?

little raptor
#

it's a magic variable
similar to this

little raptor
past wagon
#

ok

little raptor
#

hopefully it works fine

past wagon
#

yea, hopefully

little raptor
past wagon
#

ok

#

are you sure that i put the forEach part in the right place?

little raptor
#

yes

past wagon
#

actually yea, no im good

#

i just checked

#

alright

#

lemme test it out

#

IT WORKS

#

IT REALLY WORKS
YASSSSSSS

little raptor
past wagon
#

amazing

#

now i also want to do this for anther type of crate

#

that will contain the items

#

not the weapons

#
private _itemArray = [["Binocular"], ["FirstAidKit"], ["Medikit"], ["muzzle_snds_L"], ["optic_Arco_blk_F"], ["optic_Aco"], ["optic_Hamr"], ["optic_ACO_grn"], ["optic_MRCO"], ["muzzle_snds_acp"], ["optic_Holosight_blk_F"], ["HandGrenade"], ["SmokeShell"], ["U_B_FullGhillie_ard"], ["V_TacVest_oli"], ["H_HelmetB"], ["H_HelmetB_camo"], ["B_AssaultPack_rgr"], ["B_Carryall_mcamo"], ["V_PlateCarrier1_rgr"]];

here is the array

little raptor
#

well you know what to do

past wagon
#

yea

#

but i have a question

#

can i use the variable _crates again?

#

for a different type of crate?

little raptor
#

it's just a name you give to some variable.
what matters is that it's local, and what it contains.

little raptor
#

nested array = array inside another array

past wagon
#

yea i dont think there are nested arrays

#

oh

#

wait

#

yea

#

they can just be separated by commas, and not brackets?

little raptor
past wagon
#
private _itemArray = ["Binocular", "FirstAidKit", "Medikit", "muzzle_snds_L", "optic_Arco_blk_F", "optic_Aco", "optic_Hamr", "optic_ACO_grn", "optic_MRCO", "muzzle_snds_acp", "optic_Holosight_blk_F", "HandGrenade", "SmokeShell", "U_B_FullGhillie_ard", "V_TacVest_oli", "H_HelmetB", "H_HelmetB_camo", "B_AssaultPack_rgr", "B_Carryall_mcamo", "V_PlateCarrier1_rgr"];
#

there

little raptor
#

and remember that the procedure will change too

#

can you tell me how?

past wagon
#

yes

#

because there are no longer weapons and mags

#

just items

#

i will show you the finished piece of code and you can let me know if its all good

little raptor
#

ok

#

but remember that the command will be different too

#

for items

past wagon
#

yea

little raptor
past wagon
#

yea

past wagon
#

@little raptor how does this look:

private _itemArray = ["Binocular", "FirstAidKit", "Medikit", "muzzle_snds_L", "optic_Arco_blk_F", "optic_Aco", "optic_Hamr", "optic_ACO_grn", "optic_MRCO", "muzzle_snds_acp", "optic_Holosight_blk_F", "HandGrenade", "SmokeShell", "U_B_FullGhillie_ard", "V_TacVest_oli", "H_HelmetB", "H_HelmetB_camo", "B_AssaultPack_rgr", "B_Carryall_mcamo", "V_PlateCarrier1_rgr"];

_crates = allMissionObjects "Box_EAF_Equip_F";

{
_item = selectRandom _itemArray

_x addItemCargoGlobal [_item, 4]
} forEach _crates
little raptor
#

it looks fine

#

are you adding the items to the same crates?

past wagon
#

no

#

it is a different type of crate

#

but it doesnt seem to be working

#

i am getting an error

#

one sec

little raptor
#

yeah

#

you're missing ;

#

after selectRandom _itemarray part

past wagon
#

yea

#

got it

#

@little raptor I dont need a ; after } forEach _crates, right?

little raptor
#

no

#

because nothing comes after it

past wagon
#

well on the first one i need it then

#

because i added stuff after the first one

little raptor
#

yeah

past wagon
#

alright its working now

#

but there are a couple of problems

#

so, for one, not all the crates contain anything

#

for some reason

#

some crates are just empty, but most have contents

little raptor
#

probably because their classes are different

past wagon
#

im pretty sure they are all the exact same crate

#

i copy and pasted

#

and it is random

#

the ones that are empty are random every time

#

as if one of the options is "empty"

little raptor
#

probably because you have non-item classNames in that array

past wagon
#

I dont think so

#
["Binocular", "FirstAidKit", "Medikit", "muzzle_snds_L", "optic_Arco_blk_F", "optic_Aco", "optic_Hamr", "optic_ACO_grn", "optic_MRCO", "muzzle_snds_acp", "optic_Holosight_blk_F", "HandGrenade", "SmokeShell", "U_B_FullGhillie_ard", "V_TacVest_oli", "H_HelmetB", "H_HelmetB_camo", "B_AssaultPack_rgr", "B_Carryall_mcamo", "V_PlateCarrier1_rgr"]
little raptor
past wagon
#

ohh

#

yea

#

thats the problem

#

why tf cant backpacks just be normal

#
private _itemArray = ["Binocular", "FirstAidKit", "Medikit", "muzzle_snds_L", "optic_Arco_blk_F", "optic_Aco", "optic_Hamr", "optic_ACO_grn", "optic_MRCO", "muzzle_snds_acp", "optic_Holosight_blk_F", "HandGrenade", "SmokeShell", "U_B_FullGhillie_ard", "V_TacVest_oli", "H_HelmetB", "H_HelmetB_camo", "B_AssaultPack_rgr", "B_Carryall_mcamo", "V_PlateCarrier1_rgr"];

_crates = allMissionObjects "Box_EAF_Equip_F";

{
_item = selectRandom _itemArray

_x addItemCargoGlobal [_item, 4]
} forEach _crates
#

alright