#arma3_scripting

1 messages · Page 732 of 1

tough abyss
#

shouldn't grab any animals

cosmic lichen
#
_x isKindoF "CAManBase"

Will make sure only soldiers are returned, but as Sysroot said, 'units' command should not return snakes and stuff

tough abyss
#

I'd be careful w/ doing inheritance checks like that to detect units, it usually works fine but some addons as well as iirc certain animals have weird inheritance structures that can make those checks fail

pale glacier
#

Ok, I'll try

Thanks

low sierra
#

DisableAI can increase server FPS?

#

The more i disable, the more i gain FPS?

#

I made some tests about that in the past, but can't remember the conclusion... i suspect the answer is "no".

tough abyss
#

Theoretically you could expect some degree of performance improvement by disabling certain features but I'd expect it to be negligible at best

#

Rendering and scheduler (and netcode if playing MP) take up the vast majority of arma's fps load

blissful flower
#

Hi guys. Is it possible to define a public variable on the dedicated server without editing a mission or makin an addon? E.g. by userconfig or so?

tough abyss
#

You can do it via anything that supports sqf via publicVariable

#

i.e. if you have access to debug console

blissful flower
#

Debug console is not an option. Need it to be defined once on the server and spread on the clients when they connect

low sierra
#

All players will be able to do it?

crystal vessel
#

Hello
Can anyone point me to any ideas what would be a proper way to implement a deafness effect if a player is too close to a vehicles cannon firing?

tough abyss
#

@crystal vessel ACE has a hearing damage framework that does similar so you could look at what they do, but a simple implementation could probably just use this along w/ code to detect firing weapony
https://community.bistudio.com/wiki/fadeSound

pliant stream
#

you want to quickly lower the game volume and then bring it back over a long time. that alone is very difficult to do correctly, unless there is some abstraction for layered volumes

tough abyss
#

0 fadeSound 0 should deafen the player

#

then you can fade it back in over a long interval for recovery

crystal vessel
#

I am more looking into how to create the radius around the vehicle when it fires

tough abyss
#

Use a fire EH

crystal vessel
#

So like
IF autocannon_40mm_CTWS FIRE

tough abyss
#

Kinda

crystal vessel
#

i need to get nearEntities and then apply the fadesound

tough abyss
#

you'd want to set it up with this event handler

#

and then do as you describe

pliant stream
#

does CBA or something offer a layered volume abstraction?

tough abyss
#

Depends what you mean by layered I suppose

#

Arma by default supports separate audio control of master vs. environmental volume

pliant stream
#

i mean layering two distinct fades at the same time

#

a new fadeSound overrides the last one

crystal vessel
#

this addEventHandler ["Fired", {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
}];
Can I remove _unit, _mode and such without impacting?

tough abyss
#

You cannot remove them but you can replace them with placeholders

#

best to just keep them as they are though

copper raven
crystal vessel
#

So just _empty?

copper raven
#

""

tough abyss
#

Exception is if they're after all of the params that you do use

#

then you can freely remove them

#

can some one help me make a zeus register item via group config thing?

#

eh nevermind i am taking a break

blissful flower
pliant stream
#

userconfig?

blissful flower
#

Arma3/userconfig folder

tough abyss
#

@blissful flowerI don't have much experience with them unfortunately but from what I understand they operate much the same as configs

#

so I'd guess unless there's some sort of sqf init field somewhere you probably can't

tough abyss
#

It's that sort of thing that mission init files are really useful for

#

I know you said you don't want to mess with those

#

but that'd be the best way to do it as far as I'm aware

blissful flower
tough abyss
#

Right yeah I get what you mean

#

I personally am not aware of anything other than debug console that would allow that, but I also don't have much experience hosting dedicated arma servers

#

someone else might know more

blissful flower
#

Hope so. Thank you anyway.

tough abyss
#

No problem, sorry couldn't help more

crystal vessel
#

So I am missing { somewhere here
player addEventHandler["Fired",{if(_this select 1 isKindOf["Launcher",configFile>>"CfgWeapons"])then{[player]call LowArea;};}];};//[_this select 0]

crude vigil
tough abyss
#

Players are vehicles, that will work fine

#

once the syntax error is corrected

crystal vessel
#

So one become two
player addEventHandler["Fired",{if(_this select 1 isKindOf["Launcher",configFile>>"CfgWeapons"])then{[player]call CRS_BB;};};//[_this select 0]
Now I am missing a ]

tough abyss
#

addEventHandler[

#

does not have a matching ]

crystal vessel
#

Added ] at the end with the same issue

tough abyss
#

Syntax errors will be easier to spot and fix if you format your code cleaner, like so

player addEventHandler["Fired", {
  if (_this select 1 isKindOf["Launcher", configFile>>"CfgWeapons"]) then {
    [player] call CRS_BB;
  };
}];
#

that is the correct syntax and formatting

crystal vessel
#

Oh

#

Thanks

tough abyss
#

also note that you can use # as shorthand for select in most cases

#

so you can use _this#1 instead of _this select 1

crystal vessel
#

In the 3rd line Call can I do "Script.sqf"?

tough abyss
#

you would have to use execVM instead of call

#

to call an sqf file

crystal vessel
#

Thanks!

tough abyss
#

No problem

crystal vessel
#

private _caller=_this select 0; private _behindMe=_caller nearEntities["Man",50]; if(count _behindMe<1)exitWith{}; {private _PressureArc=[getPosATL _caller,(getDir _caller)-180,90,getPosATL _x]call BIS_fnc_inAngleSector; if(_PressureArc)then{ private _LoS=lineIntersects[eyePos _caller,eyePos _x,objNull,_caller]; if(!_LoS)then{_x remoteExec["Deafness.sqf",0,true];};}; }forEach _behindMe-[_caller];

#

Now that FIRED event had to call the 2nd sqf script

#

which interprets the situation and calls a 3rd one

tough abyss
#

Sounds good

#

needs some formatting work but looks okay

crystal vessel
#

I, for whatever reason, doesn't seem to work

#

I think I might have a wrong config on launchers?

#

I think RemoteExec might be used wrong

tough abyss
#
private _caller= _this select 0;
private _behindMe = _caller nearEntities["Man", 50];
if (count _behindMe < 1) exitWith {};
{
 private _PressureArc = [getPosATL _caller, (getDir _caller)-180, 90, getPosATL _x] call BIS_fnc_inAngleSector; 
 if (_PressureArc) then{
    private _LoS = lineIntersects[eyePos _caller, eyePos _x, objNull, _caller];
    if (!_LoS) then {
      _x remoteExec["Deafness.sqf", 0, true];
    };
 };
} forEach _behindMe-[_caller];
#

this should make it clearer

#

Yeah not quite sure what the purpose of the remoteExec is here

#

seems unnecessary

#

that and

#

you can't remoteExec a .sqf file

#

so that'd be what's wrong

#

I would just stick with an execVM

crystal vessel
#

I am using CRS as a base to create a project because my scripting skills are too weak

tough abyss
#

That's fair

#

just switch that remoteExec to a basic execVM and give it a test

crystal vessel
#

_x remoteExec["Deafness.sqf", 0, true];
to
_x execVM "X\Z\Script.sqf"; ?

tough abyss
#

yup

crystal vessel
#

AHAHAHAAHAA YESSSS

#

It worked!

tough abyss
#

Congrats!

crystal vessel
#

Now I have to port this for a vehicle ! 😄

tough abyss
#

For vehicles you probably don't want to do any of this code that's checking if units are behind the vehicle, unless you want deafness to work that way

#

a simple radius scan for units close to the vehicle will probably be the best approach

#

you could even possibly change the amount of deafness based on their distance from the firing vehicle

crystal vessel
#

I actually need a limited radius

tough abyss
#

remoteExec shouldn't be necessary for setUnconscious

#

it has global effect

#

for a basic radius check you can stick with just the nearEntities call

crystal vessel
#

How would I go about changing from launcher to turret of a APC/TANK?
player addEventHandler["Fired", { if (_this select 1 isKindOf["Launcher", configFile>>"CfgWeapons"]) then { [player] execVM "Pressuretest\Script\LowArea.sqf"; }; }];
I am seeing Launcher and configfile
I am guessing it need to be changed to an correct config

#

