#arma3_scripting
1 messages · Page 768 of 1
BIS_fnc_ indicates a built-in function. you can look for those in the functions viewer (underneath the debug console) if you're desperate
I’m aware of that method, but what I’m looking for is the easy button version of that. It’s LEAGUES faster and easier.
btw, if you are looking for analysis of in game functions, you should use Leo's advanced developer tools, or use Extended Function Viewer by Connor
they both have export to text buttons
The export to wiki wasn’t the one. I don’t know where I found what I’m talking about, but man, it took my scripting from essentially non-existent to almost functional just by breaking down everything I questioned very easily.
I probably have it in a text file on an external drive somewhere stupid.
I’ll have to keep those in mind! Thanks!
just use the mods above and click export
@shadow sapphire ```sqf
copyToClipboard str _function;
it'll copy the text of a function to your clipboard
you won't get the comments and stuff
That’s possibly it, I tried that command already, but I must have done it wrong. Thanks a ton, either way. I caved and used the function viewer to get what I wanted like some sort of serf.
Give up a return? Like it won't give me back a value of some sort?
yup, instead you'll have to check with scriptDone using the handle (which is the return with a spawn)
instead of it waiting for the function to send a return in a unscheduled context
before moving to next line
I see. I don't think that would negatively impact me in any way. I don't think scheduling is the issue in these contexts, but maybe it is.
if its throwing an error that it wants to be in a scheduled environment, then spawn it instead of call it
Okay, I'll do that no problem.
there's obviously a reason they want it to wait for it to exist
Does anyone knows if TFAR sound volume is affected by the game sound configuration or if that directly related to TS?
I have a little script that would like to make compatible with tfar equipment in a mod but im not sure about where to start looking.
anyone know why this code isnt working?
class CfgSounds
{
class EAS,Zombie2
{
name = "EAS,Zombie2";
sound[] = {"sounds\EAS,Zombie2.ogg", 1,1};
titles[] = {0,""};
};
};
Okay, jumped through that hoop. Still not working on dedicated server, even without the error being thrown. Good tip, no error, but my problem still exists.
,
class CfgSounds
{
class EAS,Zombie2
{
name = "EAS,Zombie2";
sound[] = {"sounds\EAS,Zombie2.ogg", 1,1};
titles[] = {0,""};
};
};```
Are you sure this is the part that's not working? What is the rest of the context? When is the sound triggered?
remove that comma
NOW
:-p
class EAS_Zombie2
Read @winter rose's comment.
(soz for the ping btw! I misattributed the quotes)
All good!
I have no idea what this does but that was the wrong fix anyway.
hmm, checking…
try spawning that part perhaps?
you need to wrap the whole thing in a spawn, not change the individual calls.
and maybe try to synchronise before calling module init?
That's a hot tip! Thanks! Will do!
Also great input! Thanks! May be just my problem!
is it even possible?
probably possible
possibly possible
Got it cheers
is the getPlayerVoNVolume command the correct command in this case?
it returns: "Return Value:
Number in range 0..1, -1 in case of error (e.g provided a non-human)" so i would say yea if you want a slider between 0 and 1.
possibly possible? possibly.
would this be possible to create with RscProgress , creating a progress bar?
https://community.bistudio.com/wiki/progressSetPosition
I want to create a volume bar that shows how loud a player is speaking
That's an interesting project.
[] Spawn {
BA4R = LogicSide createUnit ["SupportProvider_Artillery",[0,0,0],[],0,"NONE"];
BA4R setVariable ['BIS_fnc_initModules_disableAutoActivation', false];
BA6R = LogicSide createUnit ["SupportRequester",[0,0,0],[],0,"NONE"];
BA6R setVariable ['BIS_fnc_initModules_disableAutoActivation', false];
[BA6R, "Artillery", -1] call BIS_fnc_limitSupport;
[BA6R, "CAS_Bombing", -1] call BIS_fnc_limitSupport;
[BA6R, "CAS_Heli", -1] call BIS_fnc_limitSupport;
[BA6R, "Drop", -1] call BIS_fnc_limitSupport;
[BA6R, "Transport", -1] call BIS_fnc_limitSupport;
[BA6R, "UAV", -1] call BIS_fnc_limitSupport;
BA42MA synchronizeObjectsAdd [BA4R];
BA4R synchronizeObjectsAdd [BA6R];
BA6R synchronizeObjectsAdd [BHA66];
[BA4R, BA6R] call BIS_fnc_initModules;
[BHA66, BA6R, BA4R] call BIS_fnc_addSupportLink;
};```
This iteration of this block is behaving the same as any other. Working in nearly any context on local host, not working in any context on dedicated as far as I have found. Anyone have any ideas?
Doesn't appear to do anything on server exec, global exec, or local exec from a connected client.
did you try to remoteExec the spawn ?
Remoteexec it with/to which target?
use diag_log to find where it fails
I don't know how to use diag_log. I'll try to figure that out. How would it tell me that information?
Gotcha. Man. If only I understood syntax relations, haha. I'll experiment with it.
Are these things documented anywhere or is this some reverse engineering attempt?
BA4R = LogicSide createUnit ["SupportProvider_Artillery",[0,0,0],[],0,"NONE"];
diag_log format ["SupportProvider_Artillery: %1",BA4R];
You asking me? Reverse engineering?
Anyone who knows :P
Thanks a ton! I'll try throwing those in there immediately!
I'm trying to get high command and 'real' fire support on a dedicated server with clients joining in progress. I have seen several people complain about it not working, and some report back that it was finally working, but I haven't found anyone report HOW they got it working.
I know one thing, it took tons of trial and error to get the high command modules to work on dedicated server, and somehow the support modules seem entirely different.
Right ok, so we're playing guessing games here :P
So if I was to do the full code for establishing the zones, shuffling into the schedule, and then moving the hostage based on the time of day, does this look right?
// Establish possible hostage locations
private _zoneA = setPos [x,y,0];
private _zoneB = setPos [x,y,0];
private _zoneC = setPos [x,y,0];
// Randomize zones into site schedule
private _shuffled = [_zoneA,_zoneB,_zoneC] call BIS_fnc_arrayShuffle;
_shuffled params ["_siteMorning","_siteAfternoon","_siteEvening"];
// Establish schedule based on time of day
switch (_schedule)
{
case (dayTime = >= 12 && dayTime < 15): {hostage _siteMorning};
case (dayTime >= 15 && dayTime < 18): {hostage _siteAfternoon};
case (dayTime >= 18): {hostage _siteEvening};
};```
In that case definitely try publishing the setVariables
BA6R setVariable ['BIS_fnc_initModules_disableAutoActivation', false];
to:
BA6R setVariable ['BIS_fnc_initModules_disableAutoActivation', false, true];
@deep loom setPos is a binary command and hostage isn't a command at all, so I'm not sure exactly what you're trying to do.
If the zones are just ATL/AGL positions then just private _zoneA = [x,y,0];
Oh, shoot! To make it public!? Interesting. I'll try this when I get the chance.
It depends if the modules need to run init on multiple machines.
Hostage will be the variable I assign to the hostage.
hostage setPos _siteMorning then.
But I thought _siteMorning already included setPos in it? That's what I wasn't sure about.
!quote 5
stop using 'setPos' for the love of god
Leopard20; Tuesday, 10 August 2021
What's the alternative?

