#arma3_scripting

1 messages · Page 768 of 1

shadow sapphire
#

Likely!

open fractal
#

BIS_fnc_ indicates a built-in function. you can look for those in the functions viewer (underneath the debug console) if you're desperate

shadow sapphire
fair drum
#

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

shadow sapphire
shadow sapphire
fair drum
#

just use the mods above and click export

open fractal
#

@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

shadow sapphire
fair drum
#

you can spawn any of the BIS functions as well btw

#

you just give up that return

shadow sapphire
#

Give up a return? Like it won't give me back a value of some sort?

fair drum
#

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

shadow sapphire
#

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.

fair drum
#

if its throwing an error that it wants to be in a scheduled environment, then spawn it instead of call it

shadow sapphire
#

Okay, I'll do that no problem.

fair drum
#

there's obviously a reason they want it to wait for it to exist

kindred zephyr
#

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.

coarse dragon
#

anyone know why this code isnt working?

#

class CfgSounds
{

class EAS,Zombie2
{
name = "EAS,Zombie2";
sound[] = {"sounds\EAS,Zombie2.ogg", 1,1};
titles[] = {0,""};
};

};

shadow sapphire
coarse dragon
#

,

shadow sapphire
#
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?

winter rose
#

NOW

#

:-p

#

class EAS_Zombie2

shadow sapphire
winter rose
shadow sapphire
granite sky
#

I have no idea what this does but that was the wrong fix anyway.

winter rose
#

hmm, checking…
try spawning that part perhaps?

granite sky
#

you need to wrap the whole thing in a spawn, not change the individual calls.

winter rose
#

and maybe try to synchronise before calling module init?

shadow sapphire
shadow sapphire
drowsy geyser
#

is it even possible?

young current
#

probably possible

crude vigil
coarse dragon
#

Got it cheers

drowsy geyser
#

is the getPlayerVoNVolume command the correct command in this case?

fleet sand
fair drum
drowsy geyser
#

I want to create a volume bar that shows how loud a player is speaking

shadow sapphire
#

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.
fleet sand
shadow sapphire
open fractal
#

use diag_log to find where it fails

shadow sapphire
open fractal
#

creates a line in the rpt file

#

you can use it to check returns and variables

shadow sapphire
#

Gotcha. Man. If only I understood syntax relations, haha. I'll experiment with it.

granite sky
#

Are these things documented anywhere or is this some reverse engineering attempt?

open fractal
#
BA4R = LogicSide createUnit ["SupportProvider_Artillery",[0,0,0],[],0,"NONE"];
diag_log format ["SupportProvider_Artillery: %1",BA4R];
shadow sapphire
granite sky
#

Anyone who knows :P

shadow sapphire
shadow sapphire
# granite sky Anyone who knows :P

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.

granite sky
#

Right ok, so we're playing guessing games here :P

deep loom
#

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};
};```
granite sky
#

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];

shadow sapphire
granite sky
#

It depends if the modules need to run init on multiple machines.

deep loom
granite sky
#

hostage setPos _siteMorning then.

deep loom
#

But I thought _siteMorning already included setPos in it? That's what I wasn't sure about.

winter rose
#

!quote 5

lyric schoonerBOT
lyric schoonerBOT
granite sky
#

Isn't setPos kinda ok here if you don't know what's at x/y?

winter rose
granite sky
#

Ideally you would know, but hey :P

#

Otherwise you could end up with hostage under floorboards.

winter rose
granite sky
#

If you want to put the guy inside a building then there isn't a good performance option other than predefining everything, right?

deep loom
granite sky
#

ah well, if you want to pick the floor then you'll probably have to predefine anyway :P

deep loom
#

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?

granite sky
#

Not if you have the option of predefining the position in 3d.

deep loom
#

What would I use for that?

granite sky
#

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.

drowsy geyser
#

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"

granite sky
#

Yeah, that's better, assuming that it snaps to floors.

deep loom
#

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?

winter rose
#

yep

#

getPos* → setPos*

deep loom
#

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};
};```
little raptor
deep loom
#

Because I do not know what I am doing.

little raptor
#

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)

deep loom
#
// 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?

little raptor
#

Yeah

deep loom
#

Got it. Thanks.

half perch
#

Hey. Anyone can recommend a in depth scripting manual/tutorial if it exist?

winter rose
#

the wiki?

half perch
fair drum
#

you want something more?

deep loom
#

The better way to go is to figure out what you wanna do and search wikis and YouTube based on that

