#arma3_scripting
1 messages Β· Page 648 of 1

How did you throw _this into the script?
@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?
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?
something like that?```sqf
[
0,
0,
round random 1,
round random 1,
round random 1
round random 1
]
Well, looks like your conversion from Boolean to Number doesn't work...
What does your MAIN_SETTINGS_TYPE macro look like?
SQL injection, fun
its quiet large to post it here.
And yeah nah maybe.. the asyncCall function was renamed before posting it here haha
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?
I believe there is a module that does that for you π greys out everything but its area
Any chance you know what it is called?
Cover Map
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?
You'd want to pass a param through for (_this select 1)
Could you please write the whole script for me?
https://community.bistudio.com/wiki/addPlayerScores
It says server execution only, so you need to combine it with Remote Execution.
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
[player, [10e6, 10e6, 10e6]] remoteExec ["addPlayerScores", 2];
wow thank you, and this goes to the sqf file, right?
yep!
appreciate it, i often struggle with scripts in arma, may i send you a pm next time i'll need help again?
use this channel first, it is here for that π I also might not be available, while others are!
ok thank you i was just asking for a permission to write you a message, some people hate receiving unrequested messages
and that's nice of you, as some don't (ask beforehand) π
by the way are you familiar with mcc?
nope
that's pity, i've got one more script that doesn't work but it's related to mcc
tip: don't use MCC, it breaks a lot
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
just tested it and so far it seems to work perfectly π
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?
https://community.bistudio.com/wiki/Function
Make it a function.
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
? I guess I don't understand how it its "scheduled"
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
hm? about what?
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
yeah that's bad
not just reading but recompiling
And the solution is making it a function 
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
over 1000 classnames being sorted every second
you might wanna do something about that too
well. Looking into that as well
hoping to put the array function that runs once then can get passed down to the loop
I mean what's the point of that loop?
and there's also global variables
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
something like that doesn't need to be checked every second
well I wanted to do a switch command
cause techically it runs about 30 different if statements
don't believe that will work on this
and yet switch does?!
its a bunch of if else statements
call {
if (_isRaining && {_someHeavyCondition}) exitWith {};
if (... && {... && {... && {...}}}) exitWith {};
}
you can have thousands like that
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;
};
I don't see why you think it won't work
and you might wanna learn lazy eval:
https://community.bistudio.com/wiki/Code_Optimisation#Lazy_evaluation
_selecter = floor(random count _combatTracks); //Track07_ActionDark
playMusic (_combatTracks select _selecter);
selectRandom
_combatTracks
_combatDurations
_tracks = [["name", duration]];
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)];
};
};
why do you even need the duration?
are you familiar with music event handlers?
I guess not particularly with music event handling. just the one specific way
this is using a playmusic though
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;
fadeTime = diag_tickTime + _duation - 5;
if (diag_tickTime > fadeTime) then {
2 fadeMusic 0
};
addMusicEventHandler ["MusicStop", {isMusicCurrentlyPlaying = false;}];
addEventHandler ["FiredNear", _FiredNear];
isMusicCurrentlyPlaying == 0
use bool
isMusicCurrentlyPlaying = false
!isMusicCurrentlyPlaying
Well... I guess I will have to go and rewrite a good percentage of this thing
if not all of it
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.
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 ?
most likely. you can "comment" in code with a simple string, e.g```sqf
this setDamage 0.25;
"we add a first aid kit to help the player";
this addItem "FirstAidKit";
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.
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?
β¦you have a 30+ lines init? o_o
Yeah. It's Pandemic's immersive HALO jump script. I'm digging into it to customize it for our unit a bit.
if it is MP, it will be executed by each and every client machine, players joining in progress included
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.)
there a big difference between titleText and cutText?
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.
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)?
Not sure if you meant that, but:
https://community.bistudio.com/wiki/lineIntersects
https://community.bistudio.com/wiki/lineIntersectsWith
https://community.bistudio.com/wiki/lineIntersectsObjs
https://community.bistudio.com/wiki/lineIntersectsSurfaces
That what you needed? @tropic thunder
Unfortunately I think all of those are just checking intersections with game objects, not intersections with other vectors
That was the part i was unsure about
Appreciate the help though π
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
Ah finding if p3 is between p1 and p2
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...
how do i figure out the attach point coordinates on a unit to say attach something to his hip area?
this what you mean? https://community.bistudio.com/wiki/BIS_fnc_initVehicle
Hello again,
Iβm really stuck with this thing, help would be really appreciated. Thanks in advance.
sounds like a bug
Thank you for your response Connor, I will try submiting a bug report
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.
I think you should go with event handlers (https://community.bistudio.com/wiki/Arma_3:_Event_Handlers). You should combine them to cover all your cases. I would go with inventoryclosed one and take one.
[]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
that ^^^
/* 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
[] 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?
Cheers, I'll try it. Dunno if it works though even if written properly. Just something I thought of after 2 minutes of googling.
a snus mod? π€£
It is haha π
But yeah the code doesn't work π¦ Doesn't give any errors but it's not launching the "under_lip" function.
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;
};
};```
Hi, anyone knows the script to knock down people in multiplayer (with ACE unconscious effect)?
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"};
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;
};
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)
Probably best to ask in #creators_recruiting
thanks for advise
might want to put an occasional newline in the text while you're about it
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"];
?
@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!
"\n"
Is it possible to set the main menu world using playScriptedMission? Wanting to have the same world loaded everytime.
there is a launcher setting π
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
make a mod? π¬
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
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
I believe it can be a config setting, but then I have no idea how (#arma3_config may know)
Okay i'll switch, cheers
Arma2OA: Is there a gold standard for detecting when AI led groups get (chronically) stuck, and for a way of unstucking them?
stuck, as in�
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
I think it mainly happens after contact with the enemy
i think you replied to the wrong user lol. so yeah, go to the doctor
or possibly when a vehicle is destroyed in their group
hard to tell what the cause is really
@robust hollow that's was a thank you for you - had missed how to call that function from an init!
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?
ty!
Arma AI have several path gen issues. Sometimes they don't move simply because they can't find a path
is there a way specifically to detect that
you could check if the units are fleeing
already have fleeing disabled
hi how can I make the independent faction go from ally to enemy in the middle of the mission?
setFriend (see https://community.bistudio.com/wiki/Side_relations)
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"
entities are essentially living things (units)
ah okay. well its definitely not living lol
well not necessarily "living"
but I don't think stuff like buildings and props count as entities
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... π¦
[0,0,0] getDir [-0.999994, 0.00356055, 0]
gives you an angle that can be used with setDir (if I understood you correctly)
oof... I see a lot of re-script... better redesign all objects π
what do you want to do again?
Exile Traders, currently I have them set in the way Exile Eden export them, but I need real coordinates X, Y, Z, Dir
you can also play with sin and cos
he means atan2 π
BIS_fnc_dirTo (DISCLAIMER: obsolete, do not use)
I had trouble to understand that in my a-level class, but completely forget that on university lol
anyway, thanks for your help guys π
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
nope it's here, no worry
try terminating the script
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
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.
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.
you can try making your own function. I'm not sure how that function works
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!
try the fadeMusic command too:
https://community.bistudio.com/wiki/fadeMusic
reset the music volume back to the default value
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?
because BIS_fnc_fadeEffect only restore the two other settings (checked the code)
_BIS_fadeDuration fadeSound 0;
_BIS_fadeDuration fadeMusic 0;
_BIS_fadeDuration fadeSpeech 0;
// vs
_BIS_fadeDuration fadeSound 1;
_BIS_fadeDuration fadeSpeech 1;
yeah, thats honestly a bit weird, did BI not expect people to use fade in after using fade out? Anyway, thanks a lot!
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
see screenToWorld? π
i'm afraid i don't, what is it?
it is a scripting command that allows you to get e.g the screen centre ([0.5,0.5]) π
https://community.bistudio.com/wiki/screenToWorld
that's brilliant! i had no idea that such a thing exists!
[
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
because it is returning the spawned script
How do I fix it?
is there a log in your rpt file saying why it isnt working?
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.
that is basically the same thing, just saved to a different namespace
Can't find anything for firesupport in the RPT
Which one is more reliable?
if the value only needs to exist until the object is deleted then sure save to the object, otherwise i'd just do publicvariable
are you sure the target is within range?
There is a possibility that the object can die in mid mission.
Absolutely, I tried it myself with the arty computer and it works just fine.
So I was thinking update that if the object dies and remove from the array or delete the variable
pushBack- why?
Whats the difference? performance?
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.
just how many, or how many + select one?
I would avoid sending large arrays over network if I were you.
you can probably just send a request to the server to give the vehicle to you
so you only need to keep the array on the server
and transfer the number of elements to the clients
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
and how to make that request?
remoteExec a function
Well as I said, transfer the number of available elements to the clients
so that they won't make unnecessary calls to the server
how?
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.
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
your are sending the whole array over the network dude
how does that even compare?
and what I say merely sends numbers
Because this will be executed from the server, yours is sending two information, the vehicles and the index to select
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
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
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.
return is not SQF π
if you can script, you could use a waitUntil?
see findIf for performance π
@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";
does the same thing, just with more commands
Thing is multiplayer reliability
dont know what you mean by that.
Like, not being heavily effected by ping or sending too much data trough the network.
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
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.
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?
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).
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
Hahaha yeah definitely not, but I guess it worked in getting the point across πΈ
I was trying to avoid it so some of my friends can copy what I'm doing easily but thats probably the best solution. Thank you for your help
if in need, don't hesitate!
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
aren't they all children of a parent class, e.g TG_Tiberium?
you could try to use typeOf in array instead
yes they are now that I'm looking through it. doesn't decrease much though. let me try something with typeOf
would here be where i ask about configs
here or #arma3_config depending on what you want to do
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?
no
are some "TG_Tiberium" not listed in your _tiberium_classes?
yes, these are the only classes that I need. some other things are flora and stuff, but I just want the crystals
i think i might do some sort of nearObjects style of method instead. might be faster than iterating through the allmissionobjects every time
well, if you only need the close ones, yes
it might be faster
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.
30-40 ms -> hiccups and frame drops
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
I think i've seen a mod for this in workshop, mcc maybe
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
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
i dont wanna use a mod, i wanna keep it all vanilla
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?
Check where u put it's trigger. I, by no mean am a pro this this. I am in fact a very amateur and quite new in scripting. So just as a disclaimer. But, imo, u might want to put the trigger in initplayerlocal
Since in eden and lan, you are the server
Dedicated,you and the server are two different entity
I have invisible heli pad with variable name "SERVER"
ok will try that. Thank you.
Well it doesn't really matter really but I would advise u against using that kind of variable name =)))
why π³
While you are at it, check out init, initserver, initplayerlocal etc.... might help u in the long run
will do
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
No probs mate :D happy to help. Hope the code will work out for you
same π
In a scheduled environment, is it possible to make sure it isn't interrupted in between two or more commands?
you could put the code you need to execute without interruption in isNil { ... } which uses an unscheduled environment inside the code block.
nothing more than the usual side effects/rules/whatever of unscheduled code
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..
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";
not directly
Never
look into Pythia
(Maybe via extensions, but yeah)
Pythia is basically: "I have some SQF stuff, but want to have Python "
Huh, didn't know that
You can do that, if you put SQF script into your test.py
π
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?
no, _x cannot be changed
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?
Since your original idea was to change _x
What about https://community.bistudio.com/wiki/apply ?
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
sorry im big noob xd
ok i am reading it but im still confused how to utilize it as still it doesnt modify the original array?
@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? π
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
no
if you want to change _x, you have to modify the array you're iterating on:
{
_x = call some_fnc_modifyX;
_array set [_forEachIndex, _x];
} forEach _array;
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 ""
};
what this does is modify _vas right?
_va1 stays unchanged?
_va1 changes too
because of _x deleteRange [0,2];
you're deleting the first two elements
yes but it doesnt change into a string?
no
put another params after that π€·
doesn't modify the original
but you still get what you wanted
_vas params ["_va1", "_va2"];
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! π
np
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?
1/ vanilla units?
2/ which ones?
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
If you use respawns, download 3den Enhanced and use the "keep loadout on respawn" (or however it's called) to fix that
well, this does happen even in single player without respawns
In that case you may have a mod which messes it up
@past mist for example CFP (community factions project) has so many intrusive randomizations
so, looking at the classes, i see that maybe the problem is from respawnLinkedItems respawnMagazines and so on
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?
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
I do not have any script to overwrite loadouts atm
...
If you set custom loadouts in 3den, this will be transformed in a script which you should see in the mission.sqm
And even then certain mods do their own thing, so they could be the reason as well
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?
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
can you add a script in the initServer.sqf file that adds loot to supply crates?
yes
carefully
click the link π
kk
Commands used to manipulate a vehicle's (or ammo box) inventory
π
ok nice
great, thats a start
i have like 60 supply boxes
and i need their loot to be random (from a list)
okay
should i get all the item names for everything that I want to spawn in the crates?
classnames would be nice
ok
Can you force a variable to be final? Without using compileFinal.
nope
you can always define a description.ext var and use getMissionConfigValue
Kinda weird that we cant make a code block final, without having it as a string (in one way or another) π
private _finalCode = final { hint "ok" };
```could be nice yeah
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.
so! how are you going to proceed?
https://community.bistudio.com/wiki/Array The wiki page is full of examples, forEach might be best suited in your specific case
he wants random items
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
You can use https://community.bistudio.com/wiki/selectRandom to get a random item from an array
ok nice
first I need to make an array
private _weaponArray
what do I do after that? how do I list the items?
private _weaponArray = [];
that's an array, yes
alright
private _weaponArray = [hgun_ACPC2_F, 9Rnd_45ACP_Mag];
I added two items. is that correct?
@winter rose
Nope
didnt think so
A classname is a string
ok
do i need to define it then?
private _weaponArray = ["hgun_ACPC2_F", "9Rnd_45ACP_Mag"];
@winter rose
So it seems
ok how do I define it?
you just did
no you need to follow what we taught you before in #arma3_editor
you need [weapon, mag] pairs
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?
no
oof
for one, you're missing a [ at start
oh yea
for second missing ] at end
I don't think so
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
I can't believe you literally just typed all of that 
no ididnt
there is something called automation using the config.
you can support custom mods too (RHS, CUP)
still counts as typing!
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?
add it as 3rd indice of the array?
or just make it a random number
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?
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;
wat?
i dont know
first of all, it's not addWeapon
second of all,
#arma3_editor message
third of all, forEach
i am new to scripting
private _weaponArray = selectRandom _weaponArray
then what do I do?
what do you see wrong with that?
with what I just put?
this?
yes
that's what you saw?!
yea it was missing the ;
anything else?
_weaponArray = selectRandom _weaponArray
select a random element from the _weaponArray and assign it to a variable called _weaponArray
do you see it now?
I even spelled it out for you.
ok
so what's wrong with it?
so it is taking a random element from _weaponArray and assigning it to a variable?
i need a new name for a variable
yes
you're overwriting the variable
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
I mean weapon
should I just call the new variable that?
let me ask you this instead. what's the point of _?
i dont know
It makes the variable local
in other words, the variable gets deleted when your script ends.
so it's not accessible to other scripts
so any other lines of code in the same .sqf file?
not necessarily
is it a temporary variable?
do you need it somewhere else?
only in this mission
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
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
ok
that makes sense
i think i understand
so I just want:
_weapon_and_mag = selectRandom _weaponArray;
probably
depends on where you're using that
do you know what I am trying to do with the weapon array?
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?
it's an array
it's holding two elements for you: the weapon (1st element) and the mag(2nd element)
yea
so you have to "pick" them
but that is what the selectRandom does, right?
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
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
no
you simply "organized" them to be in pairs
so it wont select a pair?
it does select a pair
_array = [1,2,3,4,5,6,7];
selectRandom _array //could be any of 1-7 numbers
ok
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
yea
but look
thats what im saying
my array has the weapon grouped with it's respective mag
can you explain to me what your _weapon_and_mag array can be now?
give me an example of what it might be
["hgun_Rook40_F", "30Rnd_9x21_Mag"]
exactly
so when you selectRandom on this array, what do you get?
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?
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
yea
instead you select them yourself:
https://community.bistudio.com/wiki/select
so if I want it to give me a random pair (weapon + respective magazine), what would I do differently?
nothing
you already have a random pair
it is a random pair
ok
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
im confused
- you created an array of pairs called
_weaponArray - you selected a random pair (array) from that and called it
_weapon_and_mag - select the weapon and the mag, save them to their respective variables using
https://community.bistudio.com/wiki/select - add the weapon using:
https://community.bistudio.com/wiki/addWeaponCargoGlobal - add the mag using:
https://community.bistudio.com/wiki/addMagazineCargoGlobal
oh
i get it now
am i selecting from an array, config, or string?
_weapon_and_magazine is an array, right?
yes
ok
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.
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
close
read this
Index 0 denotes the first element, 1 the second, etc.
fixed it
lol
can you tell what is wrong
is Select not supposed to be capitalized?
no
array select index
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;
what's different between selectRandom and select?
Syntax:
selectRandom array
Syntax:
array select index
there is no =?
ok so should I put it back the way it was?
i dont see the difference
the array, then "select", then the index
that is what I put for "select"
is it?
_weapon = Select _weapon_and_mag 0;
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;
yes,
but let's say you have hundreds of crates
do you want to copy paste all of that?!
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;
ok
but wait
i dont want all the crates to have the same contents
is that what forEach does?
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];
...
};
it iterates over the array
do you know what iteration means?
it goes through the array one by one
ok
yeah kinda
not "repeat"
executes the code for every element
maybe
you could even automate the creation of them
good
what was the lesson about _?
no
oh
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)
ok
so I want to name them all crate?
the editor wont let me name them all the same thing
well actually, didn't you say you have the positions already?
in an array?
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.
Or, if part of a mod, make an unique object and find all of them on the terrain
im not using mods
yes
then no need to name them either
ok
_crates = allMissionObjects "class";
class is the className of the object
then you're done.
that plus:
#arma3_scripting message
is all you need
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?
what happened to what I said?
what
do you have to enclose a condition in {} to allow lazy evaluation?
do I still need forEach?
what do you think?
@drifting sky , yes
π
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?
k. thanks
I don't know, what do you think?
check your variable names
ok
what about the first condition? Does it need to be enclosed in {}?
@little raptor can i have
_crates addMagazineCargoGlobal [_mag, 2];
to have more than one mag in the crate?
define "a code"
a code == collection of statements and commands that follow rules of syntax to do something
in sqf code is a data type
yeah but that just leads to the question, what is a datatype
type of data?!
hehe
okay, what's the connection between code being a data type and lazy evaluation?
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
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```
is that the source of the problem right now?!
but yes
follow your logic π€·
Do both (or,and) as well as (||,&&) allow lazy evaluation? I notice the wiki only mentions lazy evaluation on the former.
nevermind
missed it
they're just alternative names for them
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
yes
can you explain the flow of the script to me?
ok
as in say in english what it does
launch that script when the Zeus Enhance interface launches?
if it has a separate display, you'll have to find it yourself
if it uses the same display as vanilla Zeus (more likely), look at this config class:
configFile >> "RscDisplayCurator"
idd = 312 (apparently)
- Select weapon + mag
- Select the weapon and make the variable
_weapon - Select the mag and make the variable
_mag - Select all of one container type and set it to
_crates - Put one weapon and 2 mags into each crate of that type
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)
you didn't explain the role of forEach
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
simple conditions like that slow it down (they execute a code)
the lazy eval is pretty much the same as if
bool = condition1 && {....; condition2}
//is the same as
bool = if (condition1) then {...; condition2} else {false}
@little raptor I think it is something wrong with _crates and forEach
a little better
is it completely fixed though?
well yeah, but what else
no
i dont see anything wrong with it
i understand what it does
and it looks like it should work to me
oh
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.
vehicle = object
yes
ok
weaponName is a string
but in the array, it is also a string
so it already has quotations
no
no
ok
_crates addWeaponCargoGlobal
that's where the problem is
do you see it now?
what is _crates?
_crates is an array
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
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?
yes
it's a magic variable
similar to this
yeah
ok
hopefully it works fine
yea, hopefully
I mean the code is good, unless you make a mistake somewhere else
yes
actually yea, no im good
i just checked
alright
lemme test it out
IT WORKS
IT REALLY WORKS
YASSSSSSS
congrats
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
well you know what to do
yea
but i have a question
can i use the variable _crates again?
for a different type of crate?
it's just a name you give to some variable.
what matters is that it's local, and what it contains.
you don't need nested arrays for that anymore
nested array = array inside another array
yea i dont think there are nested arrays
oh
wait
yea
they can just be separated by commas, and not brackets?
[ ], //<- nested array
[ ] //<- another nested array
]
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
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
yea
I'm assuming you should already know which one to pick
https://community.bistudio.com/wiki/Category:Arma_3:_Scripting_Commands
yea
@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
no
it is a different type of crate
but it doesnt seem to be working
i am getting an error
one sec
yeah
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
probably because their classes are different
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"
probably because you have non-item classNames in that array
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"]
for example, backpacks must be added with:
https://community.bistudio.com/wiki/addBackpackCargoGlobal
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
