#arma3_scripting

1 messages · Page 123 of 1

meager granite
#

Yes, but it will always be default

#

because you're comparing Number to Bool

#

you probably meant switch true do ...

#
_array select {!isNil"_x"}
#

but yeah, fix the original issue that puts it there in a first place

grand idol
meager granite
grand idol
#

Ok, thanks.

granite sky
#

NaNs aren't nils. You'd probably have to use finite

elder karma
#

Is there a script or code that can be put in a vehicle init in EDEN to prevent players from switching to the gunner's seat of a vehicle, but still allow them to switch to other seats in the vehicle? Ideally one that removes the listing of the gunner position from the command menu / scroll menu entirely when boarding or inside?

hushed tendon
#

Anyone know some good guides for using what little I remember of high school vectors to learning how they work in arma? I'd like to start out knowing just how to create the XYZ lines that come out of an object and then work from that to get a position like [1,0,1] away from that object kinda like modelToWorld but also taking the objects rotation into account

hallow mortar
hushed tendon
#

oh my test was bad that's why I thought it didn't take rotation into account

pulsar lagoon
#

Is there a script that I can use to respawn AI and players into the same vehicle? I'm making a mission using tanks with AI crews and a player as the tank commander. Is there anyway I can have the tank respawn with the crew and player in it?

sudden yacht
#

When you say respawn.. respawning at the start of the mission? Or each time someone dies?

pulsar lagoon
#

When someone dies

#

Because I can respawn the vehicle with a crew using the vehicle respawn module and the expression to respawn a crew but I can't figure out a way to get the player back in the tank as the commander

fair drum
#

you can either save the current player to the tank's variable namespace and reference it using the old vehicle argument that is passed on the vehicle module respawn expression, or you can forgo the vehicle respawn module all together and just build the tank with a respawn event handler or onPlayerRespawn.sqf, move your player, then add the crew

hushed tendon
#

I'm trying to have a script where the subject object will first store the relative values of position and rotation to the origin object and then try and make it so they stay the same no matter the future position or rotation of the origin. The positioning seems right but the rotation math is wrong somewhere and I'm not sure as to why.

params ["_originObj","_subjectObj"];

//-- Relative Positioning
private _relPos = _originObj worldToModel getPosATL _subjectObj;

//-- Relative Vector Dir and Up
private _originVecDir = vectorDir _originObj;
private _subjectVecDir = vectorDir _subjectObj;
private _diffVecDir = _originVecDir vectorDiff _subjectVecDir;

private _originVecUp = vectorUp _originObj;
private _subjectVecUp = vectorUp _subjectObj;
private _diffVecUp = _originVecUp vectorDiff _subjectVecUp;

while {alive _subjectObj} do {

    //-- Set Relative Pos
    private _newRelPos = _originObj modelToWorld _relPos;
    _subjectObj setPosATL _newRelPos;

    //-- Set Relative Vectors
    private _originVecDir = vectorDir _originObj;
    private _originVecUp = vectorUp _originObj;

    private _addVecDir = _originVecDir vectorAdd _diffVecDir;
    private _addVecUp = _originVecUp vectorAdd _diffVecUp;

    _subjectObj setVectorDirAndUp [_addVecDir,_addVecUp];

    sleep 0.001;
};
hallow mortar
#

Have you considered just using attachTo?

hushed tendon
#

this is practice for a mod I'm making where I need to store these relative values so when something gets built all the objects are in the correct locations if that makes sense

proper sigil
#

Hey, I'm trying to use init eventhandler to execute a script on vehicles that were already present in Eden editor or added later in zeus session though I'm not sure I understand how this particular EH works. I put this in description.ext like this

{
    class DNTcargoSize
    {
        class SetCargoSize {
            init = "[(_this select 0)] execVM ""DNT_supplies\DNT_setCargoSize.sqf;""";
        };
    };
};```

Is it a correct way of using this EH? Also does '_this' in this case refer to created object?
warm hedge
#

Do you mean it does work or not? I'm not a CBA user so can't tell how it should be but according to some documents I'm doubting it will work as you intended

proper sigil
#

Yeah it doesn't work. I never really used EH that require being used in configs that's why I'm looking for pointers where should I put it so it "fires" as expected

warm hedge
#

What is your actual intention then?

proper sigil
#

Script should fire whenever an entity is created during zeus session (for example zeus places a vehicle, script executes on this vehicle)

warm hedge
#

Then I guess cpp class Allinstead of cpp class DNTcargoSize

proper sigil
#

Ah I see didn't realise class name was important. So putting this in description.ext is a valid way?

warm hedge
#

Probably

proper sigil
#

Cheers going to give it a shot ;)

ocean yarrow
#

Anyone able to help with this? withered

ocean yarrow
neon plaza
#

I am trying to add a line of code that teleports the player to the officer (Which Is a player) and If the officer Is In a vehicle with seats place the player In one of the seats.

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

```sqf
// your code here
hint "good!";
```

// your code here
hint "good!";
neon plaza
#

this addAction ["Teleport to Officer", { 
params ["_target", "_caller", "_actionId", "_arguments"]; 
if !((incapacitatedState BlueForCommander)== "UNCONSCIOUS") then{ 
    _caller setPosASL (getPosASL BlueForCommander); 
}; 
}, nil, 1, true, true, "", "true", 5];

manic sigil
neon plaza
manic sigil
#

Will need some cleaning up, probably, but it should be straight forward enough XD

torpid quartz
#

Hey I'm just making a little thing where all the players on the server are going to be teleported to a new area after their screens fade to black.
This is on a trigger set to server only, just I'm not sure what I should be setting the "Player" variable to in this case to get it to work.

The fade in and out is done on another script that works fine for now.

{
player setPos (getPos TP1);
player setUnconscious true;
} forEach allPlayers;
warm hedge
#

player here only points one unit, I'm not sure the context how you've run this script but I assume you want _x

torpid quartz
#

probably that's it I'll give it a test. This is just on a trigger set to server only, the players enter it while flying through it in a vehicle and it teleports them to a crash site after a fade out done on another script

#

there's also the slight problem of teleporting everyone to the exact same location.
is there a way to make it teleport people between one location and another like [1000,1000,5] to [1010,1010,5]?

warm hedge
#
[1000,1000,5] vectorAdd [random 10,random 10,0]```
torpid quartz
#

awesome thanks Polpox, not getting any errors with this,

x_ setPos ([1000,1000,5] vectorAdd [random 10,random 10,0]);
x_ setUnconscious true;
} forEach allPlayers; ```

though just testing it by hosting a MP session on my computer and nothing is actually happening. I'm assuming this issue is because it's not being run on a dedicated server?
warm hedge
#

Not x_, it's _x

torpid quartz
#

oh my god lol

#

one sec

#

Hell yeah that works perfectly thanks Polpox! That makes a lot more things possible thanks so much!

hallow mortar
#

There is no vectorSub and that's not what this is doing

#

That is adding a randomised amount, up to 10 metres X and Y, to the destination position each time the teleport is run. It is a position randomisation to spread out the players when they're all teleported at once.

#

It has nothing to do with finding vectors between two points.

#

If you need to find a vector pointing from one point to another, just use vectorFromTo.

granite sky
#

-number is fine, -array is invalid.

hallow mortar
#

Good thing we have vectorDiff for if you want those then

granite sky
#

array1 - array2 is also valid but isn't gonna do vector stuff :P

neon plaza
neon plaza
warm hedge
#

How do you use addAction and its code

hallow mortar
pliant stream
#

is it just me or is lineIntersects a piece of shit?

lone glade
#

Which is the reason why lineIntersectsSurfaces was made

pliant stream
#

but... arma 2 D:

lone glade
#

huehuehuehue you're screwed

pliant stream
lone glade
pliant stream
#

what is this?? a functional game engine??

lone glade
#

huehuehue

#

I'm still waiting to be able to lock ground holders and have an attachTo that follows the orientation of the memory point or selection it's attached to.

pliant stream
#

gee i think that's a bit too advanced for RV

lone glade
#

Hey we got bipuuuuuurds, we can get that..... eventually......

leaden summit
#

Hey I know I can use nearestObjects [player, ["house"], 200]; to get all houses with a 200m radius of the player, what about all houses within a marker that isn't necessarily circular?

granite sky
#

use a larger radius and then _array inAreaArray "marker"

leaden summit
#

And then if the building in the larger radius isn't in the marker rinse and repeat?

granite sky
#

inAreaArray will filter the whole array from nearestObjects with one command.

#

It's also quite fast.

leaden summit
#

Cool thank you

#

Fast is good

sage marsh
#

Hey guys, is there a way to optimize an init.sqf with this in it?

warm hedge
#

this?

sage marsh
#
cutText ["", "BLACK FADED"];
0 fadesound 0;
sleep 2; 
10 fadesound 1; 
[0,0,false] spawn BIS_fnc_cinemaBorder; 
sleep 5; 
titleCut ["", "BLACK IN", 12]; 
[["26 - February - 2025", 4, 3], ["Central Niakala, Somewhere in Africa", 4, 3], ["75th Army Ranger, Callsign 'Granite 4-6'", 4, 3] ] spawn BIS_fnc_EXP_camp_SITREP;
  
sleep 8;  
[1,1,false] spawn BIS_fnc_cinemaBorder; 
 
Sleep 10; 
["Lifter 5-1", "One Minute to LZ."] spawn BIS_fnc_showSubtitle;  
 
sleep 7; 
["Watcher", "All units, search and detain our HVT. Intel suggest he is between the two points."] spawn BIS_fnc_showSubtitle; 
 
sleep 6; 
["Watcher", "Reminder, the individual must be taken alive. We need him for questioning. Good hunting, squads."] spawn BIS_fnc_showSubtitle; 
 
sleep 15; 
A2 setrandomlip true; 
["Granite 4-2", "Hey boss, i hear gunfire near our AO. Should we be worried?"] spawn BIS_fnc_showSubtitle; 
 
sleep 6; 
A2 setrandomlip false; 
A1 setrandomlip true; 
["Granite 4-1", "The whole region is a wild west. As long as we don't stray too far from our target location, we should be fine."] spawn BIS_fnc_showSubtitle; 
 
sleep 4; 
A1 setrandomlip false;
#

For some reason it lags my mission if an init file with this was in the mission folder

#

Took it out, and it'll work like nothing

#

i'm a very newbie in coding so i don't undertand lol

warm hedge
#

It doesn't really matter if it is called already

sage marsh
#

can you make an example for like 3 subtitle lines please

#

with the forEach

#

I need to see how it's done

warm hedge
#

I've just tried your code. At least in VR but doesn't really feel a big lag

#

Are you sure this part of the code is the faulty

sage marsh
#

Not lag, but the surrounding trees and building gets low in quality

warm hedge
#

Quite confusing symptom actually

sage marsh
#

Lemme take a screenshot then

warm hedge
#

It shouldn't do anything with visuals

sage marsh
#

With init file

#

No Init file

#

so just use the black fade in one then?

#

ditch the border

#

that's the mission detail on the bottom right one

#

it's just a fade in text compared to the other ones

#

Alright lemme test it out

#

Changed it into infotext

#

works like charm

#

WTF

#

So what's the issue with it?

#

The wiki says spawn so..

#

Aight, i'll try both

#

yeah, i choose the sitrep one because it looked simple

#

Call work like the spawn

#

no difference

warm hedge
#

It does actually make nearly zero sense BIS_fnc_EXP_Camp_SITREP can change how an object LOD work

sage marsh
#

Error

#
spawn {[["26 - February - 2025", 4, 3], ["Central Niakala, Somewhere in Africa", 4, 3], ["75th Army Ranger, Callsign 'Granite 4-6'", 4, 3] ] call BIS_fnc_EXP_camp_SITREP;};
#

Guess i'll stick to info text future on

warm hedge
#

We're not talking about ArmA logic or something. We're playing Arma and GUI cannot influence LODs

sage marsh
#

Well anyways, thanks guys

#

I'll just use info text from now on

#
[
    ["Speaker1", "Subtitle1", 0],
    ["Speaker2", "Subtitle2", 5],
    ["Speaker3", "Subtitle3", 10],
    ["Speaker4", "Subtitle4", 15]
] spawn BIS_fnc_EXP_camp_playSubtitles; // displays 4 subtitles with 5 seconds between them

sleep 7;
BIS_fnc_EXP_camp_playSubtitles_terminate = true; // closes subtitles;
#

i found this

#

Might overhaul my dialogue with this

#

it maybe the sleeps that impacted it

proven charm
#

what's a "map point" ?

#

honestly idk if its even possible to draw pixels/dots

#

ok

#

how many doughnuts?

#

ok ic

#

well i bet DrawLine3D is so slow

#

so good luck with that 😐

warm coral
#

is there a way to overwrite a function from a mod in a mission file?

stable dune
warm coral
#

it is loaded but for some reason it isnt registering for me

#

theres a mod called arpi which has some functions it executes when consuming items through ace

#

and i wanted to overwrite them in a mission by doing this

ar_medical_fnc_interaction_useInsectrepellent = compileFinal preprocessFileLineNumbers "fn_insectRepell.sqf";
ar_medical_fnc_interaction_usePillMalariamedi = compileFinal preprocessFileLineNumbers "fn_malariaPill.sqf";
#

and putting it in init.sqf

#

but it didnt work

#

and the way i found the functions im trying to overwrite was by finding how it was being executed in the ace self interact menu

#
class ar_Use_Paste_Desinfection_apply_other
                    {
                        displayName="$STR_ar_medical_INTERACTION_USE_PASTE_DESINFECTION_APPLY";
                        condition="call ar_medical_fnc_interaction_canUse_Paste_Desinfection";
                        exceptions[]=
                        {
                            "isNotSwimming"
                        };
                        statement="call ar_medical_fnc_interaction_use_Paste_Desinfection_apply_other"; // here
                    };
...
proven charm
warm coral
#

if it is, what do i do?

proven charm
#

then it cant be overwritten

#

you can check it by ```sqf
isFinal ar_medical_fnc_interaction_useInsectrepellent