tranquil jasper
#

memorize all wiki

#

done

crude vigil
#

You do not need to memorize wiki when you are manipulating the wiki at your will!

ebon citrus
tranquil jasper
#

I never say anything wrong because I make the wiki match my words 😛

crude vigil
#

exactly

tranquil jasper
#

The only tutorial you need:

private _wiki = "https://community.bistudio.com/wiki/Main_Page";
{
  _x call BIS_fnc_memorize;
} forEach (allPages _wiki);
crude vigil
#

why limit it with wiki when you can just use allPages?

#

just know everything!

tranquil jasper
#

slow down there, you don't want to memorize the entire internet!

crude vigil
#

Did I stutter?!

devout surge
#

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";

tranquil jasper
#

needs definition in CfgSounds in description.ext

tranquil jasper
#

well that didn't work as intended 😒

manic sigil
#

@tough abyss Are you trying to have an artillery shell land somewhere, or trying to show guns firing?

tough abyss
manic sigil
#

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

tough abyss
manic sigil
#

{_x doartilleryfire [informationhere]} forEach [array,of,artillery,names]

open fractal
somber radish
#

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

granite sky
#

getMissionConfigValue maybe?

somber radish
#

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]
somber radish
granite sky
#

Arma has a lot of commands :P

#

Sometimes my search fails me and there's an entire category that I can't find.

tough abyss
#

is the wiki not working for anyone else?

tranquil jasper
#

working fine here

drifting portal
#

Was looking for a command for whole 3 hours
Friend used the same search keywords as mine, instantly got it in the result5

modern meteor
#

Is there a command to control the moving speed of an infantry unit via script?

modern meteor
#

Thanks, works perfect

proven charm
#

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)

little raptor
#

turret path of drivers is [-1]

little raptor
proven charm
#

ok thx I will try that

modern meteor
#

Two questions:

  1. Is there a way to force the AI to use their laser if they are not in COMBAT mode?
  2. Did anyone come across a script which would swap the shoulder position camera in third person? Is this even possible in Arma?
little raptor
#

also it will be limited in comparison with vanilla 3rd person (e.g. you can't shoot)

drowsy geyser
#

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
modern meteor
#

Shame that laser is hard coded into combat mode

#

I see no reason why it would not be available in Stealth mode

little raptor
#

it's might be a bit difficult for you (also it's a bit slow) but doable

little raptor
#

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;
};
rose osprey
#

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

little raptor
#

because you're using the loop variable as the rabbit object

#

which causes the loop to fail

rose osprey
#

so i need to generate a variable comprised of like, RB and _ilp

#

and use that as teh object?

little raptor
#

wat? no

rose osprey
#

wut

little raptor
#
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]];
};
rose osprey
#

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

rose osprey
#

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?

little raptor
rose osprey
#

gotcha ya

little raptor
#

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

rose osprey
#

does the object name with an _ at the front make it a private object (ie unique to that loop iteration)?

#

ok makes sense

rose osprey
#

thanks, ya looking at getPosASL atm on there

little raptor
#

not "private object"

deep loom
#

Can I use local variables that I defined in an sqf to activate triggers in the Eden editor?

little raptor
deep loom
# little raptor 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?

manic sigil
#

The Conditions section of any trigger will monitor game states continously, though depending on latency there may be a short delay between checks.

flat eagle
#

i think you would need to store the next shifts start time

#

never mind i think @manic sigil way will work better

brazen lagoon
#

is there a class that all civilian cars inherit from?

deep loom
flat eagle
brazen lagoon
#

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

flat eagle
#

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

proven charm
#

Anyone know why using setAmmoOnPylon sometimes leaves weapons with empty magazines?

manic sigil
deep loom
#

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.

manic sigil
tidal ferry
#

Hey, is there any way to check if there's players inside of a trigger area without using the trigger params?

manic sigil
#

Player distance specificCoordinates > rangeYouWantToTrigger

tidal ferry
#

Ahh! Good idea

#

Thanks

#

Is it just getPos to get trigger coords?

#

Or is it not an object?

manic sigil
#

You can though I can feel Leopard's gaze descend upon the cursed words.

tidal ferry
#

Copy! Thanks a ton

manic sigil
#

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

deep loom
#
// 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.

open fractal
#

there is. I'll help you in like 30 if you'll still be here

deep loom
#

I'll be around.

little raptor
deep loom
#

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?

open fractal
#

@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?

deep loom
open fractal
#