Isn't setPos kinda ok here if you don't know what's at x/y?
setPosASL, setPosATL, setPosWorld
Ideally you would know, but hey :P
Otherwise you could end up with hostage under floorboards.
it's bad for the Z aspect, it's bad for performance too
If you want to put the guy inside a building then there isn't a good performance option other than predefining everything, right?
And the guy is going to be inside three buildings, two on the second floor ideally.
ah well, if you want to pick the floor then you'll probably have to predefine anyway :P
I planned on having a handful of predefined spots to work with, at least to start.
so is setPos still what I'm looking for?
Not if you have the option of predefining the position in 3d.
What would I use for that?
You could walk there and use getPosATL player
Editor can only place markers in 2d apparently, so everything else is a pain.
Some buildings might have usable building positions, but they're a pain to search and often misplaced anyway.
you can also just place an object at the postion in eden editor and then right click and copy its position, i belive it says something like: "save position to clipboard"
Yeah, that's better, assuming that it snaps to floors.
Log position to clipboard.
I put a traffic cone down in one of the spots and got this: [9106.35,10533.7,3.51721]
so would I use setPosATL with that to set the position of the hostage?
So then the updated code for that would be:
// Establish possible hostage locations
private _zoneA = setPosATL [9106.35,10533.7,3.51721];
private _zoneB = setPosATL [651.07,18364.3,0.439438];
private _zoneC = setPosATL [24860.3,21067.2,3.11268];
// Randomize zones into site schedule
private _shuffled = [_zoneA,_zoneB,_zoneC] call BIS_fnc_arrayShuffle;
_shuffled params ["_siteMorning","_siteAfternoon","_siteEvening"];
// Establish schedule based on time of day
switch (_schedule)
{
case (dayTime = >= 12 && dayTime < 15): {hostage setPosATL _siteMorning};
case (dayTime >= 15 && dayTime < 18): {hostage setPosATL _siteAfternoon};
case (dayTime >= 18): {hostage setPosATL _siteEvening};
};```
idk why you keep using setPosXXX as unary 
Because I do not know what I am doing.
An array of 3 floats already defines a position in sqf
[x, y, z]
You don't have to "set" it (if that's what you were thinking)
// Establish possible hostage locations
private _zoneA = [9106.35,10533.7,3.51721];
private _zoneB = [651.07,18364.3,0.439438];
private _zoneC = [24860.3,21067.2,3.11268];
// Randomize zones into site schedule
private _shuffled = [_zoneA,_zoneB,_zoneC] call BIS_fnc_arrayShuffle;
_shuffled params ["_siteMorning","_siteAfternoon","_siteEvening"];
// Establish schedule based on time of day
switch (_schedule)
{
case (dayTime = >= 12 && dayTime < 15): {hostage setPosATL _siteMorning};
case (dayTime >= 15 && dayTime < 18): {hostage setPosATL _siteAfternoon};
case (dayTime >= 18): {hostage setPosATL _siteEvening};
};
Better?
Yeah
Got it. Thanks.
Hey. Anyone can recommend a in depth scripting manual/tutorial if it exist?
the wiki?
I knew someone would post this
you want something more?
The better way to go is to figure out what you wanna do and search wikis and YouTube based on that
You do not need to memorize wiki when you are manipulating the wiki at your will!
Scripted grindset
I never say anything wrong because I make the wiki match my words 😛
exactly
The only tutorial you need:
private _wiki = "https://community.bistudio.com/wiki/Main_Page";
{
_x call BIS_fnc_memorize;
} forEach (allPages _wiki);
slow down there, you don't want to memorize the entire internet!
Did I stutter?!
Sorry to bother, im crating a mission with a custom sound at the start, the archive is a intro.ogg, how should i set the script for this to play once at the start? for the moment i have something like this playsound "Assets\intro.ogg";
missing ; 😁
oh but the wiki clearly states as of A3 2.08 a line terminator is no longer required anywhere by the sqf engine
https://community.bistudio.com/wiki/;
well that didn't work as intended 😒
This would be based
@tough abyss Are you trying to have an artillery shell land somewhere, or trying to show guns firing?
Wdym by show guns firing
And yes I want it to fire at a specific point
Is it necessary to script
I found a tutorial
-On Activation
.ammo = getArtilleryAmmo (gun1] select 1;
_tgt = getMarkerPos
"target1";
gun1 doArtilleryFire[
But i dont want to script every scenario
I was clarifying if you wanted to have artillery guns in the background for display purposes, or needed a specific effect :p
And unfortunately, scripting is going to be the best way to get any complex behaviour out of the game.
Consider the guidedProjectile command for ease of use:
https://community.bistudio.com/wiki/BIS_fnc_EXP_camp_guidedProjectile
I think something like this is perfect for my needs. How would I connect multiple artillery or units instead of 1? https://www.youtube.com/watch?v=uiJLOXQvYWw
That would require - unfortunately - some scripting.
Top of my head, using a forEach might be a good start, though the effects may be very condensed.
{_x doartilleryfire [informationhere]} forEach [array,of,artillery,names]
this should be the way to do it
So i have forgotten a method for getting the respawn type in a mission.
Any help anyone?
it goes something like this:
Forgotten_Fnc_ "respawn"
and returns a number between 0 and 5
if anyone knows / remembers I'll appreciate it very much much
getMissionConfigValue maybe?
I tried, but didnt make it work, maybe a syntax error, I'll try again
yeah
you are right
//I did this:
getMissionConfigValue "respawn"; //this is wrong
//the correct way is:
getMissionConfigValue ["respawn",0]
Thank you, sometimes my brain just freezes on the simplest of issues
Arma has a lot of commands :P
Sometimes my search fails me and there's an entire category that I can't find.
is the wiki not working for anyone else?
working fine here
It mostly fails for me
Was looking for a command for whole 3 hours
Friend used the same search keywords as mine, instantly got it in the result5
Is there a command to control the moving speed of an infantry unit via script?
You can forcewalk etc them
Thanks, works perfect
limitSpeed
how do you get the turrets for setPylonLoadout command? i tried allturrets but it only returns [[0]] even there are two pilots (for the blackfoot)
the other one is the driver
turret path of drivers is [-1]
there's a note on the wiki that says for driver you should use [] with that command
ok thx I will try that
Two questions:
- Is there a way to force the AI to use their laser if they are not in COMBAT mode?
- Did anyone come across a script which would swap the shoulder position camera in third person? Is this even possible in Arma?
- no
- you can create a camera and switch to that one but it won't look nearly as good
also it will be limited in comparison with vanilla 3rd person (e.g. you can't shoot)
how would i ´selectRandom´ for example 5 objects from this array and delete them?
_allElectricalSupplyBoards = position missionAreaTrg nearObjects ["Land_Cyt_FE_Dirty_ElectricalSupply_Switchboard01", 300];
{deleteVehicle _x}forEach _allElectricalSupplyBoards; //deletes every object, but I want to delete only 5 objects from this array
Thanks, so it's not really a practical option it seems.
Shame that laser is hard coded into combat mode
I see no reason why it would not be available in Stealth mode
if you really want lasers you can just use the drawLaser command and pretend the laser is actually coming from the laser device
it's might be a bit difficult for you (also it's a bit slow) but doable
_selection = [];
for "_i" from 1 to 5 do {
_selection pushBack (_array deleteAt floor random count _array);
};
if the size of your array can be smaller than 5 you can change it to:
for "_i" from 1 to (5 min count _array)
so that it doesn't try to pick too many
or you can just write a condition manually:
if (count _array < 5) then {
_selection = _array;
};
oh perfect
were talking about loops
its a sign from the universe
rabbit actually
this spawns the rabbit fine
erm
RB01 = createAgent ["Rabbit_F", position _tur, [], 5, "CAN_COLLIDE"];
RB01 attachTo[_tur,[random[10,20,30],random[10,20,30],2]];
there we go
that spawns it fine
however this for loop does not spawn them:
for "_ilp" from 1 to 10 do {
_ilp = createAgent ["Rabbit_F", position _tur, [], 5, "CAN_COLLIDE"];
_ilp attachTo[_tur,[random[10,20,30],random[10,20,30],2]];
};
im guessing its something to do with the for/_ilp reference
because you're using the loop variable as the rabbit object
which causes the loop to fail
so i need to generate a variable comprised of like, RB and _ilp
and use that as teh object?
wat? no
wut
for "_ilp" from 1 to 10 do {
_rabbit = createAgent ["Rabbit_F", getPosASL _tur, [], 5, "CAN_COLLIDE"];
_rabbit attachTo[_tur,[random[10,20,30],random[10,20,30],2]];
};
wont subsequent rabbit spawns (2-10) change all of the _rabbit variables before it (ie attach to)
or would _rabbit be unique to each loop iteration
yes
oh cool ok
thank ya
getPosASL is just a better way to do position so it doesnt spawn under ground or wherever the initial _tur position is?
in this case it doesn't matter because you're attaching the object
gotcha ya
I did it here because it's faster
getPos and position are slow
and they're very special commands
you can read up on their behavior on the wiki
does the object name with an _ at the front make it a private object (ie unique to that loop iteration)?
ok makes sense
yes
thanks, ya looking at getPosASL atm on there
it makes it a local variable
not "private object"
A laser draws a direct line straight back to you if someone is wearing night vision. This is counter productive to a stealth mission.
Can I use local variables that I defined in an sqf to activate triggers in the Eden editor?
no (or should I say it depends)
I'm trying to figure out the best way to have a hostage teleport to new locations based on the time of day. I have variables determined for the sites which are then shuffled and put into a schedule, but I don't know how to make those changes based on the schedule as the game progresses on.
Is there a place I can put a script that will continually check for changes during the game? So when the time changes to the next "shift" it will move the hostage?
The Conditions section of any trigger will monitor game states continously, though depending on latency there may be a short delay between checks.
i think you would need to store the next shifts start time
never mind i think @manic sigil way will work better
is there a class that all civilian cars inherit from?
Yeah I'm not worried about that, what I want to do is make a trigger that will teleport a hostage to a location that was set by a variable once it hits that time of day.
did a little digging and found "Car_F" dont know if this helps
i dont think thats specific to civ
oh i guess i could do faction <vehicle> and then convert that to the side of that faction and check if its == CIVILIAN
give it a try and see what happens, by the way "Car_F" will return all cars. so its not what your looking for. just thought id confirm that
Anyone know why using setAmmoOnPylon sometimes leaves weapons with empty magazines?
The smoothest way would be writing amd calling a function that waitUntil's each daytime >= shift change time you want, then moves the hostage at each step.
The easiest option would be a trigger for each shift change, but with the same basic code.
But could I take the easier option if the locations for the shift changes are randomized?
I wrote a script to define three locations, randomize the locations, and then assign them to morning, afternoon, and night. I want the hostage to move locations based on the time of day, but since the locations aren't pre-defined I can't just use a condition in the trigger without using variables.
You can, though it gets complicated. Switch-Do would be my choice.
Hey, is there any way to check if there's players inside of a trigger area without using the trigger params?
Player distance specificCoordinates > rangeYouWantToTrigger
Ahh! Good idea
Thanks
Is it just getPos to get trigger coords?
Or is it not an object?
You can though I can feel Leopard's gaze descend upon the cursed words.
Copy! Thanks a ton
Id just right click the trigger a d copy to clipboard coordinates
Give it raw data rather than an extra step calculating a static objects pos
or am i missing something in the question?
I'm already using a switch do to define the variables, I was trying to put that all in an sqf, should I just put that in the condition of the trigger instead?
// Establish possible hostage locations
private _zoneA = [9106.35,10533.7,3.51721];
private _zoneB = [651.07,18364.3,0.439438];
private _zoneC = [24860.3,21067.2,3.11268];
// Establish shifts based on time of day
private _morning = (dayTime = >= 12 && dayTime < 15)
private _afternoon = (dayTime >= 15 && dayTime < 18)
private _evening = (dayTime >= 18)
// Randomize zones into site schedule
private _shuffled = [_zoneA,_zoneB,_zoneC] call BIS_fnc_arrayShuffle;
_shuffled params ["_siteMorning","_siteAfternoon","_siteEvening"];
// Establish schedule based on time of day
switch (_schedule) do
{
case (_morning): {_siteMorning};
case (_afternoon): {_siteAfternoon};
case (_evening): {_siteEvening};
};
hostage setPosATL _schedule;
Just so you have a full idea of what I'm doing.
Feel like there's gotta be a better way of doing things that chucking that code into a condition section of a trigger. If it'll even work.
there is. I'll help you in like 30 if you'll still be here
I'll be around.
dayTime = >= 12
should be >=
also missing several;s on those lines
private _spawnPos = switch (true) do
{
case (_morning): {_siteMorning};
case (_afternoon): {_siteAfternoon};
case (_evening): {_siteEvening};
};
hostage setPosATL _spawnPos;
Okay that makes sense. So where would I put that? If I put it in the condition field of the trigger will it know what the time of day and site variables are?
@deep loom so what exactly is your intention? are the positions only going to be shuffled once or multiple times? is _siteMorning for example ever supposed to change throughout the mission?
From what I understand, you want the positions to be shuffled only once at the beginning of the mission and then the hostages to switch places based on the time of day?
That's correct. The three sites are going to be shuffled at the start of the mission and then assigned to morning, afternoon, and evening, and will not be shuffled again.
can you create/open a file called initServer.sqf in your mission root?
Hi folks, how would I go about firing a trigger when an object is shot?
//hostageSchedule.sqf
//execVM "hostageSchedule.sqf" in initServer.sqf
//or spawn as a function should work either way
private _hostage = hostage; //the hostage
// Establish possible hostage locations
private _zoneA = [9106.35,10533.7,3.51721];
private _zoneB = [651.07,18364.3,0.439438];
private _zoneC = [24860.3,21067.2,3.11268];
//shuffle positions
private _shuffled = [_zoneA,_zoneB,_zoneC] call BIS_fnc_arrayShuffle;
_shuffled params ["_siteMorning","_siteAfternoon","_siteEvening"];
private _interval = 10; //how often the script checks the time. Set this as long as you can tolerate
//"scheduled" code haha get it
waitUntil {
dayTime >= 12;
sleep _interval;
};
_hostage setPosATL _siteMorning;
diag_log format ["Hostage Morning: %1 sent to %2 at %3",_hostage,_siteMorning,dayTime];
waitUntil {
dayTime >= 15;
sleep _interval;
};
_hostage setPosATL _siteAfternoon;
diag_log format ["Hostage Afternoon: %1 sent to %2 at %3",_hostage,_siteMorning,dayTime];
waitUntil {
dayTime >= 18;
sleep _interval;
};
_hostage setPosATL _siteEvening;
diag_log format ["Hostage Evening: %1 sent to %2 at %3",_hostage,_siteMorning,dayTime];
@deep loom crude but this should work
there's no need for triggers for that
just use handleDamage or hit event handler
yeah but want to turn lights in an area off after object is shot
still no need for triggers 
triggers are a shortcut to have the game check for a condition and then execute code. this is easy but inefficient and not good for what you're doing. Leopard's suggestion is to tell the engine to execute your code whenever the entity gets hit instead of constantly checking its damage or whatever
oh right lol, i think i understand
how would i go about doing the latter?
thanks, i assume i dont need anything special for multiplayer?
that depends on what you're doing
if you want the code to only be executed on the server then you add an event handler serverside
so the question is how does your light script work
good question, give me a few to grab it
blowlights = ["Lamps_base_F","PowerLines_base_F","PowerLines_Small_base_F"];{_x setHit ["light_1_hitpoint", 0.97];_x setHit ["light_2_hitpoint", 0.97];_x setHit ["light_3_hitpoint", 0.97];_x setHit ["light_4_hitpoint", 0.97];} forEach nearestObjects [thisTrigger, blowlights, 500];
unsure if thats what youre asking or not, if you couldnt tell i know 0 when it comes to scripting
you've tested that this works when a trigger is activated?
yup, condition of blufor present
is the trigger in a separate position from the object getting shot or are the lights being shut off in the same area
same area
if !isServer exitWith {};
private _lightClasses = ["Lamps_base_F","PowerLines_base_F","PowerLines_Small_base_F"];
KJW_blowlights = nearestObjects [this, _lightClasses, 500];
this addEventHandler ["Hit", {
params ["_unit", "_source", "_damage", "_instigator"];
{
systemChat "Fired!";
private _light = _x;
for "_i" from 1 to 4 do {
_light setHit [format ["light_%1_hitpoint",_i], 0.97];
};
} forEach KJW_blowlights;
}];
see if this works as-is if you throw it in the object init
complaining of missing a semicolon around for "_i"
edited
nope, shooting isnt doing anything
edited again
nvm, throwing a frag at it worked, so just need to modify how many hitpoints required?
The hit EH will not necessarily fire if only minor damage occurred (e.g. firing a bullet at a tank), even though the damage increased.
will try handleDamage instead
if !isServer exitWith {};
private _lightClasses = ["Lamps_base_F","PowerLines_base_F","PowerLines_Small_base_F"];
KJW_blowlights = nearestObjects [this, _lightClasses, 500];
this addEventHandler ["HandleDamage", {
params ["_unit", "_selection"];
if (_selection != "") exitWith {};
{
private _light = _x;
for "_i" from 1 to 4 do {
_light setHit [format ["light_%1_hitpoint",_i], 0.97];
};
} forEach KJW_blowlights;
_unit removeEventHandler [_thisEvent, _thisEventHandler];
}];
``` @sullen sigil
nope, same thing happening -- shooting does nothing, frag grenade works
You may need to find an object you can use that reacts to bullets.
its the power generator mf
give me a few to try find something diff then one moment
fired EH returns the projectile that was fired - could be used to search for some object within a certain distance on a loop then do something
just keep in mind that bullets move very fast...even after 1 frame it could be several meters from the last position
will have to also check if object exists somewhere on a line between 2 points
yeah but the effect
bullet ricochets off the side of the generator
bravo six going dark
kill an enemy AND take out the lights
still cant find this bloody box, anyone got any idea what its called?
RAMIREZ! GO PUSH THE BUTTON ON THE GENERATOR!
it's an arma 3 object, it could be named anything
all I can say is that it's gonna start with Land_i_ and end with _f
ok i cant find it
is there a way to make it so you shoot one of the lamps and it turns the rest off in the radius
probably easier
@open fractal you able to offer any help on that bit? Cant figure it out 💀
if !isServer exitWith {};
private _lightClasses = ["Lamps_base_F","PowerLines_base_F","PowerLines_Small_base_F"];
KJW_blowlights = nearestObjects [this, _lightClasses, 500];
{
_x addEventHandler ["HandleDamage", {
params ["_unit", "_selection"];
if (_selection != "") exitWith {};
{
private _light = _x;
for "_i" from 1 to 4 do {
_light setHit [format ["light_%1_hitpoint",_i], 0.97];
};
_light removeEventHandler [_thisEvent, _thisEventHandler];
} forEach KJW_blowlights;
}];
} forEach KJW_blowlights;
wait
no this would be right assuming you can attach event handlers to terrain
just put this in the init box of a nearby object
How can I set my squad to West?
you mean they're not west already?
I made civilians into a squad I want for a zombie mission. But I set the spawner up wrong.. oops
well to make a squad join another side, just make a group on that side and use the join/joinSilent commands
Na it's all good
for example:
units squad1 joinSilent createGroup west
_westGroup = createGroup WEST;
[units _theCivilianGroup] joinSilent _westGroup;
dang, ninjaed
yours was wrong anyway 😛
I just use civilians then customised them. Then plop a blueforce guy down and make the civilians join him and bungo
In the editor
I have a hold action that looks like this. It activates an auditory alarm for 60 seconds. How can I hide this hold action for 60 seconds, at least until the alarm is done playing?
[
this,
"Activate Safe Zone Alarm",
"\a3\ui_f_oldman\data\IGUI\Cfg\holdactions\meet_ca.paa",
"\a3\ui_f_oldman\data\IGUI\Cfg\holdactions\meet_ca.paa",
"true",
"true",
{},
{},
{
params ["_target"];
[_target] call SESO_fnc_callCiviliansToSafeZone;
},
{},
[],
5,
1000,
false
] call BIS_fnc_holdActionAdd;
It's 10 x times easier putting custom gear on civilians than the actual solders. Because they come with all the smoke nades and stuff which is annoying to remove
[
this,
"Activate Safe Zone Alarm",
"\a3\ui_f_oldman\data\IGUI\Cfg\holdactions\meet_ca.paa",
"\a3\ui_f_oldman\data\IGUI\Cfg\holdactions\meet_ca.paa",
"time > _target getVariable ['SESO_cooldown', 0]",
"true",
{},
{},
{
params ["_target"];
[_target] call SESO_fnc_callCiviliansToSafeZone;
_target setVariable ["SESO_cooldown", time + 60];
},
{},
[],
5,
1000,
false
] call BIS_fnc_holdActionAdd;
that's really clever, thanks!
if you want it to work in mp, remember to broadcast
it's in an object's init, I don't need to :D
it's just 1 command https://community.bistudio.com/wiki/removeAllItemsWithMagazines
It is a very long command, Im not sure I could make it
But. My way requires no command 🙃
How would I do this block as a switch case?
If ((!isNil "BHA66") and {player == BHA66}) then {
RemoteExec ["ASG_FNC_BAA", 2];
};
If ((!isNil "RHA66") and {player == RHA66}) then {
RemoteExec ["ASG_FNC_RAA", 2];
};```
Why do you want to do it as a switch case, and why is it twice the same?
you would probably just do a switch(true) but.. I don't see why
R vs B :P
I want it as a switch case because there are more than just these two in the block. If it's not better to do it as a switch case, then I won't.
But the blocks are not the same.
squints oof
you're checking 2 different variables so...switch is not really meant for this
Ahhhh
Now I start to see it
switch (player) do {
case BHA66:
}
ah getting the nils out is annoying...
switch (player) do {
case (missionNamespace getVariable ["BHA66", objNull]): {RemoteExec ["ASG_FNC_BAA", 2];};
case (missionNamespace getVariable ["RHA66", objNull]): {RemoteExec ["ASG_FNC_RAA", 2];};
}
Yeah, if it's going to be a hassle, it works just fine as is. I just figured it was shoddy work on my part to have so many bits copy/pasted/tweaked.
why would variable be nil if it could be player?? Playing with AI off???
Well it would work, I think its probably slower and I don't like it 😄
Generally a switch is only faster if there are a lot of cases and the comparison is trivial.
Yes, these are playable slots with AI disabled.
Because it runs through every case anyway.
Ah, I see.
I would prefer putting them into an array to make the code simpler/shorter
dare I ask, but what exactly do these functions do that you are trying to remoteExec
If you feel like showing me what you mean, I'll apply it.
by very nature of their naming convention, I suspect copy-paste has been done
The remoteexec is to create and synchronize high command and support module groups.
{
if (player isEqualTo (missionNamespace getVariable [_x select 0, objNull]) then {remoteExec [_x select 1, 2];
}forEach [["RHA66", "ASG_FNC_RAA"], ["BHA66, "ASG_FNC_BAA"]]
But while writing that i started to hate it
Sorry to see that.
in unscheduled script you wouldn't have to worry about undefined variables
Well, I hope to eventually have these commands executed potentially manually anyway. Not sure about their eventual state.
I suggest taking another pass at the logic you're trying to achieve. Consider initPlayerLocal.sqf - runs on all player, and not server
isNil {
private _stuff = ["ASG_FNC_RAA", "ASG_FNC_BAA"];
private _units = [RHA66, BHA66]
private _playerIdx = _units find player;
if (_playerIdx != -1) then {
remoteExec [_stuff select _playerIdx, 2];
}
};
@still forum if you are dead set on optimizing this, remember that there is https://community.bistudio.com/wiki/vehicleVarName and he is using editor-named variables
wobcat cat
this could just be a LUT, that should make it pretty simple
private _lut = [["RHA66","ASG_FNC_RAA"], ["BHA66", "ASG_FNC_BAA"]];
private _index = _lut findIf { _x # 0 == (vehicleVarName player)};
private _selected = _lut # _index;
remoteExec [_selected # 1, 2];
not safe if _lut element doesn't exist, keep that in mind
find is much faster than findIf if you have many elements, thats why I did that.
Yours is basically same as mine just other way around-ish
tho yours doesn't have to lookup variables 🤔
I don't know about the performance impact of this, but findIf also does an early exit, no idea if find speed still faster
Fascinating stuff. I am always intrigued by you guys' work.
find does early exit, but find doesn't need to run any SQF script (and SQF be slow)
Performance most likely doesn't matter here anyway 🤣
well, it would if you wrapped it with isNil 
_list = createHashMapFromArray [["RHA66","ASG_FNC_RAA"], ["BHA66", "ASG_FNC_BAA"]];
_func = _list getOrDefault [(str player),"diag_log"];
["Function tried to run on invalid target"] remoteExec [_func,2];```
but yeah funny how it's basically the same solution, but mine came minutes later, so it just looks like I copied 😅
Both of the last ones don't consider item not found
oof str returns variable name I totally forgot
there's just too much nuance...can 1 man know everything...?
Fixed :D
dedicated doesn't have interface 
remoteExec may ignore ""
also, SQF can only be comprehended by swarm intelligence
and wiki
how did I ever program this before I discovered the discord heheh
What do you mean? Which "" would it ignore?
Whoops, didn't mean that to be a ping
Ah, I see. I thought about doing that but I wasn't sure, so I preferred a safe option that had the bonus of informing the missionmaker if they'd set something up wrong
Is there any way to force a VTOL to land in a alternative mode diffren't from it's config approuch?
IE having a Blackfish land like a traditional plane on the runway, vs trying to VTOL land.
hi, I might be blind on this one but can't find for the life of me why it is doing this.
I'm getting an error stating
'|#|sleep 1;'
error suspending not allowed in this context
I don't know how a sleep command is not allowed if I'm trying to delay a unit from spawning on each other
if !(isServer) exitWith {};
_SpawnPoints = ["flood1"];
_spawnMarker = _spawnpoints select (floor random (count _spawnpoints));
_unksSpawnPosition = getMarkerPos _spawnMarker; //[x,y,z]
newgroup = createGroup [east,true];
_newLeader = "dev_flood_combat_o" createUnit [_unksSpawnPosition,newGroup, "newLeader = this"];
sleep 1;
_newUnit = "dev_flood_infection_o" createUnit [_unksSpawnPosition,newGroup,"newUnit = this"];
sleep 1;
_newUnit = "dev_flood_infection_o" createUnit [_unksSpawnPosition,newGroup,"newUnit = this"];
sleep 1;
_newUnit = "dev_flood_infection_o" createUnit [_unksSpawnPosition,newGroup,"newUnit = this"];
sleep 1;
_newUnit = "dev_flood_infection_o" createUnit [_unksSpawnPosition,newGroup,"newUnit = this"];
sleep 1;
_newUnit = "dev_flood_infection_o" createUnit [_unksSpawnPosition,newGroup,"newUnit = this"];
sleep 1;
_newUnit = "dev_flood_infection_o" createUnit [_unksSpawnPosition,newGroup,"newUnit = this"];
sleep 1;
_newUnit = "dev_flood_infection_o" createUnit [_unksSpawnPosition,newGroup,"newUnit = this"];
newGroup setBehaviour "Combat";
sleep can't be used in unscheduled contexts, such as triggers or object init fields. You need to get it into a scheduled environment by using spawn or execVM
how is this running?
surprised that even runs
ahhh that fixed it
it explains alot why a different script was failing baddly
Thanks
hello everyone, I seem to not be able to get to documentation about init script in CfgVehicle in mods
like parameters order etc
ofc I need to get object of spawned unit but just cant get to docu about init script params
just making sure you're aware, you don't have to paste code repeatedly like this.
private _unitCount = 7;
for "_i" from 1 to _unitCount do {
_newUnit = "dev_flood_infection_o" createUnit [_unksSpawnPosition,newGroup,"newUnit = this"];
sleep 1;
};
just writing this in case you didnt know, since it can save you some trouble writing/editing so many lines
Wait, why does the init for each spawned unit contain newUnit = this? Every new unit overwrites it so newUnit will end up only containing the last one spawned, and also it's never referenced
Ah, it's because it's the alt createUnit syntax
and the one second interval is significant?
Which doesn't return a reference to the created unit
But the attempt to make it return a reference is badly implemented
oh dear
i didnt know that about the alt syntax
_newUnit is just nil then if im seeing this right
The sleep seems to be just so they don't spawn inside each other and get Arma'd
This could probably be done better with BIS_fnc_spawnGroup https://community.bistudio.com/wiki/BIS_fnc_spawnGroup
private _toSpawn = ["dev_flood_combat_o"];
private _unitCount = 7;
for "_i" from 1 to _unitCount do {
_toSpawn pushBack "dev_flood_infection_o";
};
private _grp = [_unksSpawnPosition,east,_toSpawn] call BIS_fnc_spawnGroup;
_grp setBehaviour "Combat";
hmmm perhaps
i wonder if the first unit would be the leader
or if you have to use the rank parameter
Pretty sure first spawned will be leader, which is first in the array since we're not using randomisation. But they're all the same so it doesn't matter in this case
men should not die when spawned on top of each other
i havent seen them die unless a ridiculous number are spawned
they're not the same btw the leader's classname is different
Oh right. Well, still
First one should be the leader, if not then you could createUnit that one then spawnGroup the rest and join them, or something. But I'm 99% sure the first will be leader
if BIS_fnc_spawnGroup is really as simple as that then that's pretty nice 👀 I only tried it once and got annoyed that you need the whole path if you input a CfgGroups entry
by the way do you guys know if there is like a character limit in description.ext or any sqf's?
_tower = createVehicle ["Land_TTowerSmall_1_F", position player, [], 0, "NONE"];
_trgCond = format["damage %1 > 0.6", _tower];
//_trgAct = format["%1 setDamage 1; deleteVehicle thistrigger;", _tower];
_trg = createTrigger["EmptyDetector", position player];
_trg setTriggerActivation["NONE","PRESENT",false];
_trg setTriggerStatements[_trgCond,"",""];
This is a simple test script, why this _trgCond has errors with:
Error in expression <damage 1ea53170b80# 9: ttowersmall_1_f.p3d > 0.6>
Error position: <ea53170b80# 9: ttowersmall_1_f.p3d > 0.6>
Error Missing ;
Error in expression <damage 1ea53170b80# 9: ttowersmall_1_f.p>
Error position: <damage 1ea53170b80# 9: ttowersmall_1_f.p>
Error damage: Type Number, expected Object
don't format _tower
just do "damage _tower > 0.6", but also it's a local variable, so it's not going to work
set a global variable to the tower and reference that in the trigger statement
Yeah I think that's going to be the only way, there's no way to give input parameters to a trigger statement
the game doesn't know what to do with "1ea53170b80# 9: ttowersmall_1_f.p3d" (the return for stringifying an object without a set vehicle var name), which is why your script doesn't work
If that's all the trigger is for, I bet you could get away with waitUntil {damage _tower > 0.6}
yeah this as well afaik there's no situation that absolutely requires a trigger
keep in mind any commands that take a string as "code", the game just goes call compile _thatCode
so just write the code as if it were a code block
in fact just write a code block then replace the { } with " " later
They can be very useful and are often an easier way to do something than writing some kind of hellish check loop of your own. But this is a very simple check and creating a trigger seems like overkill.
Thanks a lot. setVehicleVarName and consider waitUntil, I spent a day for this error. thanks again. @tranquil jasper @open fractal @hallow mortar
While I definitely appreciate people trying to figure it out on their own, as do the others probably, maybe come here a little sooner than a day 😛
Is it possible to get an approximate position where the object will fly, knowing its velocity?
Yes
Maths
Hello, I am using Drongo's Map Population to spawn civilians down around the map, I have then used my own code to exec on the spawned unit to turn them into zombies (WBK zombies mod) however it just spawns 20 (Defined in the Drongos pop module) copies of my character as ai without the required code being executed
This is my code
_z2 = 2;
_z3 = 3;
_z4 = 4;
_z5 = 5;
_man= this;
_ai = selectRandom ["_z1", "_z2", "_z3", "_z4", "_z5"];
private["_man"];
[_man, _ai] call WBK_LoadAIThroughEden;```
im still learning scripting
first, you go from _ai = selectRandom ["_z1", "_z2", "_z3", "_z4", "_z5"]; to _ai = selectRandom [_z1, _z2, _z3, _z4, _z5]; because you need to select a random value, not a random variable name. And it starts working (at least it does in my testing).
then you probably decide "why do i even need those temporary variables?" and shorten the entire script to
[this, selectRandom [1, 2, 3, 4, 5]] call WBK_LoadAIThroughEden;
Ah, thank you
No one knows why using setAmmoOnPylon leaves weapons without ammo/mags?
Does anyone know if it's possible to hide single groups/units from spectator?
well, https://community.bistudio.com/wiki/hideObject claims to have local effect. So running it on spectator client may be useful 🤔
I believe hide as in "not list" 🙂
well, sqf ... // Validate units { if (simulationEnabled _x && {!isObjectHidden _x} && {simulationEnabled vehicle _x} && {!isObjectHidden vehicle _x} && {isPlayer _x || {_showAiGroups}} && !(_x isKindOf SPECTATOR_CLASS)) then ... in "\a3\ui_f\scripts\gui\rscdisplayegspectator.sqf" checks for isObjectHidden. And hiding objects with hideObject through console does hide them in the spectator menu for me 😛
oooooooooh good catch 😁 😉
well, full disclosure, i've only learned about the spectator menu from your comment, so at the moment of writing the answer i was misunderstanding the question for sure. But after some check it turned out to work anyways 🤣
I have found these entries in my server's log file, any idea how I can fix the underlying issues?
2022/05/15, 12:38:41 Duplicate weapon Throw detected for B_officer_F
2022/05/15, 12:38:41 Duplicate weapon Put detected for B_officer_F
2022/05/15, 12:38:41 Duplicate weapon Throw detected for O_officer_F
2022/05/15, 12:38:41 Duplicate weapon Put detected for O_officer_F
[...]
2022/05/15, 12:39:25 Respawn failed - body disappeared
2022/05/15, 12:39:25 Duplicate weapon Throw detected for B_officer_F
2022/05/15, 12:39:25 Duplicate weapon Put detected for B_officer_F
PS: I am using AI players of the classes B_officer_F and O_officer_F.
How would I exclude a specific player from hearing a sound but still broadcast it to everyone?
["someSoundEffect"] remoteExec ["playSound", 0]; // maybe - [thatOnePlayer] ??
https://community.bistudio.com/wiki/remoteExec
targets (Optional, default: 0):
...
Negative number: the effect is inverted: -2 means every client but not the server, -12 means the server and every client, except for the client where clientOwner returns 12
You can setVariable on the trigger if you want to avoid spamming globals.
Give an example of vehicle class, pylon weapon and set value.
Replacing GBUs with missiles on a wipeout for "_i" from 4 to 7 do { (vehicle player) setPylonLoadout [_i, "PylonRack_1Rnd_LG_scalpel", false, []]; };
This isn't using setAmmoOnPylon?
oh sorry I meant setPylonLoadout
oi, you mean old GBU weapon without any ammo (now)?
that's not dynamic, you need to clean that stuff by hand (at least in my (limited) experience)
ok, how do u clean it?
check the example at https://community.bistudio.com/wiki/Arma_3:_Vehicle_Loadouts#Saving_and_restoring for the general idea, i guess
ok thx!
something like this may work after the change actually happened: sqf _veh = vehicle player; _allWeps = weapons _veh; _emptyWeps = _allWeps select {_veh ammo _x == 0}; { _veh removeWeaponGlobal _x; } forEach _emptyWeps;(add privates for your taste, make sure there are no other empty weapons at time of usage).
As an alternative - going through the pylons and saving their weapons before replacing, and then checking for empty weapons from that saved list may work better.
well I'm now removing all weapons first and then using setPylonLoadout and it seems to work
removing only pylon weaps though
cleanest way probably
Couple follow up questions:
- I want to pause the script when players are within 250m or so of the hostage so he doesn't teleport when they're in the middle of saving him.
- I'd like to stop the script from running completely once the hostage is free.
Thoughts?
would it be possible for players to get within 250 meters and not save the hostage?
If they were all killed in the process, yes.
Unlikely but still possible.
and then they come back and hostage isn't there 🙂
That would be the idea. They wouldn't be able to transport the hostage if they were under attack, but if they got a clearing they'd get them out. But the players should have an idea of the transport schedule so it shouldn't be too painful if they collected some intel beforehand.
or players just get into the next area and wait for the hostage to be teleported to them 😛
Planning on also putting in a trigger that will skip an area if the players had presence in it previously.
Also maybe add more reinforcements to the other zones if they try to cheat it.
let's start with #2 once the hostage is saved you can use this
terminate _thisScript;
Or if that happens in a separate script then you need to save the output of execVM or spawn in a variable and make it available in that other script somehow so you can terminate
Although if they scout out an area and don't get detected that's a perfectly reasonable strat.
I think I can put it in the existing script. That would be the easiest way to do it.
well, closer to the point: 1) you need to replace every _hostage setPosATL _smth; with something to the effect of "check for players inside 250 meters circle, if there are any - sleep for X seconds and check again, if there are none - proceed to TP"
Okay yeah I was thinking something like that.
something like while {!(allPlayers inAreaArray [getPos _hostage, 250, 250] isEqualTo [])} do {sleep 15;};, i guess
^ or hostage is saved
waitUntil {sleep 1; (allPlayers inAreaArray [getPos _hostage, 250, 250] isEqualTo []) and !hostageIsSaved};
``` is better no ?
except it will check every frame instead of every 15 seconds. Which (while fast, as inAreaArray is done in-engine) may (or may not, i've never checked) influence the performance
why inAreaArray, could just be distance or distance2D?
well, because inAreaArray is in-engine
isn't distance too?
distance - yes. Going through the players array - no. Let me actually test that
literally an order of magnitude faster in my testing 😛
P.S. actual numbers on my machine with 129 units: 0.233 ms with allUnits select {_x distance player < 25} and 0.025 ms with allUnits inAreaArray [getPos player, 25, 25]
So would I just put this at the start of the transport code or would I need to put this in front of each individual shift?
put the check before every _hostage setPosATL _somewhere;
So the updated script for the pause and terminate would be:
private _hostage = hostage; //the hostage
// Establish possible hostage locations
private _zoneA = [9106.35,10533.7,3.51721];
private _zoneB = [651.07,18364.3,0.439438];
private _zoneC = [24860.3,21067.2,3.11268];
//shuffle positions
private _shuffled = [_zoneA,_zoneB,_zoneC] call BIS_fnc_arrayShuffle;
_shuffled params ["_siteMorning","_siteAfternoon","_siteEvening"];
private _interval = 10; //how often the script checks the time. Set this as long as you can tolerate
//"scheduled" code haha get it
while {!(allPlayers inAreaArray [getPos _hostage, 250, 250] isEqualTo [])} do {sleep 15;};
waitUntil {
dayTime >= 12;
sleep _interval;
};
_hostage setPosATL _siteMorning;
diag_log format ["Hostage Morning: %1 sent to %2 at %3",_hostage,_siteMorning,dayTime];
while {!(allPlayers inAreaArray [getPos _hostage, 250, 250] isEqualTo [])} do {sleep 15;};
waitUntil {
dayTime >= 15;
sleep _interval;
};
_hostage setPosATL _siteAfternoon;
diag_log format ["Hostage Afternoon: %1 sent to %2 at %3",_hostage,_siteMorning,dayTime];
while {!(allPlayers inAreaArray [getPos _hostage, 250, 250] isEqualTo [])} do {sleep 15;};
waitUntil {
dayTime >= 18;
sleep _interval;
};
_hostage setPosATL _siteEvening;
diag_log format ["Hostage Evening: %1 sent to %2 at %3",_hostage,_siteMorning,dayTime];
// Terminate script if hostage is rescued
if hostageSaved = true then
{
terminate _thisScript;
}
no. The "players nearby" check goes directly above the _hostage setPosATL lines, not below them
waitUntil {allPlayers findIf {_x distance _hostagePos < _rangeThreshold} > -1; sleep 1;}
Ah gotcha
scales linearly with how deep in the array the "close enough" case is. From 0.015 ms (40% faster than inAreaArray) when the match is in the first dozen to 0.185 (640% slower) when the match is 128. Not like anyone would care with the check delay and stuff, but i still love my inAreaArray
I'm still getting used to all these new commands
ye, actual benchmarks give surprises most of the times
in my day you needed a phd in math to calculate objects in a trigger area!
well in practice nobody actually did it and just used a distance checkinstead hahah
Does anyone know how to have a random variable for a parameter?
need more info
I tried putting this in my Description.ext, but I didn't have success with it. Probably because randomStartNumber just doesn't fit the format for .ext but im not sure how I would go about having a random number be included with that since there are no examples on the wiki.
randomStartNumber = floor random 4;
class Params
{
class randomStartLocation
{
title = "Spawn Location";
texts[] = {"Point in town 1", "Point in town 2", "Point in town 3", "Point in town 4", "Random"};
values[] = {0, 1, 2, 3, randomStartNumber};
default = randomStartNumber;
};
};```
What are you trying to do exactly?
well, i've only seen this implemented like a) in params one of the values is "magic"
b) logic that actually uses the value randomizes it if it sees said magic
Randomize the location of a layout by using condiction of prescence in the editor. It would be alot easier to do that and only move the players to the necessary start location rather than move every single object that i want present at the start of the mission.
class Params
{
class randomStartLocation
{
title = "Spawn Location";
texts[] = {"Point in town 1", "Point in town 2", "Point in town 3", "Point in town 4", "Random"};
values[] = {0, 1, 2, 3, -1};
default = -1;
};
};
//
// wherever it's used. Or maybe save the value into some global variable for later reuse
private _randomStartLocation = "randomStartLocation" call BIS_fnc_getParamValue;
if (_randomStartLocation == -1) then {_randomStartLocation = floor random 4;};```something like this
Oh I get it, you want the player to be able to choose but if they don't then it is randomly picked for them
do you use any mods?
I'm gonna guess yes because the vanilla data is ok
whatever mod you're using is adding duplicate weapons to units 
Correct
Ok the above should work fine then
and yeah description.ext doesn't run sqf, but it does get preprocessed so keep that in mind - preprocessor commands are fun
can almost fake programming if you waste enough hours
For the last bit, is there a script similar to init.sqf that I can put it in that will autorun prior to mission initialization so that I can still use Condition of Presence?
what is Condition of Presence?
the editor one, i assume
yeah, but what is conditionally present?
a slider with 0% to 100% chance iirc.
well, that's the answer then 🤷♂️
oh wait I think I understand
just use random?
I think you have put down playable units at each of the 3 towns and you are asking how to use the mission parameter to make them conditionally exist. However that doesn't really work for players, the units will have to be moved to the location after mission start
It would be alot easier to do that and only move the players to the necessary start location rather than move every single object that i want present at the start of the mission.
The playable units are what I'm fine with moving around. If I place more players and conditionally remove them later, that would mean a player wouldn't exist after mission initialization. Plus, my MP player list would be excessively large.
https://community.bistudio.com/wiki/Initialization_Order doesn't mention mission parameters so I have no idea where it falls in here, but maybe you could use the parameter in the objects conditional presence to make it so enemies aren't shown unless their town is picked
and then we're SOL if we want random 🍿
what do you intend to make dependant on that random choice? Some kind of base? Enemy spawns? Mission markers?
Ok that's exactly what I was thinking, so what's the problem then?
It's a group of objects placed in certain spots. It's meant to help facilitate a cinematic opening after just getting hit by an IED. The random location is to just help things be a little bit more interesting since they wouldn't know exactly where they are in the city.
It would look weird if i just have all of the relevant objects be randomly present. Hence why i'm trying to make the location consistent by parameter so that I can use condition of presence to decide what is where.
it looks to me like mission parameters get populated at postInit stage. So way after the objects are places 🤔
Ok so what I said back in this message then
or is it preInit, oof? storeParamsValues is preInit, initParams is postInit
Mission parameters are set before any SQF files can run and condition of presence is determined happens just before Init.sqf runs from what I can tell.
in that case just put https://community.bistudio.com/wiki/BIS_fnc_getParamValue in the Condition field then in editor
and then we're SOL with random choice?
Seems like it. 
Unless someone comes soon that knows exactly when mission params become available, I think the only option is just give it a try 
At least for now, I'll have it be not-randomized. But also not super descriptive as to where the location is. Then just pick a random one on role select. Should have a similar effect, at least.
oh no well it gets harder because you want it random, because the only way to get it random is in a script, but all that stuff happens before scripts
hmm
do you want to have 3 prebuild bases and only the one around the actual spawn point should be present?
Not a single one.
maybe you can use CfgFunctions for this:
Functions with preInit attribute are called
in Initialization Order, it's the 2nd thing that happens. So maybe it can be randomized here then able to use conditional presence
It is vanilla but the errors only appeared once I enabled AI players.
that of course depends on when mission params are created though
well, i've seen at least one mission that expects them to be present at preInit stage. And works. 
Yes, since that would allow me to not have to move a bunch of stuff and only have to worry about moving players/units.
Then it seems like this could work. This requires some very in-depth knowledge on a very specific part of the game so I doubt many people would have an answer off the top of their head. Unfortunately this means the best option is probably to just try it and find out (then put info on wiki somewhere)
given the same problem i'd probably go with a) hiding all the prebuilt bases b) making arrays storing all hidden elements for every base c) unhiding the needed base at the point of actually creating a spawn. 
yeah that would work too, and doesn't require obscure ancient lore 
vanilla officer is correct tho 
I'm gonna guess it's a game bug
report it in #arma3_feedback_tracker or make a ticket on the FT
How would I go about creating a forEach loop within a forEach loop? I.E.
{
{ _x removeWeapon _x } forEach weapons _x;
} forEach _shooters;
hi, does anyone know how to add flares to a vehicle? @everyon3
I seek to unearth the arcane workings of this world. Cpt. Miller wills it.
try with many ways but nothing
loopception haha, just save the first _x into a variable
{
_current = _x;
{ _current removeWeapon _x } forEach (weapons _x); //needs paranthesis I think
} forEach _shooters;
vehicle addMagazineTurret [magazineName, turretPath, ammoCount]
Guys, is there a hotkey for the editor to snap objects to surface?
So. In a last ditch effort to randomize that number. I'm going to try and make a function for this mission spcifically. I can get the sqf part down on my own. It's just the Description Portion that I need help with.
fn_randomSpawn.sqf Is the name of my sqf file. (more to come in a second)
And this is what I have in my Description.ext right now, and here is the file path to that script. Fun%20in%20Fallujah.fallujah\Functions\Spawn, Fun%20in%20Fallujah.fallujah I'm assuming is the root in this case.
class CfgFunctions
{
class ROCKD //TAG
{
class Spawn //CATEGORY
{
preInit = 1;
file = "Functions\Spawn"
class randomSpawn {};
};
};
};```
All the script does right now is initialize a global variable as 1 to show that the script is even called. but right now nothing happens. Is my fomatting somewhere wrong or am I over thinking it?
preInit should be defined under the function class
you've put it under category
That wouldn't stop the whole script from running though, would it?
(I'll still move it though.)
wdym?
did you even execute the function?
How would you execute a function without sqf since I need it to be preInit?
does the vehicle even support it?
call/spawn
preInit executes by itself
but you'd put it in the wrong place which didn't work
I guess, the vehicle I use is from a mod and it only has 30 flares
you can't add more than max capacity
and i want to add more flares
I see. Yea now the variable gets initialized. Much appriciated.
Do you think that changing the loadout with setUnitLoadout causes the error?
I don't think so. setUnitLoadout doesn't even have a Throw weapon
do you have any command to help me add flares?
Throw weapon doesn't exist I think until a unit has a grenade
it always exists (if added via config)
Then I don't know what is causing this because as I said I don't use any mods and neither is the server.
which is why I said it could be a bug and you better report it
just dropping in to shake things up, here's some useless sqf
player addAction ["Controlled crash", {
isNil {
_time1 = systemTime;
while {true} do {};
_time2 = systemTime;
_time = [];
{
_time pushBack (_x - (_time1 # _forEachIndex));
} forEach _time2;
_crashLength = 5 * 1000;
_iterations = (_crashLength / (_time # 6)) * 10000;
for "_i" from 0 to _iterations do { };
};
}, nil, 10, false, true];
enjoy
"crashes" arma for a predetermined length of time. for missions and stuff
Ahh, so typical engine code 🤣
Yeah but this is on purpose...well, maybe BIS does it on purpose too
well it's wrong too... 
also I don't see how that's "controlled" 
would the deleteVehicle command work for deleting a single ai unit?
yes
deleteVehicle can delete any object
ok, thanks, I thought it was able to just wasn't certain.
Would the last line of code work for checking a condition. (I'm not worried about the script macro because it works. Just included for a reference.)
#define AFUNC(var1,var2) TRIPLES(DOUBLES(ace,var1),fnc,var2)
if ([_unit, true] call AFUNC(captives,setHandcuffed)) exitWith {};
idk what you mean
what does last/first line have to do with checking a condition? 
I'll post the entire if statement:
// Check if Capture Hostage and Time Limit
if (_timeLimit && _capture) then {
while {_time > 0} do {
_time = _time - 1;
sleep 1;
if ({ [_x, true] call AFUNC(captives,setHandcuffed) } forEach _hostages) exitWith {};
if (_time <= 0) exitWith {
{ _x deleteVehicle } forEach _hostages
}
}
};
I'm trying to check if the unit(s) has/have been captured, if so then stop the timer.
Oops, that's true it sets the unit, I guess how would I check to see if the unit(s) has/have been captured then.
how many of them?
idk. check the ACE docs
It depends on how many the mission creator sets, I'll check the ace docs then
I mean all or just one?
I guess all
if so what you wrote is incorrect
you're only checking the last one
assuming the getter function is getHandcuffed:
_hostages findIf {!([_x] call AFUNC(captives,getHandcuffed))} < 0
meaning all are handcuffed (none is non-handcuffed)
ok thanks for the help, I'll continue to browse through the ace docs and check to see what their getter is for the captive handcuffed
well if you can't find anything just read that function
it most likely does a setVariable on the unit to set the handcuffed mode
in which case all you have to do is read that variable
how do I get an array of all players in a vehicle?
crew _veh select {isPlayer _x}
Just one question, is this code correct? trying to get all players within 10m
_nearestEntity = player nearEntities ["CAManBase", 10];
{["someScript.sqf"] remoteExec ["execVM",_x]}forEach _nearestEntity - [player];
yes
thank you!
thx
what do you mean it's wrong? It worked when I was running it, although I realized a better way of doing this than what's currently being done. And I called it controlled because you can control the length of the freeze. Simulated would also work as a name
whats the script to disable the high altitude falling animation
not available yet
you're doing _x - (_time1 # _forEachIndex) and later use _time # 6 which can be negative
so what you wrote doesn't give the correct "crash length" or "freeze time" or whatever you want to call it
also you have a while {true} before it, which adds its own freeze time, so your freeze time is wrong
how can i get armor values of the vest, uniform, etc like Virtual arsenal does?
all that stuff is in the config
you'll need to know the classname of the clothing you want to inspect
yes you bring up good points. The first while loop exploits that sqf will terminate a while loop at 10,000 iterations (in unscheduled environment), by finding the time difference between the start and end we can calculate how many iterations are required for the requested time, as it is system-dependent and load-dependent. Another side effect of those 2 is that even the calculated time is pretty inaccurate. I've been thinking about better code for this since earlier when I posted "v1", perhaps I'll post a v2
Really?
Sqf will terminate a while loop at 10,000 iterations?
unscheduled
Now that makes more sense
just like magic numbers and strings, there exists magic functionality and this is one such case 
I dont do while-loops in umscheduled environments, so ive never even though about it
Yes because you are normal, but I've had my mind broken after multiple years of sqf programming so now I try weird stuff to learn obscure ancient knowledge
...how are you still sane?
Yet there is always more to learn
Because i took a break in 2013 to study C
But sqf was my entry to programming
Ah nice, sqf was not my first but where I really found my footing
private _class = uniform player;
getNumber(configFile >> 'CfgWeapons' >> _class >> 'armor')
``` like this its correct?
The syntax is all right, but you probably won't find that class in CfgWeapons, I think there is CfgItems. Also idk off the top of my head if "armor" is right. It might be the right property or maybe another
wearables are in CfgWeapons
If you're looking for the magical CSAT uniform armour then that's elsewhere.
im trying to get the armor values that virtual arsenal displays on each uni, vest helmet etc.. ballistic protection, explosive resistance etc
getText(configFile >> 'CfgWeapons' >> _uniform >> 'ItemInfo' >> 'uniformClass') gives you the associated vehicle class.
And then the important stuff is probably in HitPoints under the CfgVehicles info for that class.
I don't know what the arsenal shows though.
Ballistic protection, Explosive resistance, load, weight
ok i got it ty
you can use an infinite for instead:
_times = [1, 12, 30, 24, 60, 60, 1000];
_fnc_getDiff = {
params ["_time"];
_delta = 0;
_timeMulti = 1;
reverse _time;
{
_delta = _delta + (_x - _start#_forEachIndex) * _timeMulti;
_timeMulti = _timeMulti * _times#(6 - _forEachIndex);
} forEach _time;
_delta;
};
private _start = systemTime;
reverse _start;
private _freezeTime = 1000;
for [{_i = 1}, {_i > 0}, {0}] do {
if ([systemTime] call _fnc_getDiff >= _freezeTime) then {break};
};
not tested
the variable armor in the config its not the ballistic protection right?
private _uniformClass = getText(configFile >> 'CfgWeapons' >> uniform player >> 'ItemInfo' >> 'uniformClass');
private _armor = getNumber(configFile >> 'CfgVehicles' >> _uniformClass >> 'armor');
private _armorStruct = getNumber(configFile >> 'CfgVehicles' >> _uniformClass >> 'armorStructural');
private _explosionShielding = getNumber(configFile >> 'CfgVehicles' >> _uniformClass >> 'explosionShielding');
``` im checking this on different uniforms, and all have the same values, but in the virtual arsenal the ballistic protection bar changes so..
yo guys, im trying to create minaret with adhan (islamic prayer call) for imersion on kp lib takistan
tho even with
you have to check the hit points
class OPC_sound_minaret {
name = "OPC_sound_minaret";
sound[] = {"opc_sounds\sounds\minaret.ogg", 100, 1, 1000};
titles[] = {};
};
lodness pumped up distance set to 1km etc
the sound gets lost at ~50-100m distance from loudpseaker
i want it to be heard around all city area
how do you play it?
any idea? i use say3D on speaker object
[_minaret] spawn {while {true} do {(_this select 0) say3D "OPC_sound_minaret"; sleep 273;};};
use the full say3D syntax
which also specifies the distance
use say3D ["OPC_sound_minaret", 1000];
stupid question incoming, what would be an SQF script to check if someone has a backpack on?
backpack _unit != ""
i checked the config and the uni dont have the hitpoints like the vest so idk.. i guess the ballistic protection its PassThrough var but in the uni its not declared anywhere only armor, armorstructt etc
in the vest there its the class HitpointsProtectionInfo with the hitpoints armor etc, but not in the uni
@little raptor @glossy pine you magnificient bastards, checked it again https://community.bistudio.com/wiki/say3D all good now, thanks a lot 🙂
thanks! what would be a line for dropping the backpack?
can't find anything else other than some removeItem bullshittery when I look into it
there's an action for it
oh, thank you!
bookmarked.
stumbled across more trouble, trying to make this work:
if (backpack _unit = "B_Parachute") {
_gwh = "Weapon_Empty" createVehicle getPos player;
player action ["DropBag", _gwh, typeOf unitBackpack player];
};```
erroring out either that I'm missing a ) or ; depending on whether I include the if argument within a parantheses or not
== not =
great point, missed that! Still erroring out that I'm missing a ;
adding a semicolon here,
if backpack _unit == "B_Parachute"; {
_gwh = "Weapon_Empty" createVehicle getPos player;
player action ["DropBag", _gwh, typeOf unitBackpack player];
};
getting the error that the expected value is a bool and not a string
I don't get how that's the case given the argument of the if statement being a logical operator
your syntax is wrong in a few places
proper If syntax in sqf
if (condition) then {
}
createVehicle might have an error because no parenthesis
_gwh = "Weapon_Empty" createVehicle (getPos player);
createVehicle might have an error because no parenthesis
no, that's fine, theifis not though
thanks!
if (backpack _unit == "B_Parachute") then {
_gwh = "Weapon_Empty" createVehicle getPos player;
player action ["DropBag", _gwh, typeOf unitBackpack player];
};```
provides the same error
already corrected
first one, second was my bad
thanks, no longer erroring, however it's not functioning
Weapon_Empty are you sure it's correct and is a proper weapon holder?
also typeOf unitBackpack player just backpack player
try using GroundWeaponHolder
no he copied the example from https://community.bistudio.com/wiki/Arma_3:_Actions#DropBag
but you forgot ATL on getPosATL
if (backpack _unit == "B_Parachute") then {
_gwh = "GroundWeaponHolder" createVehicle getPosATL player;
player action ["DropBag", _gwh, typeOf unitBackpack player];
};
still non-functional
DreadedEntity is correct, I just copied the example
put this in the If as the first line
systemChat "if ran";
then run it again and lmk
doesn't seem like it's running...
if (backpack _unit == "B_Parachute_F") then {
systemChat "if ran";
_gwh = "GroundWeaponHolder" createVehicle getPosATL player;
player action ["DropBag", _gwh, typeOf unitBackpack player];
};
still nothing
if it still doesn't work then do this
systemChat str (backpack _unit);
if (...) {... etc
systemChat str (backpack _unit);
if (backpack _unit == "B_Parachute_F") then {
systemChat "if ran";
_gwh = "GroundWeaponHolder" createVehicle getPosATL player;
player action ["DropBag", _gwh, typeOf unitBackpack player];
};```
still nothing
hold up
hate to ask this, but unit has backpack yes?
yes
it kind of seems like the entire script that this is in doesn't run for whatever reason. Where did you put that?
is _unit defined?
was mostly messing in the zeus unit exec box
idk much about zeus stuff but usually you have to put this to refer to the object in BIS editor boxes
fuck
you're right
systemChat str (backpack _this);
if (backpack _this == "B_Parachute") then {
systemChat "if ran";
_gwh = "GroundWeaponHolder" createVehicle getPosATL _this;
_this action ["DropBag", _gwh, typeOf unitBackpack _this];
};```
this does trigger systemchat
B_Parachute
if ran isn't there
yeah because == "B_Parachute_F" guess you were right the first time
replacing the if argument to 1==1 makes it run
yup! that works! thank you!
now...
the backpack gets dropped, but places itself about 2 meters out
a relatively minor inconvenience, curious if it's fixable though
use https://community.bistudio.com/wiki/createVehicle alternative syntax and pass "CAN_COLLIDE" as special
yeah try the other syntax for createVehicle, it gives a lot greater control
for "markers" and "placement" arguments, just put what the default says for that
had to restart arma, but markers and placement seem to be optional
systemChat str (backpack _this);
if (backpack _this != "") then {
systemChat "if ran";
_gwh = createVehicle ["GroundWeaponHolder", position _this, [], 0, CAN_COLLIDE];
_this action ["DropBag", _gwh, typeOf unitBackpack _this];
}; ```
didn't test yet
yes they are optional but you need to set a parameter that comes after them so they need to be there, even if you just use the default values
in other words you can't just skip them
got it, fixed
let's see...how to explain
createVehicle [type, position, markers, placement, special] //valid
createVehicle [type, position, markers, placement] //valid
createVehicle [type, position, markers] //valid
createVehicle [type, position] //valid
createVehicle [type] //invalid, missing required 'position' parameter
createVehicle [type, special] //invalid, sqf will try to read the 'special' string as a position and will have an error
fuck, yeah just realized I messed it up
you forgot all your , and "GroundWeaponHolder" should be in the square brackets ([ ])
"GroundWeaponHolder" createVehicle [position _this [] 0 CAN_COLLIDE];
//becomes
createVehicle ["GroundWeaponHodler", position _this, [], 0, "CAN_COLLIDE"]; //forgot " " also
and that should do it
systemChat str (backpack _this);
if (backpack _this != "") then {
systemChat "if ran";
_gwh = createVehicle ["GroundWeaponHolder", position _this, [], 0, CAN_COLLIDE];
_this action ["DropBag", _gwh, typeOf unitBackpack _this];
}; ```
yeah looks nice, now don't forget to test it multiple times even though 1x is enough, then remove the systemChat's 😛
yeah, thanks. Will keep updating. I'll probably fuck it up when I'll transition it back to _player for what it's actually supposed to do
why do you use dropBag?
use putBag
just looked it up, good point. Will try in a sec
This has likely been asked many times before, but is something up with the wiki?
it's moody sometimes
Works perfectly.
if (backpack _this != "") then {
systemChat "if ran";
_this action ["PutBag"];
}; ```
😂 thanks y'all
I'm taking up all of the bandwith with my 15 tabs.
Would it be possible to use a PPeffect or something similar with sqf waitUntil {(currentVisionMode player) == 1}; to detect when a player puts on night vision, and also anable FLIR inside of the NVGS?
Something like this https://cdn.discordapp.com/attachments/788840237165051946/975561110780530729/ZRNM2ULDID5R3AGSWCH7X34ESI.jpg
Or is this completely impossible?
There is https://community.bistudio.com/wiki/currentVisionMode
however NVGs don't have FLIR
maybe could be done with a mod?
I'm not sure about the PPeffect but you can use this instead of a waitUntil https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#VisionModeChanged
yes
well
when I spawn a unit with createunit
I guess i will have to make this jip right?
turn on the JIP option of remoteExec is what I'm referring to
I'd imagine so
well
is it bad to do this for 200 units?
so like
[_unit, true] remoteExec ["enableDynamicSimulation", 0, _unit];
but for 200 units
shouldn't be any worse than just having 200 units in a mission
yep true
getarray (configFile >> "CfgWeapons" >> "LMG_Mk200_LP_BI_F" >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
why is this returning [] ?
does it have a value in config?
yes
it is the attachments classnames
check your spelling then, maybe you have a typo
I directly copied it from the config viewer
hmm definitely a problem then
I'm not sure if this has to do with anything
https://imgur.com/a/xTVnT9Q
but this is the directory when viewed in config viewer
yep
which one?
because I'm a starter at config family of commands
i would say use a combination of count and select?
try this
_properties = configProperties [configFile >> "CfgWeapons" >> "LMG_Mk200_LP_BI_F" >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems", "true", true];
_classnames = _properties apply { configName _x };
hint str _classnames;
yep it works
thanks
yep I just seen an example on the internet and that's what confused me
guy used getArray
so you are basically returning directories of entries inside that directory
then returning the class name of every directory?
yeah config can be annoying but also fun. When you have config-type stored in a variable you can still use >> too, so this would work
_properties = configProperties [configFile >> "CfgWeapons" >> "LMG_Mk200_LP_BI_F" >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems", "true", true];
{
hintSilent format ["Attachment: %1\nIsCompatible: %2", configName _x, getNumber _x];
sleep 0.25;
} forEach _properties;
oh umm I guess my example doesn't really show that lol but it works
yep lol
The easiest way to think about this is that every config can only have 2 types of "things", class or value (number, string, array); any child class can also further contain class or value. Values do not have any lower "levels", only class. Class could even be empty.
So to answer your question (let's pretend we start at ...etc.... >> "compatibleItems"), I just returned all values from this class
and those values were all "Numbers"
so if it was name = "hello";
then we use getText?
yup
and configname for the name itself
here there is a bunch of them with = 0
that means its not compatible I reckon?
so we have to do
_properties = configProperties [configFile >> "CfgWeapons" >> "LMG_Mk200_LP_BI_F" >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems", "true", true];
_classnames = _properties apply { if ( (getNumber _x) == 1) then {configName _x} };
Yeah when I saw the data, I hoped (feared?) that the mod author didn't make the config like that...but it looks like he did. I think BIS configs just use an array with the compatible types. This way is...kind of dumb
yep
real dumb lol
the middle parameter of https://community.bistudio.com/wiki/configProperties is a conditional statement so instead of configProperties [ ..., "true", true] you could have configProperties [..., "getNumber _x == 1", true]
then the ones with 0 won't even show up in _properties
yep
I figured that out but didn't know I could use the magic variable
feared it might break if I used it lol
gotta read the description on the wiki page 😛
my bad lol
is it possible to add BIS_fnc_holdActionAdd to an object and make it save and resume progress if the action is Interrupted?
something like add damage to an object while the action is in progress but if Interrupted then make it resume where it stoped?
example code:
[
Generator,
"Destroy Generator",
"\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",
"_caller distance _target < 3",
{},
{},
{ _this setdamage 1},
{},
[],
12,
0,
true,
false
] call BIS_fnc_holdActionAdd;
you would remove/readd the action I believe
I think it should be possible to "hack" the function
nope. it's not
it runs in scheduled env and uses local vars...oof 
would be really cool if it would resume where it interrupted.
well, the point of it is to hold for a certain amount of time
doing it in - - - - - - small parts kinda break the spirit
true
you could use the onInterrupted code to add another action with the remaining time and remove the current one, I believe
okay i will try
you can modify _this by reference
something similar has been done in this channel, just need to find it
_this select 3 set [20, _newDuration]
found it here
Hello, does an optimized method exist to find the nearest marker to the player?
Instead of iterating on allMapMarkers and checking for the min distance?
(i'm doing it in loop, so the big-o is not that good)
I don't know of a better way
😦
you can split world into a grid, store in hashmap (or array might make more sense).
Use the marker created/deleted eventhandlers to keep it up to date.
Then you can simply just check the grid fields around the player to find nearby markers in constant time
https://i.gyazo.com/27fd085f4a9219b5008e3f3e9d8e9fc9.png
0.0075 ms to get nearest markers, this is impressive!
Thanks @still forum 🙂
A dirtier trick if you specifically want nearby markers rather than nearest is to maintain a list of positions where the Z value is an index into the array of markers, and use inAreaArray to filter it.
You can put anything in the Z value as long as it's a number :P
Is it normal a vehicle created by createVehicle or createSimpleObject server-side will appear 2 minutes later on all clients? (simulation also disabled)
yes
why?
you said it yourself. sim is disabled
objects with no simulation have the slowest sync rate
maybe try a setPosASL or something to force the object to update
i do not think this applies
because i create the object and then right after I disable the simulation
so the object should be broadcasted first and in time
this is what I do
but now you have said that
I am setting position after disabling simulation
maybe if the pos is set before simulation is disabled
it would do the trick
remove whitespace
"from 1 to 100" will turn into "from1to100"

🤣
Delete all code in it ¯_(ツ)_/¯
Worth a try.
How can I check if the player is immobilized by his injuries waiting for a medic to heal/revive him?
Ignore me. Checking LifeState.
Can someone point me into the right direction how to achieve the following: Every time the player becomes "INCAPACITATED" I would like to deduct 10 points from a campaign point variable but not go below the value of 0. I have the name of the GlobalVariable and I am now looking for script which would trigger the calculation when the event occurs. I could start the script at the beginning of the mission. What would be the best way to achieve this?
As far as I know there is no event handler for life state changes. There probably should be.
So you'd need to poll.
do a hit event handler and report using remoteexec or setVariable with a global counter the deduction while in incapacitated
alternatively do a oneachframe loop checking states, but that just going overboard and performance wasting for what you are trying to do
Thanks guys. Unfortunately I a not familiar with event handlers. It's beyond my expertise. I was also thinking about a while loop but as MKNavaG pointed out, this might be too performance intensive. Perhaps I could check every 5s or so? Would this still have a material impact on performance?
Problem with the while loop is that it will continuously fire a TRUE return while incapacitated and repeatedly add 10 point to the campaign counter until it returns FALSE.
no, doing periodic checks instead of eachframe loop is like, a million times better, no joke haha
just add an extra conditional that would either reset when its not incapacitated anymore or when killed
{ }
else {
setVariable "dmpCVP" -10;
sleep 120;
};
sleep 5;```
would something like this work
?
never did something like this before
for reference dmpCVP is the campaign point variable.
not at all that's nonsense
you can do it with a loop (not like THAT) but like the other fellow said you're better off using an event handler that can be tied to lifestate changing
the hit event handler example would mean you detect if the player is unconscious every time they're hit instead of constantly
_key parameter returns an intger
Is there a way to convert the intger into a string? for example if key returns 1 then the string is "ESC"
Other than making a dictionary of buttons and their respective intgers?
switch case?
So a dictionary basically
I'm trying to hint back what the player is pressing
So this is the only way?
^^ 🙂
Note that you can't do the unconscious check in the handler, because you have to wait until whatever medical system does its thing.
With which medical system?
My own custom medical system, considering vanilla as base.
we are still intercepting the vanilla unconsious state tho
It seems like Arma already has a dictionary which you can #include in your script: https://community.bistudio.com/wiki/DIK_KeyCodes
we are basically doing this, again, using vanilla as reference:
player addEventHandler ["Hit",
{
if (lifestate player == "INCAPACITATED" && (missionNamespace getVariable "autoRevive" == true)) then
{
[] spawn
{
missionNamespace setVariable ["autoRevive",false];
hint "Auto-Injector is pumping adrenaline into your system!";
sleep 10;
['#rev',1,player] call BIS_fnc_reviveOnState;
[]execVM "scritps\adrenalineHit.sqf";
};
};
}];
thats a bit outdated, but it can be done
Sorry, basic question
hint format ["Campaign points, %1!", dmpVCP];
Shows: Campaign points, any
What's the correct syntax to show the value of the global variable?
I will try this. Thank you
Not that, so I'm basically trying to catch whatever key the player is pressing and then using hint to print it back
Problem is say he pressed W (DIK_W) , if I do
hint str(DIK_W)
it will not give back "W"
What does it give back?
{
if (lifestate player == "INCAPACITATED" ) then
{
[] spawn
{
hint "You lost 5 Campaign points!";
sleep 10;
[]execVM "points.sqf";
};
};
}];```
I tried this script
Killing myself with a granade
But somehow it does not get triggered
I checked lifestate player and it returns INCAPACITATED
So it should actually trigger, no?
well guess what
google was not showing me this existed:
https://community.bistudio.com/wiki/keyName
this wont get triggered if you die. This will only check for incapacitation.
Is the vanilla incapacitation and revival system turned on?
Sorry, the player did not die. I am using "MGI Advanced Modules". The player is INCAPACITATED but not dead and MGI is triggering a revive action.
are you cheking instantly after being incapacitated?
You are spawning a script into the scheduler to execute the sqf after 10 ingame seconds calculated within scheduler.
So you might end up with 10 inconsistent seconds (depending on how busy is the scheduler)
Well the hint should get triggered immediately, no?
suggest you add a hint / chat message or a diag_log AFTER the execution of the execVM so you are sure your sqf is done before the hint
indeed, it should get triggered immediately
yea but the Hint is not getting triggered
try with a handleDamage event handler instead
i tried this code
{
if (lifestate player == "HEALTHY" ) then
{
[] spawn
{
hint "You lost 5 Campaign points!";
[]execVM "points.sqf";
sleep 3;
};
};
}];```
it works
so the problem is either the eventhandler or lifestate
lifestate i checked ingame
it returns INCAPACITATED
maybe it requires a break though before checking playerstate
or the eventhandler is not right
if that one activates then you might want to try using handleDamage instead then, I dont know what MGI is supposed to do tho and I do get results with both hit and handledamage with vanilla system, so it can be an issue about locality since fired is global but i dont think thats the case since you must be trying from editor right?
that didnt, has anyone have any idea?
maybe should I broadcast to all clients the createVehicle statement in order to make it appear instantly?
that is sad because it is a global command
Is there any way to have a leaflet add a diary entry of an image after it's been viewed?
{
if (lifestate player == "INCAPACITATED" ) then
{
[] spawn
{
hint "You lost 5 Campaign points!";
[]execVM "points.sqf";
sleep 3;
};
};
}];```
Also does not work
No idea why
A couple of possibilities:
- You're installing that handleDamage EH before MGI installs its own, so the player isn't unconscious at the point the EH triggers.
- MGI doesn't set units unconscious within the EH. It fires off a spawn or something to deal with damage results.
What you could try is putting the lifestate check inside the spawn, and adding a short sleep in the hope that MGI processes first.
Yea, maybe MGI is causing the issue here
When you say putting the lifestate inside the spawn, what do you mean by that?
player addEventHandler ["HandleDamage", {
[] spawn {
sleep 1;
if (lifestate player == "INCAPACITATED" ) then {
// whatever you want to do here
};
};
nil;
}];
It's not so much that "MGI is causing the issue". If MGI is your medical system then you have to work with whatever it's doing. Same if you were running ACE or whatever.
ACE does at least have it's own (undocumented) unconscious event.
Does Arma have an integrated revive system which I could use? I don't necessarily have to use MGI.
There's an optional BIS revive system (introduced with Apex, I think) but it only works for players.
That's fine, only the player would be healed
With this script the player somehow does not take any damage anymore
oops
need to return damage amount
Fixed.