warm coral
#

it gave me true

#

so i guess not

#

but thanks anyway

proven charm
#

np

stable dune
# warm coral so i guess not

You might wait until it is final / is not nil.
Dialog that variable , what that return in init , and what that return when you are in game (when all post init etc stuff is initialized)

warm coral
#

it gave me true again

stable dune
#

Where did gave you true, in init or in debug when you are in game

little raptor
#

you can overwrite them using mods tho

warm coral
jade acorn
#

I'd like to let player enable and disable thermal vision with an addAction but without giving him any head mounted device. Is it possible? setCamUseTI doesn't work with the default "internal" unit camera and I don't see anything else relevant on the biki

limber panther
#

Greetings, just a quick question - is there any script, that would put weapon on the back? I know i can put away (holster) gun using ace mod, but can i do it by a script? Thank you.

little raptor
jade acorn
#

switchweapon

jade acorn
#

player action ["SWITCHWEAPON",player,player,-1];

limber panther
#

@jade acorn @little raptor thank you for your tips!

sullen sigil
#

what lod is lefthand usually defined in? cant seem to get selectionvectordirandup for it

little raptor
#

allLODs player select {"lefthand" in (player selectionNames _x#2)}

sullen sigil
#

thank you leopard

leaden summit
#

I've read before that using ambient animations in multiplayer isn't great because it creates multiple logics or something like that.
Does that include after they break out of the animation? For instance if I'm using a script to spawn AI and give them ambient animations will I take continuing performance hits from that when the units are dead or deleted?

little raptor
#

My guess is yes. But you have to read the function and see if it accounts for unit getting killed/deleted

#

Which is probably either checked via a loop or killed/deleted event handlers

hallow mortar
leaden summit
#

Cool thank you

molten yacht
#

Is there any way to alter the location of the subtitle given by BIS_fnc_EXP_camp_playSubtitles?

#

It's low enough to conflict with DUIHud, which is standard for our modpack....

grand idol
#

I have a script that generates map markers for vehicles when a UI button is clicked. Another click deletes all markers. The marker names are entered into a hashmap so that they can be selectively deleted later on. Another part of this script turns markers on and off for individual vehicles. I believe that a hashmap is the appropriate way to store these. This is the creating part:

{
    _thisVehicle = BSF_PlayerVehicles get _x;
    _thisVehicle params ["_vehID","_vehClass","_territoryID","_vehObject"];

    if (typeName _territoryID == "String") then {
        _markerName = format["%1_%2", _vehID, _vehClass];
        _markerPos = position _vehObject;
        _markerDir = direction _vehObject;

        _marker2 = createMarkerLocal [format["%1_2",_markerName] , _markerPos];
        _marker2 setMarkerShapeLocal "ELLIPSE";
        _marker2 setMarkerColorLocal "ColorBlack";
        _marker2 setMarkerSizeLocal [300,300];
        _marker2 setMarkerAlphaLocal 1;
        _marker2 setMarkerBrushLocal "Border";

        _marker3 = createMarkerLocal [format["%1_3",_markerName] , _markerPos];
        _marker3 setMarkerShapeLocal "ELLIPSE";
        _marker3 setMarkerColorLocal "ColorOrange";
        _marker3 setMarkerSizeLocal [300,300];
        _marker3 setMarkerAlphaLocal 0.5;
        _marker3 setMarkerBrushLocal "SolidFull";

        _marker = createMarkerLocal [_markerName, _markerPos];
        _marker setMarkerDirLocal _markerDir;
        _marker setMarkerTextLocal _vehName;
        _marker setMarkerTypeLocal "mil_dot";
        _marker setMarkerColorLocal "ColorBlack";

        VehMarkers set [_vehID, _markerName];
        _vehObject setVariable ["BSF_MarkerOn", 1];
    };
} forEach BSF_PlayerVehicles;
diag_log format["ToggleMarkerAll: VehMarkers %1 - %2",VehMarkers, typeName VehMarkers];

The log yields:
18:33:14 "ToggleMarkerAll: VehMarkers [[9,"9_Exile_Car_Lada_White"],[11,"11_Exile_Car_Offroad_DarkRed"],[12,"12_Exile_Car_Golf_Red"],[14,"14_Exile_Car_SUV_Rusty1"],[18,"18_RHICC_GREY"],[8,"8_Exile_Car_Hunter"]] - HASHMAP" (Double quotes removed for legibility).

The "delete all" code:

{
    VehMarkers deleteAt _x;
    deleteMarkerLocal _y;
    deleteMarkerLocal format["%1_2",_y];
    deleteMarkerLocal format["%1_3",_y];
} forEach VehMarkers;

When the deletion code is run, only about half of the markers listed in the VehMarkers hashmap are processed. If the same code is run again, about half of the remaining markers are deleted. Eventually, they are all gone. So it doesn't seem to be a formatting issue.
Why don't all of the hashmap entities get processed in the forEach loop? Is there a better way of iterating through a hashmap?

granite sky
#

There is forEachReversed but I'm not sure if that works for hashmaps.

#

Check whether it works if you just clear the hashmap outside the loop, like VehMarkers = createHashMap;

grand idol
granite sky
#

I mean if you do the forEach first but without the deleteAt line.

grand idol
#

How would I delete that markers that correspond to the names in the hashmap?

granite sky
#

The same way you wrote, except without the deleteAt line :/

#

A marker name is just a string. Its existence is independent from the marker itself.

grand idol
#

I get that about the name. What I mean is I don't see how if I just delete the hashmap entry in a separate scope, then delete the marker later using what to reference it's name?

granite sky
#

Why do it in that order?

#

Delete the markers using the hashmap, then clear the hashmap?

grand idol
#

Ah, got it. I'll give it a shot. Thanks

grand idol
#

Good idea. Thanks.

grand idol
#

Do you mind elaborating on this? How would it be implemented in my examples above?

granite sky
#

If count gives you _y then that's an undocumented feature.

#

looks like {condition} count array only exists for arrays anyway.

#

In some cases you can use count instead of forEach and it's fractionally faster. Maybe.

velvet merlin
#

is it a problem or only bad practice to have a semicolon on a condition in an waitUntil?

waitUntil {condition;};

#

AFAIK strictly speaking ; defines the statement. so the return/condition would come after it, no?

little raptor
#

No

#

You can place as many ; as you want

#

The scope returns its last evaluated expression

hallow mortar
#

I find that skipping the ; helps me to visually parse it as a final return, making it slightly easier to read. Game doesn't care though.

velvet merlin
#

fom addAction

#

radius: Number - (Optional, default 50) maximum 3D distance in meters between the activating unit's eyePos and object's memoryPoint, selection or position. -1 disables the radius; hardcoded limit is 50

#

is it more efficient to reduce the radius if the action doesnt need as much?

#

(aka engine checks distance first before action condition, etc)

kindred zephyr
velvet merlin
#

well this was more directed to Leopard20 / BI people with source access - you would assume distance is the first check by the engine, but we cant tell

little raptor
kindred zephyr
#

addAction at the end of the day it's an engine side solution that grants a convenient GUI addition, if you want to optimize even further you can instead use shortcuts by doing checks on keypresses for example, or even better, create your own action manually by using https://community.bistudio.com/wiki/inGameUISetEventHandler.
As long as you need to constantly verify something, either a OEF or a loop will be required.

#

that makes wonder, how often does the addAction actions check for their condition to be fulfilled 🤔

little raptor
#

every frame

kindred zephyr
#

ah nvm

#

oef

#

yeah

#

ty

viscid laurel
#

anyone know why airportvehTrigger == 1; is giving me Generic error in expression

I'm activating a trigger within a trigger setting its value to 1

vapid scarab
#

Whats its value before it is set to 1?

viscid laurel
#

isn't it 0 if its not activated?

winter rose
#

why would it be?

#

also I hope airportvehTrigger is not the trigger itself

viscid laurel
winter rose
#

you are trying to check if an object is equal to a number; not happening

hallow mortar
#

== is for comparison, = is for setting. airportvehTrigger == 1 is a check, to determine whether the variable airportvehTrigger contains the value 1. It doesn't, it contains an object (the trigger), so it causes an error because == can only compare the same type.
Doing airportvehTrigger = 1 would set the variable airportvehTrigger to contain the value 1. It would not change the state of the trigger previously associated with that variable, because that's not how triggers work; it would just replace it, leaving the trigger with no variable referencing it.

#

To check if a trigger has been activated, use triggerActivated. There's no specific command for activating a trigger, but you can use setTriggerActivation to set its conditions to something you know will be true.

#

(such as true, for instance)

tall lark
#

how easy would it be to make a script for a life server to do a driving test to get the license ? ?

winter rose
#

easy for experienced scripters, not easy for unexperienced ones, close to impossible for someone not having a PC

tall lark
#

i have a few years in arma scripting but i left arma for like 3 years so i am getting back to it

kindred zephyr
#

it really is as complex as you want the system to be in the end of the day

tall lark
#

basic really like click buy and then will spawn car with and it puts waypoints down to follow in a timer counting down

kindred zephyr
#

well, the hard part is already figured out then, which is what and how to do.
Translate that into code now, Its simple enough as you describe it

proper sigil
#

Hey! I'm having this script that runs when player uses action assigned to an item. I wanted to additionally to add an animation on player unit for duration of script execution - something like [_caller, "REPAIR_VEH_KNEEL", "ASIS"] call BIS_fnc_ambientAnim; though I read this function is not recommended for MP as it creates a logic each time it's assigned on a unit. Could anyone give me a piece of advice on how to approach that?

half sapphire
#

hey guys, might need a hand here. anyone having issues with the "put" event handler? trying this so far yields no results:

_ipos1 = getPosATL player;

RPR_itemBox = "Land_PlasticCase_01_medium_black_F" createVehicle _Ipos1; 
RPR_itemBox setPos _Ipos1;

RPR_itemBox addEventHandler ["Put", { 
 params ["_unit", "_container", "_item"]; 
systemChat format ["%1", _item]; 
}];
#

executed on console for quick testing

#

self hosted

dreamy kestrel
#

Q: about the default baked in map control... not available during the mission postInit, is it? is there a better mission event we could listen toward? Or just spawn a wait for the instance to become available?

sudden yacht
#

If um anyone would like to help me with the Playscriptedmission Command.... I would post the full code here but... its 14000+ characters. Helps...

drifting sky
#

Is there any scripting command that increases brightness of terrain and objects during night? WITHOUT affecting brightness of sky or size of stars?

hallow mortar
#

You can get decent results with setApertureNew. It does have a certain effect on the sky as well, but with some tweaking it's possible to get it nicely calibrated so it doesn't get too bright.

#

Otherwise, you could try using local lightpoints set to a faint blue-grey with no ambient colour. That can help with the near area.

drifting sky
#

I don't suppose there's a way to just add some amount of light globally to the world

hallow mortar
#

No, not really

#

Picking a cloudless night with a full moon can help

valid lichen
#

hey anyone now a good script for a vendor

half sapphire
#

well i guess the wiki is wrong then? "put" event handler does NOT work if added to the container. (does work if added to unit)
what a let down 😦

#

"take" event handler however works fine if added to container.

dreamy kestrel
grim cliff
#

working on a mission that my buddies all love to play but i keep getting a wierd bug where when i use UnconsciousReviveMedic_B animation, the player randomly appears lying on their back for both the person being revived and the person doing the reviving
heres my code:

steep verge
#

Hello i am kinda new to arma scripting and i have a question that someone would be maybe kind enough to answer 🙂

#

Is there any way to stop a BIS function that was called by a trigger? In this particular case its the call BIS_fnc_music, which i want to play some nice ambient tracks TILL another trigger (BLUFOR spotted by OPFOR) launches and terminates it. I have tried it several ways, but sadly none of them stops the actual music played by the function.

#

Thanks in advance for any kind of information or advice.

grim cliff
# grim cliff working on a mission that my buddies all love to play but i keep getting a wierd...
[player,
"Revive",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_reviveMedic_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_reviveMedic_ca.paa",
"vehicle _this == _this && alive _this && lifeState cursorObject == 'INCAPACITATED' && group _this == group cursorObject && _this distance2D cursorObject <= 2.5 && !('Medikit' in itemcargo _this && _this getvariable ['CustomMedic',false])",
"alive _caller && _caller distance2D uncpatient <= 2.5 && lifeState uncpatient == 'INCAPACITATED'",
{
uncpatient = cursorobject;
switch (stance player) do 
{
//UnconsciousReviveMedic_B
case "STAND": {[_caller,'UnconsciousMedicFromRifle'] remoteExec ["switchmove", 0, false];
[_caller,'UnconsciousReviveMedic_B'] remoteExec ["playmove", 0, false]};
case "CROUCH": {[_caller,'AmovPknlMstpSrasWpstDnon'] remoteExec ["switchmove", 0, false];
[_caller,'UnconsciousReviveMedic_B'] remoteExec ["switchmove", 0, false];};
case "PRONE": {[_caller,'AmovPpneMstpSrasWrflDnon_AmovPknlMstpSrasWrflDnon'] remoteExec ["switchmove", 0, false];
[_caller,'UnconsciousReviveMedic_B'] remoteExec ["playmove", 0, false];};
default {[_caller,'AmovPknlMstpSrasWpstDnon'] remoteExec ["switchmove", 0, false];
[_caller,'UnconsciousReviveMedic_B'] remoteExec ["switchmove", 0, false];};
};
},
nil,
{
[uncpatient, false] remoteExec ["setUnconscious", 0, false];
[uncpatient, 0.4] remoteExec ["setdamage", 0,false];
[uncpatient, false] remoteExec ["setCaptive", 0,false];
[uncpatient, true] remoteExec ["allowdamage", 0, false];
[_caller,'AinvPknlMstpSlayWrflDnon_AmovPknlMstpSrasWrflDnon'] remoteExec ["switchmove", 0, false];
private _string = format ["%1 was revived by %2", name _unit, name _caller];
[_string] remoteExec ["systemChat", 0, false];
},
{[_caller,'AinvPknlMstpSlayWrflDnon_AmovPknlMstpSrasWrflDnon'] remoteExec ["switchmove", 0, false];},
[],
11,
999,
false,
false,
true  
] call BIS_fnc_holdActionAdd;
little raptor
grim cliff
#

i used [] call bis_fnc_music and it started playing EVERY TRACK IN THE GAME playmusic ""; shut it up immediatly

#

uh.... unhinted side effect, it shut up that reack, but not the others

#

basically works like a skip track that way

little raptor
#

well just don't use BIS_fnc_music

#

use playMusic instead

grim cliff
#

terminate should work

little raptor
#

it's called and it returns bool. there's no way to terminate it

grim cliff
#

but targeting what script tpo terminate is the hard part

#

i get this when i ran ```sqf
diag_activesqfscripts

```sqf
["<spawn>
    _trackList = _this select 0;
    _trackCount = count _trackList;
    _durationList = _this select 1;
    _d","/temp/bin/A3/Functions_F/Misc/fn_music.sqf",true,77]
little raptor
#

yes but it's useless. you can't terminate it without the handle

hallow mortar
#

I feel like BIS_fnc_music should have a way to stop it, and it probably wouldn't be hard to add one

little raptor
little raptor
grim cliff
#

returns nothing

little raptor
#

wiki says it returns bool

grim cliff
#

returned true for me, but you cant target a bool?

little raptor
#

like I said it either should return the handle, or save the handle into a global var

#

its return won't be changed due to backward compatibility

hallow mortar
sharp grotto
grim cliff
#

i found the key!

terminate bis_fnc_music_spawn; playmusic "";
hallow mortar
grim cliff
pulsar bluff
#

i imagine a server event handler to detect new scripts (spawn and execvm)

neon plaza
#

Having Issues with a script. Every time the player dies the script no longer shows the option to teleport to officer In the top left hand corner. I am hoping someone will help with telling me what might be wrong.

#


this addAction ["Teleport to Officer", { 
params ["_target", "_caller", "_actionId", "_arguments"]; 
if (vehicle OpforCommander != OpforCommander) then{
    _caller moveInAny (vehicle OpforCommander);
}else{
     _caller setPosASL (getPosASL OpforCommander); 
};
}, nil, 1, true, true, "", "true", 5];

#

It It located on the Init on the player located In EDEN editor.

granite sky
#

addActions don't move to the new unit on respawn.

#

You'd have to re-add them on respawn.

steep verge
#

Thank you so much! Works like a charm of course.

hushed tendon
#

So I'm doing some scripting for a dedicated server and it works fine everywhere else I test it like usual and the proceeds to break when using it on the dedicated server like usual. I'm working with respawns, I've tried both the onPlayerRespawn.sqf and the Respawn event handler. I've done some browsing and it seems this is an issue for others as well. Is there a way to fix this, is it just me, or is there a way around this?

I'm trying to switch the players side when they die

private _grp = createGroup east;
[player] joinSilent _grp;
granite sky
#

Where are you running that code?

#

And does everything else work on the respawn handler, or are you not doing anything else?

left iron
#

is there an in-editor solution to respawning players in the air? markers dont seem to have a Z coord and respawn modules place them at ground level regardless of the Z coord.

delicate hedge
#

Hi guys, how to detect when some player (not just local Player), opens his inventory. I tried:
unit addEventHandler ["InventoryOpened", {
_opened = true;
]};

but its not detecting. Or im doing smth wrong?

#

And i declare this _opened variable before event handler as false

#

and put all that in While loop with sleep 1;

sullen sigil
#

what is unit

#

you also shouldnt recursively add event handlers

#

nor do that

delicate hedge
#

unit is some player, whos name i get in code

hallow mortar
#

As per the page KJW linked (do read it), _opened is a local scope variable. When used in the event handler scope, it's separate from any other instance of a variable called _opened, and ceases to exist when the EH code completes.

delicate hedge
#

ok i tried this:
unit addEventHandler ["InventoryOpened", {
[some args] call func;
]};
and still dont work. Do i need to pass through params these func and args variables?

little raptor
delicate hedge
#

I have other question about optimising: How to optimise variables in MP. I do setVariable with public to true, but i do it very often, and there is a big array, this script executes on every machine. And i set and get these variables in functions which i call in this script. How to make that if some local player calls these functions (do smth) , it wont just setVariable publicly but when i need to get it on other machine ill get it right

still forum
#

You cannot get it right on a different machine, without sending it to the different machine

#

Instead of sending the whole array. You could implement your own system that only sends changes to the array

delicate hedge
still forum
#

Yes, I could build something like that

solar geode
#

Am I going mad or is it impossible to visually remove rotors on a helo by setting their hitpoint damage to 1? I specifically remember that being possible before.

delicate hedge
#

wait. if i in some func which spawned on every machine setVariable in some varspace for exemple some object, will it be updated for every one?

pulsar bluff
#

better to post small script example

#

easier to help

still forum
delicate hedge
delicate hedge
#

thats might be what i need

cosmic lichen
#

I wonder how this function works. I guess it remote executes code on the server which sends the variable back to the client who executed the function. I need to check the code later.

delicate hedge
#

will it work for sp too?

#

or i need to check if its MP?

cosmic lichen
#

Probably works in SP too. Check the code in the functions viewer to be sure.

still forum
still forum
delicate hedge
still forum
#

getServerVariable would work. But its really inefficient.
Basically that transfers the full array on every get.
Instead of transferring it on every set

If you set many times and only very rarely get, that might make sense. But I don't think thats the case?

delicate hedge
still forum
#

Maybe you can change your architecture to not use that array somehow.

delicate hedge
#

i have no idea how. I store in this [_thing, _amount] and there many of that things

#

arrays*

still forum
#

is _thing a string?

delicate hedge
#

yes

pulsar bluff
#

just post the script

still forum
#

Then you could use a object to set the variables on

#

instead of array of _thing

You can do
object setVariable [_thing, _amount, true]

#

Instead of sending whole array, you only send the updated _thing value

delicate hedge
#

ok. how do i implement it? i make this big array from other array:
{
_ArrOfThingsAndAmount append [[_x, 0]];
}forEach _ArrOfThings;

then in code i change it:

{
if ((_x select 0) == _item) then {
_element1 = _x select 1;
_element1 = _element1 + 1;
_x set [1, _element1]; //here
_items pushBack _item; //other array i need in code
};
}forEach _ArrOfThingsAndAmount;

still forum
#

👀 wha

#

oof

winter rose
#

y u no use hashmap

still forum
#
{
    _ArrOfThingsAndAmount append [[_x, 0]];
}forEach _ArrOfThings;

That, with an object would be

// Initialize all things to zero
{
    Vaz_ThingsObject setVariable [_x, 0, true];
} forEach _ArrOfThings;
{
    if ((_x select 0) == _item) then {
        _element1 = _x select 1;
        _element1 = _element1 + 1;
        _x set [1, _element1];     //here
        _items pushBack _item;  //other array i need in code 
    };
}forEach _ArrOfThingsAndAmount;

That with an object would be

// Increment _item amount by one
Vaz_ThingsObject setVariable [_item, (Vaz_ThingsObject getVariable _item) + 1, true];
_items pushBack [_item, Vaz_ThingsObject getVariable _item]; // Other array, that is not network synced?
delicate hedge
winter rose
still forum
#

Then you probably want a second object for the other array

delicate hedge
still forum
#

I don't understand its purpose so 🤷 Why would you need twice the same info

delicate hedge
#

lol ok

still forum
#

Assuming every thing only exists once.
So you don't have two of the same in your array?

#

to be fair your increment code seems to expect that there are two of the same

#

But I just assumed that is because its badly written

delicate hedge
#

its like i just store the name of object i used

#

so then i can show it

delicate hedge
pulsar bluff
still forum
delicate hedge
#

ok

still forum
#

CBA would use CBA_NamespaceDummy. Thats just a model-less object thats cheap to create.
But if you don't have CBA you can't use that

#

Don't know what a vanilla one would be

pulsar bluff
#

the undeletable object is pretty good ... bis_functions_mainscope or whatever it is

still forum
#

Yeah that should work, if the _thingy names don't conflict with anything on it

#

But we need two for two arrays.
So probably create a new one.
But I think the functions mainscope uses Logic, which is not very efficient as it ticks

delicate hedge
pulsar bluff
#

i still havent seen his script so still not worth helping

still forum
pulsar bluff
#

and still dont know the actual purpose of the script, as probably there is a structural solution

delicate hedge
pulsar bluff
#

no one is judging

delicate hedge
#

there are some parts where i tried detecting when player opens inventory, but i dont know how to make it work with event handler

still forum
#

Do you have CBA mod?

delicate hedge
#

yes

#

of course

still forum
#

That has eventhandler for inventory open

#

Or atleast in config they have it, I don't know if also accessible scripted (easily)

pulsar bluff
#

so its like a drone that anyone can use (not at the same time) which has some cool abilities

#

and you need each client to have the correct state of the drone

#

@delicate hedge ?

pulsar bluff
#

the client doesnt actually need the correct state of the drone until they are "taking control" of it then

delicate hedge
#

i made that any player can attach this grens in any moment

still forum
#

Is it a mod, or a mission script?

delicate hedge
still forum
#

Mh.. Yeah CBA has display open eventhandler, but its config only.
Bah CBA documentation is oof

https://github.com/acemod/ACE3/blob/master/addons/inventory/CfgEventHandlers.hpp#L19
Here is a macro'ed example on how to detect inventory open.

So you would do something like

class Extended_DisplayLoad_EventHandlers {
    class RscDisplayInventory {
        Vazar_Drone = "_this call Vazar_OnInventoryOpened";
    };
};

in your config.cpp
Then that function is called everytime the player opens inventory. Everytime RscDisplayInventory is loaded

delicate hedge
#

if you look in script

pulsar bluff
#

it seems you might be able to just manage the grenade slots with attachedObjects _drone

#

instead of with variables

still forum
delicate hedge
still forum
#

Btw line 445

        _drone = (_this select 3) select 0;
        _num = (_this select 3) select 1;
        _attachGren = (_this select 3) select 2;
        _grenades = (_this select 3) select 3;
        _closeMenu = (_this select 3) select 4;
        _start = (_this select 3) select 5;

==

_arguments params ["_drone", "_num", "_attachGren", "_grenades", "_closeMenu", "_start"];

Same in Line 371 but bigger

delicate hedge
still forum
#

Your code could be quite a bit simpler if you just used global variables for your functions.
No need to pass _attachGren around all the time, when you can just call it Vaz_drone_fnc_attachGren and then refer to it by global variable

#
        _ItemCount = 0;
        {
            if (_x == _item) then {
                _ItemCount = _ItemCount + 1;
            };
        }forEach _inv;

That is
_ItemCount = _inv count {_x == _item};
Count how many times the condition is true. Just count

delicate hedge
#

yep

still forum
#

And yeah you could use the drone for your namespace for the thing variables. Looks fine.

But if you need second array.
Maybe you could just give them a prefix

Like instead of
Vaz_ThingsObject setVariable [_item, (Vaz_ThingsObject getVariable _item) + 1, true];
do
Vaz_ThingsObject setVariable ["prefix_" + _item, (Vaz_ThingsObject getVariable ("prefix_" + _item)) + 1, true];

That way you can just use a different prefix for your second array, and they won't conflict

You can use allVariables and filter by the prefix, to find all items that exist on it.
Though the allVariables is somewhat inefficient if you need to do it often. Would be simpler if the object doesn't have ANY variables except the ones you want on it, then you don't have to filter

#
{
    _elcfg = _x;
    _el = configName _elCfg;
    _ammoCfg pushBack _el;
} forEach _ammoCfgEnt;

==
_ammoCfg = _ammoCfgEnt apply {configName _elCfg};

velvet merlin
#

addEventHandler ["XXX","code"];
addEventHandler ["XXX",{code}];
addEventHandler ["XXX",TAG_fnc_function];
addEventHandler ["XXX",{_this call TAG_fnc_function}];

is there any speed difference with these? i think to recall some talk it recompiled(?) on each execution(?)

still forum
#

In the past it did

#

Nowadays (almost?) all eventhandlers are stored as code.
The first 3 are equal when the EH triggers.
The last one has performance overhead because the extra call

#

The first one will compile the code when you add the EH (Or when its first triggered).
Whereas the other two compiled it already earlier

pulsar bluff
#

@delicate hedge what are these vars doing

#

[_drone, AttNumG, _AttNum] call BIS_fnc_setServerVariable;

#

attnumg, attnum

still forum
#

Looks like a typo. Should be "AttNumG"

delicate hedge
still forum
#

For everywhere where you do lots of select 0, select 1, select 2...

delicate hedge
solar geode
#

You can still chop them off by collision. >_<

delicate hedge
pulsar bluff
#

perhaps a structural issue with the script is that there seems to be no oversight by the server, so clients are able to SET without an accurate GET (perhaps by latency of two clients performing an action at the same moment)

delicate hedge
pulsar bluff
#

if i was to do a script where multiple players are allowed to make changes to an entity, i would have all the SET done on the server, players would use GET to update their lists and enable/disable buttons and show/hide actions

#

player can then use the buttons/actions to request server to make changes, server then checks to see the change makes sense before new SET

delicate hedge
#

and still, i have no idea how to do such scripts

pulsar bluff
#

it might not be necessary, as long as your script is doing as you want it to

delicate hedge
#

i satrted writing it just as mission script and then wanted to make mod

delicate hedge
pulsar bluff
#

does it work?

delicate hedge
#

yes

delicate hedge
pulsar bluff
#

and the only thing is optimise?

delicate hedge
#

can you just give method how it could work, so script executes on server and players get results, as i understand it would be really good for MP servers with many players

still forum
#

You need to split your functions into real functions. Not local variables.

Then player can remoteExec to the server, to execute a function on the server.
Then the server makes the changes to the variables and broadcasts them

pulsar bluff
#

you need to also weigh up the time cost of both learning how to do it, doing it, and bug fixing/debugging it ... compared to just going with what you already have working

still forum
#

So instead of a player making the change locally and broadcasting the result.
The player instead tells the server "please do this for me"

woeful light
#

Would somone please be able to help me with a config for a mod?

pulsar bluff
#

@delicate hedge also it would be good for you to learn data structures like this, to help organize your data. a little table like this means you could remove at least one of those variables you are setting... you can see "i_uav_03" has 3 slots, while "b_uav_01" has 1 slot

#
drone_data = [
    ['b_uav_01',[[0,0,-0.1]]],
    ['o_uav_02',[[0,0,-0.1],[0,0,-0.25]]],
    ['i_uav_03',[[0,0,-0.1],[0,0,-0.25],[0,0,-0.4]]]
];```
still forum
delicate hedge
#

thanks

delicate hedge
still forum
#

[params] call MyFunction
becomes
[params] remoteExec ["MyFunction", 2];

The 2 stands for "send to the server"
Then MyFunction will run on the server, with the passed arguments

#

I would say first change your code locally to use proper functions.
And after that is done switch to remoteExec

still forum
#

Also recommend a github project to keep track of your changes.
Also makes it easier for other to look at

delicate hedge
still forum
#

Yeah the server will update the variables and stuff

delicate hedge
#

so all what players will do is just send remoteExec request and get vars?

still forum
#

The server can also reply back.
Using

[params] remoteExec ["MyFunction", remoteExecutedOwner];
That will execute the function with parameters. On the machine that originally sent the request.
So you can directly reply back to for example open some UI

delicate hedge
#

Thanks!

#

and as i understand it would load only server that much.

#

Do i need to set public true in setVariable, if func executes on server?

still forum
#

yes

#

because every player needs to know about it

#

(atleast until you implement an optimization to only send it to the player that need it, which could be done later)

delicate hedge
still forum
#

Yes.
But what about other players?
I assume they also need to know about stuff.
In case the "user" of the drone changes to someone else

#

You would need to handle that "ownership" change

#

Which you could do, send server "RequestTakeOwnership" server then handles stuff, sends all variables it needs and replies to it that it has received ownership
But you shouldn't do that now, don't do too many things at once

delicate hedge
still forum
#

yeah. You can

delicate hedge
still forum
#

That's how I would do it.
And that's also how the game does it with vehicles for example. Stuff is sent to server, some things are broadcast if all need to know. There is an owner, on ownership change request extra data is transferred.

delicate hedge
#

ok, thank you!

delicate hedge
still forum
#

Inside the inventory open script.
["Vaz_InventoryOpened", [arguments]] call CBA_fnc_localEvent;

Inside your handler script
["Vaz_InventoryOpened", { code here }] call CBA_fnc_addEventHandler;

delicate hedge
#

Vaz_InventoryOpened whats this?

still forum
#

Its the name for your "event"

delicate hedge
#

func?

still forum
#

can be anything really

delicate hedge
#

oh ok

still forum
#

Its just a global identifier. So that the addEventHandler knows what you mean

delicate hedge
#

code here - is where i do what i need

still forum
#

Yeah. The thing where you close some UI thing, what you did in your script there

#

Basically does what you had commented out with the "InventoryOpened" eventhandler

delicate hedge
#

so this " inventory open scrip" will have one line?

still forum
#

yeah

delicate hedge
delicate hedge
pulsar bluff
#

thats an example of how to structure your script

#

or at least, how i like to structure mine

#

its missing a couple things like a server queue, unnecessary and easy to add later

still forum
delicate hedge
#

thanks i'll look at this

still forum
#

When you make full functions, you'll also have to decide for a prefix. I used Vaz as example above

pulsar bluff
delicate hedge
#

ok

#

whats that _mode? where do i get it?

pulsar bluff
#

just read it a little, it shows how script can be executed with an add action to send a message to server for server to do something

#

with a couple fixes

delicate hedge
pulsar bluff
#

nah it is just instructions sent to the function. what you are trying to accomplish

delicate hedge
#

oh i get it now

still forum
#

He basically put what multiple functions would do, into just one function.

So instead of
[params] remoteExec ["FunctionName", 2];
you'd do
["FunctionName", params] remoteExec ["TAG_drone", 2];

#

And then you'd implement all your code in one single giant file

delicate hedge
#

ok

still forum
#

That's a way to do it.. but I wouldn't recommend that.

delicate hedge
#

thats nice

delicate hedge
#

you say it would be better to break it in many scripts?

pulsar bluff
#

but the point is you asked to see how a scripted system could be structured so that client is requesting server to make changes, instead of directly making changes

meager granite
#

Wish you could hashValue HASHMAP a hashmap (its values) to avoid creating intermediate array with hashValue values HASHMAP. Got so used using arrays as keys and kinda expected hashmaps to also be usable as keys.

meager granite
#

muh microseconds moment again

pulsar bluff
#

in fact the way i shown is the way Bohemia does it ... review BIS_fnc_arsenal, BIS_fnc_dynamicGroups, BIS_fnc_garage, etc.

still forum
#

hashValue should work on every data type

meager granite
still forum
#

"Wish you could hashValue HASHMAP a hashmap"
indeed you cannot, I'll fix that

meager granite
#

Sure I can hashValue anything, just wanting to be able to do

HASHMAP set [HASHMAP, VALUE]
```the same way I'm doing
```sqf
HASHMAP set [ARRAY, VALUE]
meager granite
still forum
delicate hedge
#

so with that structure i would need to make one big script (server side) where i define modes and what they do. Then other script (player side), where i call all of them?

meager granite
#

Maybe I actually don't want the whole hashmap stored

pulsar bluff
#

personally I think you should continue with your existing script, while also taking some time to learn how to structure data into arrays, and learning how to call function on server from client

delicate hedge
meager granite
#

Making hashValue HASHMAP possible would be perfect for me, no need for set [HASHMAP, VALUE] really

pulsar bluff
#

i never saw the big array in that file

delicate hedge
#

{
_AttNum append [[_x, 0]];
}forEach _grenades;

thats _AttNum

#

line 154

#

or somewhere there

still forum
#

The hash quality isn't very good though

It just forEach overall
and then combines hashValue _x, hashValue _y
together. So it hashes a bunch of hashes.
Should be okey though 🤷

meager granite
# still forum The hash quality isn't very good though It just forEach overall and then combin...
hs1 = createHashMap;
hs2 = createHashMap;
for "_i" from 1 to 1 do {hs1 set [_i, _i];};
for "_i" from 1 to 100 do {hs2 set [_i, _i];};
[
     diag_codePerformance [{hashValue hs1}]
    ,diag_codePerformance [{hashValue [keys hs1, values hs1]}]
    ,diag_codePerformance [{hashValue values hs1}]
    ,diag_codePerformance [{hashValue hs2}]
    ,diag_codePerformance [{hashValue [keys hs2, values hs2]}]
    ,diag_codePerformance [{hashValue values hs2}]
]
```Can you run this to see how faster it is?
polar belfry
#
private _position = vehicle player getRelPos [900,180];
private _newPos = _position vectorAdd [0,0,1000];

Would these lines make the _newpos be 1000m above and 900m back where the player vehicle is

opal zephyr
#

Yes

#

You could use just vector add to do the same thing though

polar belfry
#

btw is it possible to run triggers as zeus. The triggers are part of a composition I made

opal zephyr
#

I dont believe so, you could just spawn a unit into the trigger to activate it though

terse tinsel
#

I have a question for you, I have a script that will spawn a bomb in the air and drop it to the target [[8132.62,4392.19,1110.44], "ammo_Missile_Cruise_01", car1, 180, false, [0,0,0.25]] spawn BIS_fnc_exp_camp_guidedProjectile; . but I would like her to spawn on an object (plane), do you know how to write it?

opal zephyr
#

Just use the position of the plane instead of the hardcoded position you entered there

#

look at getPos and its alternatives

still forum
polar belfry
#

If I add my script in the init of an object will it run for all my players

still forum
#

ye

polar belfry
#

how do I write the condition
this && ((vehicle player in thisList) && {vehicle player iskindof "Plane"})
Where this is BLUFOR, Present

#

I guest it's if(((vehicle player in thisList) && {vehicle player iskindof "Plane"})&& ("The blufor present condition")then{

polar belfry
#

would this work

null=[]spawn{
if((vehicle player in thisList) && (vehicle player iskindof "Plane") && (side player == west))then{
#

in an object's init

proven charm
#

I doubt thisList exists in object's init

polar belfry
#

can I get away without it

proven charm
#

what are you trying to do?

polar belfry
#

It's to simulate the condition if blufor player present and in plane to do my code

proven charm
#

ok well I guess it would work then

left iron
#

ill give in i guess. how would i handle REspawning a player in MP in the air (like on a carrier deck) with a script? i found

[west, [3560,1128,5204], "West Respawn"] call BIS_fnc_addRespawnPosition;

on google, so i threw it into an SQF, what else should i be doing?

stable dune
hallow mortar
proven charm
stable dune
#

Yes. Edited. Thanks

meager granite
#

Either way looks to be slightly faster than pulling values first

terse tinsel
#

Is it possible for the unit caputre script to also record the movements of the tank's towers and guns?

little raptor
#

no

terse tinsel
#

ok thx 🙂

left iron
hushed tendon
delicate hedge
cyan ivy
#

Hello. Im trying to make a Rally raid (navigation with roadbook) for Arma reforger.
But what I need is a tripmeter, a display that show distance traveled. Is this somone inow how to make?

proper sigil
#
        if(_targetType in gargantuanCargoSize) then {[_entity, 1000] call ace_cargo_fnc_setSpace; 
            _entity addEventHandler ["Killed",{params ["_unit", "_killer", "_instigator", "_useEffects"]; 
                _unit removeAllEventHandlers "Killed";
                [_unit, "scrap", 0, 25] execVM "DNT_supplies\DNT_createSupplies.sqf";
                }
            ];
        };
        
    }];
}forEach allCurators;```

Could someone help me and explain why this piece does not works as intended on dedicated server? Script is run from initServer.sqf  like this

 ```null = execVM "DNT_supplies\DNT_setCargoSpace.sqf";```

My intention is that whenever a curator spawns a vehicle that is in global array "gargantuanCargosize" this vehicle should have assigned ace cargo space and added action by running another script 
```[_unit, "scrap", 0, 25] execVM "DNT_supplies\DNT_createSupplies.sqf";```

script using execVM. It works locally but when added to server it does neither. 

Similar problem with this piece of code

```{    
    if(typeOf _x in tinyCargoSize) then {[ _x, 2] call ace_cargo_fnc_setSpace;
                _x addEventHandler ["Killed",{
                params ["_unit", "_killer", "_instigator", "_useEffects"];
                _unit removeAllEventHandlers "Killed";
                [_unit, "scrap", 0, 1] execVM "DNT_supplies\DNT_createSupplies.sqf";}];};```
#

I've also tried using "MPKilled" instead but no effect on server and it threw error locally.

I was also thinking of trying using remoteExec but I'm getting confused on how should syntax look for example for

[_unit, "scrap", 0, 1] execVM "DNT_supplies\DNT_createSupplies.sqf";

tender fossil
#

@proper sigil have you checked server RPT output? Is e.g. gargantuanCargoSize variable defined on server?

molten yacht
#

I'm looking to have custom black bars like the cinematic ones creep up from the outside of the screen for a mission title. Is there any way to animate a cutRSC with like, scale, or moving a pair of them up from the bottom and top of the screen?

#

The existing cinematic mode function kills access to controls and the bars are too big.

molten yacht
#

Where on earth is the missing semicolon in this statement?

private _sgroup = [opfor_spawn_0] remoteExec ["TAG_fnc_spawnSquad",2];```
winter rose
#

nowhere

#

btw, remoteExec returns a string, not a group

molten yacht
#

the function being used should return a group object

#

in any case, I'm getting an error that this line is missing a semicolon

#

I have poobrain, though

#

I should just call instead of remote-exec

#

....nevermind. The missing ; was on line 1, the params

#

not 12

#

there's just a comment in the way

winter rose
#

the group will be created, but the group's variable is not sent over the network

molten yacht
#

It's executed on the server, fortunately

#
private _sgroup = [opfor_spawn_0] call SWS_fnc_spawnSquad;
_sgroup addWaypoint [_dest,10];
_sgroup;```
winter rose
#

still, remoteExec returns a string, the JIP id

molten yacht
#

Thank you for the important information

#

that is going to save my ass when I code the next function

#

Because that legit would have been like stepping on a rake

tranquil monolith
grim cliff
#

speaking of stepping on rakes...

#

i am tring to get a custom revive script working but now everything seems to be borken

#

i had a chat earlier about it and during testing discovered that the command is created on the local machine and is not available for the unit actually trying to use the action unless i used [holdactionparams, ... ]remoteexeccall ["bis_fnc_holdactionadd", -clientowner, true];

#
[player,
"Revive",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_reviveMedic_ca.paa",
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_reviveMedic_ca.paa",
"vehicle _this == _this && lifeState _this != 'INCAPACITATED' && lifeState _target == 'INCAPACITATED' && group _this == group cursorObject && _this distance2D _target <= 2.5 && !('Medikit' in itemcargo _this && _this getvariable ['CustomMedic',false])",
"lifestate _caller != 'INCAPACITATED' && _caller distance2D _target <= 2.5 && lifeState _target == 'INCAPACITATED'",
{
params ["_target", "_caller", "_actionId", "_arguments"];
switch (stance _caller) do 
{
//UnconsciousReviveMedic_B
case "STAND": {
_moves = ["UnconsciousMedicFromRifle","UnconsciousReviveMedic_B"];
};
case "CROUCH": {
_moves = ["AmovPknlMstpSrasWpstDnon","UnconsciousReviveMedic_B"];
};
case "PRONE": {
_moves = ["AmovPpneMstpSrasWrflDnon_AmovPknlMstpSrasWrflDnon","UnconsciousReviveMedic_B"];
};
default {
_moves = ["AmovPknlMstpSrasWpstDnon","UnconsciousReviveMedic_B"];
};
};
_caller switchmove _moves select 0;
_caller playmove _moves select 1;
},
nil,
{
[uncpatient, false] remoteExec ["setUnconscious", owner _target, false];
[uncpatient, 0.4] remoteExec ["setdamage", owner _target,false];
[uncpatient, false] remoteExec ["setCaptive", owner _target,false];
[uncpatient, true] remoteExec ["allowdamage", owner _target, false];
_caller switchMove "AinvPknlMstpSlayWrflDnon_AmovPknlMstpSrasWrflDnon";
private _string = format ["%1 was revived by %2", name _target, name _caller];
[_string] remoteExec ["systemChat", -clientowner, false];
/// [uncpatient, "AinjPpneMstpSnonWnonDnon_rolltofront"] remoteExec ["switchmove",0,false];
},
{_caller switchmove "AinvPknlMstpSlayWrflDnon_AmovPknlMstpSrasWrflDnon";},
[],
11,
999,
false,
false,
true  
] remoteexeccall ["BIS_fnc_holdActionAdd", -clientowner, true];
#

i am getting NO ERRORS in the report file, but neither the animations or the uncpatient remoteexec commands are yielding any results, but oddly the remoteexec for system chat IS working.
i have no errors to go off of

grim cliff
#

so i ended up restructuring the params passed to reflect what the wiki "says" is passed to the condition statements(Special arguments passed to the code: _target (action-attached object), _Caller (caller/executing unit)) and now this whole thing is falling apart and i need some help

#

as it sits right now somethign appears to be jammed in the progress condition but according to the wiki the format is correct, but no progress is made

granite sky
#

These lines are not going to work as intended due to precedence:
_caller switchmove _moves select 0;

#

owner _target also won't work there because owner is server-only and the code here is all running on the client.

#

You can just use _target instead.

grim cliff
granite sky
#

switchmove and select are both standard binary commands, so that line will do this:
(_caller switchmove _moves) select 0

hallow mortar
#

The game reads left-to-right (plus some other rules). It will see this:
_caller switchMove _moves
and then this:
select 0
and that don't make no sense to it.

granite sky
#

You need to write either this:
_caller switchmove (_moves select 0)
or this:
_caller switchmove _moves # 0

#

fuck discord

grim cliff
hallow mortar
#

Use \ to escape characters

#

Discord uses Markdown formatting, so # at the start of a line makes it into a header

upbeat hill
#

Hello im trying to reference a video to play from my modpack unsure if im doing referencing it wrong or just doing it wrong. Would very much appreciate some help heres my code

[ 
  "!Workshop\Wolfysmod\addons\Sequence-01.ogv",  
  [ 
    safezoneX + 0.5,  
    safezoneY,  
    37 * pixelGrid * pixelW,  
    21 * pixelGrid * pixelH 
  ] 
] spawn BIS_fnc_playVideo;
warm hedge
#

The location of the file is very wrong, if the OGV file is in a PBO

upbeat hill
#

it is

warm hedge
#

Specify the location in the PBO then

upbeat hill
# warm hedge Specify the location in the PBO then

This is where it is but still not working. This mod is also uploaded to the workshop so not sure if i need to reference my arma3 folder before the workshop one. Also Do i need to reference it with the file type like .pbo or does that not matter?

"!Workshop\Wolfysmod\addons\media.pbo\Sequence-01.ogv"
grim cliff
# granite sky You need to write either this: `_caller switchmove (_moves select 0)` or this: `...

ok so i made those changes and now the error im getting is:

19:36:50 Error in expression <edic"];
_moves = [];
_ismedic = _caller getvariable ["CustomMedic", false]; <<<<<<<<<<<<<<<<<<<<< this is line 11;
if (>
19:36:50   Error position: <getvariable ["CustomMedic", false];
if (>
19:36:50   Error getvariable: Type String, expected Namespace,Object,Group,Display (dialog),Control,Team member,Task,Location
19:36:50 File C:\Users\isass\Documents\Arma 3 - Other Profiles\Full_Metal_JackOff\mpmissions\co10_Escape_DES_NATO_vs_CSAT.Altis\functions\DES\fn_medicStance.sqf..., line 11
warm hedge
#

Arma 3 does not recognize your file in this way. Use relative path from your PBO, not from the EXE

grim cliff
#

but thats in the report file though. this script is getting called from a bis_fnc_holdactionadd in the starting code block from this command: ["_target", "_caller", "_actionId", "_arguments"] remoteExec ["DES_fnc_medicStance", 0, false];
which is defined in funcitons.hpp via:

class CfgFunctions
{
  class des
     {
        class DES
          {
            class medicStance{};
    };
  };
};```
granite sky
#

I don't think _caller is defined in most of those code blocks.

warm hedge
grim cliff
grim cliff
#

should i not be useing params again? is it already predefined and im just overwriting the variables with this:

granite sky
#

shrugs

warm hedge
#

You're trying to throw a string into the function, not the variable. Remove brackets for remoteExec's arguments

granite sky
#

other people's holdActionAdds are unreadable without good formatting. It's like reading assembler.

granite sky
#

That doesn't have the failing code in it.

#

ah, because it's from the medicStance function that you never pasted.

grim cliff
granite sky
#

You remoteExec DES_fnc_medicStance from the progress condition code, right

#

So I guess you're using _caller there but not defining it.

#

It doesn't inherit the previous local vars because it's a remoteExec.

grim cliff
#

let me get a shot without word wrap.

granite sky
#

You haven't pasted medicStance at all, have you?

#

You only pasted the holdActionAdd call.

grim cliff
granite sky
#

That's the holdActionAdd for like the third or fourth time.

grim cliff
#

heres the code from it:

params ["_target", "_caller", "_actionId", "_arguments"];
private ["_moves","_ismedic"];
_moves = [];
_ismedic = _caller getvariable ["CustomMedic", false];
if (_ismedic) then {
 switch (stance _caller) do {
         case "STAND";
         case "CROUCH": {
                 _moves = ["AinvPknlMstpSlayWrflDnon_medicOther"];
             };
         case "PRONE": {
                 _moves = ["AinvPpneMstpSlayWrflDnon_medicOther"];
             };
         default {
                 _moves = ["AinvPknlMstpSlayWrflDnon_medicOther"];
             };
         };
 } else {
 switch (stance player) do 
     {
         //UnconsciousReviveMedic_B
        case "STAND": {
        _moves = ["UnconsciousMedicFromRifle","UnconsciousReviveMedic_B"];
                        };
        case "CROUCH": {
        _moves = ["AmovPknlMstpSrasWpstDnon","UnconsciousReviveMedic_B"];
                        };
        case "PRONE": {
        _moves = ["AmovPpneMstpSrasWrflDnon_AmovPknlMstpSrasWrflDnon","UnconsciousReviveMedic_B"];
                        };
        default {
        _moves = ["AmovPknlMstpSrasWpstDnon","UnconsciousReviveMedic_B"];
        };
     };
    };
spawnparams = [_caller,_moves];
movement = [spawnparams] spawn {
        params ["spawnparams"];
        _caller = spawnparams select 0;
        _moves = spawnparams select 1;
     _caller switchmove (_moves select 0);
     if (count _moves == 2) then {
         _caller playmove (_moves select 1);
        };
    };
true;
granite sky
#

Dunno then. Maybe the documentation is wrong and it doesn't actually pass anything in _this.

#

In which case removing the params line should fix it.

#

you can check using diag_log or systemChat. Normally I'd say read the code, but holdActionAdd is probably quite hard.

#

_caller ending up with a string in it is rather baffling though.

grim cliff
#

revised code:

         {
             diag_log format ["_caller = %1",_caller];
            ["_target", "_caller", "_actionId", "_arguments"] remoteExec ["DES_fnc_medicStance", 0, false];
        },

report file returns with

20:11:50 "_caller = p6"
20:11:51 Error in expression <edic"];
_moves = [];
_ismedic = _caller getvariable ["CustomMedic", false];
if (>
20:11:51   Error position: <getvariable ["CustomMedic", false];
if (>
20:11:51   Error getvariable: Type String, expected Namespace,Object,Group,Display (dialog),Control,Team member,Task,Location
20:11:51 File C:\Users\isass\Documents\Arma 3 - Other Profiles\Full_Metal_JackOff\mpmissions\co10_Escape_DES_NATO_vs_CSAT.Altis\functions\DES\fn_medicStance.sqf..., line 11
upbeat hill
granite sky
#

Is p6 the editor var name of that unit?

grim cliff
#

yes. i think i just found the issue and its been in my face this whole time

#

i put the same diag_log command in from of the erroring code in the called function:

diag_log format ["_caller = %1",_caller];
_ismedic = _caller getvariable ["CustomMedic", false];

and i get this:

20:15:56 "_caller = p6" <<<<<<<<< before remoteexec
20:15:57 "_caller = _caller" <<<<<<<< inside called function
20:15:57 Error in expression <ller = %1",_caller];
_ismedic = _caller getvariable ["CustomMedic", false];
if (>
20:15:57   Error position: <getvariable ["CustomMedic", false];
if (>
20:15:57   Error getvariable: Type String, expected Namespace,Object,Group,Display (dialog),Control,Team member,Task,Location
20:15:57 File C:\Users\isass\Documents\Arma 3 - Other Profiles\Full_Metal_JackOff\mpmissions\co10_Escape_DES_NATO_vs_CSAT.Altis\functions\DES\fn_medicStance.sqf..., line 12
granite sky
#

It'll return the same "p6" string, but I have no idea how that gets into _caller in the first place. It's supposed to be an object.

#

oh wait

grim cliff
granite sky
#

oh lol

grim cliff
#

i put the variable name in quotes

#

because i copied and pasted from the line above with params

granite sky
#

Yeah, it returns "p6" anyway because that's how str _unit translates units that have var names.

grim cliff
#

right but wouldnt i be passing the literal interpretation of "_caller" and unpacking the variable through params which would then result in the variable being just _caller instead of a refference to an object

granite sky
#

yeah you identified the problem correctly

grim cliff
grim cliff
#

and the issue of the person randomly appearing in the unconscius position is still persistant

granite sky
#

You'd want to demonstrate that in a much simpler and more replicable context.

leaden summit
#

The answer is probably staring me in the face but I can't see it. I currently have the following code```SQF
params ["_colour","_startLoc","_finishLoc","_indexAddition"];
private _route = [];

(calculatePath ["wheeled_APC", "careless", _startLoc, _finishLoc]) addEventHandler ["PathCalculated", {
{
_markerNumber = _forEachIndex + _indexAddition;
private _marker = createMarker ["marker" + str _markerNumber, _x];
_route pushback _marker;
_marker setMarkerTypeLocal "mil_dot";
_marker setMarkerColorLocal str _colour;
_marker setMarkerSizeLocal [.5, .5];
} forEach (_this select 1);
}];

But at the end when I check `_route` it's empty. What am I missing to add every marker created into the array?
granite sky
#

I'm not sure that switchMove _move1; playMoveNow _move2 is legitimate in MP anyway. Leopard's example uses the same move for both.

#

I guess you want a hard transition to move1 and then a proper one to move2, but I'm not sure that's actually supported by the networking.

#

I don't really understand Arma's animation system well enough to help anyone else with it though.

grim cliff
warm hedge
grim cliff
granite sky
leaden summit
#

Oh I thought they would from the params, that always trips me up how can I fix that?

granite sky
#

@grim cliff Maybe:

_unit switchMove _move1;
_unit playMoveNow _move1;
_unit playMove _move2;
#

Assuming that there is a valid transition from move1 to move2.

grim cliff
#

just tried playmove now, character pulls out launcher, sticks his hands between his legs and inverts himself into a donut, and then stands up as the action completes

granite sky
#

It sounds like "valid transition from move1 to move2" might be an invalid assumption :P

grim cliff
granite sky
grim cliff
#

uploading video

granite sky
#

Something like this:

params ["_colour","_startLoc","_finishLoc","_indexAddition"];
private _route = [];

private _agent = calculatePath ["wheeled_APC", "careless", _startLoc, _finishLoc];
_agent setVariable ["pathColour", _colour];
_agent setVariable ["indexAdd", _indexAddition];
_agent addEventHandler ["PathCalculated", {
    private _agent = _this select 0;
    private _indexAddition = _agent getVariable "indexAdd";
    private _colour = _agent getVariable "pathColour";
    {
        _markerNumber = _forEachIndex + _indexAddition;
        private _marker = createMarker ["marker" + str _markerNumber, _x];
        _route pushback _marker; 
        _marker setMarkerTypeLocal "mil_dot";
        _marker setMarkerColorLocal str _colour;
        _marker setMarkerSizeLocal [.5, .5];
    } forEach (_this select 1);
}];
proper sigil
leaden summit
#

Wow thanks for that

leaden summit
granite sky
#

If you need it out of the event handler, yes.

leaden summit
#

Yeah I need to return it

granite sky
#

Not sure where you'd do that because PathCalculated doesn't fire immediately.

#

and the agent might not exist after the event handler completes.

#

So I guess you'd have to use a global var, but the method would depend on the use case.

#

Looks like you're only calling one of these at a time given the marker naming?

#

otherwise overlapping calls would fail anyway.

#

So you could just set a global var and then wait until it exists.

leaden summit
#

Basically I'm looking to call this function 3 times. And "out Route", "transit route" and then an "in route" to form a patrol route out of base to 2 map locations and back

#

So it plots a road route from base to A then runs again to plot a to b then finally b back to base and each time the markers get added to _route and then returned so I end up with an array of markers making up the entire patrol route (if that makes any sense)

#

I suppose route could be a global variable and then after the patrol I just empty the array 🤔

granite sky
#

you have a marker name overlap problem then.

#

oh, I guess that's what indexAddition is for.

leaden summit
#

Yeah

#

so if route 1 ends at 20 route 2 starts at 21

granite sky
#

Anyway, the PathCalculated EH can easily take five seconds to fire.

#

so you'll need some scheduling shenanigans to deal with that.

leaden summit
#

OK I'll have a play around, thanks for your help

swift solstice
#

hi question anyone know if it's possible to have a terminal assign which side a player is on?

modern osprey
#

Hi guys.

Please tell me, I'm trying to restart the server via

"password" serverCommand "#restartserver"

But for some unknown reason, the server only stops and does not restart.

What can be wrong?

proper sigil
#

How would I execute below script using remoteExec? I'm unsure what a correct syntax would be?

[_unit, "scrap", 0, 1] execVM "DNT_supplies\DNT_createSupplies.sqf";

warm hedge
#

remoteExec syntax is explained in the pinned

polar belfry
#

hello I am working on my burst missile script and have this code here. Where it takes the player position and adds 200m front of their plane and then sets the point at 750m altitude

private _position = vehicle player getRelPos [200,0];  
private _newPos = _position vectorAdd [0,0,720];
_missile = createVehicle [_bomb, _newpos, [], 0, "CAN_COLLIDE"]; 

I want to make it so this line here where it spawns stuff in an entity to kill it it just nudges it like 200m forward

{_missile = createVehicle [_bomb, vehicle player, [], 0, "CAN_COLLIDE"];
#

so I want my second piece of code to spawn the _bomb (a preset bomb in code) 200m infront of the vehicle of the player

granite sky
polar belfry
#

question is if I just add

private _position = vehicle player getRelPos [200,0];
{_missile = createVehicle [_bomb, _position, [], 0, "CAN_COLLIDE"];
triggerammo _missile

Will it blow up at the same altitude at 200m front of the plane or should I use getPosATL
like:

private _newPos = _position vectorAdd [0,0,(getPosATL player)];
modern osprey
granite sky
#

@polar belfry Just test it with the debug console. If the Z behaviour's not documented on the wiki then you'll be lucky to find someone who knows the answer.

granite sky
modern osprey
granite sky
#

No idea. Arma doesn't document what it's using for the restart.

sullen sigil
#

i thought it was #restart not #restartserver?

modern osprey
#

Arma moment

granite sky
#

#restart just restarts the mission.

sullen sigil
#

oh yeah

#

mb

modern osprey
#

#restart - restarts the mission

#restartserver - restarts the server (at least it should do so)

proper sigil
warm hedge
#

Should do

polar belfry
#

btw on getrelpos
90 is right
_relpos = player getRelPos [100, 90];

#

so would 180 be back
270 be left
and 0 be front

granite sky
#

yes. You could probably do -90 for left as an alternative.

proper sigil
vocal mantle
polar belfry
#

found how to do my thing

#

get the altitude first and then do getrelpos

#
private _position = getposatl vehicle player; 
private _newPos = _position vectorAdd [0,-500];
#

for anyone who wants it (Altitude with offset)

modern osprey
#

Tell me please. After restarting the mission using #restart - do all namespaces reset their variables?

willow hound
still forum
# delicate hedge hey man <@90532520101183488> , are you there? I have question about this. What d...

You had a addEventHandler for InventoryOpened in your original script. Commented out.
Now you have a addEventHandler, that will work. Just replace one with the other. (Remember to remove the eventhandler again once you don't need it anymore https://cbateam.github.io/CBA_A3/docs/files/events/fnc_removeEventHandler-sqf.html)
As I said before, turn your functions into real global functions, so you don't need to pass them around as local variables.
Then you also won't need to get some _function into your eventhandler

polar belfry
#

would this save a random int to the variable?

  private _rand_num1 = [100, 300] call BIS_fnc_randomInt
proven charm
#

yes

#

dont forget ; at the end

polar belfry
#

of course

delicate hedge
#

hello guys, please can someone explain me how to use event handlers in mod scripts. This scripts get spawned. I just write there addEventhandler set some code there and its just not triggers any events that i add to player

cosmic lichen
#

Post your code and what you actually wanna do.

delicate hedge
#

player addEventHandler ["VisionModeChanged", {
params ["_person", "_visionMode", "_TIindex", "_visionModePrev", "_TIindexPrev", "_vehicle", "_turret"];
hint "changed";
if (_vehicle == _drone) then {
player setVariable ["pilotNow", true];
};
}];

i get this hint "changed" only when i start game, and then when i try to take control of any drone its not hinted

still forum
#

Because the "unit"s visionmode doesn't change

#

You actually look through a different unit

#

You want to detect when someone starts controlling the drone? notlikemeow mh

delicate hedge
#

actually yes

still forum
hallow mortar
#

mission EH playerViewChanged

delicate hedge
#

works! thanks!

heavy dew
#

Is it possible to get the ammo count of a magazine from its classname?

hallow mortar
#

You can look up anything that's defined in a thing's config (which default ammo count is) using commands like getText, getNumber

#
private _magAmmoCount = getNumber (configFile >> "CfgMagazines" >> _magClass >> "count");```
heavy dew
#

neat, cheers

still forum
#

🍞

delicate hedge
polar belfry
#

does addaction work if I'm inside a vehicle for example I want some actions if I'm inside a SDV

hallow mortar
#

Yes, provided:

  • your position in the vehicle allows you to look at the thing the action is added to (doesn't matter if the action is added to you or the vehicle itself)
  • the action condition doesn't contain any requirements about what vehicle you need to be in
polar belfry
#

I see

#

I try to get all my recent scripts as actions in a sdv to emulate the schinfaxi battle from AC5

delicate hedge
#

if i get machine network ID of some player from this :
id = owner player

will i be able to execute in right way:
remoteExecCall [func, id]
????

hallow mortar
#

Well you can, but you don't need to. If you have a reference to their player object, you can just use that as the remoteExec target and skip the owner step

delicate hedge
#

so i can just write this "player" instead of its id?

polar belfry
#

is there a way to make add actions repeatable

#

maybe put them in a for loop

hallow mortar
#

They are repeatable by default unless whatever they do makes it impossible for their condition to be true

neon plaza
#

I am trying to find a spectator script I can add to player Init that will allow specate mode as If In Admin mode. Is there anyone with a script for this?

terse tinsel
#

someone can help me how to write this script to convert Asl coordinates into the location of an object (plane) [[8132.62,4392.19,1110.44], "ammo_Missile_Cruise_01", car1, 180, false, [0,0,0.25]] spawn BIS_fnc_exp_camp_guidedProjectile; Please.

hallow mortar
#

Replace the coordinates with getPosASL _plane, where _plane is whatever variable refers to the object you want to use.

#

If using the exact position results in the missile instantly hitting the plane and exploding, try (getPosASL _plane) vectorAdd [0,0,-3]

hallow mortar
# terse tinsel Thank you very much

Please don't DM me with scripting problems. Use this channel so everyone can see and help.
getPosASL returns a 3D position, which is a valid input for the function - it's exactly as if you'd written out the position coordinates yourself, just with the values automatically filled in with the object's position. I think you've probably typed something wrong.
It should look like this:

[getPosASL _plane, "ammo_Missile_Cruise_01", car1, 180, false, [0,0,0.25]] spawn BIS_fnc_exp_camp_guidedProjectile;```
or like this:
```sqf
[(getPosASL _plane) vectorAdd [0,0,-3], "ammo_Missile_Cruise_01", car1, 180, false, [0,0,0.25]] spawn BIS_fnc_exp_camp_guidedProjectile;```
If there are differences other than the name of the plane variable, that may be the source of the issue. For example, if you did `[[getPosASL _plane], "ammo_...` that would be wrong.
grim cliff
#

i want to use drawlaser to make lasers actually work during the daytime. is there a way to get the position & vector of the units rifle attached laser pointer?

warm hedge
#

Yes. But it requires a lot

grim cliff
#

how much is alot?

warm hedge
#
  1. Get weapon proxy pos/dir depends on the current weapon
  2. Create weapon Simple Object to get where should the laser pointer go
  3. Create laser pointer Simple Object to get where should the laser starts
  4. Sum them all
grim cliff
#

i want to use the drawlaser command compatible with missioneventhandler: "draw3d"

#

i just want to get the direction the players rifle model is pointing, and the attachments relative position, to use in `drawlaser [ positionasl, directionvector3d, . . .]

warm hedge
#

Pretty much what I told you is the way

hallow mortar
grim cliff
#

well that sucks. how does arma do it?

warm hedge
#

It's Engine thing. None of our business

#

selectionPosition and selectionVectorDirAndUp surely can handle this situation

terse tinsel
near snow
#

can someone point me in the right direction I am working on a scrip and I am having a bit of a hang up

I am trying to make a function to teleport a player to the cosset point on a surface/roadway lod (like how getting off ladders works)

I was trying to use something get/set postion but the only way I have found is to just to brute force it by manually setting an offset unless I am trying to overcomplicate it or overlooked something simple

warm hedge
#

lineIntersectSurfaces (IIRC) to detect such case

near snow
grim cliff
#
shield = createSimpleObject ["lxws\shield_f_lxws\shield.p3d", getPosWorld player];
{
shield animate [_x, 1,true];
}foreach animationNames shield;
shield attachto [player, [0,-0.125,-0.7],"spine3",true];
shield enableSimulationGlobal false;

i have this script to try to create a shield Ghost on the players back and im trying to figure out how to make it just a ghost that doesnt deflect bullets.
any idea ho i can do that?

meager granite
grim cliff
#

can i disable the fire geometry?

meager granite
#

Only but editing the model

#

If you have model source, just delete the LOD

grim cliff
#

its from the western saharah DLC, as far as i know, those assets are encrypted

warm hedge
#

WS shield already is a vehicle. You can just spawn it and disable damage

grim cliff
#

i want it to not BLOCK damage

warm hedge
#

Ah well

meager granite
#

I'd try something crazy like spawning it as a particle, but its gonna require some crazy scripting and I'm not sure if it will even work reliably

grim cliff
#

its getting attached to the players back as a prop

meager granite
#

Spawn a dummy entity, have it drop a particle of that shield with exact orientation (you can do that since recently) with dummy as parent and infinite life time, attach dummy to player's bone

#

Not even sure if particle will follow dummy orientation at all

warm hedge
#

You can get selection vectorDir/Up directly now

meager granite
#

Yeah but you can't operate particle once its dropped, this crazy idea will work only if particles follow parent entity orientation

grim cliff
#

can i create a proxy and attach that to the player?

warm hedge
#

No

warm hedge
meager granite
#

Huh, I wonder if that's doable

#

So many crazy crutches for a seemingly simple task

grim cliff
#

yeah...

#

wierd part is that the backpack version has no collisions when its in the backpack slot of the player

meager granite
#

Probably because the model doesn't have fire geometry

#

Guns do, I think you can hit the gun specifically even when its a proxy in players hands

#

Now we need createSimplestObject command that would create particle-like model

grim cliff
#

how can i get the model of thebackpack that the player currently has on?

meager granite
meager granite
hallow mortar
meager granite
#

"a3\...\model.mod1.p3d" or something, which you can later use for simple objects

#
  • This post was made by no mods gaming gang
warm hedge
#

To add: it even possible to delete a very certain particle drop using deleteVehicle

meager granite
warm hedge
#

No

#

The dropped particle

#
private _particles = (-1 allObjects 3) ;
_particles apply {
    if (
        getModelInfo _x#0 == "brabra.p3d"
    ) then {
        deleteVehicle _x ;
    } ;
} ;```A snippet, nothing to see here
#

Efficiency? dunno

meager granite
#

I wonder if deleting the parent deletes the particles, iirc it does but I'm not sure

#

if it does, deleting the parent might be more efficient

warm hedge
#

I don't think it should, I've never seen such instant delete

grim cliff
warm hedge
#

setvectodirandup is not a command, do you mean setVectorDirAndUp

meager granite
#

yeah, you have a typo

#

missed r

warm hedge
#

The syntax highlighter cleary said so too

grim cliff
#

wierd. that was arma autofill

meager granite
#

I think it adds new words as you go so maybe you had it with typo before and it thinks its a variable name

grim cliff
#

LOL

#

probably

ivory lake
grim cliff
#

can someone explain how to use setvectordirandup becuase it seelms like the higher i push the number the less the object moves

granite sky
#

what number?

warm hedge
grim cliff
#

not good at math just trying to rotate something attached to another object 180 degress

grim cliff
#

im trying to make it make sense by testing different numbers in the debug console but it seems to be inneffective

stable dune
#

you can easily get correct dir etc with

private _shield = createSimpleObject ["lxws\shield_f_lxws\shield_backpack_black.p3d", getPosWorld player];
private _shield attachto [player, [0,-0.125,-0.7],"spine3",true];
private _yaw = 45; 
private _pitch = -180; 
private _roll = 90;
_shield setVectorDirAndUp [
  [sin _yaw * cos _pitch, cos _yaw * cos _pitch, sin _pitch],
  [[sin _roll, -sin _pitch, cos _roll * cos _pitch], -_yaw] call BIS_fnc_rotateVector2D
];
polar belfry
#

does playsound3d need me to make a cfgsounds thing on description.ext

warm hedge
#

playSound3D does not require CfgSounds entry

polar belfry
#

thanks

polar belfry
#

is there a character limit in the init. I ask in case there is I should make my scripts for addaction in sqf files

little raptor
#

afaik no, but it's better not to use the init at all if you have a lot of code (except for calling stuff)

warm hedge
#

If there is that would mean 2^8 or 2^16 or 2^32 characters... I guess?

polar belfry
#

I will make it then for my sake in two sqf files

warm hedge
#

It is more of a matter of readability and maintenance

polar belfry
#

and do this

player addAction ["<t color='#FF0000'>Burst missile Launch</t>", "sub_missile_burst.sqf"];
still forum
#

I think its not perfect. Others have made better versions of the same

sharp grotto
#

Where do you execute it ?
Corpses are in a weird state after dying, very often it doesn't work.

tender fossil
#

Was just gonna ask that. You need to call the code on the client where player is local

grizzled cliff
#

ah the joys of this project, where deadlocking is an improvement :D

real tartan
#

I have a list of items and count of them.
Is there a fancy function that I can use to compare count ( numbers ) of each item and check, if there is tie between any of them ?
Trying to prevent a tie before using selectMax to get always some winner from list.

        private _list = [ ["land", 15], ["air", 12], ["sea", 15] ];
        private _tie = _list findIf { ... } isNotEqualTo -1;
still forum
#

You mean if any two elements have the same number?
Can you sort the list by the count?

#

If the list is sorted

private _lastCount = -1;
private _tie = _list findIf { private _result = (_list select 1 == _lastCount); _lastCount = _list select 1; _result } } isNotEqualTo -1;
real tartan
#

if there is a winner ( item with highest number ) return true
if there are 2+ elements with highest number and are same, return false --> need to recreate list

#

_list can have more entries

sullen sigil
#

hashmap and foreach 😎

stable dune
warm hedge
#

selectMax and get max amount, select the arrays that have max amount, selectRandom?

still forum
#
private _list = [ ["land", 15], ["air", 12], ["sea", 15] ];
private _winner = [-1, []];
{
  if (_x select 1 >= _winner select 0) then {
    if (_x select 1 != _winner select 0) then {_winner = [_x select 1]};
    _winner pushBack _x;
  }
} forEach _list;
#

At the end you have either

_winner = [12, ["air", 12]] have a winner
_winner = [15, ["land", 15], ["sea", 15]] Have multiple winners
Check how long the array is to find out if there was a tie on the top

#

You can also do it in one array

private _list = [ ["land", 15], ["air", 12], ["sea", 15] ];
private _winner = ["", -1];
{
  if (_x select 1 >= _winner select -1) then {
    if (_x select 1 != _winner select -1) then {_winner = []};
    _winner append _x;
  }
} forEach _list;

_winner = ["air", 12] have a winner
_winner = ["land", 15, "sea", 15] Have multiple winners

grizzled cliff
#

boom, fixed

#

50 threads all accessing the SQF engine with no crashing or deadlocking

#

:D

#

that was fun

sullen sigil
#

private _weiner

#

sorry i havent slept im being very silly

still forum
#

Performance of both of these probably not too great.
But they can both use SimpleVM

polar belfry
#

if I want to make a for loop that works as long as something is alive

#

do I write this

#
for (alive sub) do{
proven charm
#

while {alive sub} do{

polar belfry
#

oh yea

#

I forgot while

proven charm
#

with {}

still forum
# still forum You can also do it in one array ```sqf private _list = [ ["land", 15], ["air", ...

With private _list = [ ["air", 12],["air", 12],["air", 12],["air", 12],["air", 12],["air", 12],["air", 12],["air", 12],["land", 15], ["air", 12], ["sea", 15] ];
to create some load.

Normal / SimpleVM
Top one
0.107191 ms / 0.109667 ms
bottom
0.105697 ms / 0.108428 ms

Huh.. SimpleVM actually does make it worse.

private _list = [ ["air", 12],["air", 11],["air", 11],["air", 11],["air", 11],["air", 11],["air", 11],["air", 11],["land", 15], ["air", 11], ["sea", 15] ];
0.0765079 ms / 0.0772897 ms
and
0.0799486 ms / 0.0833709 ms

mh. Welp

#

Ah duh. SimpleVM doesn't work because theres a variable assignment. So it tries to build it and fails. ofc

polar belfry
#
private _position = vehicle player getRelPos [900,180];
    private _newPos = _position vectorAdd [0,0,1000];
  
    _missileDir = _newpos vectorFromTo getPosATL vehicle player;    
    _missile = createVehicle ["ammo_Missile_rim162", _newpos, [], 0, "CAN_COLLIDE"];    
    _missile setVectorDirAndUp [_missileDir, [0,0,-1]];

This is in one of my scripts I want to make it so the missile spawns 1km above the plane is this ok?

#

can I only get the Z(altitude) by any commands and do Z+1000 in vector add

oblique spoke
#

nice

polar belfry
#

I get this error with this here code

null=[]spawn{ 
  _i= 1000; 
  _bomb = "FIR_GBU24A_BLU118"; 
  _degree = 0; 
    for "_i" from 0 to 3 do{ 
 private _rand_num = [10, 250] call BIS_fnc_randomInt; 
  private _position1 = p3 getRelPos [_rand_num,_degree];     
  private _newPos1 = _position1 vectorAdd [0,0,500]; 
    _missile = createVehicle [_bomb, _newpos1, [], 0, "CAN_COLLIDE"];       
  triggerammo _missile; 
 _degree = _degree +90; 
   };
 playSound3D ["burst_missile_global_sfx.ogg", _newpos1]; 
   deletevehicle p3;   
    }```
#

should I make a variable out of "for"
like ```sqf
private _newpos2= _newpos1;

warm hedge
#

Well what is your intention there

#

What is the _newPos you supposed to use

polar belfry
#

the coordinates of the last bomb that got spawned

#

I want the sound to start from there

warm hedge
#

It looks better to execute playSound3D if _i == 0 instead

polar belfry
#
if _i ==0 then{
playSound3D ["burst_missile_global_sfx.ogg", _newpos1
}```
In the for loop?
warm hedge
#

I guess

polar belfry
#

ok will test

warm hedge
#

Also for Miller's sake, you SHOULD to use indent and spacing wisely or you will lose some sanity afterwardssqf [] spawn{ private _bomb = "FIR_GBU24A_BLU118"; private _degree = 0; for "_i" from 0 to 3 do { private _rand_num = [10, 250] call BIS_fnc_randomInt; private _position1 = p3 getRelPos [_rand_num,_degree]; private _newPos1 = _position1 vectorAdd [0,0,500]; if (_i == 0) then { playSound3D ["burst_missile_global_sfx.ogg", _newpos1]; }; _missile = createVehicle [_bomb, _newpos1, [], 0, "CAN_COLLIDE"]; triggerammo _missile; _degree = _degree +90; }; deletevehicle p3; };

polar belfry
#

In my files in notepad ++ it has indent it's just the init messes it up

warm hedge
#

In my files it has indent
and
it's just the init messes it up
My language processor failed to connect these two sentence and its meanings

polar belfry
#

sorry I wote it quickly

#

I wanted to say that when I write it in notepad++ I give it indent but sometimes init with the way it treats lines moves it

#

but thanks for the advice

tender fossil
#

Visual Studio Code entered the chat

grizzled cliff
#

30 threads pulling back player pos every 10ms and spitting it to a log file

#

no FPS impact

#

fucking right fucking on

terse tinsel
#

hey, I have a question for you. I noticed that some commands entered in the int of the Eden unit do not want to run, but if I enter the same commands using the sqs file, they work. anyone know why this is happening?

warm hedge
#
  1. What is the commands you mean
  2. Why an SQS is still used on your end
  3. And what have you done actually
stable dune
#
"true",        // condition
//change to
driver _target isEqualTo _this // check if player is driver of current vehicle
//_target: Object - The object to which action is attached or, if the object is a unit inside of vehicle, the vehicle
//_this: Object - Caller person to whom the action is shown (or not shown if condition returns false)
#

Too fast delete

#

XD

terse tinsel
warm hedge
#

Well what is the code, and still doesn't answer my question 2

terse tinsel
terse tinsel
#

the same thing happens when, for example, I want to use the player enableStamina false command

warm hedge
#

Well so, what exactly is the not working code and working code?

#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

```sqf
// your code here
hint "good!";
```

// your code here
hint "good!";
warm hedge
#

Also, SQS and SQF are not the same thing too. SQS is very obsolete and deprecated for like more than a decade

terse tinsel
# warm hedge !code

when I enter it in a text file and save it as sqf and then add exec name.sqf to the car's init, then the lights work. But when I enter this script directly into the unit's init without using exec sqf, it doesn't work. this is this command: this setVariable["ani_lightbar",1];

terse tinsel
warm hedge
#

Besides I can't really express how I am confused with out of curiosity can happen in this context, but anyways, are you actually sure it is not working? Error messages?

terse tinsel
#

I also noticed that when I type "player enableStamina fales;" in the soldier's init; this doesn't work either. But when I put it in the sqf file and execute it using this exec then it works, strange

warm hedge
#

prevents the engine from completing scripts
Nearly 100% sure this cannot be the reason. I'm thinking that because the code has been overwritten by some Mod or function else other than yours because your code does it before the first frame, and within next frames yours is somehow overwritten

terse tinsel
warm hedge
#

I would blame how the Mod is made instead of your code or how you execute them

terse tinsel
warm hedge
#

Even though I'm not saying it is the 100% reason but since how execVM works it could happen a bit of delay

granite sky
#

this setVariable ["varname", 1]; should work fine in an init box.

#

whether it has the knock-on effects you expect is another matter.

terse tinsel
granite sky
#

Are these commands on their own in the init box?

terse tinsel
terse tinsel
polar belfry
#

how to calculate difference from sea level and point underwater?

#

I am using it for a cruise missile I want to spawn from a sub. I got the over the water part but need to now make it underwater

terse tinsel
#

I also tried in eden using triggers and game logs and still nothing. And when I use the sqf file with this command then it works

terse tinsel
#

I'm closing the topic. Thank you for your help

granite sky
#

I tried both the setVariable and enableStamina just now and they work.

terse tinsel
oblique spoke
#

har har harrr

sage marsh
#

Hey guys, i got a question about APCs.

#

Why does the player control an AI mounter APC even though the Player is the passanger

#

Is there a remedy or a script that makes the AI just move towards their set waypoints

polar belfry
# polar belfry I am using it for a cruise missile I want to spawn from a sub. I got the over th...
    
 if (( getposasl vehicle player) select 2>=-3) then{ 
      private _pos = launch modelToWorld [0,2,1.6]; 
      private _missile = createVehicle ["ammo_Missile_Cruise_01", [0,0,0], [], 0, "none"];     
      _missile enableSimulation true;     
      _missile setPosASLW _pos;     
      _missile setVectorDirAndUp [[0,0,1], [1,0,0]];} 
 else{ _seaDepth = abs (getTerrainHeightASL getPosATL launch);  
       private _pos = launch modelToWorld [0,2,1.6]; 
       private _missile = createVehicle ["ammo_Missile_Cruise_01", [0,0,0], [], 0, "none"];      
       _missile enableSimulation true;      
       _missile setPosASLW _seaDepth ;      
       _missile setVectorDirAndUp [[0,0,1], [1,0,0]]; 
   } 

Here's my idea to run it

terse tinsel
#

and is it possible to write in an sqf document so that I don't have to enter the name of the unit and just use "this"?? Because I write it into sqs "this setVariable["ani_lightbar",1];" and in the unit init I enter "this exec "light.sqs"; and then it doesn't work. And I don't want to have to enter the name for each unit

polar belfry
#

yes

#

the over the water part works

stable dune
#

You can add that if condition in addaction condition, so it won't show up if vehicle position z is not > -3

polar belfry
#

I need to fire it from underwater

#

so the thing I want to do is when the sub is underwater to spawn the missile where the launch (reference point on the sub with a prop) is but on the water surface directly above it

little raptor
#

if you always do this execVM "light.sqf" you can also just write: _this setVariable["ani_lightbar",1]; in the SQF file

polar belfry
#

I need to find a way to put the missile on the water surface

terse tinsel
little raptor
#

There's no need for DMs. Just ask here

#

Other people might reply to you too

delicate hedge
#

Does BIS_fnc_setServerVariable and BIS_fnc_getServerVariable work in SP?

granite sky
#

probably a lot better than they work in MP...

cosmic lichen
#

They do

#

missionnamespace setvariable [_var,_value];
publicvariableserver _var;

granite sky
#

On MP it uses a waitUntil without sleep for the request, so it's a major performance drain.

delicate hedge
#

and publicvariableclient?

granite sky
#

hmm. I guess it's only a couple of statements per frame.

cosmic lichen
#

ok, but how do i get them on needed machine? By remoteExec?
In SP there is no server. The variable are then just available in whatever namespace they were set to

delicate hedge
granite sky
#

Uh, what's your actual use case?

delicate hedge
#

i got mod for sp and mp

granite sky
#

The BIS function there is for if you want a return value. Hence it's complicated.

delicate hedge
granite sky
#

If you don't want a return value then don't use it.

#

It's certainly not a general replacement for setVariable or publicVariableXXX commands.

cosmic lichen
delicate hedge
#

yes

#

i see no other realisation

delicate hedge
#

but thats not only for mp

delicate hedge
#

and other get

cosmic lichen
#

Questions is, how frequent do they set it. Is there no event handler that could cover that?

delicate hedge
polar belfry