Ok. you do not need a trigger for this

#

give me a minute

open fractal
sullen sigil
#

Hi folks, how would I go about firing a trigger when an object is shot?

open fractal
#
//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

little raptor
#

just use handleDamage or hit event handler

sullen sigil
little raptor
#

still no need for triggers blobdoggoshruggoogly

open fractal
sullen sigil
#

how would i go about doing the latter?

open fractal
#

info for adding event handlers at the top

sullen sigil
#

thanks, i assume i dont need anything special for multiplayer?

open fractal
#

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

sullen sigil
#

good question, give me a few to grab it

sullen sigil
# open fractal so the question is how does your light script work

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

open fractal
sullen sigil
#

yup, condition of blufor present

open fractal
#

is the trigger in a separate position from the object getting shot or are the lights being shut off in the same area

sullen sigil
#

same area

open fractal
# sullen sigil 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

sullen sigil
#

complaining of missing a semicolon around for "_i"

open fractal
#

edited

sullen sigil
#

nope, shooting isnt doing anything

open fractal
#

edited again

sullen sigil
#

nvm, throwing a frag at it worked, so just need to modify how many hitpoints required?

open fractal
#

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
sullen sigil
granite sky
#

You may need to find an object you can use that reacts to bullets.

open fractal
#

it might just be a beefy object that doesnt take damage

#

yeah what he said

sullen sigil
#

its the power generator mf

#

give me a few to try find something diff then one moment

tranquil jasper
#

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

open fractal
#

imo at that point just throw a nade at it

#

or add an action to shut it off

tranquil jasper
#

yeah but the effect

sullen sigil
#

need to have that cod theme innit

#

cant find the bloody circuit breaker object

open fractal
#

bullet ricochets off the side of the generator
bravo six going dark

sullen sigil
#

kill an enemy AND take out the lights

#

still cant find this bloody box, anyone got any idea what its called?

open fractal
#

RAMIREZ! GO PUSH THE BUTTON ON THE GENERATOR!

#

it's an arma 3 object, it could be named anything

tranquil jasper
#

all I can say is that it's gonna start with Land_i_ and end with _f

sullen sigil
#

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

sullen sigil
#

@open fractal you able to offer any help on that bit? Cant figure it out 💀

open fractal
#

i don't know if you can attach event handlers to terrain objects

#

but

sullen sigil
#

ah yeah just checked you cant

#

nvm then

open fractal
#
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

sullen sigil
#

nvm google was wrong

#

that works

#

thanks dude!

coarse dragon
#

How can I set my squad to West?

little raptor
coarse dragon
#

I made civilians into a squad I want for a zombie mission. But I set the spawner up wrong.. oops

little raptor
coarse dragon
#

Na it's all good

little raptor
#

for example:

units squad1 joinSilent createGroup west
cold mica
#
_westGroup = createGroup WEST;
[units _theCivilianGroup] joinSilent _westGroup;
#

dang, ninjaed

little raptor
coarse dragon
#

I just use civilians then customised them. Then plop a blueforce guy down and make the civilians join him and bungo

#

In the editor

cold mica
#

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;
coarse dragon
#

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

little raptor
# cold mica I have a hold action that looks like this. It activates an auditory alarm for 60...
[ 
 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;

cold mica
#

that's really clever, thanks!

ebon citrus
#

if you want it to work in mp, remember to broadcast

cold mica
#

it's in an object's init, I don't need to :D

crude vigil
coarse dragon
shadow sapphire
#

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];
};```
still forum
#

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

granite sky
#

R vs B :P

shadow sapphire
#

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.

still forum
tranquil jasper
#

you're checking 2 different variables so...switch is not really meant for this

still forum
#

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];};
}

shadow sapphire
#

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.

tranquil jasper
#

why would variable be nil if it could be player?? Playing with AI off???

still forum
#

Well it would work, I think its probably slower and I don't like it 😄

granite sky
#

Generally a switch is only faster if there are a lot of cases and the comparison is trivial.

shadow sapphire
granite sky
#

Because it runs through every case anyway.

shadow sapphire
#

Ah, I see.

still forum
#

I would prefer putting them into an array to make the code simpler/shorter

tranquil jasper
#

dare I ask, but what exactly do these functions do that you are trying to remoteExec

shadow sapphire
tranquil jasper
#

by very nature of their naming convention, I suspect copy-paste has been done

shadow sapphire
still forum
#

{
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

shadow sapphire
#

Sorry to see that.

still forum
#

in unscheduled script you wouldn't have to worry about undefined variables

shadow sapphire
#

Well, I hope to eventually have these commands executed potentially manually anyway. Not sure about their eventual state.

tranquil jasper
#

I suggest taking another pass at the logic you're trying to achieve. Consider initPlayerLocal.sqf - runs on all player, and not server

still forum
#
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];
}
};
tranquil jasper
still forum
#

wobcat cat

tranquil jasper
#

this could just be a LUT, that should make it pretty simple

tranquil jasper
#
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

still forum
#

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 🤔

tranquil jasper
#

I don't know about the performance impact of this, but findIf also does an early exit, no idea if find speed still faster

shadow sapphire
#

Fascinating stuff. I am always intrigued by you guys' work.

still forum
#

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 🤣

tranquil jasper
#

well, it would if you wrapped it with isNil meowtrash

hallow mortar
#
_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];```
tranquil jasper
#

