#arma3_scripting
1 messages · Page 637 of 1
Have you tried with doTarget?
execVM is only compiled the first time a sqf is called right? Things like #include only happen once, when it is first compiled, correct?
No. Firstly because that won't work with the advanced target selection, secondly because that wasn't required in the working version.
doWatch/doTarget/glanceAt, but yep
it compiles every time it executes.
check the example in the description. it is effectively the same as that.
https://community.bistudio.com/wiki/execVM
oh, damn it. I remember now. I need to add a fake weapon. This was the problem last time and I forgot about it because it wasn't in the main script.
true, I remember nao!
I wish they'd just make everyone's lives easier and add the fake weapon to searchlights by default
Okay, with that in place it will now track the dummy cube. But the advanced target selector seems to have some trouble.
_lightTarget = [allPlayers,_light] call BIS_fnc_nearestPosition;
with this in place rather than the cube target, it kind of freaks out a bit, snapping instantly between dead-centered and a slightly different angle (but clearly not the right angle) every time the loop runs.
Arma2OA. I'm loading an array from hpp file, using #include. I make modifications to the array, and want to save those changes so that they can be used later in the mission. However, when trying to access the same array later, I only get its configuration as it existed in the hpp file. Any ideas for a workaround?
Not talking about saving to disk
save it to a global variable when you first load it and modify that
then update it
im pretty sure i dit let me check
Hmm, can I scan the contents of the hpp file to deterimine what it contains?
it might contain multiple arrays
no it's missing the second removeAction
that's not the case
you're inserting the same variable over and over again
back to square 1
save it to a global variable when you first load it and modify that
this
in other words, call compile the script and save the result
before that script
Let me detail why I'm trying to do. First, I'm no longer using execVM, but instead i've included all the functions in the init file, and I'm "call"ing them now. And you can explain why it's not working. I compose a string as a combination of multiple sub strings. I then missionNamespace getVariable that_string. If the string !isNil, then I read the contents of the array in that variable. I make some changes to the array, and safe it using missionNamespace setVariable [that_string,new_value].
However, when using getVariable again on the same variable name, only the original value of the array is returned
If the string !isNil
you mean the variable isNil ?
I still don't know what's wrong with my searchlight tracking but at least I managed to create a dope rave https://www.youtube.com/watch?v=MyJwBNF5Gh8
I mean if the variable is not isNil
is o_cube global?
_positions = missionNamespace getVariable _positions_name;
_positions_name = (str text NEAR_HOUSE_TYPE) + "_positions";
missionNamespace setVariable [_positions_name,_positions];
There's the code I'm using to try to get and set the variable
@little raptor i had still echos
but with playsound3D Narg 😑
just replace the 3 line with _dummy say3d ["acdc",100,1,false,0]; right?
yes
it's only one line (?!)
you're not making any changes to positions!
you just read it, then save it!
Sorry, yes I am. I cut out stuff in the middle.
params ["_target", "", "_actionId"];
_dummy = "#particlesource" createVehicleLocal ASLToAGL getPosASL _target;
_dummy say3d ["acdc",100,1,false,0];
_target removeAction _actionID;
_target addAction ["AC/DC", {
params ["_target", "", "_actionId", "_dummy"];
deleteVehicle _dummy;
_target removeAction _actionID;
_target addAction ["AC/DC", "acdc.sqf"];
}, _dummy];
``` @little raptor thats the full code right now
looks good
no
cause it got that feeling that the dummy isnt deleted
and even if it was what's the point
it doesn´t create new (or more) addactions in the menü/objekt but still plays the same song while starting a new one!
you don't get any errors right?
no
that makes it so weird
if there would be no dummy i should get an error cant find dummy right?
params ["_target", "", "_actionId"];
_dummy = "#particlesource" createVehicleLocal ASLToAGL getPosASL _target;
_dummy say3d ["acdc",100,1,false,0];
_target removeAction _actionID;
_target addAction ["AC/DC", {
params ["_target", "", "_actionId", "_dummy"];
deleteVehicle _dummy;
_target removeAction _actionID;
_target addAction ["AC/DC", "acdc.sqf"];
}, _dummy];
try this
tell me what it prints in the chat
sec
1780217:<noshape>
but
uhm
now the music stops
if u start it again the number increases around a few numbers
but it works ass intended just with the message
so there wasn't a problem in the first place
I removed that bit again
so no messages anymore
I didn't change anything
OK, it is working now. I am able to reset the variables. It might have been that I was forgetting to actually save them.
you were doing it wrong
in what regard
dunno
each change i went fully back to the editor and reloaded the mission with play mp
or restated the mission
so to say
probably never saved the file
did otherwise notpad would give me a red icon telling me that is has been changed but not saved!
Searchlight update.
The light's janky movement was caused by being attached to the building. This is apparently unnecessary and only screws up its tick rate.
The target position doesn't seem to update even though the script is looping. It looks at where I was at the start, but doesn't follow if I move.
Current code:
params ["_light"];
[_light,["SEARCHLIGHT", [0]]] remoteExec ["addWeaponTurret",_light];
[(gunner _light),["SearchlightOn",_light]] remoteExec ["action",(gunner _light)];
while {true} do {
_possibleTargets = (vehicles select {typeOf _x == "C_Hatchback_01_sport_F"});
_lightTarget = [_possibleTargets,_light] call BIS_fnc_nearestPosition;
[(gunner _light),_lightTarget] remoteExec ["doWatch",(gunner _light)];
[(gunner _light),_lightTarget] remoteExec ["lookAt",(gunner _light)];
sleep 0.01
};```
note: switched to tracking the car as it seemed to be having trouble with the idea of players being inside vehicles.
I don't know 🤷♂️
All I know is that the code was correct. Whatever that was wrong on your end is not an issue anymore
hi baffled, I'm dad!
it never gets old does it?!
😄
I am trying to play a bunch of sounds 10 times around a trigger called kriek_trig. This is my attempt:
_whistles = ["\krieker\coug_whistle_00.ogg","\krieker\coug_whistle_01.ogg","\krieker\coug_whistle_02.ogg"];
for "_i" from 1 to 10 do {
playSound3D [
getMissionPath selectRandom _whistles,
null,
false,
AGLToASL (kriek_trig modelToWorld [
<placeholder_x>,
<placeholder_y>,
0]) ]
sleep 2
}
However, the issue is within the 4th parameter of playSound3D. I want to play the sound at a random RADIUS from kriek_trig, not X,Y,Z position. I want sounds to play at random directions around kriek_trig 200 meters away. How could I do this?
maths!
Dear god, no.
Aha, you almost tricked me into doing math.
Should I need to convert the getPos into ASL since playSound3D uses ASL format?
😄
or
private _randomDir = random 360;
getPosASL _object params ["_posX", "_posY", "_posZ"];
private _finalPos = [
_posX + 200 * sin _randomDir,
_posY + 200 * cos _randomDir,
0
];
quickmaffs
I'll try the previous first and see if it works as intended.
if not, ATL to ASL I believe
lmao, it crashed
But that's probably my own fault. I'm still testing if this works
For some reason, it crashes on index 1. This is my full code.
kriek_trig Trigger
Condition: Any Player
On Activation:
[] execvm "krieker\kriek.sqf";
\krieker\kriek.sqf
_whistles = ["\krieker\coug_whistle_00.ogg","\krieker\coug_whistle_01.ogg","\krieker\coug_whistle_02.ogg"]
for "_i" from 1 to 10 do {
hint str _i;
playSound3D [
getMissionPath selectRandom _whistles,
null,
false,
kriek_trig getPos [200, random 360]
];
sleep 100;
}
I am not entirely sure what is causing it. RPT just states it to be an "Unknown Module" Fault Address error.
no log message? cause it… shouldn't crash?
I am not following, sorry.
what is null?
null takes place for soundSource
soundSource param, which is ignored if position is provided
I'm gonna run a test with playSound exclusively to see if it is a logic error somehow.
(https://community.bistudio.com/wiki/playSound3D for reference)
ok, but specifically null is looking for a global variable, so it would most likely be nil. shouldnt you be using objNull?
good catch xD too much JS on my side
there is no null in SQF?
not as null
that makes sense
on the contrary, there are plenty of nulls
theres nill
objNull, grpNull, taskNull, etc
and a null type for every data type
Let's see if objNull could help with the crashing
explai?
kriek_trig Trigger
Condition: Any Player
On Activation:
[] execvm "krieker\kriek.sqf";
\krieker\kriek.sqf
_whistles = ["\krieker\coug_whistle_00.ogg","\krieker\coug_whistle_01.ogg","\krieker\coug_whistle_02.ogg"]
playSound3D [
getMissionPath selectRandom _whistles,
objNull,
false,
kriek_trig getPos [200, random 360]
];
Can .ogg files crash arma 3?
cause I made the .ogg files myself in Audacity
hm i dont think oggs are a problem.
made some myself and it worked fine
you dont need getMissionPath
the wiki says you do
instead you need to register them in a config iirc
playSound3D [getMissionPath "mySound.ogg", player]; // to play a mission directory sound
ah alright then
example 3
Can playSound3D play sound classes in CfgSounds?
the object for playsound3d is ignored if you give a valid position in param 3
yes, thus I just put objNull for it to be ignored
No. say3D can, but I don't know what other differences that might have that could inconvenience you.
my best guess would be it doesnt like the ogg files. it would only error if there was an issue with the command usage.
try with only one sound in the array?
.ogg is a perfectly normal file type to use with Arma 3. Use 'em all the time.
It requires objects to created for say3D to speak out of.
I am going to try using default arma 3 sounds
im meaning it doesnt like these ogg files. bad encode or something.
have you tried playing it from the debug console?
Something simple like
_whisles = ["A3\Sounds_F\sfx\blip1.wav"];
playSound3D [
getMissionPath selectRandom _whistles,
objNull,
false,
kriek_trig getPos [200, random 360]
];
Should work 🤞🏿
I will try this too
Thank you for the catch
arma uses a special hz thing (audacity settings), otherwise it might change the pitch or sth?
omg, it crashes when I run the previous code block in debug!
yep, Status Access Violations
lol rip
I'm going to try trimming the code down until I find the culprit. I'll just play the sound at sound source now.
_whistles = ["A3\Sounds_F\sfx\blip1.wav"];
playSound3D [
getMissionPath selectRandom _whistles,
kriek_trig
//false,
//kriek_trig getPos [200, random 360]
];
Even this crashed. That could only mean it has nothing to do with the script but with the mods that I have running. I'll just look for another way to achieve my idea. Thank you fellows for your help nonetheless!
try without mods maybe? in Eden, VR world?
Perhaps next week. I made the mistake of doing this before the start of my op and I only have 30 minutes left 🙈
#arma3_scripting message
you're using getMissionPath on a file not in your mission
woops, youre right
_whistles = ["A3\Sounds_F\sfx\blip1.wav"];
playSound3D [
selectRandom _whistles,
kriek_trig
//false,
//kriek_trig getPos [200, random 360]
];
one last test
Hey, it doesn't crash!
this is why i think it was something to do with the ogg files. was your path correct?
All of my sounds and script are located in the "krieker" folder within my mission directory.
It only seems to crash when I use getMissionpath in the 1st parameter
put the blip sound in your mission and test it
Indeed I did, I put it in in debug console, it didn't crash but I didn't hear a sound either.
you testing in editor?
Yes
perhaps it doesnt like absolute file paths (C:\...)
I will attempt a test but without the \krieker\ path, just the filename only.
Something simple as below still crashes
playSound3D [
getMissionPath "coug_growl_00.ogg",
kriek_trig,
];
So you must be right, the ogg files are badly encoded or in the wrong Hz. I don't have time to fix them today so I will delay this idea to next week for my unit.
when you try again you should test without using getMissionPath in editor. just use the paths like you had in the array and see if that works.
remove the last comma?
it was a mistake in the copy paste. I did remove it during the testing.
okido 🙂
ARMA2 is there a built-in command to return all objects of a type within a marker area?
nearestObjects, allMissionObjects ?
Well, I used nearestObjects, and then forEach of those, I transformed their position into marker space and checked if they were within the height and width of the marker.
The following should give a list of all objects with type "Object" or "Type" within the marker "markerName". Only works with a round marker though.
_objects = nearestObjects [getMarkerPos "markerName", ["Object", "Type"], getMarkerSize "markerName" select 0];
In Arma 3 there's inArea, but obviously won't work in Arma 2
were the hell is the gui editor saved? it never founds my config path
arma2OA. During a mission, I'm not able to create units of a faction, unless at least 1 unit of that faction is placed in the mission editor (even at 0 probability of presence). Is there any way around that?
does a group for that side need to exist first? iirc there is something old in a3 files about initialising sides.
That allows me to create units for a faction. However, when creating east units, they are not enemy to west.
nevermind, just saw the entry in the wiki
what "type" do wall objects belong to?
I tried Wall and Wall_F. Neither worked
Is there a function to return an object's type?
not class
some terrain walls may not have a class at all.
What do you mean?
You should use ctrl+shift+s, then paste the result in a text editor and save it.
But that alone is worthless and give error for undefined
not at all
Explain your issue then.
of course it does
you should define the base classes
if you're on dev, use import
I guess I should update the user interface page with an example
yeah
what was that function you once mentioned?
the one that exported the basic classes from the config
1: the format saved with ctrl+shift+s is worthless and no example is given for proper use of it
2: we can save it in that editor but its seems it just goes to the shadow realm
It's saved to UI namespace, thus restarting the game will wipe that data IIRC
Shift + CTRL + S, copies the gui in config format to the clipboard
it's a list of controls, which should be used in a display
@cosmic lichen
what was that function you once mentioned?
the one that exported the basic classes from the config
?
BIS_fnc_exportGUIBaseClasses IIRC
@astral tendon so use that and paste the result before the part where you define the display (or put it in another file and #include it)
https://community.bistudio.com/wiki/BIS_fnc_exportGUIBaseClasses
also, your question is related to #arma3_gui
You don't need that functions. One can also press CTRL + S and select Base Classes.
Hello is there any way to find out who put things in the weapon holder? And then sort them by owners
unless you add ur own tracking of who put what where, i dont believe so.
Thx
What class name should I use instead of "CAManBase" in order to return closest BLUFOR unit to the player? (player is OPFOR)
_cntClosestEnemies = nearestObject [player, "CAManBase"];
hint str _cntClosestEnemies;
There is no such class.
You can try B_soldier_F, but note that not all BLUFOR units come from that class.
you can filter side
The best thing to do is to filter through a list of units by side
Ok, and how do I do so?
nearestObjects and select
Or findIf if you need just one unit
There is also allUnits, which could be faster (not sure)
But you'd have to sort it too
I'm looking at the wiki now and I still cant find a way through filtering via "nearestObjects and select". General idea is that I'm trying to return distance to the closest enemy and execute a code when it'll be < 700m. I was planning to do so via nearestObject and then distance2d, but I can find a way to return closest enemy. Could you explain little bit more about "nearestObjects and select" please?
private _nearestManUnder700 = (nearestObjects [player, [“CAManBase”], 700, true]) select {side _x isEqualTo WEST} select 0
nearestObjects [...] select { side _x == West }
how can I filter Ghillie Suits from uniforms ? is there some config I can check, or do I need to create an array of uniforms ?
private _uniforms = ["U_B_GhillieSuit", "U_O_GhillieSuit", "U_I_GhillieSuit"];
if (uniform _unit in _uniforms) then { ... };
I want to support also mods, so I don't need to define array for every mod
well, there is not really a config entry in uniforms stating hasBranchesAndLeaves = 1 sooo maybe you could use find in the uniform's name to see if it contains ghillie?
yeah, some modded ghillies have different name classes
is there some kind of camouflage coef defined in config?
^ my question, tho
it might also be a skimpy catsuit that has an excellent night time coefficient 😄
😄
maybe configfile >> "CfgWeapons" >> "U_B_GhillieSuit" >> "ItemInfo" >> "uniformClass"
uniformClass = "B_sniper_F";
idea to get all ghillie suits (with modded)
private _all = "getnumber (_x >> 'itemInfo' >> 'type') isEqualTo 801 && getNumber (_x >> 'scope') > 1" configClasses (configfile >> "CfgWeapons") apply { configName _x };
private _list = _all select
{
private _config = toLower _x;
["ghillie", "sniper"] findIf { [_x, _config] call BIS_fnc_inString } != -1
};
copyToClipboard str _list;
If you know the mods, an array is eaiser. 10 mintues looking through ace arsenal. There isnt terribly many ghillies usually
I'm having an issue (please at me as I have the server muted) but for some reason, my code isn't working properly... and I don't know what to think about this
if {false} then {
hint "I Ran";
};
is returning as Error if: Type Code, expected bool
you cant have curly brackets surrounding the outer test of an 'if'
must be round brackets
I swear I am remembering this wrong then
yep
yes, and waitUntil
I swear this language hurts my insides more and more
well, if there is new mod, I need to include that to script. my way you don't need to define array for every mod possible
yeah, dynamic finding is better if you have a variable mod setup. but its also prone to missing a ghillie that has an effed up config.
well, also if modder decide to rename classname, f*** me right ? 😄
Yeah or it looks like a ghillie but has no camo value or sth
There is no protection against poopy mods
am not sure if this falls under scripting, but is there any way to modify the behaviour of the EG Spectator cam/mode?
like changing the distance at which unit name is displayed instead of squad name, placement of tags, editing name/tag layout etc.
can't find anything in the wiki
i got a issue if i host a server via arma client i got a addaction to change the daytime as init on a object ```sqf
this addAction ["day",{setDate[2035,6,24,12,00],hint "Es werde Licht!"}]; this addAction ["night",{setDate[2035,6,24,22,00],hint "Bravo six going dark!"}] ;
but it only works if the Host presses it not the clients
and ideas
(self hosted via client btw.)
Clients' local date is automatically and periodically synchronised with the server date
you are changing the local date, that means the server will reset it
its confusing for me so i should besqf [[2035,6,24,12,00]] remoteExec ["setDate"];; instead of ```sqf
setDate[2035,6,24,12,00];
Yes, but you still need to define the target
global so all player! how do i do that?
https://community.bistudio.com/wiki/remoteExec
See targets
Are DLC checks tied to just models?
Wanted to include DLC exclusion in a mission and a command like getAssetDLCInfo returns Apex for the AK-12s added in Contact for instance.
"DLC exclusion" ?
Spawning items at random and want the option to exclude classes from the list if they are part of a certain DLC.
not just models, but models too
Thanks
this addAction ["Tag",{[[2001,6,22,12,0]] remoteExec ["setDate"];,hint "Es werde Licht!"}];
gives me invalid number in expression
this addAction ["Tag",{[[2001,6,22,12,0]] remoteExec [setDate];,hint "Es werde Licht!"}]; missing [
;, 🤔
[2001,6,22,12,0] remoteExec ["setDate",0];```
it should be correct
sec
remote exec doesn't need a target
@grim coyote the example on wiki shows [[2001,6,22,12,0]] remoteExec ["setDate"];
ah, okay
"];,hin
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
shouldn't ;, be correct tho?
No, since it's inside the {}
I don't understand. everything you type is eventually in a { }
["Tag", {[[2001,6,22,12,0]] remoteExec ["setDate"];,hint "Es werde Licht!"} ];
I mean every code
this addAction ["Tag",{[2001,6,22,12,0] remoteExec ["setDate",0];hint "Es werde Licht!"}];
``` didn't work no error but not working !
@jade abyss invalid number in expression
I still don't get it. if it was in a [] it'd make sense but not in {}
?
, is another line expression separator like ;
u are one step further then me at least i dont even get the diferrence between {} and[]
we're talking about the fundamentals of sqf
Try executing it
liek u wrote?
also, you might want to learn some sqf first
might be an idea but then its just for 1 mission im planing to do
the rest is nearl zeus only
I said "some"
Try executing this in the console:
call { [[2001,6,22,12,0]] remoteExec ["setDate"];,hint "Es werde Licht!"}
No, not you @sharp skiff
ah ok XD
I'm not in the game rn, but I'm assuming you're right!
but I just don't understand why
in case you didn't read that
you should understand the "terms" part before any scripting
hint "a";, hint "b";
The , is just wrong there.
but this isn't
hint "a";; hint "b";
and I don't understand why!
but doenst change the outcome
It's the same as:
call {hint "a";, hint "b";}
do you have comments in your code?
yeah, I'll investigate that later!
Does it even add the action to your scrollmenu?
Are you trying it in MP?
Or Editor/singeplayer?
iirc, setDate needs to be set on the Server, if MP
MP editor
I thought you said it was throwing invalid number error
yes for the set date
the addaction works fine but executing it (aka the set time) gives me invalid...
yeah well nope
[2001,6,22,12,0] remoteExec ["setDate",0]; Ignore what Razer told you, use what you used before
this addAction ["Tag",{[[2001,6,22,12,0]] remoteExec ["setDate",2];}];
That works for me ☝️ *
this addAction ["Tag",{[[2001,6,22,12,0]] remoteExec [setDate];,hint "Es werde Licht!"}];
This you had, the comma was wrong, remove the comma
this addAction ["Tag",{[[2001,6,22,12,0]] remoteExec [setDate];hint "Es werde Licht!"}];
Too slow, already got that.
error missin [ on this addAction ["Tag",{[[2001,6,22,12,0]] remoteExec [setDate];hint "Es werde Licht!"}];
ah
oops
this addAction ["Tag",{[[2001,6,22,12,0]] remoteExec ["setDate"];hint "Es werde Licht!"}];
you give remoteExec the NAME of the command, that means in quotes
This will wait for the periodic server date sync tho
Prolly, but it execs anyway. 0 works too, sure. He is just spamming it to everyone, and i assume the Server will send the update anyway later?
this addAction ["Tag",{[[2001,6,22,12,0]] remoteExec ["setDate"];hint "Es werde Licht!"}]; that did work
full code right now im testing it with a friend now! ```Sqf
this addAction ["Tag",{[[2001,6,22,12,0]] remoteExec ["setDate",2];hint "Es werde Licht!"}];this addAction ["Nacht",{[[2001,6,22,22,0]] remoteExec ["setDate",2];hint "Bravo six going Dark!"}];
because you were in an array?
Since this is done, you might want to read that link
leo already gave that to me im on it
I know, i quoted him, just to remind you
which would be not a problem btw if that would hapen to all players at the same time!
Hello everyone! I need help making so that a players init stays the same even after it respawns. Does anyone now how to do this?
1/ init fields are baaad
2/ use respawn EHs 😉
maybe 🤷
this wasn't:
#arma3_scripting message
and it threw an error
SQF
I used:
this addMPEventHandler ["MPRespawn", {#20 lines of pasted here}];
and it did not work.
you used init field
if (local this) then { this addEventHandler ["Respawned", { /* some stuff that might be global or local IDK your code */ }] };
So is should just put that code into the units init?
yes, but it also depends on what is the code you put in there
Just an Addaction that worked locally, before said unit respawned.
then this should work, if you also add that action in the then block too
guys, do we know if allowdamage false works on buildings?
thanks
Thanks Lou this seems to be working!
so remoteExec should also work with say3D right?
is there a way to get the nearest wheel to an object. lets say a device that shreds a tire on a vehicle to it when activated.
cursorobject setHitPointDamage["HitLFWheel",1]; would hit the left front tire, for example, but how to i get HitLFWheel as a nearest object?
selectionPosition or something like that
so apparently i can use the startparameter filepatching allowed. what exactly does that do? allow me mess with files during runtime?
when do they get reloaded?
i wanna work on a small editor module
i feel like thats very basic stuff for developers sorry
https://community.bistudio.com/wiki/Arma_3_Startup_Parameters#Developer_Options
Has some information.
do i need additional stuff? the CMA:developementsetup mentions an arma 3 p:drive and stuff
no
I get that, but that doesnt really get what the nearest one is.
@trail wedge
how to i get HitLFWheel as a nearest object?
it's not an object. It's a selection.
You have to search among the object's selections to get the wheels, then sort them by distance to get the nearest one
will attempt again, however they seem to have different names from selection that their hitpointdamage name.
if you don't know how, read:
https://community.bistudio.com/wiki/selectionNames
https://community.bistudio.com/wiki/select (for filtering)
https://community.bistudio.com/wiki/selectionPosition
https://community.bistudio.com/wiki/modelToWorld
for sorting:
https://community.bistudio.com/wiki/apply
https://community.bistudio.com/wiki/sort
(or use the BIS fnc)
will attempt again, however they seem to have different names from selection that their hitpointdamage name.
you can probably get the selection from the hit points config
For a refueling script how often is too often to update the fuel? It's a global command so obviously I would assume thats a ton of unnecessary network traffic if you do it multiple times a second. Should I just calculate the time it'd take to fill and then just fill it once the time is over
how do i get the array out of a string like this:
"[""A3\Sounds_F\weapons\Explosion\expl_big_1.wss"",""A3\Sounds_F\weapons\Explosion\expl_big_2.wss"",""A3\Sounds_F\weapons\Explosion\expl_big_3.wss""]";
or: how do i directly pass an array from an editor module input box?
it looks like a simple array, so parseSimpleArray
in other cases, you can call compile the string
thanks that looks just like what i need
great, it works. glad that theres a function for it.
*command 😛
Okay, I've been trying to find a good way to turn a string into an object reference, for an forEach loop.
ouch in advance
I found this thread on the forums;https://forums.bohemia.net/forums/topic/228871-convert-string-to-variable/
what are you trying to do, why are you trying that?
Basically, I've got a bunch of locations where something could be and got tasks and everything set up accordingly, and want to delete a bunch of those "empty" locations once they're not needed anymore
[format["%1_tsk1",_x]] BIS_fnc_deleteTask;
deleteVehicle [format["%1_sector",_x]];
} forEach _leftover_array;```
but deleteVehicle requires an object reference, not a string
as stated by Dedmen in that very link you provided, use getVariable
…then WHY using format if these are already objects??
deleteVehicle _x;
```?
oh wait no
private _obj = missionNamespace getVariable [format ["%1_sector", _x], objNull];
deleteVehicle _obj;
I remember those are not actually the objects I want deleted. So I'm using invisible helper objects as "locations". On those objects I spawn sector modules. Those sector modules is what I want deleted. And they're named x_sector.
so 0_sector, 1_sector, etc?
so I have an empty helper object named something like location_hills_frini_5 and ontop of that later on, I spawn a sector module, which is kept track of by adding "_sector", so like location_hills_frini_5_sector
aaah okay I think I understand what you posted
so missionNamespace contains every single object as a variable?
missionNamespace is the (uhuh) mission's namespace, where theGuysHealth = 1 variables go
OneVar = player;
// same as
missionNamespace setVariable ["OneVar", player];
So, missionNamespace getVariable [format ["%1_sector", _x], objNull]; is looking at the mission, and in it for a variable labelled location_hills_frini_5_sector that is an object (with objNull like a stand-in representing like the "concept" of objects)
Is that......... sorta correct way to look at that?
Hello
Hope someone can help a person new to scripting with seeing what is wrong with this piece.
I am trying to get an addAction to work on a mp server. Have gotten it to work in local test, but when running on mpserver i get:
'[ray1] |#|remoteExec "AL_gravity\gravity_generator..' Error remoteexec: Type String, expected Array
this addaction ["Run latest test phase",{[ray1] remoteExec "AL_gravity\gravity_generator.sqf";},[], 1.5, true, true, "", "true", 9, false, "", ""];
remoteExec takes an array to its right @crude prism
@tribal onyx objNull here being a fallback value in case the provided variable name doesn't exist
thanks for your help, this works like a charm.
I also noticed a complete stupid mistake; [format["%1_tsk1",_x]] BIS_fnc_deleteTask; it's missing the call for that function. That's why I was getting even more errors across the entire thing. Darn typo (also proof I'm a tad tired)
Like this?
this addaction ["Run latest test phase",{[ray1] remoteExec [execVM,2] "AL_gravity\gravity_generator.sqf";},[], 1.5, true, true, "", "true", 9, false, "", ""];
how can i run that "on activation" in a trigger : ```sqf
[radio, ["acdc", 100, 1, false, 0]] remoteExec ["say3d"];
nevermind i forgot an ;
i need a ruber ducky :-I
iam a total math noob. what kind of numbers are numbers like this here. 😬
lightnings = 1.02838e-036;
thats what i get when i check certain weather parameters on the client side
Ever heard of scientific notation? That number means “too small value”
How small it is? In the 1.02838e-036 case, 0.00000000000000000000000000000000000102838
Also, the answer for your question: This article does have one https://community.bistudio.com/wiki/Number
Thanks alot 👌 😅
I highly doubt this is possible, but does anyone know of a way to get the players current weapon OBJECT, in order to for example get it's position, or to change it's texture using hiddenSelectionsTextures?
If not, does anyone know how the game actually creates the weapon object. Like how it attaches to the players hand etc?
not possible
darn
engine process
you can do it in the next version
with an improved attachTo
next version?
Proxies are basically handled by Engine so
next build (v2.02)
it's not even in Dev build yet
Somewhere in this Discord, Dedmen's posts. He teases some sweeties around here
But not really a document
check out dedmen's twitter
@modern sand https://twitter.com/dedmenmiller
at least you can attach the weapon to the hand properly!
without an each frame loop
almost - see the doc
Yeah well I could make my weapon just a static object, and attach it to the players hand. However the current attachTo command doesn't support rotation, so hopefully the new update isn't long 🙂
I think it is! 😐
It'll be in the dev build tho so you can give it a test when it comes out
I'll check if it is
- will be. not out yet (as of now)
in short; don't expect it to drop in the game, unless it actually drops 🤷♂️
we all know that game devs like to show off stuff which will never end up in-game 🤣
currently i have my undercover agent set to captive, even after the players "rescue" him, to avoid some frustration of the ai shooting the undercover agent, so theres still risk of them getting shot, without any real danger, unless there is a stray bullet or a nade
but this is now creating a problem for me
if im in a car, and tell the ai to get in they wont
i have to get out, and get back in
is there maybe a smarter way to go about fixing this
or should i just ignore it
The way I would do it (not necessarily the best)
- addAction on the player
- displays when you are in a car and the AI is nearby
- uses
moveInCargoto put the AI in your car
yeah... problem with AI is that they don't like to be in the same vehicle as other factions (even when civilian, which you are when captive).
So either have them get in first, or force them in like Nikko mentions
oh also, this is unrelated to scripting so i might have to this somewhere else: but for some reason when i play in MP (even in editor) the systemchat..sidechat.. like its just gone, i cant see it
which is going to be difficult because i have friendly ai send some messages there
vanilla?
I'm not sure, but it could also be due to some difficulty settings
Dedmen is one of us! 😛
@ember path I would bet more on a locality issue
pretty sure sidechat doesnt work when you are the only one online
atleast its that way in a2
or it will not broadcast atleast
*chat have always been local effects commands
pretty sure sidechat doesnt work when you are the only one online
you can side chat to yourself
unless he was testing in a self hosted MP session, which makes it weird
that, I can't know. 🤷♂️ nor mods or anything.
Hi, I need help with waitUntil in second while {true} loop. With current syntax code doesn't passes through (no error message), I was trying to use waitUntil { musicBoolean == false }; it gave error: Undifined behavior: waitUntil returned nil. True or false expected. I couldn't find solution in the wiki. What am I doing wrong?
_enemyCheckLoop = [] spawn
{
while {true} do
{
musicBoolean = false;
if (distanceToClosestEnemy < 700 && ClosestEnemy knowsAbout player > 3) then { musicBoolean = true; } else { musicBoolean = false; };
hint str musicBoolean;
sleep 1;
};
};
while {true} do
{
waitUntil { missionNamespace getVariable ["musicBoolean", false] };
if (dayTime < 22) then { playMusic _randomDay; } else { playMusic _randomNight; };
};
First loop work fine, I tested it multiple times, hint str musicBoolean; always returns desired true/false value
waitUntil requires to be spawned
@wary hill ```sqf pwease
As well as, assuming _randomDay and _randomNight is defined.
_actionAmbient = ["action1", "action2", "action3", "action4", "action5", "action6", "action7"];
_dayAmbient = ["day1", "day2", "day3", "day4", "day5", "day6", "day7", "day8"];
_nightAmbient = ["night1", "night2", "night3", "night4", "night5"];
ClosestEnemy = (nearestObjects [player, ["CAManBase"], 700, true]) select {side _x isEqualTo WEST} select 0;
distanceToClosestEnemy = player distance2D ClosestEnemy;
//hint str distanceToClosestEnemy;
_enemyCheckLoop = [] spawn
{
while {true} do
{
musicBoolean = false;
if (distanceToClosestEnemy < 700 && ClosestEnemy knowsAbout player > 3) then { musicBoolean = true; } else { musicBoolean = false; };
hint str musicBoolean;
sleep 1;
};
};
while {true} do
{
_randomDay = selectRandom _dayAmbient;
_randomNight = selectRandom _nightAmbient;
_randomAction = selectRandom _actionAmbient;
waitUntil { musicBoolean == false };
if (dayTime < 22) then { playMusic _randomDay; } else { playMusic _randomNight; };
//if (distanceToClosestEnemy < 700 && ClosestEnemy knowsAbout player > 3) then { playMusic _randomAction; } else { playMusic _randomDay; };
sleep 10;
};
```sqf 👀
sorry, I don't understand
see pinned messages; your code will be highlighted
hint "hello world";```and not```
hint "hello world";```
oh, ok
if you use waitUntil { missionNamespace getVariable ["musicBoolean", false] }; instead of waitUntil { musicBoolean == false }; the error you described does not come up
With current syntax waitUntil { missionNamespace getVariable ["musicBoolean", false] }; code doesn't passes through (no error message)
or you just set musicBoolean = false; at the start
I did it in the 1st loop
_enemyCheckLoop = [] spawn
{
while {true} do
{
musicBoolean = false;
if (distanceToClosestEnemy < 700 && ClosestEnemy knowsAbout player > 3) then { musicBoolean = true; } else { musicBoolean = false; };
hint str musicBoolean;
sleep 1;
};
};
I'm very sorry, but I copied the line and it just works fine for me. What do you mean with it doesn't pass through
the loop you are spawning (first) is executed later. So what ever you write inside that spawn might or might not be executed after your second loop starts
distances never update
so it never becomes true
yeah. that too
private _actionAmbient = ["action1", "action2", "action3", "action4", "action5", "action6", "action7"];
private _dayAmbient = ["day1", "day2", "day3", "day4", "day5", "day6", "day7", "day8"];
private _nightAmbient = ["night1", "night2", "night3", "night4", "night5"];
MusicBoolean = false;
_enemyCheckLoop = [] spawn
{
private ["_closesEnemy", "_distanceToClosestEnemy"];
while {true} do
{
_closestEnemy = (nearestObjects [player, ["CAManBase"], 700, true]) select {side _x isEqualTo WEST} select 0;
_distanceToClosestEnemy = player distance2D _closestEnemy;
if (_distanceToClosestEnemy < 700 && _closestEnemy knowsAbout player > 3) then { MusicBoolean = true; } else { MusicBoolean = false; };
hint str MusicBoolean;
sleep 1;
};
};
while {true} do
{
waitUntil { MusicBoolean };
private _randomMusic = if (dayTime < 22) then { selectRandom _dayAmbient } else { selectRandom _nightAmbient };
playMusic _randomMusic;
sleep 10;
};```
// waitUntil { missionNamespace getVariable ["musicBoolean", false] }; // when blocked out code passes through
if (dayTime < 22) then { playMusic _randomDay; } else { playMusic _randomNight; }; // music starts playing
_closestEnemy = (nearestObjects [player, ["CAManBase"], 700, true]) select {side _x isEqualTo WEST} select 0;
findIf
or forEach + exitWith
waitUntil { missionNamespace getVariable ["musicBoolean", false] };
and
waitUntil { musicBoolean == false };
do opposite things. One does fire on musicBoolean beeing false, the other on true
also, no provision for the array being empty
it'll throw an error if there's no enemy nearby
musicBoolean == false
wat?!
!musicBoolean
Oh, ok, lemme check ur code, but as I understand it doesn't return anything in my case there's error of undefined behavior (returns nil)
And why two loops? Is one part of the code running on another machine?
well, it never exits the first loop either
so it will never play the music
the first loop is spawned...
right
terrible code structure
yes 😄
if (_distanceToClosestEnemy < 700 && _closestEnemy knowsAbout player > 3) then { MusicBoolean = true; } else { MusicBoolean = false; };
MusicBoolean = (_distanceToClosestEnemy < 700 && _closestEnemy knowsAbout player > 3);
if (dayTime < 22) then { playMusic _randomDay; } else { playMusic _randomNight; }; is in the 2nd loop and executes when there is no waitUntil that causes all the problems
I bet, it doesn't
let's start all over: What is the goal of your script? Are you coding a MP mission?
Okay, I double checked
//waitUntil { missionNamespace getVariable ["musicBoolean", false] };
if (dayTime < 22) then { playMusic _randomDay; } else { playMusic _randomNight; }; //fires and music is played
waitUntil { missionNamespace getVariable ["musicBoolean", false] };
if (dayTime < 22) then { playMusic _randomDay; } else { playMusic _randomNight; }; //doesn't fire and music isn't played
however in 2nd case if there is no any enemy at the whole map music starts playing. Works same way as code you send earlier
English only, bon sang :p
How can one make a script with a variable that is determined when the script is called?
// in the script
myVar = "value";
```?
I mean like my script has the variable a. I don't say what a is in the script but when i run the script (execVM "mysript.sqf" ["value i want the a variable to be"]) a is what i put into the between [].
I think they called parameters in English.
a situation like this?```sqf
private _a = objNull;
[_a] execVM "myScript.sqf"; // _a = player
hint str (_a == player); // true
They are called arguments sorry.
Okay so the question in is how to make arguments for scripts.
So instead of a script I need to create a function and put that into the description.ext?
a script can also take arguements. The way you add them is the same.
Okay, thanks a lot!
So I got this script: player setVariable ["copLevel",1,true]; And I am trying to get it so that it works for everyone in bluefor anyone got any ideas
I found a problem with waitUntil, thank you @little raptor, @rancid mulch for your help!
@north cloud yes, forEach and select allUnits where side is blufor
@winter rose Could you explain it more I am very new to scripting and just trying to get some doors working for a mod I am using
sorry, was at work, yeah testing it editor MP thing, but ive also noticed this while playing on a server. Other players can see the chat, i cant
sometimes it even stops showing up mid mission, idk what could be causing this, unless im pressing a key combination that turns it off
U regulate(enable disable) it server side but if u can’t see it through ur client whilst enabled then it’s a local issue
oh reading a thing, it must be the stream friendly ui thing
(i run obs while playing arma to capture clips)
hi im looking for help with scripting an AI unit to drop intel next to its body when the AI is killed so the player can pick it up
you need an event handler:
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Killed
as for dropping intel, you can either add it to the body, or:
_weaponHolder = createVehicle ["WeaponHolderSimulated_Scripted", ASLtoAGL getPosASL _unit, [], 0, "CAN_COLLIDE"]; //create weapon holder to store the item
_weaponHolder addItemCargoGlobal ["intelItem", 1]; //your intel item
copy paste example:
this addEventHandler ["Killed", {
params ["_unit"];
_weaponHolder = createVehicle ["WeaponHolderSimulated_Scripted", ASLtoAGL getPosASL _unit, [], 0, "CAN_COLLIDE"];
_weaponHolder addItemCargoGlobal ["DocumentsSecret", 1];
}];
I have the headle and the intel codes just cant get the intel to spawn at his feet
see Leopard20's last code snippet: it creates an object holder that is then filled with land_document
the 2nd script by Leopard20 is doing exactly that
The item I'm using there won't work tho!
Correct, thus I also know that devs like to show off stuff which will never end up in-game
Every modder / dev is guilty of that I believe 😄
nah, I rarely release any info until I am 101% sure it will make it 😄
Do you guys have an idea of how to make a more efficient dynamic enemy count in an area with the player in the center each x seconds than this?
_tempTrg = createTrigger ["EmptyDetector", getPos player];
_tempTrg setTriggerArea [100, 100, 0, false];
_tempTrg setTriggerActivation ["WEST", "PRESENT", false];
_tempTrg attachTo [player, [0,0,0]];
sleep 1;
while {true} do {
_enemyCount = player countEnemy list _tempTrg;
hint str _enemyCount;
sleep 1;
};
you could shift it to eventhandler based. if more than x eneimies had their killed EH fired, spawn new ones
i get that you want to spawn new enemies but stay under a certain level?
You could also try using nearEntities instead of a trigger.
Yeah, around 20, idk yet exact number. Actually I might make detection as a boolean and adjust a following code
If you only call it every couple seconds it shouldnt be to bad
I would like to have a 'fuel low' event instead of the 'fuel empty' event. I presume, I am not able to do it without having a loop?
bingo (fuel)
Woooow
bingo 😆 ? Where do I find corresponding event?
swoosh
usually at retirement homes 🤣
😅
but afaik is there no other way to get "low fuel" unless you have a loop to check the current amount in the tank
Yes, already thought so. Although there must be some internal check -> bingo
Well of course there is, the game engine handles the fuel after all...
which is simply updating an internal variable, which can be access through fuel, nothing more, nothing less
So could there be an EH for fuel changed? yes. Question is though, how far do you go?
Trigger every 25%, every 10%, every 1%, every tick?
I guess a simple loop and a switch can do magic as well.
even if you check every 15s,it's still "accurate"
I have a couple of waitUntil which don't work as intended in subscope, pls help
actionAmbient = ["action1", "action2", "action3", "action4", "action5", "action6", "action7"];
dayAmbient = ["day1", "day2", "day3", "day4", "day5", "day6", "day7", "day8"];
nightAmbient = ["night1", "night2", "night3", "night4", "night5"];
detectionBoolean = false;
musicBooleanStop = false;
addMusicEventHandler ["MusicStop", {musicBooleanStop = true}];
[] spawn {
while {true} do {
detectionBoolean = true;
_closestEnemy = player findNearestEnemy player;
_distanceToClosestEnemy = player distance2D _closestEnemy;
_enemyAwareness = west knowsAbout player;
if (_enemyAwareness > 3.95 and _distanceToClosestEnemy < 450) then {detectionBoolean = true;} else {detectionBoolean = false;};
hint str detectionBoolean;
//sleep 1;
//hint str _enemyAwareness;
sleep 2;
};
};
[] spawn {
scopeName "ambientLoop";
while {true} do {
player SideChat "break point in ambient loop";
_randomDay = selectRandom dayAmbient;
_randomNight = selectRandom nightAmbient;
_randomAction = selectRandom actionAmbient;
player SideChat "randomization is passed";
//hint str detectionBoolean;
/*
waitUntil { missionNamespace getVariable ["detectionBoolean", false] };
player SideChat "waitUntil is passed";
*/
if (dayTime < 22) then { playMusic _randomDay; } else { playMusic _randomNight; };
waitUntil { missionNamespace getVariable ["detectionBoolean", true] or missionNamespace getVariable ["musicBooleanStop", true]}; // WORKS AS INTENDED
if (missionNamespace getVariable ["detectionBoolean", true]) then {
scopeName "ActionLoop";
while {true} do {
playMusic _randomAction;
player SideChat "_randomAction is playing";
sleep 4;
waitUntil { missionNamespace getVariable ["detectionBoolean", false] or missionNamespace getVariable ["musicBooleanStop", true]}; //PROBLEM: this passes despite "detectionBoolean" is actually true and "musicBooleanStop" is false
player SideChat "waitUntil in ActionLoop has been passed!";
if (missionNamespace getVariable ["detectionBoolean", false]) then {breakOut "ActionLoop"}; //PROBLEM: this passes despite "detectionBoolean" is actually true
sleep 1;
};
sleep 1;
};
sleep 1;
};
};
more code please!
not more, but moarrr
waitUntil { missionNamespace getVariable ["detectionBoolean", false] or missionNamespace getVariable ["musicBooleanStop", true]}; //PROBLEM: this passes despite "detectionBoolean" is actually true and "musicBooleanStop" is false
that is correct, if TRUE or FALSE (equals TRUE) continue
if (missionNamespace getVariable ["detectionBoolean", false]) then {breakOut "ActionLoop"}; //PROBLEM: this passes despite "detectionBoolean" is actually true
that is correct, the value which is returned by missionNamespace getVariable ["detectionBoolean", false] is being checked, so if detectionBoolean = true, than the IF statement will continue
@wary hill make sure you read the syntax on https://community.bistudio.com/wiki/getVariable
because I have the feeling you misunderstood that
Ok, thanks, I'll do it again
Arma2OA: Are variables and event handlers attached to an object automatically removed from memory when the object is deleted?
I was hoping to use this construction waitUntil { missionNamespace getVariable ["detectionBoolean", false] but is there any other way to pass waitUntil with boolean?
they are in A3. unless there's a bug in A2, I'd expect the same
what do you mean? you are passing it with a boolean
how accurate is lineintersects? Can I use it to move spawned units upward when they are intersecting another object's geometry?
yes
Well, it appears to be accurate enough for my purposes. Seems odd that there is no point intersect though.
there is, with another command
it only uses the VIEW lod, so not much
use lineIntersectsSurfaces not in A2
View lod seems pretty good. What lod is better?
wait, is view lod based on the current actual view lod??
ROADWAY or GEOM for what you ask
or is it max view lod?
no, what blocks visibility
what you're thinking of is the resolution lod (processed by the graphics card)
which is not accessible btw
so view lod does not vary according to distance
is there a script (not the ALIAS one) for utilizing the levitation techniques of Contact Campaign? More specifically, one that functions properly for multiplayer?
no
I think view lod is sufficient for my needs.
but remember that the lod must have been loaded by the engine in order for it to work
wait, so it wont work for areas far away from players?
hmm... what's the alternative for A2OA?
not sure. maybe getPos?
not sure how that pertains
For the intersect functions in Arma2, the wiki makes no mention of LOD or problems that could result from that
if you set the position of the object to like [_x,_y,1e4] (ASL or ATL), then try the getPos _unit select 2, it returns the height to the next roadWay surface.
combine that with some trial and error and you can place your unit somewhere "safe"
what does 1e4 stand for?
10^4
so when you set the z to a really great height, it moves the unit down until it touches the first surface?
or do you mean wait for it to fall?
it returns the height to the uppermost surface. so yeah you can put the unit there
you don't wait. it happens instantly
if it's unscheduled, the unit won't even notice it
well, there's the problem
I'm not sure if the isNil trick works in A2, but if it doesn't, you can use a test object
I only want this to happen if the unit's initial position is intersecting an object already
which is why I said trial and error
for objects that start inside of buildings, it won't work at all, will it?
why shouldn't it?
because they'll end up on the roof, wont they?
yes, like I said, use trial and error
example
_pos = getPosASL _unit vectorAdd [0,0,1];
_unit setPosASL _pos;
_unit setPosASL (_pos vectorDiff [0, 0, getPos _unit select 2]);
this will place the unit on top of the next surface within a 1 meter height
so not enough to put it on a roof or even the next floor
it will only move if it's stuck
you can do something like that in a loop to find the best position
because I'm not sure how it'll work if, e.g. you're stuck in a rock that is 3 meters high
Um. I'm not following the logic of that code. On the third line it appears to be getting the difference between _pos and _pos, which is zero, right?
Alright, I think i'm starting to get it
if you move a position 2 meters higher, but you were already on a surface, you get a 2 meter diff, so you're back at your initial pos
does allMapMarkers return markers in specific order? like alphabetical or by how old it is?
but if you were stuck, diff < 2, and you move higher
is this sound? if getPos == getPos + 1, then unit is NOT stuck?
I mean height component, obviously
Wait, no that isn't sound
because it could be inside something tall
Ok, here's a question
there might be a slight error
if the unit is inside, let's say a terrace, and moving it up 1 meter leaves it still inside the terrace, because it might be tall. Won't unit setPos getPos +1z, set the unit on the ground??
and not on top of the terrace, which is what I want
If it is intersecting with a terrace, for example, it should be put on top of the terrace.
But if inside of a building, it should not be moved
which is what it does right now
not just terrace, but walls and rocks and things like that
does it have to be a unit as in a man, or can it be any object?
any object
I'll try it, but I doubt this will work
for walls you also need to check horizontal intersect
I know that it does
because I've used it before
As long as the center of the unit is not inside of a wall, i think it'll be alright
exitwith can terminate a script and return to the calling script, correct?
yes
but it depends on the scope
func = { if(condition) exitWith { do_thing;}; }; exists func, correct?
and returns to whatever called func
yes
is there any problem returning nil from a functoin>?
not unless the calling script expects a return value
yea. in general if the function has a chance of returning a value then it always should, but if it never returns a value then you dont need to check for it.
so say you have a function that returns a number, but has early exit conditions, you might use -1 as default to say the script exited early. that way the calling script still gets a return value, and can know the script didnt complete
what I'm looking for is when returning an object or array, or array of objects, a value to indicate when object or array is not found
objNull or empty array would be my suggestion
probs objNull because then you can do isNull _a
what about this example:```
if ("1Rnd_SMOKE_GP25" in _magazines) exitWith { [GP25Muzzle,1Rnd_SMOKE_GP25]; };
nil;
returning an array in the first case, and nil otherwise
anything wrong with just testing isnil?
you can do it however you want, both are valid.
func_C = { }
func_B = { call func C; }
func_A = {
private [ "_A" ];
call func_B;
}```
func_C and func_B have access to _A, correct?
they should do
and if there's another _A in a scope above func_A, func_c and func_B will definitely refer to func_A's _A, when accessing it, correct?
yes, as long as you dont private _a in the lower scopes
local variables look from the current scope up until it finds a scope with the variable defined.
eg
call {
private _a = 1;
call {
private _a = 2;
call {
_a // 2
};
_a // 2
};
_a // 1
}
thanks
https://community.bistudio.com/wiki/createMarker
createMarker is giving a error "error 4 elements provided 2 expected" but the Parameters has 4 what the hell?
channel: Number - (Optional) The marker channel for MP. since Arma 3 v2.01.146752
creator: Object - (Optional) The marker creator for MP. since Arma 3 v2.01.146752
you're using v2.00 😉
unless you're on the dev version
🙄 great, so I just need to assume that does not work if I just see "since"
yeah... wiki is always as clear as it could/should be
so I just need to assume that does not work if I just see "since"
i wouldnt say that. because not all "since" comments are for the current dev version
can you play full screen videos like how the campaign does it's news casts?
Hey, question for anyone. How would I go about all AI and players being paused at the beginning of a multiplayer mission. (Unable to move and all AI frozen) until I run a script or trigger or however to unfreezing them and "Start" the mission. I want it so I can get Everyone to load in and be ready then unpause it to all start at the same time.
try the animStateChanged EH and switchMove

Arma Cell: Double Agent
Yes me too. But only with a silenced Walther PPK.
I'm trying to make a module with a function that is supposed the get the reference to the module object. I copied this from vanilla module, but it does not work for me:
_logic = _this param [0,objNull,[objNull]];
I get Error Type String, expected Object at that line and I have no idea how to fix that.
stop giving it a string as the first argument 🤷
just diag_log _this and see what you get
you obviously aren't getting what you're expecting, so check what you have and go from there
no, I dont want some other object. I want to get the module itself, a reference to it. Kinda like the game logic object
are you sure the error is from that line?
yes
checked in RTP
_logic = _this param [0,objNull,[objNull]];
if (_logic>
11:52:01 Error position: <param [0,objNull,[objNull]];
if (_logic>
11:52:01 Error Type String, expected Object```
are we finally able to use hash map in sqf??
Well I am, you probably aren't 🤣
ok, I think I got it wrong
so if it doesn't match, it'll use the default param
the garbage data causes problems later it turns out
💀
I need to do some fixing and see what comes up then
us wen?
12:18:32 Error position: <param [0,objNull,[objNull]];
>
12:18:32 Error Type String, expected Object
_logic = _this param [0,objNull,[objNull]]; is literally the only line in the function and it still gives me the error.
Taro i figured that out 2 days ago. This select 1 select 0 is a string telling yiu how the module got executed: in editor on a oaram change or on missionstart ("init")
@thorn saffron sqf systemChat str _this; // to see what is what? also, use params 😛
Any other input parameters need to be defined in the config under Attributes. Their classname will be saved as an variable into the logic object.
Get the parans through
_logic getVariable ["myVariableClassName",defaultValue]
yeah I get that
They are not saved into the _this namespace
from Heli DLC AI spawning module:
private["_emitter","_activated","_initialized"];
_emitter = _this param [0,objNull,[objNull]];
_activated = _this param [2,true,[true]];
_initialized = _emitter getVariable ["initialized",false];
//make sure the emitter is initialized only once
if (_initialized) exitWith {_emitter setVariable ["activated",_activated];};
_emitter setVariable ["initialized",true];
_emitter setVariable ["activated",_activated];```
And somehow that works...
Variable*
Yes because param is different from params. Are you sure that works because it works? and not just because it doesn't throw an error and falls back to objNull?
Also don't use private [...], its bad.
I thought params still throws error when you pass wrong parameter type
I used that line too, stolen from a vanilla module but it didnt work
Since Arma 3 v1.53.132691, onscreen errors are displayed for when the input is of the wrong type or size.
Sounds to me like it will error when you pass wrong type.
But it probably just continues executing with the default value then.
_logic objecr is this select 1 select 0 iirc
Also keep in mind there are two kinds of modules
Editor run and mission run?
I never dealt with modules before so I just copied stuff from the wiki and the vanilla modules. If that does not work, well I have no idea what to do
I already told you to just diag_log _this, check what you have, and then write your code according to that
And Lou also repeated that again
but you seem to just be ignoring what people tell you and instead try to find your own route which keeps failing
Yeah, diag_log ["hello im a module with these params:",_this] gives a good idea
ok. I see what popped up
I think the real question here is how that function is executed.
If it's actually a module function, it will always have the module object passed to it
so maybe your config is wrong
It has the module object passed to it, just not as first param
I think is3DEN = 1; makes a difference to the parameters passed to it
Yeah but the vanilla way uses a different position in the array that didnt work with my module as well 🤷
but for now a systemChat str _this is the best idea
I was just blindsided by the fact wiki stuff and vanilla stuff does not work.
Yeah module wiki is awful
I just reverse reverse engineered the smoke module in the end
and I looked at Heli DLC AI spawning module, with has the same setup, so yeah...
Shall I just repeat that "is3DEN = 1" makes a difference because 3DEN modules work differently?
OH...
Dang reading really is benefitial huh?
The Modules page is not wrong, its all written there, you just need to look
facepalm
just a quick question: are module functions called? Meaning you can't have sleep in them and instead I need to have an inbetween function that spawns the proper function?
Nah, the modules page is still poop.
It does not state what parts in the config are important etc
Its confusing and it didnt help me at all
https://community.bistudio.com/wiki/Modules#Creating_the_Module_Config
almost every config entry is commented here tho, and explained what it does
Well it would be nice to have an explanation on "how to make a barebone module and add up from there"
Yeah i tried using that config in slight variation but it didnt work and the attributes thing didnt at all
I had to change it to arguments to be displayed
For what it's worth the config actually did work for me. I just glossed over the eden init bit with caused issues for me, but that's on me
Well all i can say is: my customer experience with this documentation was awful and frustrating.
well, at least there is some, try taking a shot at editing lighting configs 😄
or dealing with physx
Atleast you can help to fix it if you want to ¯_(ツ)_/¯
Is there any way to sort groups by callsign in the High Command menu without removing and re-adding all groups?
Yeah ill make a tutorial once i understand a bit more whats going on
Or just tell the people in #community_wiki how to fix it
how do i use allowdamage with a group? I've tried 'a1 allowdamage false;' but didnt work. a1 being the group variable?
That command only takes one object, so you'd have to do something like use forEach on the group @dire topaz
cheers
There's an example on the wikipage that you can use as a starting point
right, im stumped, '{ this allowdamage false } forEach [1, 2, 3, 4, 5] a1;' i honestly cant wrap my head around this, anyone able to help?
Did you even read the examples?
Because the answer to your question is literally in there.
thats not what i want
It is, but okay.
@dire topaz allowdamage only works on units, so you need to go through every unit in the group and set it individually. You use forEach to go though every unit
ahh okay
(of course you have to alter the used command in there...)
so i literally put unit, group player
you literally put units group player. no ,
a1 is the group? or a player?
group
then forEach a1;
okay ty
@jade abyss shouldn't it be forEach (units a1)?
Ah, yeah @thorn saffron
fsmowl?
@dire topaz { _x allowdamage false } forEach (units a1);
(will give you the translation via DM
if needed )
cheers
please (I already read it .fsm 🦉)
If you don't spell the letters as "single letters", then it fits
Is there a way to work around holdactions fading if they are longer than ~15 seconds?
don't think so freddo. Seems like a design flaw
guess I should create a ticket
I'm trying to get a flare to spawn randomly in a 150 radius around the object "bob". I'm not sure how to implement this flare script into scripts that randomly spawn stuff in a radius. Anyone able to help?
The flare script:
flrObj = "F_40mm_white" createvehicle ((bob) ModelToWorld [0, 100, 150]); flrObj setVelocity [0,0,-20];
The flare script
😱
use the createVehicle array method instead
Is it bad? @winter rose
flrObj = createVehicle ["F_40mm_white", bob ModelToWorld [0, 100, 150], [], 150, "NONE"];
flrObj setVelocity [0,0,-20];
nono (well, a bit) it's a reference to someone that joined this Discord, asked for "the car script" as if everybody should know it, then left 😄
private _spawnPos = bob getPos [150, random 360] vectorAdd [0, 0, 100];
(if you want a 2D 150m distance at a random 360° angle)
@hushed tendon ↑
Alright
I know I've done this before but I can't remember or find out how to launch the code in a sqf from a trigger. Isn't it something like execVM "test.sqf"; in the activation?
Yeah that will execute the test.sqf script once the trigger activates
Hmm. I'm using the flare script in the sqf and the trigger is being activated so I don't get why it isn't working
is it possible that the sqf doesn't know the information on where "bob" is?
nope
bob is a global variable (on the machine)
i can use a task state as trigger activation right? (eg obj. 1 complete = Trigger activation) im not ingame right now ,just a theory!
it would be better to remoteExec playMusic then?
as trigger= on activation? yes
on task success (instead of checking its state?)
it's just that having a trigger checking every 0.5s if a task is completed is not great; on the contrary, if you simply play the music when you decide to "validate" the task, then nothing is "waiting" for anything 😉
well yeah thats much better 🤣 just had this thoug while listening to AC/DC - Demon Fire i though hey that would be nice if that would play if the ac-130 levels the town and the infantry watches XD
@winter rose Is it possible that part of the code simply does not work with sqf files such as you can only use sleep in sqfs
sleep only works in a suspended context, so you might have to spawn your code; using execVM will also suspend, if you're doing it that way
myCode = { sleep 1; hint "Hello Dolly!"; };
call myCode; // results in an error
[] spawn myCode; // results in hint
I have the execVM called in a trigger and as far as I know that is the only way to call an sqf
but if I understand you correctly sleep will work ingame as long as you call it like you have shown?
in a spawned code (execVM, spawn, etc)
not from a trigger/init field
where sleep and such don't work:
https://community.bistudio.com/wiki/Scheduler#Unscheduled_Environment
so an sqf called by an execVM would work but not if started by a trigger?
an sqf (file) can only be called by an execVM or a Function compile
sqf code cannot sleep in a trigger field no
it should throw an error if you have the -showScriptErrors flag enabled in the launcher
Yes Ryko
then no problem at all
Sorry if I didn't make that clearer
you have no concern about sleep then, because execVM creates a new script 😉
Let me guess:
- player enters trigger
- slight delay
- execVM flare script, flare gets created and launched
Maybe the whole picture might clear this up
I'm trying to make flares spawn at random and repeating (prob between 5-30 seconds) in a random direction while in a 75m radius from the SL.
Well your script will have to have a loop in it, because the trigger will only spawn one time.
Yeah but right now I'm trying to do it in steps and I need to make sure the sqf will even spawn a flare
so what's the problem?
Well the process right now is
1)Trigger is activated
2)execVM calls sqf
3)sqf run flare script
flrObj setVelocity [0,0,-20];```
Yet the flare doesn't spawn
Is it possible that it is spawning but just under the map?
first things first you should be having an error somewhere, are you displaying script errors with the -showScriptErrors flag?
Is that the black box that shows on the screen?
yup
Yeah I'm getting one. Says something about line 1
if you're going to be doing any scripting, get to know your report (.rpt) file, it's located somewhere like C:\Users\YOU\AppData\Local\Arma 3\..... .rpt, everything will be saved there in the most recent file
And that script error will also be there in case you miss what the black box reports, and will allow you to track down the error
The error is from the sqf on line 1
Fab. Now what does the error actually say
flrObj = createVehicle ["F_40mm_white", bob ModelToWorld [0, 100, 150], [], 150, "NONE"];
It'll give you the position
My guess is that it doesn't like bob ModelToWorld [0, 100, 150] as a position array
Maybe replace that with player for the time being and then you can finesse it
You could add a line after it's created:
flrObj setPosATL (getPosATL flrObj vectorAdd [0, 0, 100]);
So just flrObj = createVehicle ["F_40mm_white", player, [], 150, "NONE"];
flrObj = createVehicle ["F_40mm_white", player, [], 150, "NONE"];
flrObj setPosATL (getPosATL flrObj vectorAdd [0, 0, 100]);
flrObj setVelocity [0,0,-20];
yeah with those it still gives an error on line 1
pastebin the entire script
It moves slow(ish)
ja, das ist gut 😄
60kmh isnt quite "slowish" but alright :D
It should take 5 seconds to reach the ground
takes like 15
I've tested my code locally, it works without errors, so I'm not sure what your problem is
don't forget friction 🙃
Hmmmm if you put your flare at .z == 100 and it moves -20m/s on z
How can it take 15 seconds
Arma has no bugs. Only features
Either you messed up your code or flares have their own scripted physics that dont allow fast movement
My bet is on the second
don't forget friction 🙃
the flare may slow down by itself
Also, -20 definitely plummets those flares into the ground, -0.5 makes it a reasonable descent
They don't, if you don't setVelocity on them, they hover until they self destruct
@winter rose is "this" wrong to play the music globall? ```sqf
this ;[["acdc",0]] remoteExec ["playMusic"];;
I don't get why this isn't working 😩
If I'm getting an error from the sqf that means everything but the code inside the sqf is working, but the code in the sqf is fine
(acdc is defined in description.ext)
yes, wrong 😄
well it triggers but wont play so i need to get rid of this somehow
["acdc"] remoteExec ["playMusic"]
```should do
error missin ; hmm
You should get yourself visual studio code and the sqf extensions. They tell you where your code is wrong
in CfgMusic I hope 👀
How are you calling the sqf? Ie., where/what is the statement
Alsp the code obviously isnt fine if it throws an error :D
I'm calling the sqf from an execVM that is in a trigger
Yes, show me that statement
@winter rose yes it works with another add action code i use for a radio but what do i need to replace "this" with
or extend with what
do you even know what this is?
I don't know what you mean by statement. Are you talking about the code in the sqf? @worn forge
magic? as far as i know it makes arguments visible and accessible to the script
@hushed tendon SOMEWHERE, you are calling the execVM statement. Either:
- In a trigger in the eden editor.
- In a script.
- In an INIT field of a unit.
What I want/need/am desperate to know is where that is happening, because how you are calling it could be problematic.
kind of
what it does is return the object which the init field belongs to
Yeah kinda. It collects arguments depending on where its used.
But its still just a variable, in this case a magic one
ah ok
which you don't need for playMusic
so i need to get rid of this and/or tell it to play it on the whole server or each client?
ok
so i have to somehow define "everyone"?

?