So Launcher to Turret and CfgWeapons to Cfg(vehicle0?

tough abyss
#

Vehicle weapons are all defined in CfgWeapons iirc so that can stay the same

#

you just need to change Launcher to the class type you're looking for

#

so just changing launcher to turret could be what you want

crystal vessel
#

So the Launcher is a class of the CfgWeapons, right?

#

Not sure if Cannon is correct

tough abyss
#

Launcher is a base class that all launcher-type weapons inherit from

#

isKindOf does an inheritance check to see if a given object's class inherits from another class

#

so when you do weapon isKindOf "Launcher" it's trying to see if weapon is an object that inherits from class Launcher

#

I'm not sure which base class you need to use to be honest

#

you could try cannon

#

best way to figure it out would be to open config viewer and dig through cfgWeapons for a vehicle weapon you want it to work with and see which classes that weapon inherits from

crystal vessel
#

Okay, will check it out

#

So based on the path, it should be
configFile>>"CfgVehicles"

#

uhh.. the vehicle is that. I just don't know the class

tough abyss
#

The vehicle will be there, yes

#

but you're looking for the weapon, yeah?

crystal vessel
#

I am looking for the specific class it might be tagged under, yes

tough abyss
#

You can find references to the vehicle's weapons in its vehicle config I believe

#

so hopefully that can help you to get to the weapon

real tartan
#

somebody remember name of function that create grey marker on map bounding to building shape ?

crystal vessel
#

@tough abyss
private _PressureArc = [getPosATL _caller, (getDir _caller)-180, 90, getPosATL _x] call BIS_fnc_inAngleSector;
To turn it into 2 arcs,
Should it be
[getPosATL _caller, (getDir _caller)-180, 90, getPosATL _x] && [getPosATL _caller, (getDir _caller)-180, 90, getPosATL _x] ?

tough abyss
#

Why do you need 2 arcs?

crystal vessel
#

I want to have 2 position that give a deafness effect

tough abyss
#

Alright

#

Well && would require them to be in both positions since it's checking for both conditions to be true

#

if you want either to work you want to do OR which is ||

crystal vessel
#

[getPosATL _caller, (getDir _caller)-180, 90, getPosATL _x] II [getPosATL _caller, (getDir _caller)-180, 90, getPosATL _x]? (just add the correct values)

tough abyss
#

Yes though to make it cleaner I'd recommend doing this

private _inSectorA = [getPosATL _caller, (getDir _caller)-180, 90, getPosATL _x] call BIS_fnc_inAngleSector;
private _inSectorB = [getPosATL _caller, (getDir _caller)-180, 90, getPosATL _x] call BIS_fnc_inAngleSector;

if (_inSectorA || _inSectorB) then {
  // code here....
};
#

or something similar

#

if you want to make it more efficient you could stop it from getting the caller's pos and dir twice by saving it once like this

#
private _callerPos = getPosATL _caller;
private _callerDirBehind = _callerDir - 180;
private _inSectorA = [_callerPos, _callerDirBehind, 90, getPosATL _x] call BIS_fnc_inAngleSector;
private _inSectorB = [_callerPos, _callerDirBehind, 90, getPosATL _x] call BIS_fnc_inAngleSector;

if (_inSectorA || _inSectorB) then {
  // code here....
};
crystal vessel
#

How do you get that script format?

tough abyss
#

```sqf
code here
```

crystal vessel
#

Ok

tough abyss
#

there ya go

crystal vessel
#

Now to edit the current code

#
private _caller= _this select 0;
private _behindMe = _caller nearEntities["Man", 50];
private _callerPos = getPosATL _caller;
private _callerDirBehind = _callerDir - 180;

if (count _behindMe < 1) exitWith {};
{
 private _inSectorA = [_callerPos, _callerDirBehind, 90, getPosATL _x] call BIS_fnc_inAngleSector;
 private _inSectorB = _callerPos, _callerDirBehind, 90, getPosATL _x] call BIS_fnc_inAngleSector;

 if (_inSectorA || _inSectorB) then {
    private _LoS = lineIntersects[eyePos _caller, eyePos _x, objNull, _caller];
    if(!_LoS) then {
      _x execVM "Pressuretest\Script\Deafness.sqf";
    };
 };
} forEach _behindMe-[_caller]
tough abyss
#

just need to adjust _inSectorA and _inSectorB to the areas you want

crystal vessel
#

Issue arises that arma tells me _callerDir is not a variable

tough abyss
#

ah haha

crystal vessel
#

Error undefined variable in expression : _callerdir

tough abyss
#

my bad

#

it should be

little raptor
#

getPosATL is fast

#

the real slowdown is the function itself

tough abyss
#

private _callerDirBehind = (getDir caller) - 180;

#

that's true

#

but code clarity is more important than micro-optimization anyways

tough abyss
#

true, good catch

#

just copied/pasted

little raptor
#

lineIntersects
that checks view LOD
that's not what you should use for something like "deafness"

crystal vessel
#

spotted it quickly 😄

#

Just as you posted

#

IT VERKSSSS

#

hehehehe

little raptor
#

private _inSectorA = [_callerPos, _callerDirBehind, 90, getPosATL _x] call BIS_fnc_inAngleSector;
private _inSectorB = _callerPos, _callerDirBehind, 90, getPosATL _x] call BIS_fnc_inAngleSector;
these are literally the same thing

#

wat?

tough abyss
#

placeholder

#

he's going to change them later

crystal vessel
#

Yes, I have to change it so it is to the sides

#

So 90 is 90* from the players rear

tough abyss
#

you'll likely end up needing to throw out _callerDirBehind then but

#

¯_(ツ)_/¯

crystal vessel
#

Oh

#

¯_(ツ)_/¯

tough abyss
#

Since you'll need one to each side

#

not a big deal though

little raptor
crystal vessel
#

?

little raptor
#

clockwise

crystal vessel
#

oh clockwise

little raptor
#

oh that's not a dir

#

that's angle

#

I thought you're talking about getDir

tough abyss
#

it's just a sector angle yeah

#
 private _callerDir = getDir _caller;
 private _inSectorA = [_callerPos, _callerDir - 90, 90, getPosATL _x] call BIS_fnc_inAngleSector;
 private _inSectorB = [_callerPos, _callerDir + 90, 90, getPosATL _x] call BIS_fnc_inAngleSector;

this will give you 90 degree sectors on both sides of the player

#

can adjust to your liking

#

lol

crystal vessel
#

lol indeed

amber sapphire
#

Messing around with some vehicle concepts lately and have been trying to disable vehicles automatically exploding after their hithull points have surpassed 0.9 From what I've been reading on the wiki, it appears I might have to make a config patch. I was wondering if there's an easier way I'm overlooking?

crystal vessel
#

what is this ?+ 90, 90,

little raptor
#

CW

crystal vessel
#

so it's 90 degrees to left and right?

little raptor
#

_callerDir +90 -> right

#

_callerDir -90 -> left

crystal vessel
#

ok

tough abyss
#

yup

#

and the plain 90 in both of them is the total width of the sector

#

which gets split down the middle

#

so 45 degrees to the front and back of the player's sides

#

that's the main thing you're left to adjust to your liking

tough abyss
#

unless you're willing to make them invincible :P

amber sapphire
#

Fair enough. I was wondering because in the Contact campaign Eddie is set to not drop below a certain damage threshold to prevent players from soft-locking the mission.

tough abyss
#

You could do that with sqf, yeah, but like I said you'd end up making it invincible

#

You'd pretty much just hijack the HandleDamage EH for the vehicle and make it return 0 if the vehicle's health is at or below the threshold (or if applying the current dealt damage would do so)

amber sapphire
#

Gotcha.

#

Gave me something to play around with for awhile, lol.

tough abyss
#
// PreventExplosion.sqf
params[["_vehicle", objNull, [objNull]], ["_dmgThreshold", 0, [0]]];

_vehicle addEventHandler ["HandleDamage", {
  params ["_vehicle", "_selection", "_damage", "_source", "_projectile", "_hitIndex", "_instigator", "_hitPoint"];
  if (_damage > _dmgThreshold) then {
    0; // Prevent selection damage from exceeding dmgThreshold by returning 0
  };
}];
#

this would probably do the trick

#

[car, 0.9] execVM "PreventExplosion.sqf"

#

prevents car from exceeding 0.9 dmg on any selection

amber sapphire
#

Lmao, you sent that after I had half of my own script written.

tough abyss
#

Haha

amber sapphire
#

Wasn't asking for handouts, but I'll gladly take it. Appreciate it, man.

tough abyss
#

No problem, lmk if it doesn't work, didn't actually test it

#

might've botched something

amber sapphire
#

Will do.

mystic shell
#

I too need help with a script...

tough abyss
#

Come and ye shall be helped

little raptor
tough abyss
#

Ah, doc wording was a bit vague

#

I'll rework it, thanks

mystic shell
#

I'm trying to script a more realistic respawn for multiplayer missions.

When killed, players respawn in an already loitering helicopter.

I'd like said helicopter to unload or rappel troops on a spot designated by troops on the ground, marked by a flare or by smoke.

tough abyss
#

@amber sapphire Might want to go grab the updated copy, made a syntax error too :P

amber sapphire
#

Yeah, I see that.

#

I'll give the updated version a try.

mystic shell
tough abyss
#

Yeah that's definitely a bit of a tall order

mystic shell
#

thought as much

tough abyss
#

like, pretty much an entire addon's worth of stuff

mystic shell
#

I've seen something similar before

#

so maybe someone has ideas

amber sapphire
#

I wouldn't say an entire addon, but it would be a lot of coding.