but yeah funny how it's basically the same solution, but mine came minutes later, so it just looks like I copied 😅

still forum
#

Both of the last ones don't consider item not found

tranquil jasper
#

oof str returns variable name I totally forgot

#

there's just too much nuance...can 1 man know everything...?

hallow mortar
tranquil jasper
#

dedicated doesn't have interface meowtrash

still forum
#

remoteExec may ignore ""

#

also, SQF can only be comprehended by swarm intelligence

#

and wiki

tranquil jasper
#

how did I ever program this before I discovered the discord heheh

hallow mortar
#

Whoops, didn't mean that to be a ping

still forum
#

_func = _list getOrDefault [(str player),""];
[] remoteExec [_func,2];

hallow mortar
#

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

outer fjord
#

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.

ashen warren
#

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";
hallow mortar
#

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

tranquil jasper
#

how is this running?

ashen warren
#

[]exec "Floodspawner1.sqf"

#

ohh, I see

tranquil jasper
#

surprised that even runs

ashen warren
#

ahhh that fixed it

ashen warren
dry smelt
#

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

open fractal
hallow mortar
#

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

open fractal
#

i found that odd as well

#

perhaps it's referenced elsewhere somehow?

hallow mortar
#

Ah, it's because it's the alt createUnit syntax

open fractal
#

and the one second interval is significant?

hallow mortar
#

Which doesn't return a reference to the created unit

#

But the attempt to make it return a reference is badly implemented

open fractal
#

oh dear

#

i didnt know that about the alt syntax

#

_newUnit is just nil then if im seeing this right

hallow mortar
#

The sleep seems to be just so they don't spawn inside each other and get Arma'd

open fractal
#
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

hallow mortar
#

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

tranquil jasper
#

men should not die when spawned on top of each other

open fractal
#

i havent seen them die unless a ridiculous number are spawned

#

they're not the same btw the leader's classname is different

hallow mortar
#

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

open fractal
#

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

tranquil jasper
#

by the way do you guys know if there is like a character limit in description.ext or any sqf's?

quasi rover
#
_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

tranquil jasper
#

don't format _tower

#

just do "damage _tower > 0.6", but also it's a local variable, so it's not going to work

open fractal
#

set a global variable to the tower and reference that in the trigger statement

tranquil jasper
#

Yeah I think that's going to be the only way, there's no way to give input parameters to a trigger statement

open fractal
#

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

hallow mortar
#

If that's all the trigger is for, I bet you could get away with waitUntil {damage _tower > 0.6}

open fractal
#

yeah this as well afaik there's no situation that absolutely requires a trigger

tranquil jasper
#

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

hallow mortar
quasi rover
#

Thanks a lot. setVehicleVarName and consider waitUntil, I spent a day for this error. thanks again. @tranquil jasper @open fractal @hallow mortar

tranquil jasper
#

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 😛

tough abyss
#

Is it possible to get an approximate position where the object will fly, knowing its velocity?

winter rose
#

Yes
Maths

long bolt
#

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

south swan
#

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;

long bolt
#

Ah, thank you

proven charm
#

No one knows why using setAmmoOnPylon leaves weapons without ammo/mags?

cosmic lichen
#

Does anyone know if it's possible to hide single groups/units from spectator?

south swan
winter rose
south swan
#

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 😛

winter rose
#

oooooooooh good catch 😁 😉

south swan
#

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 🤣

vague geode
#

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.

drowsy geyser
#

How would I exclude a specific player from hearing a sound but still broadcast it to everyone?

