#arma3_scripting
1 messages · Page 619 of 1
Is indeed that, but the EH is linked to the curator object. Not an insurmountable problem but not ideal
how can i make a sound/source follow an object? i.e. attach a sound to a moving object
yep, that did it
im jsut struggling with the titles
this doesnt work anymore, does it?
titles[] = {
0, <t color="#ff0000">Red text</t>,
1, <t color="#00ff00">Green text</t>
};```
never mind, you have to designate titlesStructured = true;
albeit, the titles dont ever fade

don't you need "quotes" ?
i'll just spawn BIS_fnc_showSubtitle; at the end of ym script
with an empty string
the subtitles never fade
well, they fade after a considerable time
never mind that
doesnt seem to work either
addMissionEventHandler ["MPEnded", {/*code*/}];```
doesn't seem to be firing at the end of an MP mission, is this a known bug?
It's not called on clients when client disconnects from server (and mission continues).
though
in which case did you encounter this issue @slim oyster?
EH put on server during preInit, endMission command remoteExec'd to server.
I can see that the clientstate changes, and the mission ends via the command
try in initServer.sqf or in a postInit? it may be too early, although I don't know about it
when using setPos on an object that is attached to another object, the position argument for setpos is relative to the parent object, right?
never mind, cant use setpos for an attached object
Yep.
simply use attachTo again
yep
is there a command to wakeup and object's physx simulation?
after i detach an object, it remains floating there
but as soon as i touch or shoot it, it falls
would giving it velocity work?
nope, didnt work
ok, setvelocity works, so long as the velocity is not a zero-vector
enablesimulation true; should also wake it up
that doesnt do it, since the simulation is already enabled
also, biki is down, once again
how do i select the last element of an array?
array select (count array - 1)
that's the point
If you need it later, it will be bad
i reversed the array and took the first member
That's slower
i dont need anything else
it is
but im not running it 1000 times per second
infact, im expecting to run it once an hour
how many elements does it have?
probably 1 to 3
No it never does!
How do I select backwards in an array? For instance: sqf _array = [1,2,3]; _array SELECTBACKWARDS [0, 2]; // returns [3,2]
Do reverse?
That's all I could think of as well, but I just wanted to check if there was something I missed since using that makes things slightly more complicated. Thanks for the confirmation!
How do I check if a player has closed a dialog?
you could check if the display is null. eg isNull findDisplay idd
Or maybe unload EH
Ill look into both thanks!
do mission event handlers have to be executed on every machine? or can i keep it in a initServer?
depends where you need them to execute.
if (_cashString != "cash") exitWith {};
if !(_cashString isEqualTo "cash") exitWith {};
anyone know which is faster for evaluating?
¯_(ツ)_/¯
Hello all. I was wondering if anyone had a work around. Im trying to attach objects to a helicopter. The command works however the AI bugs out while flying the helicopter litterally trying to fly to the moon. I was wondering if anyone had a work around?
Do you need the heli to fly a set route or with different waypoint positions each time? @sudden yacht
@oblique arrow i want it to still be dynamic. I dont want to use unit capture. 😛
Yeah thats what I was going to recommend if it was a set route 
You'll have to wait for someone smarter than me with that problem then 
Looking for someone that knows how to make the ocean scripted to have much bigger waves then max settings in default arma.
You have to make a config. So no luck via scripting
ahhh... oh snap this the real POLPOX
?
you made a ton of awesome mods right?
No
=] retextured cbrn suits, blurry laser!? polpox's quick death screen
artwork supporter, too
anyone know which is faster for evaluating?
@robust brook
the first, less commands
also case insensitive
Hi, are global variables still "alive" when going back in the lobby ?
I believe so
Alright thanks
_emptyModel setPos [_emptyModelpos select 0, _emptyModelpos select 1, 0.1];
Do get anything wrong?
the setpos is incorrect
if _emptyModelPos is defined somewhere, no
but you can do otherwise:
private _emptyModelPos = getPosATL _emptyModel;
_emptyModelPos set [2, 0.1];
_emptyModel setPosATL _emptyModelPos;
// or
_emptyModel setPosATL (getPosATL _emptyModel vectorAdd [0,0,0.1]); // if you want to only up it
_emptyModelpos = getPos _plane; _emptyModel setPos [_emptyModelpos select 0, _emptyModelpos select 1, 0.1];
like this ?
for example yes
otherwise, you don't know what is _emptyModelpos
_emptyModelPos, btw
private ["_plane"]; _plane = _this select 0; _emptyModel = "\A3\data_f\ParticleEffects\Universal\Universal"; _emptyModelpos = getPos _plane; _emptyModel setPos [_gpos select 0, _gpos select 1, 0.1];
@daring sentinel
params ["_plane"];
that's the problem??
How do i get the opposite-vector for vectordir and vectorUp?
multiplying them by -1 doesnt cut it
vectorMultiply -1 ?
doesnt work
shouldn't it? 🤔
or there is some magic at play
to my knowledge, it should
what im trying to do is place an object on another object
and i have a preview of this object placement
i then get the model-to-world of that preview object and attach a copy of it to the parent object at that position
and then i copy the vectorDir and VectorUp of the preview object
but they are flipped, so i tried to multiply those vectors by -1, which... does nothing
here's the paste of the script: https://pastebin.com/EmC7nPH7
there's a lot wrong with it atm, but try to diregard that
i get the object to attach to where i want it to, but the rotation on both vertical and horizontal axes are flipped
as in, the dir and up
maybe it is relative to the attach object - same as setDir
yes
they are
@ebon citrus You should convert the vectors to model coordinates.
Relative to the object it's being attachedTo
obj2 attachTo [obj1, ....]
or set before attaching
Rotation is in obj1 model coordinates
or set before attaching
Yeah. This is better
@winter rose rotation set before attaching doesnt translate to the attached object
the transforms get reset when you attach an object
@ebon citrus You should convert the vectors to model coordinates.
@little raptor how?
vectorWorldToModel
exactly the command i was looking for
im only aware of the config way: https://community.bistudio.com/wiki/Arma_3_Sensors_config_reference
(@vernal mural reveal, to force a spotting)
will make active radar aware of an object ?
alright, that worked it out for me. Thanks @little raptor
np
@vernal mural If the radar has an "AI", yes.
Use the alternative syntax
_radar reveal [ _target, 4]
@ebon citrus I'm not sure how you plan to use that, but do not use the attachTo command every frame or something. It's slow
whazzat?
also what does this have to do with this channel? @harsh vine
figured some smart guy was gonna gonna say something ...but i will remove it to make u happy ...plus i was just showing how my process bar turned out that the guys helped me with.
@harsh vine no flame-baiting 👀
it is not to make anyone happy, if you want to share your progress say it, it's not unwelcomed
if you want to share your progress say it, it's not unwelcomed
Yeah if you had said that you want to show what you've managed to do I wouldnt have said anything
@little raptor where's attachTo and eachframe?
never would cross my mind
I didn't read your code
How do I prevent a dialog from being closed with Esc?
If you have a safe method for closing it, I think you can do it with keyDown event handler
If it returns true, the vanilla game keybindings are ignored.
Does anyone have experience with createSoundSource ?
I'd like to play my sounds within a random area (or randomly from a set of premade markers).
createSoundSource ["hissing", position mytrigger, ["hissmarker","hissmarker_1","hissmarker_2"], 0];
But the above code will only play the sounds from the origin. Changing the value of the "placement" argument does nothing either.
Anyone have any ideas?
is there a way to stop vehicles from doing their ejection-animations when getting out?
more specificly, the RHS c130j
every time you get out, even with moveOut, the back doors animate
Isn't an action animation like that defined in a vehicle config?
i cant find it
never mind, i was looking at the wrong class
here it is
class RHSUSF_EventHandlers {
getIn = "_this call rhs_fnc_C130_doors";
getOut = "_this call rhs_fnc_C130_doors";
};```
ok, so looking through the scripts, i can use doorhandler_R/L respectively on the doors to keep them open
how would i remotely spawn a function?
["param", "my_fnc_function"] remoteExec ["spawn", target]
will that work?
["Some parameter string"] remoteExec ["X_fnc_Y", 42];
[player, [
"Teleport players on Pad",
{
params ["_target", "_caller", "_actionId", "_arguments"];
[player] remoteExec ["removeAllActions",0,true];
[] spawn {
[teleFrame, "teleport"] remoteExec ["say2D"];
["teleportIn", ["","BLACK", 2]] remoteExec ["cutText", 0];
sleep 5.3;
_players = nearestObjects [teleFrame, ["Man"], 5, true];
{
_location = getPosASLW telePosition;
_x setPosASLW _location;
} forEach _players;
["teleportIn", ["", "PLAIN"]] remoteExec ["cutText",0];
};
},
"",
1.5,
true,
true,
"",
"player inArea teleTrigger",
5,
false,
"",
""
]
] remoteExec ["addAction",0,true];
This is not appearing for each player. Am i using player wrong?
its called from an sqf file ran on the server
what is the practical difference between getDir and getDirVisual?
can i attach a camera to an object? Or do i need to set the camera pos each frame?
no idea
i tried to attach a camera object to a fast moving object
but the camera object gets real jittery
Due jittering, I would advise you to continuously change position with a smooth commit time.
You do not need to set pos each frame and I believe that would still cause an annoying effect like attaching does (may be dependent on certain circumstances though), although I have never tried it.
ok, so i tracked down the cause of the jitter, and it is SOLELY caused by the camSetDir command
if i drop that out, all jitter disappears
if i add even 0.01 cam commit time, the camera wont rotate, since im running on each frame
and i mean the cam wont rotate AT ALL
fps is static, but the camera is jittery as all hell
the vector im giving it is changing smoothly, but the camera refuses to rotate without jittering
the camera direction updates every 0.5~ seconds
moving the setDir into a while-loop that runs at a lower frequenzy fixed the jitter
Yes, that is what I meant that it would still cause an issue running it in each frame :)
i see
albeit, the setpos needs to run on each frame
but! another question
how can i make the camera disregard collision?
atm, it refuses to collide with some objects and just sort of jumps around when it has to
setPos or camSetPos?
dunno about collision, I did not experience anything regarding that.
as far as I can remember, at least..
because, at the moment im having the issue of the camera dropping to sea-level as soon as it is placed inside an object by camSetPos
Are hint messages local?
Yes AFAIK
Okay, on that note, how would I globally hint everyone? E.g., if somebody opens a restricted door it lets everyone know
remoteExec?
oh, thank you
Not sure if this is a script thing and I have no idea how to do scripting and sadly not wanting to really learn it. Does anyone have a quick thing that can make a box spawn ai, so for instance you could walk up to it and have it spawn you a riflemen or something to join your group?
Ok, what i have found:
When using attachTo on a fast moving object, the attached object very briefly (in render time scope) teleports to the center of the parent object before being moved to its designated position, even when setting the offset in the attachTo command
what are you attaching? why not do it before its moving?
I'm taking a look at RHS's moveInside script
Theyre moving the object inside the aircraft relative to it
ah.. the holy grail

It was a good read on vectors
Anyways, it bugs out like hell if the plane is moving
I just came out of shower, but i wonder if using simulation time scope would fix it
Otherwise it would have to be fixed engine-side
its not really something the engine is meant for
I suspect the parenting of an object is being reinitialized every time the attachTo command reruns
This could be avoided by simply changing the offset if the parent is same
A little bit of smarts
@young current arma was not meant for a lot of things, but because people took it outside its intended purpose, we have gotten a lot of nice things
I know. I do that myself too.
Just wanted to make sure you know it might not be attainable
Yes, i am very aware
You could try using setpos commands after the attachTo
This is more of a study than a priject
Setpos doesnt work when using attachTo
If the problem is as i suspect
It could be remedied with an easy engine side chabge
Change*
"easy"
That would not break any existing scripts
Easy as in one if-check
If the parent is already the parent, you dont need to reparent
I would not make assumptions like that though
It is a conjecture, yes
From logical standpoint, IF the issue is as i suspect, it would be easy
But i dont know the details
Arma 3 isnt open source

Pliz Bohemia, open source arma, plox
(Just a joke, dont take it seriously, i know the security implications this would have)
OR!
it could be that the plane's movement-position is not being updated synchronously with the attachTo command and the attached object briefly has incorrect location
or i might just be entirely wrong and it's something else
so for instance you could walk up to it and have it spawn you a riflemen or something to join your group?
@next marsh That sounds like it would be relatively easy to make even without scripting knowledge and there are already some scripts that do stuff like that out there
The basic steps would be to
add the recruiting actions to the box (addAction)
when someone executes one of the actions:
create an ai unit
get the player that exxecuted the action
add the ai unit to the players group
it looks like you can do the last 2 steps using createUnit although I havent used that command before
Would you be able to walk me through how to add all that in qhen I have a chance tonight?
Is the script responsible for the Radar-display open already? Or is it engine-side/encrypted?
engine-side I believe
heck
i wanted to add altitude-indicators to the radar-display
well, i guess i'll make my own radar-display then
cardgames* and professional street artists
yeah, i was scrolling through the Rsc configs
ion ui_f
and ui_f_jets
but couldnt find it with a long scrub
might be the AAR?
air-to-air-radar?
🤷♂️
AAR = After Action Review no?
an unfinished A3 feature
i found all the radar icons
but i cant find the RscDisplay
arma 3 does a lot of their UI in sqf instead of configs, is there a reason for that?
I suppose it prevents reloading to check/debug the config🙃
maybe peeps in #arma3_gui know
Im trying to use sqf onButtonClick = player customChat [_channelD, format ["%1 folded!", name player]]; but it keeps coming up with an error saying it expects an "=" sign rather than "%". Any ideas?
Is that in a config? Or in a script?
In a dialog
You probably need to wrap the whole thing in quotes, and change the quotes around %1 folded! to single quotes.
You might also have an issue with _channelD not being defined.
^
Perfect thanks! Didnt realize using " could cause an issue
do the loiter waypoints actually work combat wise? it seems that aircraft loiter with its radius but won't engage any threats
How would I pull the value out of a while loop? E.g. while {_doingTest} do { _pos = getPos player; systemChat str(_pos) };
I would like to get _pos out so I can use waituntil
@fair drum No. Loiter shouldn't be used for aircraft
@mortal nacelle Which value?!
the coordinates of the player from getpos
Do you want to use it in the same handle?
Uhm, I can try and explain what I am doing so it will make more sense - I am trying to get the players position until they reach a certain area
so then I can delete the instruction marker and place another
So only get it once they've reached there
okay, but how do i know when they have reached that point? waituntil?
oh
waitUntil {getPos player inArea _marker; sleep 1};
got it, thank you. i thought i was over-complicating things
actually, if inareaarray uses the whole location of a trigger i'd prefer that
means there is more room for error for the person driving
yeah, inArea is enough
@mortal nacelle If you use triggers, there's no need for inArea either
Just set the trigger completion statement to deleting the marker
alright
You could also work with waypoints.
They automatically get removed once player is close. Then the next one gets shown.
yeah just normal move waypoints that you would give to AI. if you give it to a player, it just shows them where to go
but how would i get that to show only when the script is called
shouldn't that sleep 1; be at the start?
yes
it MUST be before the end. otherwise it won't return anything.
how would i get that to show only when the script is called
Show what?
whats the ACE command to cause surrender script wise?
cause if I do the surrender action from base arma, then they cannot use handcuffs
might be...
[unit,true] call ACE_captives_fnc_setSurrendered;
How do I count the number of the same element in an array Arma 3? For instance: _1sInArray = 1 countAmountInArray [1,1,1,1,0,9,0,3] //returns 4
Probably something like this
TAG_fnc_countInArray = {
params [["_array", [], [[]]], "_search"];
_filtered = _array apply {_x isEqualTo _search};
_inArray = count _filtered;
_inArray
};
_result = [[1,1,1,1,0,9,0,3], 1] call TAG_fnc_countInArray;
btw... never say any programming language which has a function like this by default...
Are we able to ask questions regarding CBA functions here?
why not; a lot of people use CBA in scripting so perhaps we can also supply an answer to your question. And if not you can always ask the CBA devs directly through their official channels.
👍
Okay, well, I am trying for better practise to use the function 'CBA_fnc_waitUntilAndExecute' instead of waitUntil.
But, I am not getting the hang of it, and was wondering if somebody could point me in the right direction.
[{getPos player inArea p3area}, {hint "test"; deleteMarker "Driving Test"}] call CBA_fnc_waitUntilAndExecute;
official documentation: https://cbateam.github.io/CBA_A3/docs/files/common/fnc_waitUntilAndExecute-sqf.html
And what are you expecting vs what is happening?
Yes, I am on that documentation and I am passing the parameters that are required, the other 3 are saying optional.
I am expecting it to wait until I have reached the trigger position p3area, which worked fine with waitUntil, however, with this function, it is literally just flying through the whole of my script.
keep in mind it works differently than waitUntil
waitUntil blocks the code will it is allowed to run, CBA_fnc_waitUntilAndExecute will wait till _condition is true and will then run _statement
any code after CBA_fnc_waitUntilAndExecute will still run normaly (non-blocking)
Oh, how can I stop that?
put the code you want to have on hold in the _statement code 😉
Uhmm, confused 😦 There is like 50 lines of code though? And I am using that function 4 times within the script
If I put my code into pastebin you'll see what I mean
if you have a lot of code, put it in a function and call that
so you want to place the first marker, wait till person is there, and than remove the first marker and place a second one
yes
exactly that
until they get to the fourth marker, then i delete the vehicle and teleport them back to the spawn point
I would make 4 functions, one for each marker:
TAG_fnc_point1 = {
// place marker etc.
[{getPos player inArea p1area}, {deleteMarker "Driving Test"; call TAG_fnc_point2}] call CBA_fnc_waitUntilAndExecute;
};
Where you call the first function directly, and the last function will not call for the next point but remove everything and TP player.
although you might need to use the _args part to send data to the next function
which data?
the vehicle for example, since the code is executed outside of the script scope, meaning _veh does not exist inside the code block of CBA_fnc_waitUntilAndExecute (which is required to remove it again)
or you can simply store it with missionNamespace setVariable ["TAG_vehicle", _veh] before running the functions and then retrieve it at step 4
so i'd store it when i create it at the beginning of the script?
yes
I see, thank you
Evening fellas, is there a way to sync AI that have been spawned post-mission start to sector control?
Or something with a similar effect on AI behaviour
@exotic flax I'd need to store the location where the vehicle came out as well right?
Because I am teleporting to that point
in that case yes
👍
unless the position is always known (which is seems to be at getMarkerPos "drivingTestStart")
if i do a "entity killed" mission event handler, and I run it in init.sqf with 20 people, will that code execute 20 times when someone kills a unit? theres no mention of if its global, local, or server on the wiki
Mission event handlers are specific EHs that are anchored to the running mission and automatically removed when mission is over. These events fire only on the machine where they have been added.
for years I've never been able to get in thisList to work
so I make a trigger with the condition dude in thisList
create a unit called dude
he enters the trigger, nothing happens
and what are the other settings of the trigger?
everything is default
except for whatever I put in on activation
for testing purposes I put hint "complete"
activation drop down is set to none
make sure the trigger activation is with of "Present" type
otherwise will always be empty (since it doesn't check for anything)
well, that won't work... since it doesn't check for anything to activate on
like I said; put Activation to "Any Player" and Activation Type to "Present"
I got it to work with infantry using that method, I had to set trigger owner to get it to work on vehicles
it's strange you have to have 2 activations instead of just the in thislist condition
I'd assume putting whatever in thislist is the activation
that's to prevent having EVERYTHING in thisList (like animals, objects, etc.), and to make sure the trigger is only active when needed (eg. with the Radio triggers it won't run any code until the radio command has been given)
it's simply to improve performance
and the wiki would have explained that 🤷♂️
didn't find that in the wiki
Any reason why this wouldn't work inside a UI 'onLoad' script:
// working code
diag_log "-- before Spawn";
0 = [_display] spawn {
params ["_display"];
diag_log "-- inside Spawn";
// do some stuff with display/controls
while { (ctrlVisible 42420001) } do {
diag_log "-- inside While";
// do some stuff with display/controls
uiSleep 3;
};
};
diag_log "-- after Spawn";
// working code
The above only prints "before Spawn" and "after Spawn", while the rest is ignored
and yes, I know spawn is unscheduled so the order might differ, but at the moment it's not printing anything from inside the spawn.
Not sure whether this is scripting or not but I was curious how Arma 3 Epoch made it so when there are items on a shelf, it displays them. I am assuming its scripted, but perhaps its in the model. So my question is how do you do that?
@tiny wadi you could look at the source code of Epoch: https://github.com/EpochModTeam/Epoch
🤦♂️ That made too much sense, lol.
How do I turn this array [[1,2], [3,4]] into an array like this [1,2,3,4]?
you can add the two of them together
_mainArray = [[1,2], [3,4]];
_mainArray = (_mainArray select 0) + (_mainArray select 1);```
Ill give it a go thanks!
Does anyone understand how bis_fnc_moduleSpawnAI and bis_fnc_moduleSpawnAISectorTactic work and how they cause the AI to capture sectors. I'm trying to replicate the same thing but with AI spawned after mission start.
@exotic flax Because you're not referencing the control properly
which control? it doesn't even execute the spawn
I simply removed all other code (like getting the _display and _control)
while {ctrlVisible (_display displayCtrl 42420001)} do {...}
the rest of the script is running file, and everything is shown/hidden properly
I can't use while since I need a sleep
still doesn't answer my question
What question?
The above only prints "before Spawn" and "after Spawn", while the rest is ignored
Because you're doing it wrong. It doesn't even enter the while
so spawn is not executed at all
Are you sure?
@exotic flax afaik spawn creates a separate thread independent of the current script loop
doesn't change anything (I've added it to see if that would solve the issue)
And regarding ctrlVisible :
Parameters:
idc: Number - control ID
_bool = ctrlVisible 100;
That doesn't make sense tho
@potent dirge I know spawn creates a separate threat, but it should still print stuff in my RTP
Displays could have the same IDC
I can fix that the moment it actually gets there 🤷♂️
replace (ctrlVisible 42420001) with true just for testing sake
Is that a code you put in onLoad?
onLoad = "spawn thatFnc"
He said it doesn't even get there @potent dirge
onLoad = "[""onLoad"",_this,""RscDisplayMain"",'UNITAF_NewMenu'] call (uiNamespace getVariable 'BIS_fnc_initDisplay')";
and my code is in RscDisplayMain.sqf (within 'onload' case)
PS. I know it's also a #arma3_gui question, but since it's a script which isn't doing what I'm expecting I placed it here
but changing it to while {true} do { still doesn't make the spawn work
have you defined _display?
yes and is used before and after my code
Although it should work even if you havent
A silly question. Isn't the scheduler busy or something?!
diag_activeScripts
it shouldn't, but testing now
You can spawn a simple code, see if that works:
[] spawn {
systemChat "ScriptDone"
}
If not, the scheduler is busy
Maybe due to a while loop without sleep
22:09:04 "-- before Spawn"
22:09:04 "[0,0,0,0]"
22:09:04 "-- after Spawn"
22:09:04 "[1,0,0,0]"
Did you try a simple spawn, just to make sure that it doesn't work at all?
Like what I posted above?
what is "scheduler is busy"?
If it has too many scripts running, it will be busy
for "_i" from 0 to 100 do {
[] spawn {while {true} do {}}
}
Now it is busy
It means it has too many scripts before reaching a code
I mean in relative terms! 🙂
newly spawned scripts are executed immediately
before the spawn it has none, after the spawn it has 1 🤷♂️
No they're not
they never ran, so they have the longest time since they last ran, meaning they execute next
What if it is at the end of the queue?
what end?
I just told you how it works
so they have the longest time since they last ran, meaning they execute next
Last one added
the only thing I can image is that the scheduler is not running when in the main menu, and therefor not running spawned code... but that doesn't sound logical
main menu with world loaded in background? or world=empty?
But if you do this:
for "_i" from 0 to 1000 do {
[] spawn {while {true} do {for "_i" from 0 to 1e5 do {}}}
}
And then spawn a new code, it won't execute right away @still forum
could make a difference
scheduler sorts by last execution time. newly spawned script has "0" so is supposed to execute right away
I've got world=VR and intro is running
@little raptor that code will never run properly, since _i inside the spawn doesn't exist 🤷♂️
don't think I ever tried running scheduled in main menu
That number was too big!
since _i inside the spawn doesn't exist 🤷♂️
huh? why would it need to?
true... the for loop has it's own _i
@exotic flax Yes it does
anyhow... seems that spawn simply doesn't work in the main menu
And then spawn a new code, it won't execute right away
yeah as I said, it sorts by last execute time, there you spawn 1000 new scripts with last exec time of 0
so spawning one more with time 0, they are all equal
for "_i" from 0 to 1000 do {
[] spawn {while {true} do {for "_i" from 0 to 1e6 do {}}}
};
[] spawn {hint "test"; };
this won't hint "test" immediately, because you have 1001 scripts with last exec time of 0.
But when many scripts are running, and have been running for a while, new script gets "prio"
This is how I tested:
for "_i" from 0 to 1000 do {
[] spawn {while {true} do {for "_i" from 0 to 1e4 do {}}}
}
I closed the menu, waited for 2 seconds:
[] spawn {systemChat "processed"}
And it didn't execute immediately
when I do that I drop to about 2fps
and you get one script execute per frame, so you need 1000 frames to get to the last spawn
now it is 1e4
its weird, that for loop seems to not suspend after 3ms
it should not be able to run more than 3ms
ok, so I can see that the spawn is added to the scheduler with diag_activeSQFScripts, but is not running...
probably because the NewExpression instruction is missing
Maybe scheduler doesn't work in the main menu
for "_i" from 0 to 1000 do {
[] spawn {while {true} do {for "_i" from 0 to 1e6 do {1;}}}
};
[] spawn {hint "test"; };
this suspends correctly now that it has the NewExpression instruction in the loop
Oh
But still it doesn't show the systemChat for me
Use 1e4:
for "_i" from 0 to 1000 do {
[] spawn {while {true} do {for "_i" from 0 to 1e4 do {1}}}
}
Sooooo
A new way to haxor in arma I guess
Making the game freeze essentially
which freeze?
The 2fps thingy
2fps is not a freeze tho
and you can just crash the game if you want, so why freeze it
Can promise ya that most people would report it as "random freezing"
Hey, while you're here please is there anyway to sync AI to Sector Control after mission start. I've looking into BIS_spawnAI and BIS_spawnAISectorTactic functions but can't seem to find anything relating to AI behaviour.
this won't hint "test" immediately, because you have 1001 scripts with last exec time of 0.
But when many scripts are running, and have been running for a while, new script gets "prio"
That's what I meant by "queue". So technically, the scheduler is "busy"
in short; when those modules are called it will run some FSM files to manage the AI
That's what I meant by "queue". So technically, the scheduler is "busy"
Although I can see the scheduler is empty, so that's not my issue
Maybe it simply doesn't work in the main menu
Or maybe it gets terminated immediately after running
I see it in diag_activeSQFScripts, so it's there
Or maybe the scheduler gets "cleared" and reset
I'm not sure what's going on. But normally your code should execute as it is correct and I can't think of any other reason why it doesn't work. Maybe Dedmen can check if what I said is true?
script simulation seems to always run, can't see anything that would disable it in main menu
@exotic flax How does your display get created?
automatically 😉
If you create it during a mission, does it work? (I mean the spawn)
it removes the default main menu, and replaces it with a custom one
^
when using createDialog "RscDisplayMain" is does run the spawn
ok. So whatever it is it is related to the scheduler not working in the main menu
Maybe you can find a more "creative" way to work around it?
Like, instead of using onLoad, use an init code that gets executed in the main menu
And if your display exists, it does whatever it should
you checked that diag_activeScripts lists it after you added it
try logging a second later and check if its still there
maybe the display is loaded before the background mission is loaded, on mission load, scheduler list is emptied. Maybe it gets emptied right after you added your scirpt
Exactly what I was thinking!
when checking diag_activeScripts about 100 lines of code later it still exists
100 lines of code in unscheduled is still instant
It doesnt matter how many lines after
so how to do that... I can't execute scheduled code, so can't wait a second in that code...
a button
Use an init function that gets executed in the main menu
or maybe b button
Yeah but that would be weird since he's trying to replace the main menu!
I'm sure he can add a quick button just for testing
For testing, yeah of course!
at least someone is helping
which one?! 😅
exactly 😉
onLoad:
22:52:32 "-- before Spawn"
22:52:32 "[0,0,0,0]"
22:52:32 "-- after Spawn"
22:52:32 "[[""<spawn>
params [""""_display""""];
_control = (_display displayctrl 42420001);
diag_log """"-- inside Spawn"""";
diag_"","""",true,1]]"
onButtonClick:
22:52:58 "-- some button --"
22:52:58 "[37,0,0,1]"
22:52:58 "[[""<spawn>
private _display = displayNull;
waitUntil {
_display = if is3DEN then {findDisplay 313} else {findD"",""cau\discordrichpresence\fn_init.sqf [DiscordRichPresence_fnc_init]"",true,110],[""<spawn>
while {TRUE} do {
sleep 300;
skipTime (_this - dayTime);
};
"",""a3\map_VR_scenes_f\scenes\intro1.VR\initintro.sqf"",true,9],[""BIS_fnc_displayMission"",""A3\functions_f\respawn\fn_initRespawn.sqf [BIS_fnc_initRespawn]"",true,33],[""<spawn>
while {!isNull _this} do {
_this setDir (direction _this + (_this getVariable """"BIS_VR_speed""""));
sle"",""A3\functions_f_bootcamp\VR\fn_VRSpawnSelector.sqf [BIS_fnc_VRSpawnSelector]"",true,40],[""<spawn>
while {!isNull _this} do {
_this setDir (direction _this + (_this getVariable """"BIS_VR_speed""""));
sle"",""A3\functions_f_bootcamp\VR\fn_VRSpawnSelector.sqf [BIS_fnc_VRSpawnSelector]"",true,40],[""<spawn>
while {!isNull _this} do {
_this setDir (direction _this + (_this getVariable """"BIS_VR_speed""""));
sle"",""A3\functions_f_bootcamp\VR\fn_VRSpawnSelector.sqf
so doesn't exist anymore 🤔
on what?
create a function
And set:
postInit=1
and let it do what you're trying to do with your display
It will work
AFAIK
@exotic flax Something like:
[] spawn {
_maxTime = 3;
waitUntil {!isNull findDisplay IDD || time > _maxTime};
//now do what you want
}
that should only work when there's no -world=empty
but will try
so the spawn is now working, and the while
not doing what I want, but that's another problem I have to tackle
What do you mean?
If it works, you can do whatever you want
[] spawn {
_maxTime = 3;
waitUntil {!isNull findDisplay IDD || time > _maxTime};
_display = findDisplay IDD;
// working code
diag_log "-- before Spawn";
0 = [_display] spawn {
params ["_display"];
diag_log "-- inside Spawn";
// do some stuff with display/controls
while { (ctrlVisible 42420001) } do {
diag_log "-- inside While";
// do some stuff with display/controls
uiSleep 3;
};
};
diag_log "-- after Spawn";
// working code
}
but what I want is not working yet, but at least I can now make that work
🤷♂️
the code is executed correctly, but the code itself is not working yet (as in, I made a mistake somewhere inside the spawn
doesn't look like it
probably same issue as CBA Settings
because only preStart = 1 should run even without a mission loading, but is too early
Are you sure?
I said postInit because I was sure it wasn't early
But I'm not sure about preStart
preInit works
Good!
but not with -world=empty, which is the least of my problems
so when respawn tickets reach 0, and I add more tickets, it changes the spawn typee to on dead body instead of base... anyone know why?
Question regarding this event handler (https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#HandleDamage)
What would be the correct condition check for checking if the source was another players vehicle or not
as in; got hit by vehicle driven by another player, or getting shot by a gun on a vehicle?
although _source is the part you want to be checking
and perhaps _instigator
yeah, exactly that, the area will be closed so nobody will be able to shoot however, people might just think its funny to ram eachother
and when the vehicle gets damaged i have it set to fail instantly
but i'd like to exitwith if the damage is done by another vehicles player
if damage zone is "", it is either a fall or a vehicle collision
if damage zone is "" and there is an instigator, then it is driver's fault
hint "Objective Alpha has been taken by BLUFOR.";
redalpha1 call BIS_fnc_removeRespawnPosition;
redalpha2 call BIS_fnc_removeRespawnPosition;```
Doesn't actually delete the respawn points given. Anyone know why? (Using the 3den editor respawn module)
going to try use this method tomorrow. Will come back if it doesn't work https://discordapp.com/channels/105462288051380224/105462984087728128/733334448636035082
where should I define variables if init.sqf is too slow by the time they need to be used?
im aware and have been reading it
but expressions of eden editor are not JIP
which would be a init box in the editor correct?
no, init boxes are one level below that
I just created a function with the variables and put a preinit value to it
should be the fastest correct?
Anyone can point how to use setVelocity in a junction with setVectorDirAndUp ?
//eachFrame
_vel = velocity _vehicle;
_vehicle setVectorDirAndUp [...];
_vehicle setVelocity _vel;
results into _vehicle rotating on its position without movement;
@quartz pebble What are you trying to achieve?
@quartz pebble
If you're trying to rotate the object then set its velocity so that it moves in the new direction:
_veh setVectorDirAndUp [...];
_veh setVelocityModelSpace [0,_speed,0]
this causes the vehicle to move forward
Alternatively:
_speed = vectorMagnitude velocity _veh;
_veh setVectorDirAndUp [_dir, _up];
_veh setVelocity (vectorNormalized _dir vectorMultiply _speed);
To preserve last relative velocity:
_vel = velocityModelSpace _veh;
_veh setVectorDirAndUp [...];
_veh setVelocityModelSpace _vel
Hey, I'm syncing a support requester module to the player with "player synchronizeObjectsAdd [Support_Requester_01];" using a trigger and it's working perfectly. Can I do something similar but syncing a provider to the Support_request_01 module? As in, I have added a some arti and CAS to the support requester already but I want to add a bombing run later on in the mission with a trigger.
yes
How would one do that?
I've tried "Support_request_01 synchronizeObjectsAdd [NewProvider];" but that didn't seem to work.
You have to sync the provider module to the provider unit
_providerUnit synchronizeObjectsAdd [Support_cas_provider];
, then:
[player, Support_Requester_01, Support_cas_provider] call BIS_fnc_addSupportLink;
If the Provider is a virtual one, I don't have to sync it to a unit right?
I'm not sure
you still have to sync it with the (virtual) provider
BIS_fnc_addSupportLink; worked a treat! 😄
YEah, I have the virtual provider setup and sync'd to the trigger (Not sure that is needed but it's working) and then using BIS_fnc_addSupportLink; on the trigger.
Hi guys! Trying to achieve a thing here:
I have a truck named truck1.
I attach an ATV called ATV1 to it
I add a HoldAction to truck1 that detaches ATV1
I now want this script to attach an ATV and add the HoldAction to any object with a variable name that containts "truck". Is there a way to do that?
Here's the script in its current form.
goose1 = "OPTRE_M274_ATV" createVehicle position truck1;
goose1 attachTo [truck1,[0,0,1]];
goose1 setVectorUp [0,2, 1];
goosePodList =
[
goosePod1,
'Unload Mongoose',
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
'(_this distance _target < 3)',
'_this distance _target < 3',
{},
{},
{
goose1 attachTo [truck1,[0,-3,1]];
detach goose1;
},
{},
[],
3,
12,
true,
false
]
call BIS_fnc_holdActionAdd;
@surreal anvil ```sqf
I now want this script to attach an ATV and add the HoldAction to any object with a variable name that containts "truck". Is there a way to do that?
So if I understand correctly, you've set up some vehicles called "truckX" and you want to add the hold action to all of them?
And also attach the ATVs?
Yeah, regardless of their name. So for instance, I have truck1, truck2, truck3, all the way up to truck15.
I'd like the script to attach an ATV and add the HoldAction to any object that has a variable name that contains "truck"
its easy
{
if ("truck" in vehicleVarName _x) then {
_x call _script
}
} forEach vehicles;
Oh my
goose1 = "OPTRE_M274_ATV" createVehicle position _this;
goose1 attachTo [_this,[0,0,1]];
goose1 setVectorUp [0,2, 1];
goosePodList =
[
goosePod1,
'Unload Mongoose',
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
'(_this distance _target < 3)',
'_this distance _target < 3',
{},
{},
{
goose1 attachTo [_this,[0,-3,1]];
detach goose1;
},
{},
[],
3,
12,
true,
false
]
call BIS_fnc_holdActionAdd;
I'm gonna give this a try right now 😄
Also, don't use position for createVehicle. It requires an AGL position. You're providing an AGLS position.
Though won't this script still just add more HoldActions to goosePod1?
Yes
I'm saying the position format is wrong
Since you're attaching the atv, it won't matter
It was just a tip
You could even put [0,0,1e3] or any other position
sqf createVehicle getPosASL _this;
Oh, AGL. I can't read
There's no getPosAGL command, so you have to use that
Thanks for the tip. Will likely save me headaches down the road 😄
No problem! If you didn't intend to place the vehicle on top of an object, it wouldn't make much difference
is there a way to close/kill the two cutRsc from the main menu?
["MainMenuDummy","MainMenu"]
BIS_fnc_rscLayer is not yet available in main menu
So! I've managed to get the script to add ATVs to all the "trucks", now renamed "goosePod".
The issue I'm having now is telling the HoldAction how to detach the ATV from the goosePod.
Here's the script snippet:
{
if ("goosePod" in vehicleVarName _x) then {
_x call {
goose1 = "OPTRE_M274_ATV" createVehicle position _this;
goose1 attachTo [_this,[0,0,1]];
goose1 setVectorUp [0,2, 1];
[
_this,
'Unload Mongoose',
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa",
'(_this distance _target < 3)',
'_this distance _target < 3',
{},
{},
{
{
detach _x;
} forEach attachedObjects _this;
},
{},
[],
3,
12,
true,
false
]
call BIS_fnc_holdActionAdd;}
}
} forEach vehicles;
I'm getting an error saying that _this in the following snippet is of type array but it's expecting of type object. I'm a bit confused right now. 😄 ```sqf
{detach _x; } forEach attachedObjects _this;
So it's not implicitly referring to the goosePod in this case?
If you read the biki it says:
https://community.bistudio.com/wiki/BIS_fnc_holdActionAdd
codeStart: Code - Code executed when action starts. Passed arguments are:
params ["_target", "_caller", "_actionId", "_arguments"];
in other words, that's what _this now is
simply put, the truck is now _target, or _this#0
If you change the code to either of these, it'll work:
params ["_target"];
{detach _x; } forEach attachedObjects _target;
or
{detach _x; } forEach attachedObjects (_this#0);
Yeah 😅
And if I wanted to grab the actionId it'd be _this#2?
Thanks a lot, Leopard. Being able to iterate through a session's list of vehicles has opened a lot of doors for me 😄
@surreal anvil By the way, you didn't need to do : _x call {...} there. I only said that in case you wanted to execute that as a function. If you only want to use that code there and don't need a function, you can write:
{
if ("goosePod" in vehicleVarName _x) then {
goose1 = "OPTRE_M274_ATV" createVehicle position _x;
goose1 attachTo [_x,[0,0,1]];
goose1 setVectorUp [0,2, 1];
...
...
...
Even more efficiency? Don't mind if I do! ❤️
what would be the scripting command to get the path of the user's profile-directory?
Or is this even possible?
can script even access content in the profile-folder?
afaik, no
let's say, i take a screenshot and it is saved in the profile folder, i cant then use that ascreenshot in the mission?
that would be pretty unsafe
fair enough
could be wrong. just my gut feeling
no can do, anyway.
you could get it while developing, that's it
can i capture the user's screen in some way and use that?
no
shame
i wanted to be able to take screenshots during the mission and display them in the credits
a nice idea indeed, limited by the technology of our time
welp, i' guess i'll have to be satisfied with saving some components of the scene and creating them in the same place and use PIP to display that scene
just people with PIP disabled wont have such a good experience
if in credits, you can use a camera?
hey guys i was trying to make a scene for a screenshot, im searching for a script to light up the lights of empty vehicles
@winter rose i had a poke around the credits script
and i managed to make the background transparent
so i can paste texture-surfaces behind it in the scene
and then project camera-content to that texture surface by PIP
and i also added my own twist to the credits scene
once im done with it, i'll post a preview of what im doing
just making a story-mission for a unit
…why not using a camera behind the credits scroll?
?
because i want the "pictures" to be offset
so that there is a main-scene
and then the "pictures" to the sides
oh, ok then
indeed PiP for two different pics
the main scene doesnt need pip
i use the main camera for the main scene
and then i create 2-polygon surface in the view of that camera
and project the view of another camera to that surface using PIP
the main scene doesnt need pip
…I figured that much
and then i create 2-polygon surface in the view of that camera
if you have access to controls, you could display PiP on one?
I believe so, even ogv
im so stupid
excellent
yeah, so i'll make a control
with some polaroid-edges
and then add PIP to the center of it
blur the camera effect enough to that it's not obvious
BLAM!
picture
because the idea of the story is that one of the player characters is a photographer
and "takes pictures" throughout the story
is the main scene static?
and i want it to display the player's gear and positions correctly
fairly static, yeah
but not STATIC
there is movement to the main scene
wind blowing trees and grass and the sky
I would say… you could invert PiP ←→ real render (if it is easier to you)
I've been googling a bit trying to find how to execute pre-existing actions on objects like turning on the lights, opening a door, etc. Can somebody point me in the right direction?
For vehicles, reading the subentries of UserActions in the config viewer usually yields all readily available animations.
For map building doors, the Edit terrain object module works best in my experience.
Lights are trickier, especially if AI is in control of the vehicle. The AI will do whatever it wants with all vehicle lights, so the easiest workaround for turning (collision) lights off in AI controlled vehicles is to damage them with the setHit command. For lamps like street lights, switchLight is available.
There are a few other light commands for other use cases here: https://community.bistudio.com/wiki/Category:Command_Group:_Lights
setpilotlight and setcollisionlight with the disableai "lights" command will force lights on/off and stop ai from changing it.
Any idea why the return of canAdd would change from false to true after dropping and picking up your backpack? The value from loadBackpack does not change. In case it has any effect, I increased the maximumLoad config value for the backpack. addItem will still work even though canAdd returns false, but I use canAdd to check available space before adding gear.
is there a script to check for 0 respawn tickets?
I'm using the respawn tickets module but I want to have a custom mission end when it reaches 0
Alright, there's some voodoo going on. Adding a launcher weapon seems to mess with things. With a half-full backpack and no launcher weapon, player canAdd "item" returns true. After adding a launcher weapon, which automatically takes a round out of the backpack, player canAdd "item" returns false, even though there is more room in the backpack now.
does setViewDistance hardlock the view distance in a way that others cannot change it , or will they be able to lower it. in a mp scenario
be aware that in MP, the view distance is set by the server,
players changing their own viewdistance has no effect
unless the mission allows them to use a script or mod that does it
@reef edge If you're sure it's a bug, report it on feedback tracker so it can be fixed.
@short flame that would be… #arma3_config
ok thanks
fairly sure the answer is no, but does anyone know of a way to stop enabled UI controls being brought to the front when you click on them?
Jesus christ. They have made the editor so much better since last time I used it properly...
@ionic orchid Yes. Add an event handler to it, and when it's clicked on, set the focus on some other control:
onMouseButtonDown= "ctrlSetFocus (ctrlParent (_this0) displayCtrl IDC)"
Any idea why vehicle player is returning the player even though I am in a vehicle?
@tiny wadi mods perhaps?
So trying to read up on applying PIP's into monitors. I noticed there was talk about Laws of War updating some sort of functions to this? Or is it still the 'create a fake camera' the most used method like in Killzone's tutorial?
@winter rose Not sure, I am running mods but I tested it in the default offroad and got the same result
@little raptor cheers, I'll see if it helps
@tiny wadi vehicle player might be the same as the name of the player, but it's not actually the player. Did you test: vehicle player == player?
Typically, when vehicles don't have varNames and you use : vehicle player, the command returns the effectiveCommander's name
@ionic orchid I also noticed there's an onKillFocus event handler as well:
https://community.bistudio.com/wiki/User_Interface_Event_Handlers#onKillFocus
So you just make sure the focus is on that control. No need to add onMouseButtonDown to every control.
I haven't tried it out, but my worry is if I have more than 2 controls stacked then I'll have to ctrlSetFocus on them all to get them into the proper order
I've already moved onto a different answer to my problem, but it's worth checking out anyway because I've run into this in the past
I don't know if you remove the focus if it puts the control back where it was
Normally my Google-Fu is pretty good but when it comes to Eden stuff it's hard.
Can someone link me something about the best way to go about creating large missions?
I have a mission that I want to last for a long time with heaps of different little missions that will require loads and loads of different units. I'm asusming just placing them down over the map on mission start is going to lag out everything. Like do you need to delete certain triggers and objects and the sorts once a mission is complete?
I
Id wager there is not such thing written down for such a complex thing
so its not your google-fu failing, there just isnt such full guide in existence
I've have a script that seems to work so I can call it and it spawns units on a trigger but my issue is I can't find information about the cfggroups or what not.
The "path" to the units I want.
then you need to figure out smaller question like that and try look for them or ask them here
@young current Thanks mate. Was killing myself googling the same things over and over -.-
"how to make a large mission" however is too general
Yeah I was googling things like "Eden large missions clean up" and the sorts. Few random forum posts but nothing useful.
Does the Eden editor spawn in the objects even if they are out of spawn / view range?
Or the engine or whatever handles that side of things haha.
@ionic orchid No. You only set the focus on a control that is NOT one of those stacked on top of each other (only one control can be in focus at any time).
You can even use a fake button that is either hidden or off-screen as focus ctrl
Once you change the focus, the control orders are reset
I know this for sure because I use it in my mod
coolio
Can i use doTarget on a player using a tsrgeting pod?
I want to set the target fo the targeting pod
it's a bit awkward in my case (and I've already ditched this idea) as I've created a new RscMapControl to overlay the existing 12/51 main map
I have extra controls in that display, and when I click on the new map it pops on top of everything
so it'll be interesting to see how fiddling the focus affects the map
What language is this scripting in btw?
@ebon citrus I'm not sure, but if they're like UAV cameras, you can use lockCameraTo
https://community.bistudio.com/wiki/lockCameraTo
I gotta go learn some syntax. It's almost the complete opposite of other languages I'm used to.
@little raptor oh cheers
I was going to try `lookAt
`
I'll take a look at this tomorrow
Thank you!
@ionic orchid If you happen to have used my AIO commanding, menus, that's exactly the problem I had with the waypoint menu. That's what I did to fix it
good to know you've been in the same position! thanks for the help
@quasi cobalt It's a custom-made language.
And it bears a lot of similarities to C IMO
Was gonna say, never heard of SQF before.
Thanks for the link @ebon citrus
"Scripting is not a solution to everything." Hahaha could have fooled me.
As the language / functions changed much over the years? If I find a script from like 2015 am I going to have to look over it and update?
Not really @quasi cobalt - I'm pretty sure 99% of anything you come across is going to work just fine.
In some cases, it'll just be using older syntax/techniques, which by itself isn't a bad thing, but better ways may have come along since then.
I have a mission that I want to last for a long time with heaps of different little missions that will require loads and loads of different units. I'm asusming just placing them down over the map on mission start is going to lag out everything. Like do you need to delete certain triggers and objects and the sorts once a mission is complete?
@quasi cobalt - Also, yeah, Arma really isn't a fan of large numbers of AI - though the biggest performance hits come from the number of AI that are in combat. Usually then followed by AI that are actively moving, then AI that are idle.
Personally, I always try to stick to a hard limit of 200 AI at any one time, though the number depends on how good your server is. IMO less than 100 is generally advisable, particularly if you can stick to < 100 in combat at any one time.
One thing that might be of use to you is https://community.bistudio.com/wiki/Arma_3_Dynamic_Simulation - it allows you to set it up so simulation is disabled on any AI that are too far away from players. This can help improve performance, though bear in mind units won't move, fight or take damage when simulation is disabled.
However, if you're building a large, relatively static mission, it might save you from going too far down the scripting rabbit hole, and doing full dynamic spawning of AI like a lot of missions do.
@cold glacier Thanks mate. Having some trouble getting a Heli service script to work.
It's from 2017 so not as old as some of the others I've found.
@cold glacier cheers for mentioning that system, I had rolled my own dynamic unit handler and following that page will let me delete a bunch of code
That Dynamic Simulation looks amazing. Thank you.
That was my thinking Spoffy. These other huge missions that I can't see spawning all the enemies you encounter at the start of the missions
No worries! Sometimes it's worth going with a custom solution, really does depend on your use case. But if you want to place a big number of AI up front, and no have then lag your server, it's a solid bet. :)
ServiceHeli.sqf
_veh = _this select 0;
_vehType = getText(configFile>>"CfgVehicles">>typeOf _veh>>"DisplayName");
if (_veh isKindOf "helicopter") exitWith {
_veh sidechat format ["Servicing %1.", _vehType];
_veh setFuel 0;
sleep 3;
_veh setVehicleAmmo 1;
_veh sidechat format ["%1 Rearmed.", _vehType];
sleep 3;
_veh setDamage 0;
_veh sidechat format ["%1 Repaired.", _vehType];
sleep 3;
_veh setFuel 1;
_veh sidechat format ["%1 Refueled.", _vehType];
sleep 2;
_veh sidechat format ["Service Complete", _vehType];
};```
Trigger Condition
`call{{_x iskindof "helicopter" && isTouchingGround _x && speed _x < 1} count thislist > 0 } `
OnActivation
`call{_handle = [(thisList select 0)] execVM "scripts\ServiceHeli.sqf";}`
Woo, sorry... Thought it made it smaller. Should this work or am I wasting my time trying to work it out?
Yeah, right idea, no reason something like that shouldn't work.
Couple of issues with it off the top of my head (literally about to sleep, so can't really go into too much detail)
Condition and OnActivation - Suppose thisList consisted of two objects: [Man, Helicopter]
Your Condition would loop through the list, and find that the helicopter met all of the requirements.
So it would activate the trigger.
However, the trigger passes the very first item in thisList every time - in this case, the man.
So you'd end up with the wrong object being passed to ServiceHeli.
Now, the second issue is that setFuel, setVehicleAmmo, both require the vehicle to be local to the computer that the SQF is running on.
(You can see 'A Local' in the top left of the wiki page, meaning the arguments to the command need to be local to the machine it's running on)
For example, https://community.bistudio.com/wiki/setVehicleAmmo
However, vehicle locality is passed around a lot. Usually, vehicles are local to whoever is driving them.
So if your trigger runs on the server, and the pilot lands in the trigger zone, the vehicle is on the pilot's machine, but the code is on the server. Those commands then won't work properly.
(This is all assuming your mission is multiplayer)
I recommend having a read of this page to get a grasp of those concepts.
Other than those issues @quasi cobalt, I don't see any real reason why that script wouldn't work. But I'm tired, and might have missed something!
@cold glacier You're a legend! Thanks heaps mate.
I understand what you mean so that gives me something to look at. Thank you 🙂
I understand yet can not get it working. I tried 2 other scripts as well with no luck, similar concepts.
Has anyone got a heli rearm/repair script that they know works so I can at least 100% confirm it's me missing something haha.
Is there any to make delay due to the vehicles speed differentness
(I want to make particle effect rear of the vehicles)
How do I filter arrays with nested arrays to remove duplicates like:
[[[1,2],[3,4]], [[3,4],[1,2]], [5,6]] into [[[1,2],[3,4]], [5,6]]
be aware that in MP, the view distance is set by the server,
@finite sail yes , thats the problem , when i host an MP server , view distance drops to 1km (start of the fog) , regardless of my view and object distance (I host non-dedicated) thats why i wondered if there is a way to hardcode view range
@copper needle you could organize that array into a tree, keep all the path information like this:
[[[ [value: 1, path: [0, 0, 0]], [value: 2, path: [0, 0, 1] ], [ [value: 3, path: [1, 0, 0] ... etc ... ]
and then filter out the duplicates, then reconstruct an array using the paths. that way all duplicate leaf items are gone but the structure of the array is still kept
duplicates can be checked by like so:
checked = []
for item in list-to-check:
count_before = count checked
checked pushBackUnique item
if count checked > count_before:
the item isn't a duplicate
else
the item is a duplicate
from my experience pushBackUnique has decent performance
the issue is [[1, 1]] counts as a duplicate and will become [[1]], don't know if thats what you want
I appreciate it thanks!
Another question
If I have an array like this: [5, 87, 8, 6, 7, 14, 4] How do I detect that there are 5 numbers that go sequentially (4, 5, 6, 7, 8)?
private _array = [1,2,3,4,3,2,1,0,6,7,9,10,11];
private _wantedLength = 5;
private _currentSequence = [];
{
if !(_currentSequence isEqualTo []) then
{
private _previousValue = _currentSequence select (count _currentSequence -1);
if (_x != _previousValue + 1) then
{
_currentSequence = [];
};
_currentSequence pushBack _x;
} else {
_currentSequence = [_x];
};
if (count _currentSequence == _wantedLength) exitWith {};
} forEach _array;
_currentSequence; // or count _currentSequence == _wantedLength if you want a boolean
```(fixed and working)
@copper needle ↑
Hello, if I connect on my server, then I use the cmd _marker setMarkerPosLocal [-999999,-999999,0];
then I go in the lobby (without disconnecting), then spawn again, the marker is still at [-999999,-999999,0]
is there a way to reload markers?
So if I decide to change my slot, the marker position will reset according to his position in the sqm mission
is there a way to reload markers?
you can have the server use a global setMarker* command on it
I would like not to use a global cmd for every one. But it's ok I figured it out. I'm going to sort all the markers at the server start, then share that array with JIP ON
I understand yet can not get it working. I tried 2 other scripts as well with no luck, similar concepts.
@quasi cobalt - Might want to check that:
A) your triggers are firing
B) The script is being executed.
To test the first, make the trigger OnActivation into something like:
["Fired trigger"] remoteExec ["hint", 0]. That should cause a hint on your machine when the trigger fires.
To test the second, put the same thing at the very top of your script (with different text, like "Script ran"), and try again and see if you get that.
If both of those things work, the issue is with the logic of the script. If not, it's most likely something to do with your trigger or the location of your script file
Make sure you also check the .RPT file for script errors, or turn on 'Show Script Errors' in the launcher.
Disclaimer: 'Show Script Errors' may cause awareness of how badly a lot of scripts are written in Arma.
@winter rose There was a better way tho. You could just sort the array, start from the first and keep going while diff=1.
@little raptor right, I didn't get he wanted a sequence in a scrambled array, figured it now
all I miss here is a sort
Hi guys! I remember asking a few months ago about why a script adds one holdAction per client to an object.
If I recall correctly it's because remoteExec runs ones per client and server. Does it do that even if it's in an .sqf-file and not in the init of an object?
remoteExec is used to remote execute something
if you call it in an init field, it will simply call remoteExec multiple times
@surreal anvil Add a variable to the unit when you add the holdAction:
unit setVariable ["AddedHoldAction", true, true]
So you can always check whether it's already added and only add hold action if it's false
When you want a server-side on a mission, I can make a pbo with scripts inside, but how do I call that script when the server start ?
See the event scripts page on the biki
Yes I read it
But I dont see how a client can execute something for the server
like initServer ?
y, so I can create a initServer.sqf in my pbo, right ?
the question would be: what do you actually want to do?
Instantiate extdb3
on my server side
just want to get how it works, try some queries...
What's the ideal way to use BIS_fnc_ambientAnim in multiplayer so that all players (JIP included) can see the animation but you also avoid countless logic entities?
@compact maple are you familiar with SQL?
@ebon citrus y
is that yes or why?
it is yes, sorry
I'm already on that website x)
extdb3 is in laymen's terms an API for sql in arma
My problem is to get my server side pbo working
I mean, I dont even know if it's supposed to be a pbo, but if I want a server-side on my server, what should I do
it's jsut a mod that is not necessary on the client. i.e. not referenced in the mission
right
@vague geode server-side
@winter rose I have tried to do that but they just didn't do anything. Should I spawn the code with a 10 sec delay?
initServer.sqf Executed only on server when mission is started. See Initialization Order for details about when the script is exactly executed.
Where should I create this file so ? Im a little bit confuse
In the root of the mission folder
@compact maple some details about event scripts, including initServer.sqf, here: https://community.bistudio.com/wiki/Event_Scripts
yes
every player needs to have a valid copy of the mission
alright thanks
sleep 10;player call CFP_main_fnc_randomizeUnit;
How would I make this execute only on one player when he initializes. As right now it executes the script on everyone when someone initializes into the game
couple of ways, actually
you can either check if the player is the unit in the init-field, if youre lazy
remembler to use spawn if you want to use that sleep
as the init field is non scheduled
the reason you want to check if the unit is the player is because the init-field executes on every connecting player's client
So I need to do:
spawn sleep 10;if (isPlayer _unit01) then {call CFP_main_fnc_randomizeUnit;};
Would that be correct?
no
[this] spawn {params ["_unit"]; sleep 10; if (_unit isEqual player) then {[] call CFP_main_fnc_randomizeUnit}}
Something like that
isEqual
that no exist
Then there should be (isPlayer _unit)?
_unit isEqualTo player
Oh 😅
isPlayer is to check if a unit is a player, not especially the local one 😉
full code?
[this] spawn {params ["_unit"]; sleep 5; if (_unit isEqualTo player) then {[] call CFP_main_fnc_randomizeUnit}};
Just changed the isEqual to isEqualTo and the sleep duration to 5 instead of 10
and what does it say? error Script, expected Nothing?
Nothing at all so far
it seems to be a proper code - if put in the init field```sqf
[this] spawn {
params ["_unit"];
sleep 10;
if (_unit isEqualTo player) then
{
[] call CFP_main_fnc_randomizeUnit
}
};
Might be due to the fact that CFP randomization doesn't seem to work in multiplayer on players, and only in that instance, it just doesn't work when executed by a dedicated server unless I directly execute it on players via Console
The original code was working, unfortunately executing it every time someone connected
I'll just have to do some more testing and see if it'll work then
yeah, sorry
isEqualTo
im too used to the autocomplete
😅
you remember what you write
Alright I've tried modifying it and using it in the form you've provided, here's what I got so far:
- It doesn't give any sort of feedback, no error
- It works only so far when called in as 'player call CFP_main_fnc_randomizeUnit;", of course that has the previous mentioned issue
not here indeed; not related to scripting. Try finding help regarding L*fe on their Discord server, listed in #channel_invites_list @warped dew
Thank you!
@compact maple If you want to run a script on mission start from inside of a PBO, this is probably what you want:
https://community.bistudio.com/wiki/Arma_3_Functions_Library#Pre_and_Post_Init
You set up your script as a function using Cfgfunctions, and set it to postinit as described in that link.
PBOs need to be a part of a mod which you load. You can use a custom mod and load it only on the server, to make sure the code only runs serverside.
Y, I added my func to CfgFunctions
But I used call compile preprocessFileLineNumbers in my initServer file on the client
Should I change to this pre/post Init ?
Depends if you want it in a mod, or in the mission.
I want the script to be initialized in a mod (server side)
Basically Im setting up extdb3 and I dont want it to be in the mission folder
Then try postInit in your CfgFunctions.
So I dont need that initServer file in the mission folder, right ?
Will test that, thank you
would anyone have a script that allows players to access zues? its a modded server and the mod that allows players to access zues is touchy and is broken more then it works, it would be nice if i had a program that i can run when the mod doesnt work.
theres already 2 player slots that allow zues access however the rest of my unit cant use it.\
What you need to do is:
- Create as many Zeus modules (
ModuleCurator_F) as you need during the mission preInit. iirc, Zeus Modules created after preInit will not work but I'm not sure about that - Later in the mission, assign players to a "free" Zeus module (or you can assign them from the start, doesn't really matter)
All of these steps have to be executed on the server side, otherwise it won't work.
You can take a look at https://www.github.com/Heyoxe/Echos-Sandbox-Everywhere/tree/master/addons%2Fmain%2Ffunctions%2Fsystem%2Ffn_preInit.sqf and also the fn_postInit file, it usually works fine
How to attach "ACE_IR_Strobe_Item" and turn it ON since start of the mission?
if "in Eden", move your question to #arma3_editor
if #arma3_scripting, you are in the good spot
well it seems i need scripted implementation thru "ace_interaction" module
[car, car, ["ACE_IR_Strobe_Item"],true] remoteExec ["ace_attach_fnc_attach"];
i'll try
working as intended
@little raptor lockCameraTo doesnt work
neither does lookAt
or doWatch
is there really no way to turn the targeting pod camera to look at a position/target?
ok, issue
the turret of the targeting pod does not show up on allTurrets
-1 doesnt work either for lockCameraTo
shitty idea: what if you make targeting pod UI from scratch using your own camera and rsc overlay
Hey there, does anyone know how to script a rotating lightcone?
if it's only sideways rotation like the cop car lights you can use a while loop
while {true} do { cone setDir (getDir cone + 1); sleep 0.1; }
https://community.bistudio.com/wiki/hasPilotCamera
Check these commands @ebon citrus
I guess if I want it to rotate upwards or downwards I have to use vectordirandup?
@warm hedge can i kiss you?
Not here, dude
@brave jewel you only need setVectorDir you're right setVectorDirAndUp
😄 I was like:"WTF? How am I supposed to do it with only dir?" 😄 But thanks mate, you helped me out
@brave jewel im wrong again, you do only need dir or up to rotate the cone
this shit's so confusing
just set the cone's dir to wherever you want it to point (assuming the light aligns with the cone object's vectorDir)
indeed this stuff is really confusing
is there a function or bis function that can change my string of a weapon classname to its actual name? ex: "srifle_DMR_03_khaki_F" to "Mk-I EMR 7.62 mm (Khaki)"
displayName
is BIS_fnc_typeText global or local?
kk
I placed Spartan SAM in our base to defend attack from enemy jet. Not always, but sometimes this SAM attacks our fighter jet. Is there a way to prevent it?
the base arma SAMs? if not, what mod?
Vanilla mod, Mk-49 Spartan SAM
ah yes the boat one. I'm surprised it can get a lock on a friendly unit. whats the current setup you have?
wait a minute.
just give them lock true, allowDamage false, setfuel 1, setVehicleAmmo 1