tough abyss
#

Wouldn't take long to do the respawn in helicopter part, but smoothly integrating it with the helicopter following flares/smoke and the various edge cases would take a while

mystic shell
#

yea, I've got the respawn part down already

#

it's just the deployment part lol

#

so if I were to change the request around, to make it more feasible - what would you suggest is possible to achieve something similar to what I had in mind?

tough abyss
#

To get the heli to deploy at the flare zone?

mystic shell
#

something along those lines, is that 'easy' to script?

crystal vessel
#

If anyone knows, since I have been looking.
CfgWeapons subclass rifle and launcher exists
I have no idea how to find the cannon for a M1A2 Slammer

tough abyss
#

Well I haven't done it myself, but plenty of addons have vehicles that are scripted to go to the locations of flares

crystal vessel
#

It counts as a cannon_120mm but it is not under cannon or turret for config

tough abyss
#

so you could take a look around or piece together a method

#

as for how to smoothly integrate said method with whatever else you have written is up to you

mystic shell
tough abyss
#

I imagine for something so important that BI probably has a function for it already laying around somewhere

#

but if not could always do good ol waypoint coordinates

mystic shell
tough abyss
#

Neither have I!

#

But I'm sure it can be done

#

Alas AI behavior / vehicle control is pretty much the one corner of arma modding I'm not well versed in

mystic shell
#

thanks for your thoughts anyway

#

looking around, might be able to achieve it with support requester/provider module...

crystal vessel
#

@tough abyss

player addEventHandler["Fired", {
  if (_this select 1 isKindOf["rifle", configFile>>"CfgWeapons"]) then {
    [player] execVM "Pressuretest\Script\LowArea.sqf";
  };
}];```
#

Does this only react to the player firing?

tough abyss
#

Yes

crystal vessel
#

Or will it also take into account if he is operating a tank?

tough abyss
#

Hm

#

Nope

#

However

#

You can use "FiredMan" instead of "Fired"

#

and then it will work for both

#
player addEventHandler ["FiredMan", {
    params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_vehicle"];
}];
#

those are the params for it

crystal vessel
#

I am looking or ANYTHING so i guess Fired works

tough abyss
#

If you want anything then you should use FiredMan

crystal vessel
#

Oh

tough abyss
#

Fired only works outside of vehicles

crystal vessel
#

OHHHH

tough abyss
#

In the text for the "Fired" EH:
Triggered when the unit fires a weapon.
This EH will not trigger if a unit fires out of a vehicle. For those cases an EH has to be attached to that particular vehicle.

crystal vessel
#

FOUND IT

#

It was Firedman I needed

#
player addEventHandler["FiredMan", {
  if (_this select 1 isKindOf["cannon_120mm", configFile>>"CfgWeapons"]) then {
    [player] execVM "Pressuretest\Script\LowArea.sqf";
  };
}];```
#

This fixed it

tough abyss
#

Ah there ya go

crystal vessel
#

FiredMan and Cannon_120mm is the sub class for weapons

tough abyss
#

Pretty sure that's only going to apply specifically to 120mm cannons

#

might want to go with a base class

#

such as if Cannon is available

crystal vessel
#

I will after

#

I need a last fix

#

So now I added a third Sector

#
private _caller= _this select 0;
private _behindMe = _caller nearEntities["Man", 50];
private _callerPos = getPosATL _caller;
 private _callerDir = getDir _caller;