["someSoundEffect"] remoteExec ["playSound", 0];  // maybe - [thatOnePlayer] ??
south swan
granite sky
granite sky
proven charm
granite sky
#

This isn't using setAmmoOnPylon?

proven charm
#

oh sorry I meant setPylonLoadout

south swan
#

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)

proven charm
#

ok, how do u clean it?

south swan
proven charm
#

ok thx!

south swan
#

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.

proven charm
#

well I'm now removing all weapons first and then using setPylonLoadout and it seems to work

#

removing only pylon weaps though

tranquil jasper
deep loom
tranquil jasper
#

would it be possible for players to get within 250 meters and not save the hostage?

deep loom
#

Unlikely but still possible.

south swan
#

and then they come back and hostage isn't there 🙂

deep loom
# south swan 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.

south swan
#

or players just get into the next area and wait for the hostage to be teleported to them 😛

deep loom
#

Also maybe add more reinforcements to the other zones if they try to cheat it.

tranquil jasper
#

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

deep loom
#

Although if they scout out an area and don't get detected that's a perfectly reasonable strat.

deep loom
south swan
#

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"

deep loom
south swan
#

something like while {!(allPlayers inAreaArray [getPos _hostage, 250, 250] isEqualTo [])} do {sleep 15;};, i guess

tranquil jasper
#

^ or hostage is saved

vapid trellis
south swan
#

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

tranquil jasper
#

why inAreaArray, could just be distance or distance2D?

south swan
#

well, because inAreaArray is in-engine

tranquil jasper
#

isn't distance too?

south swan
#

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]

deep loom
south swan
#

put the check before every _hostage setPosATL _somewhere;

deep loom
#

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;
}
south swan
#

no. The "players nearby" check goes directly above the _hostage setPosATL lines, not below them

tranquil jasper
#
waitUntil {allPlayers findIf {_x distance _hostagePos < _rangeThreshold} > -1; sleep 1;}
south swan
tranquil jasper
#

I'm still getting used to all these new commands

south swan
#

ye, actual benchmarks give surprises most of the times

tranquil jasper
#

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

elfin comet
#

Does anyone know how to have a random variable for a parameter?

tranquil jasper
#

need more info

elfin comet
#

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;
    };
};```
tranquil jasper
#

What are you trying to do exactly?

south swan
#

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

elfin comet
# tranquil jasper What are you trying to do exactly?

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.

south swan
#
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
tranquil jasper
#

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

little raptor
#

I'm gonna guess yes because the vanilla data is ok

#

whatever mod you're using is adding duplicate weapons to units meowsweats

tranquil jasper
#

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

elfin comet
tranquil jasper
#

what is Condition of Presence?

south swan
#

the editor one, i assume

tranquil jasper
#

yeah, but what is conditionally present?

crude vigil
#

a slider with 0% to 100% chance iirc.

tranquil jasper
#

mission params don't have that

#

right, a mission param can't do that however

south swan
#

well, that's the answer then 🤷‍♂️

tranquil jasper
#

oh wait I think I understand

open fractal
#

just use random?

tranquil jasper
south swan
#

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.

elfin comet
tranquil jasper
south swan
#

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?

tranquil jasper
elfin comet
#

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.

south swan
#

it looks to me like mission parameters get populated at postInit stage. So way after the objects are places 🤔

tranquil jasper
south swan
elfin comet
#

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.

south swan
#

and then we're SOL with random choice?

elfin comet
#

Seems like it. Sadge

tranquil jasper
#

Unless someone comes soon that knows exactly when mission params become available, I think the only option is just give it a try thonk

elfin comet
#

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.

tranquil jasper
#

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

south swan
vague geode
tranquil jasper
#

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

vague geode
tranquil jasper
#

that of course depends on when mission params are created though

south swan
#

well, i've seen at least one mission that expects them to be present at preInit stage. And works. meowsweats

elfin comet
tranquil jasper
#

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)

south swan
#

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. meowsweats

tranquil jasper
#

yeah that would work too, and doesn't require obscure ancient lore meowtrash

little raptor
#

I'm gonna guess it's a game bug

broken forge
#

How would I go about creating a forEach loop within a forEach loop? I.E.

{
  { _x removeWeapon _x } forEach weapons _x;
} forEach _shooters;
old grotto
#

hi, does anyone know how to add flares to a vehicle? @everyon3

elfin comet
old grotto
#

try with many ways but nothing

tranquil jasper
old grotto
#

vehicle addMagazineTurret [magazineName, turretPath, ammoCount]

modern meteor
#

Guys, is there a hotkey for the editor to snap objects to surface?

elfin comet
#

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?
little raptor
#

you've put it under category

elfin comet
#

That wouldn't stop the whole script from running though, would it?

#

(I'll still move it though.)

little raptor
#

did you even execute the function?

elfin comet
#

How would you execute a function without sqf since I need it to be preInit?

little raptor
little raptor
#

preInit executes by itself

#

but you'd put it in the wrong place which didn't work

old grotto
little raptor
#

you can't add more than max capacity

old grotto
#

and i want to add more flares

elfin comet
vague geode
little raptor
old grotto
tranquil jasper
#

Throw weapon doesn't exist I think until a unit has a grenade

little raptor
vague geode
little raptor
tranquil jasper
#

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

tranquil jasper
#

"crashes" arma for a predetermined length of time. for missions and stuff

cosmic lichen
#

Ahh, so typical engine code 🤣

tranquil jasper
#

Yeah but this is on purpose...well, maybe BIS does it on purpose too

little raptor
#

also I don't see how that's "controlled" thonk

broken forge
#

would the deleteVehicle command work for deleting a single ai unit?

little raptor
#

deleteVehicle can delete any object

broken forge
#

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 {};
little raptor
#

what does last/first line have to do with checking a condition? thonk

broken forge
#

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.

little raptor
#

setHandcuffed
isn't that function a setter?

#

not getter?

broken forge
#

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.

broken forge
#

It depends on how many the mission creator sets, I'll check the ace docs then

little raptor
#

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)

broken forge
#

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

little raptor
#

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

mental prairie
#

how do I get an array of all players in a vehicle?

little raptor
drowsy geyser
#

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];
drowsy geyser
#

thank you!

mental prairie
tranquil jasper
keen folio
#

whats the script to disable the high altitude falling animation

little raptor
little raptor
glossy pine
#

how can i get armor values of the vest, uniform, etc like Virtual arsenal does?

tranquil jasper
#

all that stuff is in the config

#

you'll need to know the classname of the clothing you want to inspect

tranquil jasper
# little raptor you're doing `_x - (_time1 # _forEachIndex)` and later use `_time # 6` which can...

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

ebon citrus
#

Sqf will terminate a while loop at 10,000 iterations?

tranquil jasper
#

unscheduled

ebon citrus
#

Now that makes more sense

tranquil jasper
#

just like magic numbers and strings, there exists magic functionality and this is one such case aviator

ebon citrus
#

I dont do while-loops in umscheduled environments, so ive never even though about it

tranquil jasper
#

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

ebon citrus
#

Ive done sqf sibce 2012, strictly speaking

#

And ive done weird stuff

tranquil jasper
#

...how are you still sane?

ebon citrus
#

Yet there is always more to learn

ebon citrus
#

But sqf was my entry to programming

tranquil jasper
#

Ah nice, sqf was not my first but where I really found my footing

glossy pine
#
private _class = uniform player;
getNumber(configFile >> 'CfgWeapons' >> _class >> 'armor')
``` like this its correct?
tranquil jasper
#

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

fair drum
#

wearables are in CfgWeapons

granite sky
#

If you're looking for the magical CSAT uniform armour then that's elsewhere.

glossy pine
#

im trying to get the armor values that virtual arsenal displays on each uni, vest helmet etc.. ballistic protection, explosive resistance etc

granite sky
#

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.

glossy pine
#

Ballistic protection, Explosive resistance, load, weight

little raptor
# tranquil jasper yes you bring up good points. The first while loop exploits that sqf will termin...

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

glossy pine
#

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..
dry smelt
#

yo guys, im trying to create minaret with adhan (islamic prayer call) for imersion on kp lib takistan

#

tho even with

little raptor
dry smelt
#

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

little raptor
dry smelt
#

any idea? i use say3D on speaker object

dry smelt
little raptor
#

which also specifies the distance

glossy pine
#

use say3D ["OPC_sound_minaret", 1000];

serene rose
#

stupid question incoming, what would be an SQF script to check if someone has a backpack on?

glossy pine
# little raptor you have to check the hit points

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

dry smelt
serene rose
serene rose
#

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

serene rose
#

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

tranquil jasper
#

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);
copper raven
#

createVehicle might have an error because no parenthesis
no, that's fine, the if is not though

serene rose
copper raven
#

backpack _unit = "B_Parachute"

#

assignment is not comparison

#

(getPos playe)r?

serene rose
#

already corrected

#

first one, second was my bad

#

thanks, no longer erroring, however it's not functioning

copper raven
#

Weapon_Empty are you sure it's correct and is a proper weapon holder?

#

also typeOf unitBackpack player just backpack player

#

try using GroundWeaponHolder

tranquil jasper
#

but you forgot ATL on getPosATL

serene rose
#
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

tranquil jasper
#

put this in the If as the first line
systemChat "if ran";
then run it again and lmk

serene rose
#

doesn't seem like it's running...

tranquil jasper
#

issue is probably with "B_Parachute" then

#

try B_Parachute_F?

serene rose
#
if (backpack _unit == "B_Parachute_F") then {
    systemChat "if ran";
    _gwh = "GroundWeaponHolder" createVehicle getPosATL player;  
    player action ["DropBag", _gwh, typeOf unitBackpack player];
};
#

still nothing

tranquil jasper
#

if it still doesn't work then do this

systemChat str (backpack _unit);
if (...) {... etc
serene rose
#
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

tranquil jasper
#

hate to ask this, but unit has backpack yes?

serene rose
#

yes

tranquil jasper
#

it kind of seems like the entire script that this is in doesn't run for whatever reason. Where did you put that?

tranquil jasper
#

try it with systemChat 😛

#

you should know how it goes now lol

serene rose
tranquil jasper
#

idk much about zeus stuff but usually you have to put this to refer to the object in BIS editor boxes

serene rose
#

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

tranquil jasper
#

yeah because == "B_Parachute_F" guess you were right the first time

serene rose
#

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

copper raven
tranquil jasper
#

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

serene rose
#

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

tranquil jasper
#

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

serene rose
#

got it, fixed

tranquil jasper
#

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
serene rose
#

fuck, yeah just realized I messed it up

tranquil jasper
#

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

serene rose
#
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]; 
}; ```
tranquil jasper
#

yeah looks nice, now don't forget to test it multiple times even though 1x is enough, then remove the systemChat's 😛

serene rose
#

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

little raptor
#

use putBag

serene rose
agile pumice
#

This has likely been asked many times before, but is something up with the wiki?

tranquil jasper
#

it's moody sometimes

serene rose
#

😂 thanks y'all

serene rose
true frigate
#

Or is this completely impossible?

tranquil jasper
#

maybe could be done with a mod?

hallow mortar
drifting portal
#

it states that it has local effect

#

does that mean I have to remoteExec this ?

tranquil jasper
#

yes

drifting portal
#

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

tranquil jasper
#

I'd imagine so

drifting portal
#

is it bad to do this for 200 units?

#

so like

 [_unit, true] remoteExec ["enableDynamicSimulation", 0, _unit];
#

but for 200 units

tranquil jasper
#

shouldn't be any worse than just having 200 units in a mission

drifting portal
#
getarray (configFile >> "CfgWeapons" >> "LMG_Mk200_LP_BI_F" >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems");
#

why is this returning [] ?

tranquil jasper
#

does it have a value in config?

drifting portal
#

it is the attachments classnames

tranquil jasper
#

check your spelling then, maybe you have a typo

drifting portal
tranquil jasper
#

hmm definitely a problem then

drifting portal
#

what type of problem exactly

#

1 minute

drifting portal
tranquil jasper
#

oh

#

so that's not an array

drifting portal
#

yep

tranquil jasper
#

those are individual properties

#

yeah you'll need to access a different way then

drifting portal
#

which one?

#

because I'm a starter at config family of commands

#

i would say use a combination of count and select?

tranquil jasper
#

try this

_properties = configProperties [configFile >> "CfgWeapons" >> "LMG_Mk200_LP_BI_F" >> "WeaponSlotsInfo" >> "CowsSlot" >> "compatibleItems", "true", true];
_classnames = _properties apply { configName _x };
hint str _classnames;
tranquil jasper
#

np

#

yeah config array looks like this:
name[] = {0, 1, 2, 3};

drifting portal
#

guy used getArray

drifting portal
tranquil jasper
#

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

drifting portal
#

yep lol

tranquil jasper
#

and those values were all "Numbers"

drifting portal
tranquil jasper
#

yup

drifting portal
#

and configname for the name itself

drifting portal
#

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} };
tranquil jasper
#

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