if (count _behindMe < 1) exitWith {};
{
 private _inSectorA = [_callerPos, _callerDir - 90, 90, getPosATL _x] call BIS_fnc_inAngleSector;
 private _inSectorB = [_callerPos, _callerDir + 90, 90, getPosATL _x] call BIS_fnc_inAngleSector;
 private _inSectorC = [_callerPos, _callerDir +10, -10, getPosATL _x] call BIS_fnc_inAngleSector;

 if (_inSectorA || _inSectorB) then {
    private _LoS = lineIntersects[eyePos _caller, eyePos _x, objNull, _caller];
    if(!_LoS) then {
      _x execVM "Pressuretest\Script\Deafness.sqf";
    };
 if _inSectorC {
    private _LoS = lineIntersects[eyePos _caller, eyePos _x, objNull, _caller];
    if (!_LoS) then {
      _x execVM "Pressuretest\Script\Front.sqf";
    };
 };
} forEach _behindMe-[_caller]```
#

So SectorC

#

and IF new

#

Fight now I am not getting ANY interaction, so there is a question where di one of the codes break

tough abyss
#

missing parentheses in the 2nd if statement

#

around _inSectorC

#

also what is sector C supposed to be

#

because it's not set up correctly

crystal vessel
#

fixed it

#

private _inSectorC = [_callerPos, _callerDir + 10, 10, getPosATL _x] call BIS_fnc_inAngleSector;

tough abyss
#

Why 10 degrees to the right?

crystal vessel
#

This is the FRONT of it

#

So the right and left will cause deafness

#

and front will kill

tough abyss
#

Yeah I'm saying you're not really getting the front

#

you're getting

#

a 10 degree wide sector 10 degrees to the player's right front side

crystal vessel
#

So I need 2 Sectors?

tough abyss
#

if you just want a 10 degree region in front of the player you just need

private _inSectorC = [_callerPos, _callerDir, 10, getPosATL _x] call BIS_fnc_inAngleSector;
crystal vessel
#

oh

tough abyss
#

though 10 degrees is quite small

#

might want to do 30 degrees minimum

#

also

#

you're doing this on the list of units in _behindMe

#

so none of them will ever be in front of you

#

need to do a separate code section for this sector

#

oh nvm

#

you left it named _behindMe but it's just a radius check

#

probably want to rename that to make it less confusing

#

anyways going to bed, hope it goes well

crystal vessel
#

Thanks

cyan dust
little raptor
cyan dust
little raptor
cyan dust
#

Should there be a time interval between group creation and setGroupOwner call? We tried waiting several seconds and it seems to do the job then

copper raven
#

yes i think

#

try next frame

real tartan
little raptor
#

I don't think you can

copper raven
real tartan
hallow mortar
#

Land_HelipadEmpty_F or Land_InvisibleBarrier_F would be good candidates, but it's not very important

crystal vessel
#
private _caller= _this select 0;
private _radius = _caller nearEntities["Man", 50];
private _callerPos = getPosATL _caller; 
private _callerDir = getDir _caller; 
#

What would be the correct way to get the direction of the weapon pointing?

#

Weapon for a tank turrent

#

I have weaponDirection on my ideas list

craggy lagoon
#

I've got a trigger that I would like to activate if any of the following ("FlexibleTank_01_sand_F","ACE_medicalSupplyCrate","Box_NATO_Ammo_F","Box_NATO_AmmoOrd_F") item types move into the trigger zone but I can't seem to figure out how to write the condition. Anyone willing to help me out on this please? It would be greatly appreciated!!

steel fox
#

@craggy lagoon
something like this should do it

(thisList findIf {(typeOf _x) in ["FlexibleTank_01_sand_F","ACE_medicalSupplyCrate","Box_NATO_Ammo_F","Box_NATO_AmmoOrd_F"]}) > -1;

What are you trying to accomplish?

craggy lagoon
#

@steel fox Thank you, I'm just wanting to display text when one of these items shows up in a zone. I was able to get it work when I specified one item but couldn't get it to work with when I wanted there to be a selection of items. I will test this out shortly, thank you again!!

craggy lagoon
#

@steel fox That worked perfectly, thank you so much!!

steel fox
#

np

low sierra
barren pewter
#

I know how to make myself spawn at a random position, but how do i make a wrecked helicopter and some weapons and supplies spawn there with me

#

At the start of game

steel fox
barren pewter
#

@steel fox at first i couldnt think of a way but i think i know how i can do it now, thanks

steel fox
#

happy to help

acoustic abyss
#

I find myself spending unnecessary time fitting a ladder exactly so that the "climb ladder" prompt appears easily for the player. What scripting command puts players in ladders?

acoustic abyss
#

Yes! Just googled it meself. ... Where do I find the laddernumber:
unit action ["ladderUp", targetObject, ladderNumber, positionNumber] ?

acoustic abyss
#

Thank you

little raptor
#

it's the index of the entry in ladders array

little raptor
tidal ferry
#

Hey- so

#

This is a big command, and math/vectors aren't my strongsuit, so does anybody know how I could tweak this script to move an object horizontally?

#
bob = createAgent ["C_man_1", player getRelPos [5, 0], [], 0, "CAN_COLLIDE"];
bob switchMove "ladderCivilUpLoop";
pos1 = getPosASL bob;
pos2 = pos1 vectorAdd [0,0,0.75];
bob addEventHandler ["AnimDone", 
{
    pos1 = pos2;
    pos2 = pos2 vectorAdd [0,0,0.75]
}];
onEachFrame
{
    if (!alive bob) then 
    {
        onEachFrame {};
        bob switchMove "";
        bob removeAllEventHandlers "AnimDone";
    };
    bob setVelocityTransformation [
        pos1, 
        pos2, 
        [0,0,0], 
        [0,0,0], 
        [0,1,0], 
        [0,1,0], 
        [0,0,1], 
        [0,0,1],
        moveTime bob
    ];
};```
little raptor
tidal ferry
#

I'm looking to use objects

little raptor
#

setVelocityTransformation causes jittery anims

tidal ferry
#

I.e. have a straight object just move at a continuous speed horizontally

#

Without having to use weird workarounds like attachto moving units

little raptor
tidal ferry
#

Think it's intended for SP though

#

I tried it in SP and it worked

little raptor
#

and use a desired time (or speed) to calculate the new interpolated position every frame

tidal ferry
#

Hmm, okay

#

Execution locality? Server I assume?

little raptor
#

see the wiki

fervent kettle
#

Can someone help me with this

[] spawn{
private _currentLeader = leader player;
teleportPlayer setPosATL (getPosATL _currentLeader vectorAdd [2,0,0.5]);
hint "teleported to squad leader";
};

I want to teleport a player to another players location, drops me an "expect object" on line 3

fervent kettle
#

an addAction in another file

#

teleportPlayer = player addAction ....

little raptor
#

also why do you create a variable for it?

fervent kettle
little raptor
fervent kettle
#

No the addAction references to another file where the code above is in.

little raptor
#

show me your script

fervent kettle
#

onPlayerRespawn.sqf

teleportPlayer = player addAction ["<t color='#0ac6d2'>Teleportieren</t>", "_resupply\scripts\teleport.sqf", [], 6, false, false, "", "true", 0.2];

teleport.sqf

[] spawn{
private _currentLeader = leader player;
teleportPlayer setPosATL (getPosATL _currentLeader vectorAdd [2,0,0.5]);
hint "teleported to squad leader";
};
winter rose
#

so teleportPlayer is a number
you cannot teleport a number 😉

little raptor
#
params ["_player"];
private _currentLeader = leader _player;
_player setPosATL (getPosATL _currentLeader vectorAdd [2,0,0.5]);
hint "teleported to squad leader";
brazen smelt
#

Not sure if its scripting related but is there a code or function to prevent an A.I unit from getting its ownership changed?

fervent kettle
#

Ah okay, thanks I was kinda relying on some other stuff I did with spawn[] that did almost identical functions

past wagon
#

are there commands or functions that give coordinates for parts of an ellipse? for example, I have a rectangle with a size, position, and rotation. How can I find the coords at the top of the rectangle?

winter rose
#

I don't think there are commands for that, perhaps a function but I wouldn't bet on it

past wagon
#

guess ive got some math to do

steel fox
#

Couldn't you just calculate the vector from the origin point upwards with size then rotate with the rotation?

past wagon
#

maybe

brazen smelt
winter rose
#

as in, just don't transfer them there?

#

it is not an automatic process

anyway, why would you want to override this transfer?

brazen smelt
#

I found the variable to prevent transfer. I had a smooth brain moment.

#

Some of our CAS is virtualized, so when they get spawned in, upon transfer they go all wonky as we were using ACE's Headless Control

#

On another note however, I got my initPlayerLocal.sqf looking like this:

// This executes the briefing SQF. - Shows the briefing in the map screen.
[] execVM "briefing.sqf";

// Whitelisted ACE Arsenal
[arsenal_1] execVM "scripts\arsenal.sqf";
[arsenal_2] execVM "scripts\arsenal.sqf";
[arsenal_3] execVM "scripts\arsenal.sqf";
[arsenal_4] execVM "scripts\arsenal.sqf";

// Logistics Spawner
[spawner_1] execVM "scripts\LogiSpawn.sqf";

This is the best way to go about it?

#

I never felt like I understood what should go in init.sqf, what goes in initplayerlocal.sqf, etc.

steel fox
craggy lagoon
#

I'm attempting to get the varname of a vehicle with Achilles Execute Code Module in Zeus trying to run

hint vehicleVarName player;

but nothing returns. Is there different code that I should be attempting to run?

#

I set the name in the editor so I know something should be coming back.

steel fox
#

@craggy lagoon

hint vehicleVarName (vehicle player);

that should do it

acoustic abyss
#

I'm trying to create a "Son Tay" style mock up of an existing base on Tanoa, on another terrain. For that I need to collect the classnames, positions, and orientations of all the buildings within an area.
Does anyone know of a script (or command) that does this?

craggy lagoon
#

@steel fox Thank you but still getting nothing back, can this be done from the debug console?

steel fox
#

Should work, the player is inside the vehicle you set the name on right?

craggy lagoon
#

Nope that was the issue. Thank you!!!

steel fox
tough abyss
#

configs = [(configfile >> "CfgGroups" >> "West" >> "rhs_faction_usmc_wd"),2,false] call BIS_fnc_returnChildren select {inheritsFrom _x isEqualTo (configFile >> "Man");

#

why the hell does this not work?

#

it trips up on "man"

steel fox
# acoustic abyss I'm trying to create a "Son Tay" style mock up of an existing base on Tanoa, on ...

just compile a list of the objects then spawn them again?

private _objectList = [];

forEach {

  _objectList pushBack [typeOf _x, getPosATL _x, getDir _x];

} (_pos nearObjects _radius);

forEach {
  _x params ["_type", "_posATL", "_dir"];
  private _object = createVehicle [_type, _posATL, [], 0, "CAN_COLLIDE"];
  _object setDir _dir;
} _objectList;

You just have to figure out how you pass _objectList from the one script to the other. are you recreating it in the same mission?

are you using Eden or in a mission?

tough abyss
#

this is the new code configs = [(configfile >> "CfgGroups" >> "West" >> "rhs_faction_usmc_wd"),2,false] call BIS_fnc_returnChildren select {inheritsFrom _x isEqualTo (configFile >> "Man")}; and I cant post screenshot of my error

little raptor
tough abyss
#

haha so you can do awesome tricks like grab all the sub classes from a config entry. when it works right, ive gotten it to automatically pull all the units from a group and plug them into the respawn loads that you can select from using the ingame respawn loadout function for multiplayer.

#

Now i want to do factions and zeus, ive already used CBA that adds code to every units init, removing them from the zeus editable objects if they are not a west side unit.

#

Anyway i need to figure out how i can grab all the configs and plug them into the .... command that registers the cfg to be available in the interface. The issue is the array wants you to have cfg, price . So i dont know how i combine an array of cfgs with an array of prices .....

plush nova
#

is it possible to have an artillery computer style UI for an equippable launcher

tough abyss
#

probably. but there might be multiple ways to achieve a goal like that. so the launcher is non negotiable?

#

I wanted to make packable boats, like uav bags that open up into assault boats that you can wear on your back. So my failed attempt was to look at the configs

#

luckily someone already made the mod, and i need to study that mod more, very simple but he was able to like copy the elements from one backpack, and make a seperate custom backpack, and change it up.

#

if the launcher has to be equip able, then it might change your approach. Where as if you just opened up an artillery computer of a scripted spawn artillary, you could trigger that through the mission event flare gun script. You can even customize the colors i think

#

so white flare, red flare, green flare could all do different things

plush nova
tough abyss
#

i see

acoustic abyss
steel fox
#

Are you creating the mock up in the eden editor?

acoustic abyss
#

I got the gist of the nearestobjecs command. I have an array of all sorts of objects. How do I "place" the array to see what I've extracted 😆 ?

steel fox
#

loop over the array and create the object with create3DENEntity command

acoustic abyss
#

Let's see!

steel fox
#

ah, and rotation is done with set3DENAttribute

acoustic abyss
#

Oof I'm stuck here. My extracted array using nearestTerrainObjects and nearObjects does not have position data for all these detected objects. And _ create3DENEntity_ obviously needs that.

#

Let me look at your suggestion 😄

steel fox
#

that might help yeah...

#

although if you use it in the same editor environment. you could just run the getPos on the object in the recreation code.

#

then ctrl+c it to the other terrain.

acoustic abyss
#

I'll admit my scripting grammar isn't great. But Arma gives a "missing ;" error with this part of your script:


  _objectList pushBack [typeOf _x, getPosATL _x, getDir _x]

}```
steel fox
acoustic abyss
#

(nearObjects has no problem)

#

That was my first guess. No dice 😦

steel fox
#

then also forEach is missing its array

#

after the } it needs an array to loop over

acoustic abyss
#

I am going to brew some coffee...

plush nova
#

doesn't foreach go after the block, not before?

acoustic abyss
#

depends on the command. I am not familiar with pushback :/

plush nova
#

so forEach is geenrally used like

{
  dothingwith _x;
} forEach someList;
steel fox
#

yeah

#

it is

plush nova
#

whereas in the example it's being used like

forEach {
  dothingwith _x;
} someList;

which might work idk

#

but if there's a syntax error that'd be most likely to be the problem imo

steel fox
#
private _objectList = [];

{

  _objectList pushBack [typeOf _x, getPosATL _x, getDir _x];

} forEach (_pos nearObjects _radius);

that is how it should be

acoustic abyss
#

Ahhhh, I was looking in the wrong scope :(. I will try this.

#

That's odd.

acoustic abyss
#

(_pos nearObjects _radius); ^ This does give a list of objects.

steel fox
#

_pos is a position and _radius is set to a number right?
It works for me

kindred zephyr
#

is it possible to avoid a large number display as a scientific notation? Just today I learned that arma only likes to show up to 6 digit numbers only, sadly 😦

steel fox
#

_objectList is local to the script.

acoustic abyss
#

For debugging, I used player for _pos and 100 for _radius. Again, the command (_pos nearObjects _radius); gives a list of objects, fine.

#

OK.

kindred zephyr
#

it's a integer @steel fox - sorry bad ping

#

that must be displayed as is

acoustic abyss
#

I already tried making the objectList a global variable. @kindred zephyr what is an integer?

steel fox
#
objectList = [];

{

  objectList pushBack [typeOf _x, getPosATL _x, getDir _x];

} forEach (_pos nearObjects _radius);
objectList

this will return your object and make objectList global.

acoustic abyss
#

ahhhhh

acoustic abyss
#

position player.

#

D'oh.

steel fox
#

no player works

acoustic abyss
#

Oh. Because it seems to work now.

#

Armacebo effect?

steel fox
#

as long as it works

acoustic abyss
#

I am clearly not getting part of this. But thanks.

steel fox
kindred zephyr
#

@steel fox a gui, but I was using small numbers for test, the actual number goes over 1mil and its being shortened sadly, its being already converted into a string befor being shown

steel fox
#

how are you getting the number? cut it up, convert to string, then add it all back together?

steel fox
#

that will output the number as you want it

kindred zephyr
#

@steel fox thanks but found an easier solution using the next command:

_number toFixed 0; //Number has 10 digits

It takes advantage of the fact that it already transforms the number into a non-shortened version and the hides the decimals using 0 spaces

steel fox
#

I saw that, does that just retain the amount of digits and not just do a round?

#

toFixed 2 gives you a nimber with 2 digits. I thought toFixed 0 would give you, well the first digit only.

kindred zephyr
#

No, its doesnt seem to work like that. It takes the float and according to the numbers of decimals you want to shows shortens or lenghtens after decimal. Setting it to 0 hides the decimal and still show an unshortened float

little raptor
#

it'll be inaccurate

#

numbers in SQF are floats

tough abyss
#

And yet people are still writing configs with float values into the quadrillionths for some reason

#

hit = 7.0000000000001

#

lets say you have an array of classes, and you need to add , 0.001 into the array after each config, how would you do that?

little raptor
tough abyss
#

yes

#

i have all the classes

#

i can make up the 0.001

little raptor
#

there are many ways

#

the shortest one is:

flatten(_array apply {[_x, 0.001]})
tough abyss
#

okay thanks

#

i will have to look into flatten, and apply

#

ive never seen those before

#

flatten is very useful and also unfortunately not very well known

little raptor
#

it's new

tough abyss
#

yeah 2.02

past wagon
#

I'm getting Error: Undefined Variable in Expression on this line in initServer.sqf:

call TRI_fnc_pathZone;

This is my description.ext:

class CfgFunctions {
    class allFunctions {
        class TRI {
            class lootSpawn {
                file = "functions\lootSpawn.sqf";
            };
            class vehicleSpawn {
                file = "functions\vehicleSpawn.sqf";
            };
            class gameFlow {
                file = "functions\gameFlow.sqf";
            };
            class pathZone {
                file = "functions\pathZone.sqf";
            };
        };
    };
};

Not sure what the problem is :/

tough abyss
#

class Extended_Init_EventHandlers { class Man { init = "_this call (compile preprocessFileLineNumbers 'entSpawn.sqf')"; }; };

#

this is mine

#

i have cba

#

ehh it wont help lol

#

idk what yours is trying to do

past wagon
#

im sure it is lmao

#

what did I do wrong

little raptor
#
class CfgFunctions {
    class TRI {
        class category {

that's how it should be

past wagon
#

ahhhh

#

but wait

#

seems to be showing up fine there ^

past wagon
past wagon
tough abyss
#

Yeah you had the tag and the category flipped around so it's registering them as

#

category_fnc_fncName

little raptor
#

your function name is: allFunctions_fnc_blabla

past wagon
#

yeah im a little stupid

#

just a little

tough abyss
#

clearly the best route here is to change it to BIS_fnc_functionName 😉

#

well i get errors but my script works

#

What errors are you getting?

#

part of the function

#

c1 addCuratorEditableObjects [[z1], true]; if (isServer) then { {[_x, [-1, -2, 0]] call bis_fnc_setCuratorVisionModes;} forEach allCurators; }; configs = [(configfile >> "CfgGroups" >> "West" >> "rhs_faction_usmc_wd"),2,false] call BIS_fnc_returnChildren; loadouts = []; {loadouts pushBack getText (_x >> 'vehicle')} forEach configs; publicVariable "loadouts"; loadouts apply {[_x, 0.01]}; loadouts append ["ModuleRemoteControl_F", 0]; [c1, loadouts] call BIS_fnc_curatorObjectRegisteredTable;

#

this is my init sqf

#

it works, it makes the zeus only able to place faction units + remote control module, but like i get errors

#

Didn't end up using flatten?

#

it works without it, flatten seems to need [] [[]] [[[]]]

#

loadouts apply {[_x, 0.01]} will produce that

#

as you're turning every class into a sub-array

little raptor
tough abyss
#

well i just have one zeus module and one player

#

at the moment

little raptor
#

loadouts append ["ModuleRemoteControl_F", 0];

#

this is inconsistent with the rest of your array

little raptor
tough abyss
#

easy to plug in c1 zeus z1 player

little raptor
#

I'm not talking about that

#

loadouts =
for example

tough abyss
#
configs =
loadouts =
#

oh I don't have a good grasp of local and public variables

fair drum
#

reminder that flatten gives an array as its return. it does not modify the original array

tough abyss
#

but i do have somewhat of an understanding

past wagon
#

Sorry guys, apparently I'm kind of rusty with Arma scripting at the moment. I have a function that is supposed to run in init.sqf but nothing is happening. The script is not running at all.

This is my description.ext:

class CfgFunctions {
    class TRI {
        class allFunctions {
            class lootSpawn {
                file = "functions\lootSpawn.sqf";
            };
            class vehicleSpawn {
                file = "functions\vehicleSpawn.sqf";
            };
            class gameFlow {
                file = "functions\gameFlow.sqf";
            };
            class pathZone {
                file = "functions\pathZone.sqf";
            };
        };
    };
};

This is my init.sqf:

call TRI_fnc_pathZone;

This is my function, pathZone.sqf:

_pathZonePos = [["centerZone"], ["water"]] call BIS_fnc_randomPos;
_pathZoneDir = random 360;

"pathZone" setMarkerPos _pathZonePos;
"pathZone" setMarkerDir _pathZoneDir;

_sideA = 10000 * (sin _pathZoneDir);
_sideB = 10000 * (cos _pathZoneDir);

_pathZonePos params [_posX, _posY, _posZ];
_pathStartPos = if (random 1 > 0.5) then {
    [_posX + _sideB, _posY + _sideA]
else {
    [_posX - _sideB, _posY - _sideA]
};

player setPos _pathStartPos;

The map markers pathZone and centerZone are placed in the editor. I am running the mission but nothing is happening and I have no clue why. I'm not getting any error messages or anything.

little raptor
tough abyss
#

global*

#

anyway but my error is getting a string for a number

#

in the function

tough abyss
little raptor
little raptor
past wagon
tough abyss
#

well i still have error, but everything works, or well let me check the remote control module

little raptor
tough abyss
#

hmm im going to try and use flatten then

#

with the pushback

past wagon
tough abyss
#

@tough abyss If you're going to be flattening it, you can switch it back to append

past wagon
#

did you mean this:

call { TRI_fnc_pathZone };

?

little raptor
past wagon
#

ok yeah lmao 😅

little raptor
#

I said missing }

past wagon
#

yeah

tough abyss
#

nvm

little raptor
past wagon
#

i just realized that. where should I put the } ?

#

yeah

tough abyss
#

well I lost my module

#

with pushback

#

and still have error

little raptor
past wagon
#

ohhhhhhh

#

i see

little raptor
#

your if then

past wagon
#

yep

#

sorry

#

thanks

tough abyss
#

@tough abyss

loadouts apply {[_x, 0.01]}

try switching that to

loadouts = flatten(loadouts apply {[_x, 0.01]});
#

and switch the pushback to an append

past wagon
#

okay so what is a linter? I cant find anything about one on the wiki

tough abyss
#

It's just software that does checks for basic syntax errors like that

#

included in some text editors and I believe there's also been a few made specifically for arma

past wagon
#

oh cool

tough abyss
#

Idk why when i threw flatten in there it didnt work

#

because you didn't store it anywhere

tough abyss
#

you need to tell it to store it in loadouts

#

otherwise it does nothing

past wagon
#

yeah ive just been coding in python recently for school so I get mixed up sometimes I guess

little raptor
#

you shouldn't flatten it

tough abyss
#

idk right now, my zeus is limited to one faction, everything costs 1 point.... ill figure out how to do different costs for the units, but for now i have to look at listeners for alive events 😦

little raptor
#

altho according to the wiki you should thonk

tough abyss
#

It is the correct syntax

#

according to biki

little raptor
#

not that function

tough abyss
#

Well that's the function he's using

#

¯_(ツ)_/¯

#

the flatten fixed all my errors

#

and even fixed the costs

#

so things are not free

#

DId you change your pushBack to an append?

#

Otherwise that will not do what you want

#

yes

little raptor
tough abyss
#

I tried

#

maybe i forgot a bracket

#

He tried to but he wasn't storing the return

#

oh

#

he just did flatten() with no variable assignment

little raptor
tough abyss
#

Simple mistakes, grats on getting it working though

#

and for the love of god start using private vars instead of globals

jade acorn
#

hey, working on a single player mission. I have a conversation system which requires a certain key to be clicked in order to open it. In my case I'd like to use Space, which is by default binded to opening stuff. Can I change the default binding of this key within a mission or a mod, so it's not binded to more than two actions but just that convo? I am using CBA so it may be easier, however I'm not sure if it's even possible.

little raptor
#

why not just use that?

tough abyss
#

so this has nothing to do with scripting, why cant i fire a m136? the rhs rocket launcher

#

disposable

#

I can zoom, but it wont fire

#

its like rhs is broken, other people get a sight

little raptor
tough abyss
#

its a disposable isnt it?

little raptor
#

¯_(ツ)_/¯

#

does it have a mastersafe or something? thonk

tough abyss
#

ill chekc

#

whats master safe?

little raptor
#

I don't remember what it's called

tough abyss
#

oh cool

#

theres a reload thing

#

well rhs settings are dumb

#

and i turned it back on, i figured it out thanks

plush nova
#

is there a way to "reset" or cancel the current gesture without affecting the primary animation

little raptor
past wagon
#

I'm looking for something to make a plane just fly in a completely straight path. I just want it to fly at a set altitude at max speed for like 5 minutes without turning or anything. Waypoints have been a little unreliable. Anyone know of a method that might work?

little raptor
#

or maybe "<none>"

plush nova
#

hmm ok i'll try those

#

presumably using playactionnow ors omething similar, right

little raptor
#

yeah

little raptor
past wagon
#

ok

#

thank you

fiery gull
#

Is it not possible to remove the main turret from the prowler?

``` doesn't do anything but it is listed as an animation in the cfg
past wagon
warm hedge
brazen lagoon
#

any suggestions on how to do a checkpoint system? I wanna do a race, and my ideal system is like Forza Horizon's checkpoint system

#

can I just do this with the stuff from Karts DLC?

tough abyss
#

@brazen lagoonJust have a trigger that stores the vehicle's pos and orientation in a global var and then use that data

brazen lagoon
#

what do you mean

#

as in use a trigger as checkpoints?

tough abyss
#

Yes

#

You can get a vehicle that activates a trigger

#

and then store that vehicle's position and orientation in a var

#

and then have some other system that takes that var and moves the vehicle back to that position and orientation

#
private _vehicle = vehicle player; // Get this via a trigger
LAST_CHECKPOINT = [getPosWorld _vehicle, [vectorDir _vehicle, vectorUp _vehicle]];
#

so this would store the data

#

and then to "load" the checkpoint you could just do this

#
private _vehicle = vehicle player;
_vehicle setPosWorld LAST_CHECKPOINT#0;
_vehicle setVectorDirAndUp LAST_CHECKPOINT#1;
#

would need some refinement and customization to work exactly how you want but that'd be the core of it

#

hey

#

anyone on?

#

i want to make a nothing variable, and then use an expression to assign the variable if it does not exist

#

isnil and isnull i am confused on

#

haha nvm, either var = nil will work because its nil, or it will work because its a latch, I think my code will work regardless if i understand how to check if variables exist

#
if (isNil "VarName") then {
  //...
};
#

it has to be in quotes?

#

got it

#

it has to be either quotes or code

#

for your purpose quotes is best

#

thanks

past wagon
#

So, I have a plane that flies a long distance from its starting point to a single waypoint. The problem is that it does not fly in a straight line. It usually starts out flying at the wrong angle, and slowly corrects itself after if has already drifted off-course a bit. I would like it to fly in an (almost) perfectly straight line. What can I do to fix this?

flint topaz
past wagon
flint topaz
#

set it’s direction to a calculation of the direction you need?

past wagon
#

yes

#

I already have

#

it starts in the right direction, and on its way to the waypoint it swerves around a bit and doesnt always go completely straight like I want it to

#

I want to minimize that

flint topaz
#

Gotta love arma 🤦‍♂️

past wagon
#

mhm

tough abyss
#

@past wagonYou could have some sqf that continuously corrects its direction, but it could result in weird behavior

#

something like this

#
// ForcePlaneDir.sqf
_this spawn {
  params["_plane", "_flightTime", "_dir"];
  private _startTime = diag_tickTime;
  while {diag_tickTime - _startTime < _flightTime} do {
    _plane setVectorDir _dir;
    sleep 0.1;
  };
};
#

just a rough method but might work for what you want

#

you just input the plane, the time you want it to keep it straight for, and the desired direction

#

alternatively if you just want it to keep whatever direction it starts with so you don't have to input a vector, this would do the trick

#
// ForcePlaneDir.sqf
_this spawn {
  params["_plane", "_flightTime"];
  private _startTime = diag_tickTime;
  private _startDir = vectorDir _plane;
  while {diag_tickTime - _startTime < _flightTime} do {
    _plane setVectorDir _startDir;
    sleep 0.1;
  };
};
#

first version you could do [plane, 20, [1,0,0]] execVM "ForcePlaneDir.sqf" for a 20 second flight straight along the X axis

#

second version could just do [plane, 20] execVM "ForcePlaneDir.sqf" for a 20 second flight along its initial direction

wind cairn
#

does a forEach loop change how a script runs?

steel fox
#

Wdym? Change the scope? No. Its just a loop

wind cairn
#

In one of my scripts, having a forEach loop at the end of the function messes up the entire running of the script. most of the parameters passed in are made null and it breaks the functioning of the rest of the script

#

should i link the code

winter rose
wind cairn
#

I made a reddit post with all the info, should i jsut link that?

#

has the output and stuff

steel fox
#

Please put the code in sqfbin aswell. Thw syntax highlighting makes everything easier

wind cairn
#

ok

steel fox
#

Also, reddit is slow on my phone meowsweats

wind cairn
tough abyss
#

Looks like a deltaT issue to me, the code that converts the objects for text output with str probably gets scheduled after some of the objects are deleted by the forEach

#

resulting in NULL-object

wind cairn
#

does system chat need to be converted to str?

tough abyss
#

Are the objects successfully deleted or is it just the text output you're concerned with?

wind cairn
#

with the forEach loop all objects are deleted, and without it none are deleted

steel fox
#

Makes sense, the other code doesn't have a deleteVehicle anywhere

wind cairn
#

yeha :/

tough abyss
#

So sounds like it works fine then?

#

I believe what I described above is what's causing your text output to fail

wind cairn
#

yeah trying that now

wind cairn
steel fox
#

Is the code called or spawned? If spawned, don't and try calling it.

wind cairn
#

called

tough abyss
#

@wind cairn What'd you change?

wind cairn
#

removed all the text outputting

tough abyss
#

Oh I wasn't saying that it'd fix deletion, just that I had an idea why your text wasn't outputting properly

wind cairn
#

oh ok

tough abyss
#

So you're saying it's deleting all of the objects instead of all but one?

wind cairn
#

yeah

tough abyss
#

Hm

wind cairn
#

i think the issue has to be something with the forEach loop, since with it commented out text outputting and the array altercations work perfectly

steel fox
#

Try using apply instead of a select? And just delete with that?

tough abyss
#

Code overall looks fine, looks like some weird code conflict of some kind

steel fox
#

Idk why the forEach is doing the wonky and can't test so id day just

_missionObjects apply ([{deleteVehicle _x}, {_x}] select _x isEqualTo _objectToKeep);
#

On phone so expect atleadt one syntax error meowtrash

still forum
#

_x is is undefined?

#

In the isEqualTo

steel fox
#

Welp

#

Wrap it in the code block with a call

wind cairn
#

_objectsToDelete = _missionObjects apply { if (_x != _objectToKeep) then {deleteVehicle _x} };

#

this seems to work

steel fox
#

Yeah, i was tying to eliminate the if

#

But that works aswell

tough abyss
#

Code clarity is far better than reducing chars/statements

#

if SQF had proper ternary operations it'd be another story but I hate when people do it w/ array select

still forum
#

_x isNotEqualTo _objectToKeep && { deleteVehicle _x}

:D

steel fox
#

No

#

No

#

Thats the worst of all, using lazy eval

wind cairn
#

What confuses me, does apply not do exactly the same thing as a forEach loop? iterating over the array and applyin the code to each entry?

still forum
#

But you want to delete all objects but one? Why not just do

_missionObjects - [_objectToKeep]

Then you don't need to check inside the loop

still forum
wind cairn
#

huh weird

tough abyss
#

No the worst of all is ```sqf
{
deleteVehicle _x;
} forEach (allMissionObjects - [_objectToKeep]);

wind cairn
#

lmao

steel fox
#

Well, that changes the whole code function but true

winter rose
#
DELETE * FROM mission_objects
steel fox
#

Yeah, dedman caught that already

still forum
steel fox
tough abyss
#

Indeed it was meant to be humorous

#

I can't see why you'd ever want to delete all mission objects but 1

wind cairn
#

so I can have multiple spawn points for an item whihc is randomly selected

#

Couldn't find any other way of doing it

still forum
#

Huh?
You spawn a item at many spots, then delete all but one?

tough abyss
#

Oh god

wind cairn
#

i guess, ik its inefficient

tough abyss
#

Why not just.... randomly select a spawn point?

#

And then spawn it?

steel fox
#

Why not just selectRandom the array of pos?

still forum
wind cairn
#

yeah thats actually a way better idea

still forum
winter rose
wind cairn
#

is createVehicle supposed to create 2 objects?

#

it seems likes its creating the object at the desired location but then creating a second one at a random position close to the object

tough abyss
#

createVehicle should only create a single object

#

what's your code look like?

wind cairn
tough abyss
#

That looks fine

#

What about your code that calls that?

wind cairn
#

function call

#

[["box1Pos", "box2Pos", "box3Pos", "box4Pos", "box5Pos", "box6Pos"]] call Buzz_fnc_boxSpawner;

tough abyss
#

Are any of the objects placed in 3DEN beforehand?

wind cairn
#

nope

#

this stuff makes no sense sometimes

tough abyss
#

Ah I know what's happening

#

You don't have any code to prevent multiple objects from being spawned at the same position, and when it tries to do so, since CAN_COLLIDE is not a param in your createVehicle call it prevents them from colliding by putting the second one away from the existing one

#

So you need to either prevent multiple objects from spawning at the same pos or set CAN_COLLIDE to allow them to spawn at the same pos

wind cairn
#

But why is it trying to spawn multiple objects anyway?

tough abyss
#

I presume you run the code multiple times?

wind cairn
#

nope, just once in the init.sqf

tough abyss
#

Well that is peculiar then

wind cairn
#

no idea whats happining

tough abyss
#

See if it happens spawning in a different object perhaps?

wind cairn
#

yeah still happens

winter rose
wind cairn
#

dedicated server

winter rose
#

so it's created once by the server then once by every connecting client

wind cairn
#

ah

winter rose
#
if (isServer) then { /* */ };
```but better use `initServer.sqf` 😉
wind cairn
#

thank you!

tough abyss
#

Welp that was more straightforward than I imagined

#

Should've just asked that

wind cairn
#

yep

crude vigil
# wind cairn dedicated server

Probably your other code had same problem as well, dedi was first deleting it then you were questioning why only one object is left... thats cos the dedi side left only that object from random selection.

wind cairn
#

That would make a lot of sense aswell

#

🤦‍♂️

tough abyss
#

And so the usual answer to these types of problems surfaces

#

"networking fuckery"

wind cairn
#

Yep, I didn’t even know it was called on the client aswell since it didn’t say on the little descriptions on the event scripts page

tough abyss
#

The biki documentation is notoriously patchy

crude vigil
#

what are you using? init.sqf ?

tough abyss
#

some things are given in extreme detail and others are expecting you to revive dead languages to understand what they're talking about

winter rose
#

well, if you need moar details don't hesitate to ping in #community_wiki, we can sometimes provide edits where needed 🙂

tough abyss
#

Yeah don't get me wrong, a lot of the pages are pretty nice

#

just a few notable areas where things are incredibly vague

#

nice work on that script optimization page btw, lots of good stuff there

winter rose
# tough abyss just a few notable areas where things are incredibly vague

no worries, we are aware that the wiki ias, hem, quality differences let's say 😄 but sometimes we don't notice/work on it because it may be assumed that people know / deduce / find in outside resources, so something that appears "obvious" to us may need to be addressed
don't hesitate, it's a genuine, healthy invite 🙂

tough abyss
#

Fair enough, I'll let you guys know next time I stumble into a rough part of documentation 😛

#

I'll say one area that is severely lacking in proper documentation as far as I can tell is anything regarding .RTMs

#

Mostly have to resort to outdated youtube videos and vague outdated posts on the forums

winter rose
#

ooooooh yeah.
and that's definitely not my turf 😬

#

(but we have @warm hedge on our team *hint hint* 😏)

tough abyss
#

😮

warm hedge
#

wha-

winter rose
#

you
write RTM
nao

😄

#

we shall call the article… RT(F)M 😂

tough abyss
#

From the experiences friends and I have had with them, should be more like RTFA

#

as in Run The Fuck Away

#

but yeah any improvement to that documentation would be vastly appreciated by many I assume

#

Oh yeah and another thing

#

the BISkeleton.p3d that pretty much every RTM tutorial tells you to use is super hard to find on the internet unless you know someone who already has it

#

the original BI download link for it has been down for god knows how long

#

and with armaholic down most links on the forums to it are dead as well

#

had to find it on some ancient apache webserver

pliant stream
#

those torrents still work

tough abyss
#

Blech, torrenting

pliant stream
#

what's wrong with torrents?

tough abyss
#

Nothing but it shouldn't be the standard for distributing files

#

It's 2021, let me download things with my browser in 1 click

reef flint
#

Does playsound work on a multiplayer server? will the other players hear it?

tough abyss
#

Nope, has local effect

#

Can remoteExec it to get around that, though

reef flint
#

Could you give me an example?

tough abyss
#

Sure!

#
["soundName"] remoteExec ["playSound"];
#

just change soundName to whatever your config sound name is

reef flint
#

Wow, that's a lot simpler than I thought. This is able to be executed via trigger on Radio Alpha, right? And this'll be heard by all players? (global sound)

tough abyss
#

This will be global, yes

#

As for execution via trigger

#

make sure that the trigger code isn't already running locally for each player, if it is you can stick w/ just basic playSound w/o remoteExec

reef flint
#

Sorry, kinda got lost there now. how do I make sure it isn't running locally for each player? Will the server only condition mitigate that?

tough abyss
#

Yes the server only condition would do that

reef flint
#

If you mean that all players will have the trigger for Radio Alpha execution, they don't, only one player will have it

tough abyss
#

What I'm saying is if you want to do remoteExec you need to make sure it's only executing on the server

#

but might be better to just stick w/ normal playSound w/ locality

#

aka just use playSound w/o remoteExec

#

basically, playSound only runs locally but if your trigger gets run for every player locally then that doesn't matter

reef flint
#

Or I should try it out with server only condition. I've found that using regular playSound without remote exec doesn't let the sound play globally

tough abyss
#

Yup worth a shot

reef flint
#

Might be because it's a dedicated server

#

Thanks so much! I'll try it out and see if it works!

tough abyss
#

No problem, if you run into issues and I'm still awake I'll try to help you out

reef flint
#

That means a lot. Thanks!

craggy lagoon
#

Is there a way to get the correct ammo name for a static weapon? I'm attempting to create a rearm ammo create for the "RHS_Stinger_AA_pod_WD" turret and when I attempt to use "rhs_ammo_fim92_missile" or "rhs_mag_2Rnd_stinger" with the "call ace_rearm_fnc_createDummy" command it will create the ammo box but the turret won't rearm. I've been able to make this work for other static weapons so I'm guessing I'm just using the wrong type of ammo.

craggy lagoon
#

@little raptor That is where I got the rhs_ammo_Fim92_missile name from and I didn't see anything else in there.

#

I'll keep looking.

tough abyss
#

@craggy lagoonIf you have the weapon available as an object, you can get its exact current ammo type like this w/ debug console

currentMagazine weapon;
#

Actually, if it's a turret you may want to use this

craggy lagoon
#

I wasn't able to get anything back with them. If I use the Huron Ammo container to span an rearm box for the stinger turret I'm able to reload the turret. What could I run on the ammo box that is spawned from the Huron ammo container to see what it contains?

digital hollow
craggy lagoon
#

I'm sorry I'm not following what you mean by that's not how it works? You can spawn individual ammo rearm boxes with Ace. Just need to change your settings Ace Logistics, Rearm, Rearm Amount set to Amount based on caliber.

digital hollow
#

Right, but those boxes don't contain the "ammo" inventory item. They are just dummy objects that abstract the ability to increase the vehicle's ammo state.

pale glacier
#

Hello!
This script locks doors (usually in house \ object init) and if a unit have a "key" item in their inventory, it opens the door \ gate.
Problem - doesn't work in MP. Can you please point me to the issue?

If !isServer exitWith {};
[this, player] spawn { params ["_door", "_unit"];
    _door setVariable ['bis_disabled_Door_1', 1, true];
    waitUntil {sleep 1;
        if (
            (_door getVariable ['bis_disabled_Door_1', 1]) >0 &&
            {_unit distance _door < 3} &&
            {'Keys' in (uniformItems _unit + vestItems _unit + backpackItems _unit)}
        ) then {
            _door setVariable ['bis_disabled_Door_1', 0, true]
        };
        (_door getVariable ['bis_disabled_Door_1', 1]) ==0
    };
    waitUntil {sleep 1; (_door animationPhase 'Door_1_rot')>0};
    _unit groupChat "The gate is open";
    _unit removeItem 'Keys'
};
digital hollow
#

It's run on server and being passed player

pale glacier
#

Can you be more gentle with me? 😂
I'm pretty noob in Server stuff
So what do I need to do exactly?

cosmic lichen
#

player variable is unknown on the server.

#

Just check if a player is in range.

digital hollow
#

You'll need to do your checks per-player

{
    private _unit = _x;
    // do your checks
    
} forEach allPlayers;
pale glacier
#

Alright, I'll dive into it. Thanks guys

crude vigil
#

To me , it looks fine if this code was done on all non server instances as well. But in case you want to pass it to server, that groupChat will not work as you expect either (message will only be seen on server so either only for hosting player or for no one in dedi scenario.)

pale glacier
crude vigil
#

Actually in both cases groupChat will fail anyways.

crude vigil
pale glacier
#

Yeah will do. Thanks

teal turret
#

hello again people 🙂

#

I just dont understand the wiki

#

and another thing
i am trying to get the ai units get out from heli, they do get in but then i cant make them get out of the heli when heli is landed

#

i just dont understand

#

can someone explain it to me?

#

i even tried to unnassign vehicle

little raptor
teal turret
#

heliback3 is the name of the helicopter

little raptor
#

I know

#

you say it doesn't work

#

and in the next line you say it works

#

that's the wat

little raptor
teal turret
#

at it is
heliback3 land "land dont work but when i type ["true", "heliback3 land 'LAND'"];

little raptor
#

the helicopter pilot must be "ready" for landing to work

#

so if you use waypoints the second code is the correct way

teal turret
#

how do i put the code in the chat

winter rose
wicked roostBOT
#
How to use SQF syntax highlighting in Discord

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

// your code here
hint "good!";
winter rose
teal turret
#

thanks

#

//  _wh0 setWaypointType "MOVE";
_wh0 setWaypointSpeed "NORMAL";
_wh1= getMarkerPos "_heppa";
_wh1 = _GG2 addWaypoint [_wh1, 0];
heliback3 land "LAND";
_wh1 setWaypointType "TR UNLOAD";
heliback3 disableAI "TARGET";
heliback3 disableAI "AUTOTARGET";
heliback3 allowfleeing 0;
heliback3 setbehaviour "CARELESS";
_wh1 setWaypointStatements ["true", "heliback3 land 'LAND'"];
sleep 10;
{soldier action ["getOut", heliback3]};
doGetOut ["_s1", "_s2", "_s3", "_s4", "_s5"];
```sqf
#

lol xDD

little raptor
teal turret
#

thanks @little raptor

crude vigil
teal turret
#

heliback3 land "LAND"; dont work
but
setWaypointStatements ["true", "heliback3 land 'LAND'"]; works

#

i am sorry i cant articulate myself wert well

#

very*

crude vigil
teal turret
#

so i managed to make the heli land like this

#
_heli_1= createVehicle ["RHS_UH60M2_d", getMarkerPos "_paddi_1", [], 0, "NONE"];
_heli_1 setdir 140;
_heli_crew1 = [getMarkerPos "mkr_heli", west,2] call BIS_fnc_spawnGroup;
_units = units _heli_crew1;
_units params ["_h1","_h2"];
_heli_crew1  addVehicle _heli_1;
[_h1] orderGetIn true;
[_h2] orderGetIn true;
//=======================


_wh0 = _heli_crew1 addWaypoint [getMarkerPos "_heppa", 0];
_wh0 setWaypointType "TR UNLOAD";
_wh0 setWaypointSpeed "FULL";
_wh0 setWaypointBehaviour "SAFE";
_heli_1 land "LAND";
#

now the crew even lands without any problem 🙂

plush nova
#

so it seems like if i createUnit then immediately addWeapon/addMagazine to it, it works in SP but not MP (running from a client, unscheduled)

#

addWeapon and addMagazine seem to be local argument/global effect and createUnit creates the unit locally right

#

so this should work

#

or is there some weird init where createUnit doesn't "finish" until it's told the server so it's not a valid unit for inventory purposes

tough abyss
#

Try addWeaponGlobal and addMagazineGlobal

#

just be careful not to run addWeaponGlobal on dedi server as it's broken for dedi

little raptor
plush nova
tough abyss
#

Never had any issues applying commands to objects immediately after creation

little raptor
plush nova
#

hmm ok it seems to work but it's very dependent on how long i sleep for

#

addMagazineGlobal seems to work but i also need to setIdentity which doesn't, so i still need to sleep :/

tough abyss
#

@plush novaYou could just remoteExec setIdentity like so

#
[params] remoteExec ["setIdentity"];
plush nova
#

so i am remoteexecing it

#

it just only works if i sleep 1 first inside a spawn

tough abyss
#

Odd

plush nova
#

if i createUnit and then immediately remoteExec setIdentity it doesn't work

#

yeah

tough abyss
#

I mean if it works

#

¯_(ツ)_/¯

plush nova
#

yea hi'm just worried it will randomly not work because of lag or something

tough abyss
#

Safe option might be to do something like this

#
fnc_IdentifyAfterInit = {
  params["_unit", "_identity"];
  waitUntil {!(isNull _unit)};
  _unit setIdentity _identity;
};
publicVariable fnc_IdentifyAfterInit;
[_unit, _identity] remoteExec ["fnc_IdentifyAfterInit"];
#

or define fnc_IdentifyAfterInit somewhere else first so you don't have to publicVariable it

#

up to you though, sleep will probably be fine in most cases

plush nova
#

hmm

#

oh i see

#

that makes sense yeah

#

ill try it out

tough abyss
#

hey

#

so im trying to give all players zeus, but it seems like the code doesn't work unless its local or when the player has already spawned and not in loadout menu.

#
_logic = createCenter sideLogic;
_logic = createGroup sideLogic;
_zeus = _logic createUnit ["ModuleCurator_F",[0,0,0],[],0,"NONE"];
_zeus setVariable ["Owner", ""];
_zeus setVariable ["Name", ""];
_zeus setVariable ["Addons", 2];
_zeus setVariable ["Forced", 0];
[_x, _zeus] remoteExec ["assignCurator",2];
_zeus addCuratorEditableObjects [[_x], true];
[_zeus, [-1, -2, 0]] call bis_fnc_setCuratorVisionModes;
_zeus addCuratorPoints 0.1
 }forEach (call BIS_fnc_listPlayers);
steel fox
#

run it local with initPlayerLocal? saves you the remoteExec

tough abyss
#

and that would work?

#

alright ill look into it

steel fox
#

whoops

#

Nope Nope

#

assignCurator is a server command.

tough abyss
#

They're remoteExecing it on the server though

#

so should work fine

#

well so i put it in a init player local sqf

#

and well was not a solution

steel fox
#

Did you remove the forEach?

tough abyss
#

_logic = createCenter sideLogic;
_logic = createGroup sideLogic;
_zeus = _logic createUnit ["ModuleCurator_F",[0,0,0],[],0,"NONE"];
_zeus setVariable ["Owner", ""];
_zeus setVariable ["Name", ""];
_zeus setVariable ["Addons", 2];
_zeus setVariable ["Forced", 0];
[_player, _zeus] remoteExec ["assignCurator",2];
_zeus addCuratorEditableObjects [[_player], true];
[_zeus, [-1, -2, 0]] call bis_fnc_setCuratorVisionModes;
_zeus addCuratorPoints 0.1;```
#

Also createCenter sideLogic is unnecessary

#

all sides have centers created automatically in arma 3

#

awesome

#

thanks

#

np

#

hmm ill probably take a break, but yeah, after this problem then i gotta solve alive problems

#

like i have a script that makes every west vehicle a respawn vehicle, to get the player closer to the action, but theres no way to preload alive units