tranquil jasper
#

then the ones with 0 won't even show up in _properties

drifting portal
#

I figured that out but didn't know I could use the magic variable

#

feared it might break if I used it lol

tranquil jasper
#

gotta read the description on the wiki page 😛

drifting portal
drowsy geyser
#

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;
winter rose
little raptor
#

I think it should be possible to "hack" the function

#

nope. it's not

#

it runs in scheduled env and uses local vars...oof meowsweats

drowsy geyser
#

would be really cool if it would resume where it interrupted.

winter rose
#

well, the point of it is to hold for a certain amount of time
doing it in - - - - - - small parts kinda break the spirit

drowsy geyser
#

true

winter rose
#

you could use the onInterrupted code to add another action with the remaining time and remove the current one, I believe

drowsy geyser
#

okay i will try

copper raven
#

something similar has been done in this channel, just need to find it

copper raven
drowsy geyser
#

found it here

tough abyss
#

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)

still forum
#

I don't know of a better way

tough abyss
#

😦

still forum
#

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

tough abyss
#

yeah, good idea

#

I will do that, thanks

tough abyss
granite sky
#

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

tough abyss
#

Is it normal a vehicle created by createVehicle or createSimpleObject server-side will appear 2 minutes later on all clients? (simulation also disabled)

tough abyss
#

why?

little raptor
#

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

tough abyss
#

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

tough abyss
#

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

noble zealot
#

There is a way to minimize sqf?

#

And make the sqf file smallest as possible?

still forum
noble zealot
#

"from 1 to 100" will turn into "from1to100"

still forum
noble zealot
#

🤣

cosmic lichen
noble zealot
#

Worth a try.

modern meteor
#

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?

granite sky
#

As far as I know there is no event handler for life state changes. There probably should be.

#

So you'd need to poll.

kindred zephyr
#

alternatively do a oneachframe loop checking states, but that just going overboard and performance wasting for what you are trying to do

modern meteor
#

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.

kindred zephyr
kindred zephyr
modern meteor
#
{ }
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.

open fractal
#

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

modern meteor
#

ok, i will look into the eventhandler,

#

thank u

drifting portal
#

_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?

spring root
#

switch case?

drifting portal
#

I'm trying to hint back what the player is pressing

drifting portal
granite sky
#

Note that you can't do the unconscious check in the handler, because you have to wait until whatever medical system does its thing.

kindred zephyr
#

you can, I actually do it

#

thats how I did autorevivers for our mission

granite sky
#

With which medical system?

kindred zephyr
#

My own custom medical system, considering vanilla as base.

granite sky
#

uh

#

If you have your own medical system then you can order stuff how you like.

kindred zephyr
#

we are still intercepting the vanilla unconsious state tho

hallow mortar
kindred zephyr
# granite sky If you have your own medical system then you can order stuff how you like.

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

modern meteor
#

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?

drifting portal
#

Problem is say he pressed W (DIK_W) , if I do
hint str(DIK_W)
it will not give back "W"

hallow mortar
#

What does it give back?

modern meteor
#
{  
    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?

drifting portal
kindred zephyr
modern meteor
#

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.

kindred zephyr
#

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)

modern meteor
#

Well the hint should get triggered immediately, no?

kindred zephyr
#

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

modern meteor
#

yea but the Hint is not getting triggered

kindred zephyr
#

try with a handleDamage event handler instead

modern meteor
#

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

kindred zephyr
#

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?

modern meteor
#

running it from a description.ext for a mission

#

i'll have a look at handleDamage

tough abyss
#

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

deep loom
#

Is there any way to have a leaflet add a diary entry of an image after it's been viewed?

modern meteor
#
{
    if (lifestate player == "INCAPACITATED" ) then  
    {    
        [] spawn   
        {  
         hint "You lost 5 Campaign points!";                   
        []execVM "points.sqf";
        sleep 3;             
        };  
    };  
}];```
#

Also does not work

#

No idea why

granite sky
#

A couple of possibilities:

  1. You're installing that handleDamage EH before MGI installs its own, so the player isn't unconscious at the point the EH triggers.
  2. 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.

modern meteor
#

Yea, maybe MGI is causing the issue here

#

When you say putting the lifestate inside the spawn, what do you mean by that?

granite sky
#
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.

modern meteor
#

Does Arma have an integrated revive system which I could use? I don't necessarily have to use MGI.

granite sky
#

There's an optional BIS revive system (introduced with Apex, I think) but it only works for players.

modern meteor
#

That's fine, only the player would be healed

modern meteor
granite sky
#

oops

tranquil jasper
#

need to return damage amount

granite sky
#

Fixed.