#arma3_scripting

1 messages · Page 776 of 1

little raptor
#
params [
            ["_centre", getPosASL player, [[]]], ...
];
private _pos = _centre getPos [_radius, _dir];
_pos set [2, _center#2];
_bolt setPosASL _pos;
worthy igloo
#
        params [
            ["_centre", getPosASL player, [[]]],
            ["_radius", 250, [0]],
            ["_dir", random 360, [0]]
        ];
        _pos = _centre getPos [_radius, _dir];
        _pos set [2, _center#2];
        _bolt = createVehicle ["LightningBolt", _pos, [], 0, "CAN_COLLIDE"];
        _bolt setPosASL _pos; 
        _bolt setDamage 1;
``` gave an error
little raptor
#

what error?

open fractal
worthy igloo
#

lmao i fixed works now

#

thanks for help

little raptor
#

well the code isn't strictly correct tho

#

if the terrain is not flat what I wrote is wrong

#

better use AGL format

little raptor
#

it will always strike at the "ground" (sea if sea, terrain if terrain)

#

what I wrote before might've given you a position under the terrain if you tried it on a mountain for example

worthy igloo
#

?

little raptor
#

that part probably no

#

but the lights yes

#

afaik light commands are local

worthy igloo
#

so vice versa ?

mortal saffron
#

Can someone help me with a script for making a respawn point off a back pack. I have it working for the most part, except the the respawn module does not always deploy at the backpack (pack) position...

#

So far i have

#

`if (hasInterface) then
{
// ------------------------------------------------------------------------
_allowDeployRespawn = player getVariable ["allowDeployRespawn",false];
if !(_allowDeployRespawn) exitWith {};
// ------------------------------------------------------------------------

// deploy respawn
player addAction ["Deploy Respawn",{
    [west, pack, "Camp"] call BIS_fnc_addRespawnPosition;
},nil,1.5,true,false,"","",3,false,""];

// ------------------------------------------------------------------------

};`

little raptor
#

There's nothing two way about this

elder verge
#

Doesn anyone have a working zombie script that changes civies into zombies? I searched online for it, and either i got people asking for money, or broken links

little raptor
#

zombies need animations

#

You can't do that with scripts

#

You need some zombie mod

#

There's a ton of those on the workshop

elder verge
#

I've been in a vanilla official zeus session and this guy had zombies everywhere, it was so cool

little raptor
#

You sure they weren't a bunch of wounded civilians?!

#

Because vanilla doesn't have zombie anims

elder verge
#

they were hunched over running, different "styles" like runners, quiet ones, and a boss zombie like a windego

#

thw boss zombie wore like a giant deer head with antlers, wearing a ghillie suit

#

it could jumo as high as buildings and shit, was super cool. wasn't sure how to replicate that on vanilla

#

i'd very much like to learn how this is done so i can get other zeus to do it and have immense amounts of zombie slaying fun

true bear
#

Hey guys, I'm doing a spawn script, but I'm having trouble setting an identity to the spawned jet. Anyone know of a simple line to name the spawned object? ```_airframe1 = [getMarkerPos "marker1", 140, "B_Plane_Fighter_01_F", west] call BIS_fnc_spawnVehicle;

_crew1 = _airframe1 select 2;
_wp1 = _crew1 addWaypoint [getMarkerPos "marker2", 0];
_wp1 setWaypointType "MOVE";
_wp1 setWaypointSpeed "CARELESS";

_wp2 = _crew1 addWaypoint [getMarkerPos "marker3", 0];
_wp2 setWaypointType "MOVE";
_wp2 setWaypointSpeed "CARELESS";
_wp2 setWaypointStatements ["true", toString {_veh = vehicle this; deleteVehicleCrew _veh; deleteVehicle _veh}]```

tough abyss
#

Hello everyone, is it possible to use setVelocity and setVectorUp simultaneously in a loop? When creating a loop like this, the object does not respond to setVelocity, but if you remove setVectorUp, then everything is fine

addMissionEventHandler ["EachFrame", {
    _vUp = ...some calculations...;
    _velocity = ...some calculations...;

    myObject setVectorUp _vUp;
    myObject setVelocity _velocity;
}, []];
little raptor
#

But you're doing that

#

So it should already be good thonk

little raptor
true bear
#

trying to set a variable name so i can use triggers in game for it

#

tried lines like _veh setVehicleVarName "jet1"; missionNamespace setVariable ["jet1", _veh, true]; but didnt work

little raptor
true bear
#

oh, no I defined it with the _airframe1. but still didnt work 😮

little raptor
#

_airframe1 is an array

#

the vehicle is the 1st or 2nd element in the array

#

Not sure which

#

Check the wiki

true bear
#

oh wait. so if I define the vehicle, like B_Plane_Fighter_01_F it should work?

little raptor
#

No

#

Just check the wiki

#

Array format [createdVehicle, crew, group]:

#
_veh = _airframe1#0
true bear
#

it worked! but still a bit confused. why the #0 ?

tough abyss
# little raptor So it should already be good <:thonk:700311400152825906>

Tested it like this, instead of calculations I set standard values. Unfortunately, the object was moving, but not smoothly, it was constantly jerking. In general, it seems that currently in Arma it is impossible to simultaneously change the vector of an object and push it via setVelocity

addMissionEventHandler ["EachFrame", {
    _vUp = [0, 0, 1];
    _velocity = [20, 0, 0];

    myObject setVectorUp _vUp;
    myObject setVelocity _velocity;
}, []];
winter rose
true bear
#

ah got it thanks

devout gazelle
#

Anyone know what is wrong with this line?

{_vehicle unassignVehicle _x} foreach units _group;

(I'd like to use this on a waypoint activation )

warm hedge
#

Does it know what _vehicle is?

#

Oh yeah true what he said

devout gazelle
#

I defined it

#

Ah wait...

#

haha I didn't name the vehicl.. i named the unit in the vehicle 😛 XD

#

Thanks

granite sky
#

(unassignVehicle only takes a single unit parameter)

devout gazelle
#

Nope- still getting error:
On activation: (Thats it)

Missing ;

#

{QRF_Veh unassignVehicle _x} foreach units QRF_1

warm hedge
#

An error tells nothing without the actual code, show us

devout gazelle
#

Aight. I used this instead.

{ unassignVehicle _x } forEach crew QRF_Veh; crew QRF_Veh allowGetIn false;

opal zephyr
#

It looks like wounded civilians with their movement speed and animations sped up, and a janky attack thats probably an entirely unrelated animation. Its cool that someone did it in vanilla, but was probably a lot of work

proven charm
#

Is the iskindof a slow command? Like does the engine have to make a loop or something to check it?

drifting portal
#

@little raptor in case you are wondering

#

and when you are in contact with them it damages you a bit and starts a whole series of ppEffects

#

and its generally a pretty 'laggy' script

#

early versions of it crashed servers too

drifting portal
drifting portal
#

I would say really fast

proven charm
#

hmm ok

drifting portal
# proven charm hmm ok

tried
allMissionObjects "Air";
result:
Execution Time: 93.0909 ms | Cycles: 11/10000 | Total Time: 1024 ms

proven charm
#

what about doing >> on configs, is that fast or slow?

drifting portal
#

you should try checking if a method is slow or not by using code performance in debug console

proven charm
#

yeah I'm going to try. thx for the help, appreciated!

#

just how relatively fast everything is I don't know

#

Result:
0.0008 ms

Cycles:
10000/10000

Code:
configfile >> "CfgVehicles"

drifting portal
proven charm
#

yeah I see it's definitely slower

#

another test (getting slower):

#

Result:
0.0014 ms

Cycles:
10000/10000

Code:
configfile >> "CfgVehicles" >> (typeof player)

drifting portal
#

yes the more you add to it the more it gets slower

#

that's config

proven charm
#

sure thing

#

hmm I think this check helps to see the relative speed:

#

Result:
0.0003 ms

Cycles:
10000/10000

Code:
_i = 578; _i

drifting portal
tough abyss
#

i assume you know the tho coz your uzing EZM

copper raven
proven charm
drifting portal
copper raven
versed widget
#

there is issue with inputAction command when action has double input like eject which is "x2 V" sometimes the code executes sometimes not i still cant figure how to fix that

drifting portal
#

This number ranges from 0 to 1

#

Just make the condition > 0

versed widget
warm venture
#

Does anyone know how I could check if an item is a weapon or optic?

#

(from a gui/dialog shop)

warm venture
# proven charm BIS_fnc_itemType
  class gang {
      name = "Hideout Armament";
      side = "civ";
      conditions = "";
      items[] = {
          { "hgun_Rook40_F", "", 200, 0, "" }, //Rook 9mm
          { "hgun_PDW2000_F", "", 200, 0, "" }, //PDW2000
          { "SMG_02_F", "", 200, 0, "" } //Sting 9mm
    };
    mags[] = {
          { "16Rnd_9x21_Mag", "", 200, 0, "" }, //16Rnd 9mm Mag
          { "30Rnd_9x21_Mag", "", 200, 0, "" }, //30Rnd 9mm Mag
          { "30Rnd_9x21_Mag_SMG_02", "", 200, 0, "" } //30Rnd 9mm SMG Mag
    };
    accs[] = {
          { "acc_flashlight", "", 200, 0, "" }, //Weapon Flashlight
          { "optic_ACO_grn", "", 200, 0, "" }, //ACO - Green
          { "optic_Aco", "", 200, 0, "" } //ACO - Red
    };
};

Do you know how I could check if an item is inside the accs[] section?

young current
viral basin
#

Hey there, i added a $pboprefix$ file to my pbo with the content bla. Afterwards i used the prefix in an include like #include \bla\fileinthesamepbo.hpp but i always get Include file bla\fileinthesamepbo.hpp not found. - did i do anything wrong? Or don't prefixes work in a simple mission pbo? Greetings

worthy igloo
young current
#

just does not add up, sorry

abstract shuttle
copper raven
#

or even better - there probably is a user action EH for that

versed widget
#

i may just wrap the code in while loop to check when the player is outside vehicle at 200m high, though i hate the sound of it

#

oh wait i misunderstood addUserActionEH that may come in handy actually

drifting portal
#

Account for both pathways

#

that's how I done my eject script

little raptor
drifting portal
#

yes? if statment?

little raptor
#

Why add a slow EH when there's a fast EH for it?

drifting portal
#

which one?

little raptor
#

User action

drifting portal
#

what if a person ejects via double V

little raptor
#

Doesn't it trigger in user action?

drifting portal
#

no

#

idk tbh

drifting portal
#

i have done _text = "Eject"

#

as far as that goes it won't trigger when double V

#

maybe with other condition it does? idk

drifting portal
little raptor
#

What does it have to do with what I said?

#

I said user action

#

That's UI action

drifting portal
#

so I'm confused

little raptor
drifting portal
#

well I will count that on google then lol

copper raven
#

user action triggers when the action happens, it doesn't have to do anything with keys

versed widget
versed widget
drifting portal
#

yes but ignore that

#

since I had a mis understanding of how something works

#

don't follow my method

worthy igloo
neon swift
#

Hey Y'all Trying to make a scrip that creates a trigger for part of it and I just can;t get it to work.

_trig = createTrigger ["EmptyDetector", _dz, true]; _trig setTriggerArea [15,15,0,false,-1]; _trig setTriggerActivation ["B_T_VTOL_01_vehicle_F", "PRESENT", false]; _trig setTriggerStatements [ "this", "objNull setVehicleCargo _vic;", "'UNLOADING NOW!' remoteExec ['systemChat'];" ];

What am I doing wrong?

#

_dz is the a pos for where the trig should be. It should be activated by the VTOL flying over but it doesn't seem to see it

little raptor
#

And _vic is not defined in the trigger activation statement

neon swift
#

They are defined earlier in my script. sorry was packed with other lines didn't feel like grabbing them.

just so u know this is how I'm defining them.

`private _spawn = [getMarkerPos _start, 1, 50, 5, 0, 0.25, 0] call BIS_fnc_findSafePos; //find safe place to spawn Heli
private _dz = getMarkerPos [_drop, true]; //finds the 2D spot for where to drop supplies. Returns a PositionAGL
private _kill = getMarkerPos [_end, true]; //finds the 2D spot for where the heli should end its flight.

private _crew1 = creategroup civilian; //sets vic crew to civ faction so nobody will shoot at the VTOL while it makes its delivery.
private _crewLead = leader _crew1;
private _vic1 = [_spawn, 0, "B_T_VTOL_01_vehicle_F", _crew1] call BIS_fnc_spawnVehicle; //spawn the vic on the spawn position.
private _v = _vic1 select 0; //Vic1 is an array containing both the vic and its crew. This line selects the Heli out of the array for later editing.
private _pos = getPosATL _v; //find the VTOL's pos
_v setPosATL [(_pos select 0), (_pos select 1), (_pos select 2) + 150]; //sets Heli's altitude to 50 meters off the ground`

_start, _end, _drop, _vic are all defined in params by the user. _vic is the only object, the rest are markers.

granite sky
#

well, _vic still won't be defined in the trigger statement.

#

Trigger statements run in a separate scope.

neon swift
#

oh even if they are in the same script??

granite sky
#

Yes.

#

You can effectively pass vars into trigger statements by setting variables on the trigger and then reading them back.

neon swift
#

yeah writing it out now one sec

#

`_trig = createTrigger ["EmptyDetector", _dz, true];
_trig setTriggerArea [15,15,0,false,-1];
_trig triggerAttachVehicle [_v];
_trig setTriggerStatements
[
"this",
"missionNamespace setVariable ['LX3_cargoDrop', false, true];",
"'UNLOADING NOW!' remoteExec ['systemChat'];"
];

if (LX3_cargoDrop == false) then {
objNull setVehicleCargo _vic;
sleep 5;
missionNamespace setVariable ["LX3_cargoDrop", true, true];
};`

#

still not kicking crate out the back

mortal saffron
# little raptor What is pack?

"pack" is the name of the object (backpack) that the player carries. I have based it off an addaction that is mostly working but i do not understand how to script

open fractal
#

!code

wicked roostBOT
#
How to use SQF syntax highlighting in Discord

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

// your code here
hint "good!";
neon swift
#
if ([missionNamespace getVariable "LX3_cargoDrop"] == false) then {
    hint "code goes here!";
};
#

it's not finding when it goes false

hallow mortar
#

Why is your getVariable enclosed in []? it's not an array

still forum
#

comparing variables to ==false or ==true basically never makes sense.
If its already a boolean it doesn't make sense, if its not it will error

neon swift
#

very new if ya can't tell lol

hallow mortar
#
if !(missionNamespace getVariable ["LX3_cargoDrop",true]) then { ...```
[] are used for _arrays_, a data type consisting of multiple values. You need () for order of precedence stuff like this.
I have switched to the other syntax of `getVariable` so you don't get an error if this is checked before the variable gets defined.
#

Note the use of ! before the if condition. This means "reverse boolean". Without it, if the condition evaluates to true, it does the then. With it, if the condition evaluates to false, it counts as true (reversed) and it does the then.

#

As Dedmen mentioned, you don't need to do if (_boolean == true) -type checks, because that's just checking if the boolean is true and then...returning another boolean that's true. You only need to return the original boolean; it will already be true or false.

neon swift
#
if !(missionNamespace getVariable ["LX3_cargoDrop",true]) then {
    'UNLOADING NOW!' remoteExec ['systemChat'];
    sleep 5;
    missionNamespace setVariable ["LX3_cargoDrop", true, true];
};

This is what I am using. I know the var is being set to false but I'm still not seeing my hint to know this if statement ran

hallow mortar
#

When does this if get checked?

neon swift
#

shortly after the trigger that changes it. Adding a wait unil now

hallow mortar
#

Are you checking it shortly after the trigger activates, or shortly after you create the trigger?

neon swift
#

trigger activates.

hallow mortar
#

Why not just put it in the trigger?

mortal saffron
neon swift
little raptor
# mortal saffron I probably have not defined pack. I dont know how to make this work and am looki...

try:

if (hasInterface) then
{
    // ------------------------------------------------------------------------
    _allowDeployRespawn = player getVariable ["allowDeployRespawn",false];
    _pack = backPackContainer player;
    if (!_allowDeployRespawn || isNull _pack) exitWith {};
    // ------------------------------------------------------------------------    
    pack = _pack;
    // deploy respawn
    player addAction ["Deploy Respawn",{
        [west, pack, "Camp"] call BIS_fnc_addRespawnPosition;
    },nil,1.5,true,false,"","",3,false,""];

    // ------------------------------------------------------------------------
}; 
little raptor
#
_trig = createTrigger ["EmptyDetector", _dz, true];
_trig setTriggerArea [15,15,0,false,-1];
_trig triggerAttachVehicle [_v];
_trig setVariable ["my_vehicle", _vic];
_trig setTriggerStatements 
    [
        "this", 
        toString {
          _vic = thisTrigger getVariable ["my_vehicle", objNull];
          objNull setVehicleCargo _vic;
          'UNLOADING NOW!' remoteExec ['systemChat'];
        }, 
        ""
    ];
neon swift
#

until a few mins ago I had no idea triggers had isolated variable spaces. Taking notes, ty

mortal saffron
#

@little raptor No errors, but the addaction did not appear. I have been using this in the backpack init [this, ["Deploy Respawn",{[west, pack, "Camp"] call BIS_fnc_addRespawnPosition;},nil,1.5,true,false,"","",3,false,""]] remoteExec ["addAction",0,this];

little raptor
#

and pack is not defined in that code either

mortal saffron
little raptor
#

in fact it breaks everything

mortal saffron
#

Its working with [this, ["Deploy Respawn",{[west, pack, "Camp"] call BIS_fnc_addRespawnPosition;},nil,1.5,true,false,"","",3,false,""]] remoteExec ["addAction",0,this]; except the respawn position looks like it is not on the backpacks actual position in the respawn menu. Works most of the time but not all. So thought a script mite help

#

ah

little raptor
#
this addAction ["Deploy Respawn",
{[west, _this#0, "Camp"] call BIS_fnc_addRespawnPosition;}
,nil,1.5,true,false,"","isNull objectParent _originalTarget",3,false,""]
#

try that

mortal saffron
#

no error, yet no addaction

little raptor
#

which are not backpacks at all

#

they're just weapon holders

#

it will show if you change isNull objectParent _originalTarget to true

#

but it will only work once

#

once you pick up the bag then throw it elsewhere it will no longer work

mortal saffron
#

Would calling a script fix that?

little raptor
#

it can be fixed but needs a lot more work

mortal saffron
#

yeah, like getting player position and variables like if player has moved >500m and backpack is on ground etc

#

I just dont know how to do all that 😦

#

and respawn module called to pack position etc

#

should be in the vanilla somehow

little raptor
#

you just need a put event handler

#

you can add this in initPlayerLocal.sqf

player addEventHandler ["Put", {
    params ["_unit", "_cont", "_item"];
    
    if (getNumber (configFile >> "CfgVehicles" >> _item >> "isBackpack") == 1) then {
        if (_cont getVariable ["hasRespawnAction", false]) exitWith {};
        _cont addAction ["Deploy Respawn",{[west, _this#0, "Camp"] call BIS_fnc_addRespawnPosition;},nil,1.5,true,false,"","true",3,false,""];
        _cont setVariable ["hasRespawnAction", true, true];
    };
}];
little raptor
fossil coyote
#

_mycount = (count _items) -1; for "_x" to _mycount do { player addItemToUniform (_items select _x); };

This counts the items inside of a players uniform and makes sure that the original items are transferred to the different uniform when toggled using the ACE Self interact menu. What should be added so that a units insignia is also remembered and transferred over to the player in addition to the items?

little raptor
little raptor
little raptor
#

also fast/slow are relative terms

#

in general anything less than 1 us (0.001 ms) is fast (for SQF at least)

#

anything above 1 ms is slow. and typically will affect FPS (if unscheduled)

#

but as I said fast/slow are relative terms

#

e.g. if you want to multiply 5 by 10, doing this is slow (and stupid, and inaccurate), because you can just do 5 * 10:

_result = 0;
for "_i" from 1 to 10 do {
  _result = _result + 5;
};
```so that's why the real question you should be asking is what's faster than what you have in mind.
#

also it's important to consider where you're running something

#

e.g. a script that runs once at init and takes 0.1 ms is fast

#

but if that script runs every frame it's slow

little raptor
#

because they're compiled code

#

not interpreted like SQF

outer loom
#

Can I player setPosASL ... in multiplayer or it will cause some bug/desynchronizations? (Is there a better way to teleport player?)

little raptor
#

yes

solid kernel
#

I am calling getUnitLoadout on a unit that has containers (uniform, vest, backpack) inside its backpack, and I'm getting these boolean fields for the containers. I can't find any documentation on what they mean.
https://community.bistudio.com/wiki/Unit_Loadout_Array

[
    [],
    [],
    [],
    [],
    [],
    [
        "B_Carryall_khk",
        [
            ["H_HelmetIA", 1],
            ["200Rnd_65x39_cased_Box", 1, 200],
            ["B_Carryall_khk", true],     // backpack
            ["V_BandollierB_oli", false], // vest
            ["U_C_Poor_2", false]         // uniform
        ]
    ],
    "H_Cap_blk",
    "",
    ["Laserdesignator_03", "", "", "", ["Laserbatteries", 1], [], ""],
    [
        "ItemMap",
        "",
        "",
        "ItemCompass",
        "ItemWatch",
        ""
    ]
]
little raptor
#

false means it's not backpack (defined in CfgWeapons)

solid kernel
#

Backpacks are defined in a different config than vests 😃 . That's very Arma. Anyway it's probably worth mentioning on the wiki page what this boolean field means.

unique sundial
little raptor
proven charm
proven charm
#

assuming gang is defined in configfile

meager granite
#

Anyone seen Tried to AccessTargetList for non-local AI group while non-local targeting was disabled! Engine will now enable non-local targeting which will hurt clientside performance. client-side RPT error before?

#

My guess would be that it has something to do with disableRemoteSensors?

#

I have it as disableRemoteSensors true; on both clients and server, though not instantly, after some other loadings.

winter rose
meager granite
#

I barely have anything related to AI in my mission 🤔

#

There are few server-side createAgent's which do nothing but have an addAction on them, and some Logic units.

winter rose
#

any knowsAbout or such?
the sensors thing might be as well

#

as in
"the AI info won't be updated on the client to save CPU"
"I want AI info"
"OK, restarting the system at your own risk!"

meager granite
#

Single knowsAbout which totally doesn't happen on join (when this message shows up)

winter rose
#

in triggers perhaps?

meager granite
#

Nope

#

The only difference I had recently is that I made static units into createAgent instead of createVehicle so they work with animations better

winter rose
#

then idk, the mystery remains =)

meager granite
#

Very descriptive errors, thanks Arma very cool

meager granite
#

Apparently its on profiling build 🤔

unique sundial
velvet merlin
#

whats the most efficient way to get all players and the units in their groups (alive and dead) ?

granite sky
#

Maybe this in the worst case:

_players = allPlayers - entities "HeadlessClient_F";
_groups = [];
{ _groups pushBackUnique group _x } forEach _players;
_units = [];
{ _units append units _x } forEach _groups;
velvet merlin
#

had this, but apparently its terrible inefficient:

#
_revivableUnits = [];

{
    _revivableUnits pushBackUnique _x;
}
forEach (switchableUnits + playableUnits + allPlayers - (entities "HeadlessClient_F"));

_revivableUnitsCopy =+ _revivableUnits;

{
    _unit = _x;

    {
        _revivableUnits pushBackUnique _x;
    }
    forEach ((units (group _unit)));
}
forEach (_revivableUnitsCopy);

_revivableUnits```
#

tx. let me see how yours compares

granite sky
#

Should be slightly worse for low-player-count cases but a lot better if you have groups with multiple players in them.

velvet merlin
#

down to 0.467

#

still quite expensive

#

alternative could be a cache with initEH + killed + entityDeleted - fairly complex and if "player in group" state can change, need still to track that by other means

willow hound
#

What's your use case?

devout gazelle
#

Anyone know a skip time command that sync with all players on the server?

willow hound
drifting portal
drifting portal
#

I read that, still confused lol

#

like for example when does Deactivate fire?

#

when does Analog fire too?

#

if somebody changes their VTOL vectoring, is that analog ?

granite sky
#

I would guess that Analog fires if you manage to attach an analog input to a user action.

#

and that input changes at all.

#

activate/deactivate would be keyup/keydown triggered

drifting portal
#

hmm

granite sky
#

(well, vice versa)

drifting portal
#

I thought deactivate related to if a user deactivates an action

#

such as dismounting a bipod

#

after mounting it

#

still confused about analog, is it supposed to be something like thrust or vectoring?

granite sky
#

Doesn't match the spec anyway. He said all units in player groups.

meager granite
#

Oops, messed up

#

@velvet merlin ```sqf
diag_codePerformance [{
private _players = switchableUnits + playableUnits + allPlayers;
private _revivableUnits = [];
{
_revivableUnits append units _x;
} forEach (_players arrayIntersect _players - entities "HeadlessClient_F");
_revivableUnits arrayIntersect _revivableUnits;
}]

#

[0.00332,100000] vs yours [0.00455,100000] on my PC

winter rose
granite sky
#

arrayIntersect is pretty bad for large arrays.

meager granite
#

yeah, needs test on a real server

#

Still having heavy engine command is sometimes better than lots of simple sqf commands

#

better as in quicker

opal zephyr
#

disableCollisionWith is simply not working for me. I'm trying to disable collision between a static object and a plane, that should be ok right? Since only one is a physx object. I've also tried disabling simulation on the static object as well to see if that helps but it doesnt. The line of code disabling the collision is placed at the bottom of the code so it runs last

velvet merlin
meager granite
#

@velvet merlin Ran yours vs mine script on live server with 90 players, no AI though

#

["0.28633",10000] vs ["0.18398",10000]

#

Maybe using just allPlayers without playableUnits can help it though if you don't need AI on playable units slots

#

allPlayers returns dead players too, unlike playableUnits

meager granite
#

So I did an extreme test to see which code works better to return unique units, spawned 100 groups of 8 AI players and used allUnits instead of allPlayers to simulate a case if there is say 800 players all grouped up in small groups.

    private _players = allUnits;
    private _leaders = (_players arrayIntersect _players - entities "HeadlessClient_F") apply {leader _x};
    private _revivableUnits = [];
    {
        {
            _revivableUnits pushBackUnique _x;
        } forEach units _x;
    } forEach (_leaders arrayIntersect _leaders);
    _revivableUnits;
```^ `["8.83972",100]`
```sqf
    private _players = allUnits;
    private _leaders = (_players arrayIntersect _players - entities "HeadlessClient_F") apply {leader _x};
    private _revivableUnits = [];
    {
        _revivableUnits append units _x;
    } forEach (_leaders arrayIntersect _leaders);
    _revivableUnits arrayIntersect _revivableUnits;
```^`["8.62000",100]`
#

So append and then arrayIntersect is a bit better in case where all players are grouped up and there are no AI

#
for "_i" from 1 to 100 do {
    private _pos = player modelToWorld [0,10 * _i, 0];
    [_pos, side group player, configFile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry" >> "BUS_InfSquad"] call BIS_fnc_spawnGroup;
};```to spawn these 800 test units
#

Now if we pick 100 random units from allUnits to assume they're players (unknown if leaders or not) with

allPlayersTest = (allUnits call {
    private _return = [];
    for "_i" from count _this to 1 step -1 do {
        _return pushBack (_this deleteAt floor random _i);
    };
    _return;
} select [0, 100]);

performance results are

{
    private _players = allPlayersTest;
    private _leaders = (_players arrayIntersect _players - entities "HeadlessClient_F") apply {leader _x};
    private _revivableUnits = [];
    {
        {
            _revivableUnits pushBackUnique _x;
        } forEach units _x;
    } forEach (_leaders arrayIntersect _leaders);
    _revivableUnits arrayIntersect _revivableUnits;
}
```^`["2.38037",100]`
```sqf
{
    private _players = allPlayersTest;
    private _leaders = (_players arrayIntersect _players - entities "HeadlessClient_F") apply {leader _x};
    private _revivableUnits = [];
    {
        _revivableUnits append units _x;
    } forEach (_leaders arrayIntersect _leaders);
    _revivableUnits arrayIntersect _revivableUnits;
}
```^`["1.19019",100]`
#

once again, append and arrayIntersect are much better in a case with 12.5% of units being "players".

#

So in the end

    private _leaders = (allPlayers - entities "HeadlessClient_F") apply {leader _x};
    private _revivableUnits = [];
    {
        _revivableUnits append units _x;
    } forEach (_leaders arrayIntersect _leaders);
    _revivableUnits arrayIntersect _revivableUnits;
```for just `allPlayers`
or
```sqf
    private _players = allPlayers + switchableUnits;
    private _leaders = (_players arrayIntersect _players - entities "HeadlessClient_F") apply {leader _x};
    private _revivableUnits = [];
    {
        _revivableUnits append units _x;
    } forEach (_leaders arrayIntersect _leaders);
    _revivableUnits arrayIntersect _revivableUnits;
```for several commands for initial list.
#

Not sure if you even need switchableUnits, not exactly sure how team switch works

#

Why leaders instead of groups? Tests show it works a bit quicker on same set of test data for whatever reason.

#

@velvet merlin ^

raw scaffold
#

I want an AL-6 PELICAN (drone) with the turret of the Darter. Anything is possible with arma but what needs to be done to make it happen?

opal zephyr
#

Like the camera turret?

#

If that is what you want, afaik that would need to be done on a config and model level and would require a custom modification of it, which being an arma asset would render it against the tos.

drifting portal
honest pilot
#

I try to make a trigger execute a line of code, but it dosen't work
if ["task3", "SUCCEEDED", "true"]; then execVm "KIA.sqf";

#

it says i need a boolean type

granite sky
#

what's the condition supposed to be?

honest pilot
#

but I did have add the ``

granite sky
#

(in english, given that your code doesn't make sense)

honest pilot
upper siren
#

is there any way I can "reignite" burning vehicle wrecks?

#

They seem to give out the best looking fire/smoke combination

granite sky
#

@honest pilot Yes, I mean describe in english what you want it to do.

honest pilot
#

but for that, it need the task3 to be succeeded

granite sky
#

Is this a task created with the BIS task framework? Like BIS_fnc_taskCreate?

#

Maybe:

if (["task3"] call BIS_fnc_taskState == "SUCCEEDED") then { execVM "KIA.sqf" };
honest pilot
#

oK

#

mb it would work

#

my game crash

#

ok

#

i'll try both

granite sky
#

nah that last one doesn't work. It needs a Task type as input.

honest pilot
#

oh ok

#

It works

#

thanks

polar bramble
#

I have made several functions inside a sqf file in my mission folder. How do I call them? (I’ve seen execVM, but I have multiple functions in one file)

granite sky
#

That's kinda bad practice these days, but all you need to do is set global variables to those functions and then execute the file once, like this:

MyTag_funcname = {
  // function code here
};
MyTag_funcname2 = {
  // other function code
};
versed widget
#

is there a way to get position of a selection, unfortunately non of the getpos command return a pos hitpoints or selections

willow hound
#

Combine selectionPosition with modelToWorld*.

versed widget
#

thanks !

tough abyss
#

Hello everyone, how can I find an extra element in an array?

tough abyss
winter rose
#

oh, array difference!

versed widget
#
  playSound3D ["Tire_Blowout_SFX\sound\WheelsPOP.ogg",
               _WheelASLPOS, false, getposASL _WheelASLPOS , 5, 1, 100]; ```
is it possible to skip the 3rd argument while using the ones after it ?
open fractal
#

you an "skip" optional arguments by just filling in the defaults

versed widget
open fractal
#

question, why don't you just use the sound source again for that parameter?

#

if _object is your sound source getPosASL _object can be your sound position

versed widget
#

im using selectionPosition to modelToWorldWorld to get ASL POS of a selection, the problem for me now is im getting error trying to change GetposASL with _WheelASLPOS

open fractal
#

is _WheelASLPOS an object?

versed widget
#

i have mistaken the first one should be _Veh and the second should be _WheelASLPOS, but still getting the error
_WheelASLPOS is location an Array

open fractal
#

read the wiki

#

you need an object for soundSource and an array for soundPosition

versed widget
#

soundSource is _Veh and soundPosition is _WheelASLPOS

open fractal
#

you can probably use objNull or something for soundSource since you're specifying a position

halcyon oar
#

Hey, anyone here knows a way to disable a specific zeus module?

winter rose
#

remove it from the mission?

hallow mortar
#

They might mean disabling Zeus' ability to use a specific module. If so, it might be possible to target it using removeCuratorAddons - the page for addCuratorAddons has an example of targeting an individual module so it seems like it should be doable. You'd need to find the module in the config somewhere to get the right name though, and I don't know if all mods have their zeus modules listed separately like that.

opal zephyr
#

I'm super new to multiplayer scripting and am reading through the page on the wiki for it. The main process of the script it creating an object and then adjusting its position and angle and such. I need to do much more research but figured id ask if anyone had any suggestions or methods they like to use to ensure things like this sync across clients

little raptor
#

all of which are global

#

so you don't need anything special for multiplayer

#

it's the same as single player

opal zephyr
#

I was looking at things like public variable, but those two things look neat

past yarrow
#

I have a suicide bomber script that creates a shack the bomber comes out of.

opal zephyr
#

The script could happen frequently, it relies on other events taking place. Is the one time thing comment because of sending a lot of info, or is there another reason for it?

little raptor
#

how frequent?

#

unless you mean several times every second don't worry about it

past yarrow
#

_slum = ["Land_Slum_House01_F","Land_Slum_House02_F","Land_Slum_House03_F","Land_cargo_house_slum_F"]; _slumHouse = selectRandom _slum; _building = createVehicle [_slumHouse, _newpos, [], 0, "CAN_COLLIDE"]; _building setVectorUp [0,0,1]; _building setDir random 360;

#

This works in multiplayer.

opal zephyr
#

Its pretty light and I think it would be alright. Ill test it out though

past yarrow
#

Moving things around isn't that taxing, creating things like that is.

opal zephyr
#

It would be optimal to run the whole script on the server though right Leopard? As apposed to running it one every client

little raptor
past yarrow
#

No need to run on every client.

little raptor
#

as I said in the beginning it's global

opal zephyr
#

Cool, and in terms of it being a mod, because its just running on the server and relies only on vanilla content, could the server be the only thing with the mod loaded? Assuming it was dedicated, if it was client hosted then that client would ofc have it

little raptor
#

it can, but I don't recommend making such assumptions when designing a mod

#

instead make sure everything is right yourself

#

e.g. if you want something to only run on the server, use the isServer check

opal zephyr
#

Ok, ill try and put this into practice, thanks again

opal zephyr
#

If I want to have the script run even if there is no server, i.e. if someone is in singleplayer. Would I go about that by going through all the clients and checking if any of them is a server, and then if none of them are run it normally?

little raptor
opal zephyr
#

ah ok

little raptor
#

server always exists

opal zephyr
#

is isNil supposed to check if a variable exists? Because it just gives me an error saying the variable isnt defined.. Like I know, thats the whole point of the check

hallow mortar
#

Make sure you're passing the name of the variable as a string ( isNil "_variableName" )

opal zephyr
#

woops, thanks

hallow mortar
#

Depending on your purpose, you can also use the alt syntax of getVariable which allows you to assume a default value if the variable is undefined

opal zephyr
#

The code looks like this :

if (isNil "_craterArray") then{
        _craterArray = ["1"];
        systemChat "created";
};
#

Its designed to run once at the start and then never again, however it isnt working and is running every time

hallow mortar
#

You're creating a local variable (indicated by leading _) which may not exist outside of the current instance of the script

opal zephyr
#

facepalm, ofc. Is there a way to go about it?

#

The script loops and I dont want to be resetting array every loop

hallow mortar
#

If you want the variable to be accessed by other scripts on the same machine, make it a global variable (not the same as a network global variable) by omitting the _

opal zephyr
#

Ill be running the script on a server which will be distributing its content to the clients. The script is called in an event handler and I need the script to belong to only that object from the event handler

#

Wouldnt a global variable defeat that purpose?

hallow mortar
#

Sorry, it's too late in the day for me to wrap my head around what you're trying to do here

#

If someone else doesn't get to it I'll try to remember to come back tomorrow

opal zephyr
#

All good haha, thanks for your help already

#

To better articulate what I said above. I need to loop a function called from an EH and use a local array inside of it. My problem is with creating the array at the start, because if I loop over it every time then it would be reset to empty everytime which I can't have. I need the array to belong only to the object the event handler its attached to.

little raptor
#

which will be distributing its content to the clients.

#

I hope you don't mean the array

opal zephyr
#

no, just the position and existence of the objects in the array

#

Using the commands you mentioned above

little raptor
#

position is an array. and the client can get the pos themselves

#

why broadcast it?

opal zephyr
#

I thought I had to

#

I was going to create it all on the server and then use setVectorDirAndUp as well as setPosWorld to update it everywhere so that the clients could see it the same way the server did

little raptor
#

it doesn't matter where you execute those

opal zephyr
#

What do you mean?

little raptor
#

I mean they take global args and have global effect

opal zephyr
#

ok, if im creating the objects on the server though I might as well execute them from there though right? Since the objects only exist on the server at that point... or does simply creating the vehicle create them across all clients as well?

little raptor
#

well at init yes, you should do createVehicle and setPosXXX, etc. together
if the object was not local, all clients get a copy as well
and the object is simulated where it's currently local

opal zephyr
#

So if I were to create it on the server during runtime and it was a static object then would I need to push information to the clients? Or would be doing it on the server be enough?

little raptor
#

but after init it doesn't matter where you execute setPosXXX, etc.

little raptor
#

your question makes it seem you didn't

opal zephyr
#

I read it, I may not have understood all of it though

#

Reading it makes me think remoteExec would work, however it would be calling the entire script on the clients instead of just the final positions

little raptor
#

again, what you're doing is all global. you only need remoteExec when either the effect or arg is not global

opal zephyr
#

I think im missing the idea on part of that, despite me using only local variables, the effects are still global across all clients?

little raptor
little raptor
#

when you make changes the server picks up the changes and syncs them

#

your question was like: if I create an object and assign it to a local var, does the object get deleted when the script ends (because the local var is destroyed)?

#

ofc not

opal zephyr
#

Ill try and put this into practice, I feel ill need a lot more experience with it before I understand it

little raptor
#

a local variable is a variable that is local to the script (or code), and once it's destroyed the var is destroyed too
but a local object is one that only exists on the current machine
also all global objects are always local to a certain machine (it can change), and that machine is responsible for letting the server know how to update the object

opal zephyr
#

Thankyou for all this info

honest pilot
#

hey I got a little problem on this script but i don't see it

_APC = createVehicle ["B_APC_Tracked_01_rcws_F", [18248.6,13528.9,0]]; _crew = createVehicleCrew _APC; _crew addWaypoint [17507.4,13198.6,0];

little raptor
#

it should work fine

honest pilot
#

0 elements given

honest pilot
little raptor
honest pilot
#

?

little raptor
#

groupName addWaypoint [center, radius, index, name]

#

it should be _crew addWaypoint [[17507.4,13198.6,0], 0];

honest pilot
#

but it's just a Pos

#

Ohhhhh

honest pilot
#

thanks

#

@little raptor also what should be the code to add passengers to the apc and make them disembarck once apc have reatch the Pos ?

#

like an group

little raptor
honest pilot
#

yea

#

but to spawn them into the APC

little raptor
#

moveInCargo

honest pilot
#

Ok

little raptor
#

for making them get out use this:

_wp = _crew addWaypoint ...;
_wp setWaypointStatements ["true", toString {commandGetOut thisList}]
honest pilot
#

so it should be
`
_Squad = (configfile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry" >> "BUS_InfTeam") call BIS_fnc_spawnGroup ;

_Squad moveInCargo _APC
`
ik for the move in Cargo but to spawn them

#

Ok

little raptor
honest pilot
#

Oh ok

#

thanks

honest pilot
#

@little raptor its says moveinCargo group waited 0 given

little raptor
#

also I don't know what translation you use for those texts but it's crap and meaningless

honest pilot
#

sry

#

_APC = createVehicle ["B_APC_Tracked_01_rcws_F", [18248.6,13528.9,0]]; _crew = createVehicleCrew _APC; _wp = _crew addWaypoint [[17507.4,13198.6,0], 0]; _wp setWaypointStatements ["true", toString {commandGetOut thisList}]; _wp setWaypointStatements ["true", toString {_APC = vehicle this; commandGetOut units this}]; isNil { _Squad = [[0,0,0], west, configfile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry" >> "BUS_InfTeam"] call BIS_fnc_spawnGroup; {_Squad moveInCargo [_APC, 1]; if (vehicle _APC != _APC) then {deleteVehicle _APC}} forEach units _Squad; };

#

I corrected the missed variables

#

but it still says that it need an Object to set on Cargo, but for the script _Squad isn't concider as a groupment

little raptor
#

why on earth did you change _x?

#

it's a magic variable

#
_APC =  createVehicle ["B_APC_Tracked_01_rcws_F", [18248.6,13528.9,0]];
_crew = createVehicleCrew _APC;
_wp = _crew addWaypoint [[17507.4,13198.6,0], 0];
_wp setWaypointStatements ["true", toString {commandGetOut thisList}];
isNil {
  _Squad = [[0,0,0], west, configfile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry" >> "BUS_InfTeam"] call BIS_fnc_spawnGroup;
  {_x moveInCargo _APC; if (vehicle _x != _APC) then {deleteVehicle _x}} forEach units _Squad;
};
#

try that code

#

don't change anything

honest pilot
#

OOk

little raptor
#

I corrected an error just now

honest pilot
#

Ok

#

that works

#

but it seems the group is After deleted

#

if i read the code

little raptor
#

did you try the new code?

honest pilot
#

yes

little raptor
honest pilot
#

ok

#

because form what i see the crew of the APC is getin'out the APC

#

but there is no group goin' outside the APC

#

Even more, it seems the Group ins't sit into the APC so it delete it

#

Maybe because the _x is concider as _crew

#

@little raptor

honest pilot
#

ah

little raptor
# honest pilot because form what i see the crew of the APC is getin'out the APC

try this then:

_APC =  createVehicle ["B_APC_Tracked_01_rcws_F", [18248.6,13528.9,0]];
_crew = createVehicleCrew _APC;
_wp = _crew addWaypoint [[17507.4,13198.6,0], 0];
_wp setWaypointStatements ["true", toString {commandGetOut (crew vehicle this - thisList)}];
isNil {
  _Squad = [[0,0,0], west, configfile >> "CfgGroups" >> "West" >> "BLU_F" >> "Infantry" >> "BUS_InfTeam"] call BIS_fnc_spawnGroup;
  {_x moveInCargo _APC; if (vehicle _x != _APC) then {deleteVehicle _x}} forEach units _Squad;
};
#

it should only dismount the units in squad

honest pilot
#

it does the same

little raptor
#

I just tested it

#

it works perfectly fine

honest pilot
#

the _Squad team don't exist

#

it got certainly deleted

little raptor
#

no

#

the script works fine

#

copy the whole script

#

and don't modify anything

honest pilot
#

I check it out on the spectator view, no squad of solidier appear on the list

little raptor
#

and restart your game

honest pilot
#

Ik

#

If I cut the code at _crew = createVehicleCrew _APC;

#

A squad of 4 appear at 0,0,0

#

but not in the APC

little raptor
#

like I said I just tested the code

#

and it works fine

#

I don't know what you're doing wrong, but the script should work

honest pilot
#

so u got passengers on the seat of APC ?

little raptor
#

yes

#

and they got to the marker

honest pilot
#

a team of 4

little raptor
#

and only that other squad got out

honest pilot
#

On witch map

little raptor
#

it doesn't matter

honest pilot
#

cause im on RV map

little raptor
#

the script should work fine

#

and if you don't believe me here it is

little raptor
#

the size of the VR terrain is 8192

#

you have a 18248.6 in your coordinates

#

it's way off the map

meager granite
#

Is there a way to get 3DEN's layer parent ID by layer ID?

#

Do I have to tap into UI to figure it out?

#

Expected Tree control on the left to have layer IDs as tvValue or something - nope

meager granite
#

Looks like all3DENEntities's layers order is the only thing I have, gonna have to compare it against tree on the left to figure it out

#

Unless I'm over-complicating it and there is a much easier way

proven charm
#

how good is the floating point comparison these days? is something like this reliable: 123.456 == 123.456

still forum
meager granite
#

If you're comparing coordinates, do vectorDistance, if some arbitrary float values have something like abs(float1 - float2) <, depending on what you need

still forum
#

123.456 == 123.456 is 100% reliable.
(122.456+1) == 123.456 is not

proven charm
#

humm I'm trying to use pushbackUnique [_cost,_itemName]; wasn't sure if that works, it looks like it does in my tests

little raptor
#

have fun 🤣

proven charm
little raptor
#

exactly

#

when is it true and when is it false? blobdoggoshruggoogly

#

you can't really predict it unless you do it the way CPU does it meowsweats

still forum
#

in a better world isEqualTo would compare exactly, and == would approximate by 0.00000001 😄

proven charm
#

as long as pushbackUnique works with floating points i'm happy

little raptor
#

ofc it works

#

every number in SQF is a float

#

how can it not work?

still forum
#

Well it "works"
it uses exact equal comparison

proven charm
#

dunno ;D

still forum
#

it uses isEqualTo

proven charm
#

ok great

little raptor
still forum
#

My visual studio even warns me about it 😄

little raptor
#

now it doesn't work meowsweats

proven charm
meager granite
#

Not sure why would you even need such unique floats, but something like

_a = createHashMap;
{
    _a set [_x toFixed 3, _x];
} forEach [0.7, 0.3+0.4];
values _a;
```might solve it for you
#

Tweak _x toFixed 3 to needed precision, round or whatever you need it for

still forum
#

or you could round them like
(round (_x * 100)) / 100
that might work okeyish

meager granite
#

Also hashmaps are amazing, thanks for making them happen, @still forum I use them a ton now.

#

And @unique sundial too, I guess?

unique sundial
#

floats comparison is done using epsilon usually

#

i have nothing to do with hashmap it’s all dedmen

meager granite
#

Wish we had <HashMap> = <HashMap> select <Code> though.

#

Had a usage for <HashMap> apply <Code> that would return resulting new HashMap with same keys buy code-returned values too

#

Will need a new command name though

little raptor
#
  • createHashmapFromArray
meager granite
#

Yeah, that's what I did instead of it

meager granite
#

No event handler for layer getting hidden\shown either? 🤔

outer loom
#
Toggleflashlight = addUserActionEventHandler ["headlights", "Activate", {

[[],{

    _flashlight = player getVariable ['flashlight', objNull];

    if (!(isNull _flashlight)) then {

        player setVariable ['flashlight', objNull, true];
        player say3D "click";
        detach _flashlight;
    deleteVehicle _flashlight;

    } else {

    _flashlight = "#lightreflector" createVehicleLocal position player;
        _flashlight setLightConePars [70, 25, 5];
        _flashlight setLightAttenuation [2, 6, 6, 0, 2, 15];
        _flashlight setLightIntensity 45;
        _flashlight setLightAmbient [1,1,1];
        _flashlight setLightColor [1,1,1];
        _flashlight setLightUseFlare true;
        _flashlight setLightFlareSize 0.5;
        _flashlight setLightFlareMaxDistance 500;
        _flashlight attachTo [player, [-0.05,0.04,0.2], "head",true];

        player setVariable ['flashlight', _flashlight, true];
    player say3D "click";
            };
    }]remoteExec ["spawn",0];
}];

Description:
I put this script in onPlayerRespawn.sqf
It works, if I start server solo, but when my friend join. _flashlight will not attach. Should I put that in every unit init?

Expectation:
_flashlight for every player that is on/off with headlights key biding and visible for other players.

still forum
#

why respawn, if you want on every player then put it into initPlayerLocal.sqf

#

Also if just ONE player switches their headlights, you want the lights of EVERY player to switch? Are you sure about that?
That seems unintuitive to me

outer loom
still forum
#

No its not global

#

keybinds are local

drowsy geyser
still forum
meager granite
little raptor
#

=== and !== too plz meowsweats (isEqualTo vs isNotEqualTo)

meager granite
#

Speaking of comparisons, checking if two variables reference same array or hashmap could be useful. I remember having a need for it at some point. I guess there is no way to do that efficiently?

#

#arma3_scripting_dreams

winter rose
winter rose
meager granite
#

~= feels like assignation\modification, similar to +=, /=, etc. in other languages

winter rose
#

fair
but isn't ~ usually some bitwise operator?

meager granite
#

yeah, doubt anything bitwise will ever be in SQF

#

Speaking of shorthand assignment operators, stuff like this get used all the time:

_array set [_index, (_array select _index) + 1];
```would've been great to have something like `_array inc _index` as a single command;
#

and something for subtraction

proven charm
#

(_array # _index)++ 😀

meager granite
#

Not possible with SQF at all

proven charm
copper raven
still forum
copper raven
#
makearray 0
assignto _ident
endstatement
getvariable _ident
push 0 // say this is x
callbinary pushback
endstatement
getvariable _ident
push 0
callbinary select
callunary ++ // this increments x

when you call this code, the array will be [1], the next time you call it, it's going to be [2]

meager granite
still forum
#

Yes, but if you'd make it replace the array element it wouldn't

little raptor
#

doesn't have to be array

_num inc 1;
_num dec 2;
still forum
copper raven
#

not speaking about arrays, incrementing just isn't a thing, arrays can be modified by reference because they have a makearray instruction, and it's always a new one

#

every other value is always the same reference, (push inst)

meager granite
# little raptor or just `inc _num`

Was talking about incrementing a value at index in array, would be

_array set [_index, _array select _index inc 1];
```while my motivation was replacing lots of commands with a single one
little raptor
still forum
#

Yes

#

thats why you cannot do that

little raptor
#

so it is possible to increment by reference

still forum
#

Yes but you can't without breaking stuff

copper raven
little raptor
#

why doesn't pushBack break stuff? thonk

meager granite
#

Also, where's muh hashMapNull thronking

still forum
copper raven
meager granite
#

Yep, I do that right now

little raptor
still forum
copper raven
#

it's a makearray, it's a new array everytime

meager granite
#

creates empty hashmaps though, triggers an OCD

still forum
#

Unless with bytecode with optimizer, then its sometimes a constant

copper raven
#

constants are strings, scalars, etc, the ones that are a push in the asm

still forum
copper raven
little raptor
copper raven
#

they are

#

you can't modify them

meager granite
#

Yeah, they return new null objects, but isn't empty hashmap bigger than null hashmap?

#

Muh bytes

still forum
copper raven
#

well with a proper analyzer you can find some other cases(atleast i did)

little raptor
#

just do it once meowsweats

copper raven
#

that sounds like a huge trap that can require some deep debugging once you fall into it 😄

meager granite
little raptor
#

or do count _hashmap == 0

#

which means it's empty and no extra bytes used blobdoggoshruggoogly

meager granite
#

I use it for getOrDefault and getVariable <array>

still forum
#

A empty hashmap is just a nullptr (plus some size variables). same as empty array. Its not expensive

meager granite
#

So createHashMap doesn't actually create anything until first set\merge\whatever? thronking

still forum
#

yes

meager granite
still forum
#

it creates a HashMap typed value, same as the other null commands

little raptor
#

same as empty array
you sure empty array is not an array with 0 size? thonk

still forum
#

empty array is a nullptr with two 0 sizes

winter rose
#

hashmapNull kinda

little raptor
#

SQF is weird... meowsweats

#

just when you think you know it... meowsweats

still forum
#

Well thats behind SQF, not really SQF itself 😄

proven charm
#

so isnull createHashMap is never true?

little raptor
#

it never works to begin with

meager granite
#

There is no isNull <HashMap>

copper raven
#

because it makes no sense

#

it's like saying add isNull []

proven charm
#

dedmen said "A empty hashmap is just a nullptr"

still forum
#

C++ land null != SQF land null

#

a null object is not (always) a nullptr, but its still null

proven charm
#

oh you were talking about c++ implementation?

little raptor
#

yes. SQF doesn't even have pointers

proven charm
#

alright 🙂

tough abyss
#

im having an error at ```sqf
_wepMagazines = getArray (configFile >> "CfgWeapons" >>_rifle >> "magazines");

expected config entry type string in a file that im executing btw
```sqf 
[]spawn{
spawnLoot = true;
  while{spawnLoot}do{
           _magazineArry = [1, 2, 3, 4];
        private _buildings = [];
        private _buildingBlacklist = [''];
        private _weaponPool = [''];
            _weaponPool = "
             getText (_X >> 'dlc') isEqualTo 'CUP_Weapons'
            " configClasses (configFile >>"CFGweapons");
             _buildings append (nearestObjects [player, ["house"], 50]);
             
        {
        
         _buildingPosition = [_x] call BIS_fnc_buildingPositions;
         
            {
                    _rifle = _weaponPool call BIS_fnc_selectRandom;
                    _magazineCount = _magazineArry call BIS_fnc_selectRandom;
                    _holder = "WeaponHolderSimulated" createVehicle [0,0,0];
                    _holder setPos _x;
                    _holder addWeaponCargoGlobal [_rifle, 1];
                    _wepMagazines = getArray (configFile >> "CfgWeapons" >> _rifle >> "magazines");
                    _magazines = _wepMagazines select 0;
                    _holder addMagazineCargoGlobal [_magazines, _magazineCount];
                    _holder addWeaponCargoGlobal [_rifle,1];
            } forEach _buildingPosition;
        }foreach _buildings;
    };
};  

meager granite
#

Anybody knows how to calculate rotation for 3DEN's rotation attribute? Googling on forums gave no working solutions.

warm hedge
#

rotation to what? Or What to rotation?

proven charm
#

@tough abyss make sure the _rifle variable is string

#

it looks like it's config

tough abyss
#

ive missed a lot of sleep today how would i do that again?

#

just _rifle = string right?

meager granite
proven charm
#

to make it string

warm hedge
#

So vectorDir vectorUp to rotation?

#

Think I've done an opposite already, but not sure this way

meager granite
#

Yes, or whatever can be had from the object

#

BIS_fnc_getPitchBank doesn't return anything close to values that 3DEN wants

tough abyss
# proven charm should be: configname _rifle

ive tried this but same error

[]spawn{
spawnLoot = true;
  while{spawnLoot}do{
           _magazineArry = [1, 2, 3, 4];
        private _buildings = [];
        private _buildingBlacklist = [''];
        private _weaponPool = [''];
            _weaponPool = "
             getText (_X >> 'dlc') isEqualTo 'CUP_Weapons'
            " configClasses (configFile >>"CFGweapons");
             _buildings append (nearestObjects [player, ["house"], 50]);
            _rifle = configName (configFile >> "CFGweapons"); 
        {
        
         _buildingPosition = [_x] call BIS_fnc_buildingPositions;
         
            {
                    _rifle = _weaponPool call BIS_fnc_selectRandom;
                    _magazineCount = _magazineArry call BIS_fnc_selectRandom;
                    _holder = "WeaponHolderSimulated" createVehicle [0,0,0];
                    _holder setPos _x;
                    _holder addWeaponCargoGlobal [_rifle, 1];
                    _wepMagazines = getArray (configFile >> "CfgWeapons" >> _rifle >> "magazines");
                    _magazines = _wepMagazines select 0;
                    _holder addMagazineCargoGlobal [_magazines, _magazineCount];
                    _holder addWeaponCargoGlobal [_rifle,1];
            } forEach _buildingPosition;
        }foreach _buildings;
    };
};  

little raptor
#

also didn't you ask this question before?

#

pretty sure I answered it thonk

meager granite
#

I did and I failed to figure it out back then

little raptor
#

this was my answer

#

I don't recall if I tested it

#

but it should be correct

proven charm
#
_wepMagazines = getArray (configFile >> "CfgWeapons" >> _rifle >> "magazines"); 
// To:
_wepMagazines = getArray (configFile >> "CfgWeapons" >> (configname _rifle) >> "magazines");
meager granite
proven charm
#

or simply to: ```
_wepMagazines = getArray(_rifle >> "magazines");

tough abyss
#

thanks for your help dude

proven charm
#

yw

modern meteor
#
visionMode[] = {"Normal","NVG"};

Does anyone know how to add thermal vision?

solid kernel
#

I want to add a backpack or vest to an ammo crate with stuff already inside. What is the easiest way?

I can do that by

  1. adding the backpack/vest to the crate
  2. calling everyContainer for the crate
  3. searching for the newly added backpack/vest in the output
  4. adding stuff to that
    This is quite complicated. Is there an easier way?
warm hedge
little raptor
#

As far as I know

warm hedge
#

If that's the only way, (which I do think so also) perhaps we can make a ticket so the commands will return the container

#

...Or, completely new command?

solid kernel
#

Can I assume that the newly added container is always the last element of everyContainer

#

or well, it doesn't seem to apply to vests, only backpacks. It looks like vests come first, then the newly added vest, then all backpacks.

#

although if we could assume that the newly added vest is always the last non-backpack element, it could still be found that way

modern meteor
warm hedge
modern meteor
#

sorry

#

didnt realise there is a seperate chat for it

fossil coyote
bright sparrow
#

Is there any way to disable or restrict mods on a server that is hosted via upnp (on pc)

winter rose
bright sparrow
halcyon oar
ruby plover
#

Hey, would anyone know how I could code it so that after a 7 second sleep command, I'd be able to force unconscious an entire squad? One of my friends suggested this but I'm really unsure, it'd be on a trigger, what I have currently is this:

[4] spawn BIS_fnc_earthquake;
sleep 7;

winter rose
ruby plover
#

Is the x a replacement or just part of the code

open fractal
#

triggers also execute code unscheduled, you will need to wrap it in [] spawn {"code here"} to use sleep

granite sky
#

Huh. Used leaveVehicle on a pilot group. They got out of the thing and then got back in again and flew off.

#

I guess there is no reliable way to reverse addVehicle

open fractal
#

maybe it's bugged and you need to unassign it as well?

granite sky
#

unassignVehicle specifically doesn't remove the group assignment.

#

leaveVehicle is the only one that's supposed to touch it, although I suspect the TR Unload waypoint also does for cargo groups.

opal zephyr
#

After last nights assistance with understanding multiplayer coding I tried to get things to work with it. I converted my script into an addon as I have in the past without issue and am executing the script from the postInit section of my config. The actual script contains a "isServer" check at the beginning of it.

The script runs correctly in both singleplayer and localhosted sessions, however it does not on dedicated servers. I've tried executing it a number of ways, including initServer and havnt had any luck.

The contents of the script is just some createVehicle and position updates on said vehicles, which i've been told update globally by themselves.

granite sky
#

Scatter some diag_logs around, then you'll know what's executing and what isn't.

opal zephyr
#

Ok ill try that. Would it show up in the server rpt since thats where im calling it?

granite sky
#

Yes.

#

Make sure you're not using -nologs

#

server should call preInit, initServer.sqf, postInit and init.sqf in that order.

opal zephyr
#

Hmm, I can't seem to find its rpt file, is it supposed to be located with the other rpt's?

granite sky
#

What other RPTs...

opal zephyr
#

The standard client ones

granite sky
#

It'll be in the server's profile folder.

#

Which shouldn't be the same as the client profile folder.

opal zephyr
#

ah, thanks

drifting portal
#

A really simple question,

_MagList = magazinesAmmo player;
_SortedMags = [];
{
    _MaxCapcity = getNumber(configFile >> "CfgMagazines" >> _x >> "count");
    
} forEach _MagList;

_SortedMags;

I have a mag array of the player's mags, I want to sort them by their ammo count, I do have access to the ammo count of each mag, I just don't know how to sort them.

#

what do I need to put in the forEach for it to sort it?

#

decreasing order

opal zephyr
#

@granite sky Your suggestion was helpful, it looks like the script is being called and is passing the isServer check. However its not getting to the next step which is the EH's. Here is that code section:

_curators = allCurators; 
allPlanes = entities [["plane"], [], false, false];

{
_x addEventHandler ["CuratorObjectPlaced", {
    params ["_curator", "_entity"];
    systemChat "added";
    
    allPlanes pushBack _entity;
        
        
    _entity addEventHandler ["Killed", {
        params ["_unit", "_killer", "_instigator", "_useEffects"];            
        [_unit] spawn planeKilled;
        diag_log "planeCrash Eh1 Added";
    }];
}];

_x addEventHandler ["CuratorObjectDeleted", {
    params ["_curator", "_entity"];
    
    allPlanes deleteAt (allPlanes find _entity);
}];

} forEach _curators;
little raptor
#

And you can't sort in "forEach"

#

You have to construct a new array, sort it, then extract your original elements

granite sky
#

The sort command can also be used if you need it to be faster, but it's stricter on the input requirements.

drifting portal
little raptor
#

Wat? Just look at how BIS_fnc_sortBy works

granite sky
#

@opal zephyr Are you sure the curators have been initialised at the point you're calling that?

opal zephyr
#

Im calling that with postInit, so curators should be created already

#

allPlanes is empty though since the mission in this case is empty

granite sky
#

I'm not even sure whether the curator events are triggered local to the current curator or the curator object.

#

Would need to do a lot of testing.

#

Your systemChat there won't do anything on a DS though. You'd need to remoteExec it to the client.

opal zephyr
#

Ya, that was for earlier testing, never removed it

#

Is there a better way to get vehicles during runtime?

#

Apart from checking with a timer

little raptor
#

I don't know how it works exactly

#

Half the time it doesn't return anything

#

Better go through all players and find ones that have synced curator modules

#

Also if that script is running at server Init it won't work

opal zephyr
#

The command was returning correctly everywhere but dedicated. I guess I can try doing it based on sync with players, thanks for the suggestion!

little raptor
#

So players are irrelevant. you better get the modules instead

opal zephyr
#

Ik, you recommended to go through players to get the modules

#

as apposed to using allCurators

#

I could consistently get them with a timer that checked every 10sec or something, but id rather not

little raptor
#

You can get the modules directly

opal zephyr
little raptor
#

Nothing meowsweats

opal zephyr
#

ok.. lol

little raptor
#

I meant players that are zeus

#

Which is not what you want here

opal zephyr
#

how do you get the modules directly? And do you think it would work apposed to my current method

little raptor
#

Well idk where those EHs execute. Probably where the zeus player is local

opal zephyr
#

It looks like they do

#

The timer method is seeming more and more to be the option to go with haha

#

Hmm actually I think I can simply use missionEventHandler "EntityKilled" and just check if the entity is a plane

#

That should work even if the entity is added by a zeus during runtime, or the vehicle respawns or whatever else happens

granite sky
#

EntityKilled is generally really useful. The stock Killed EH only fires on local objects, so it's a pain for vehicles because they switch locality when players board them. MPKilled runs everywhere, which you usually don't want to do either.

opal zephyr
#

I have the script running on the server and everything now, however it acts differently on the dedicated then it does on the other server types. It seems like its slow or something, the objects arent being created in the correct spots, and the rotations arent correct. A couple of the objects are somewhat correct, but overall its a mess 😂

drifting portal
#

and if so how did you do it

opal zephyr
#

Its a addon and runs when a jet dies

drifting portal
#

oh alright I thought it was a zeus script

tough abyss
#

Does anyone know the execution locality of AllMapMarkers?

#

Whether it's globally executed or locally or both?

warm hedge
#

Since it is a getter there's no point to execute in globally

#

So local

tough abyss
#

I kind of need it to be able to have a players group receive the markers

#

So they can be drawn with draw3dicon

#

But only allow up to 10 at a time

tough abyss
#

Got a weird question how smart is the ArmA 3 Scheduler?

tough abyss
#

So a simple FIFO queue?

#

With no priority definitions?

winter rose
#

yep

#

max 3ms each script, if too many scripts, a lot of delay for everyone

little raptor
# tough abyss With no priority definitions?

priority is with scripts that have not executed for the longest time. it's not just FIFO. it always (meaning every frame afaik) sorts its scripts by their last execution time

little raptor
tough abyss
#

@little raptor Ah so LRU policy.

violet prairie
#

Hi! I'm trying to get into coding for arma and wanted to start with a fairly simple checkpoint missions where npcs will automatically stop at the gate until let through via radio command. I (think) I have the stop and go mechanic set up, but I can only spawn in one vehicle at a time as the variable in use cannot be shared, and I would like to make the vehicles spawn in randomly from a pool of randomized preloads but I'm not sure how.

#

Does anyone have any resources/Ideas?

winter rose
violet prairie
#

And is there a way to make those vehicles have a particular variable name when they spawn?

winter rose
#

no, in a script
and (global) var names are possible but usually not required

violet prairie
winter rose
#

in the mission directory yes

violet prairie
#

Got it, okay, um... I'm really new to that and I wouldn't be sure how to do that but I'll see what I can do

#

Is there a way to make these vehicles follow a predetermined path?

serene rose
#

any idea how I could automate this into a single trigger?
code is basically meant to teleport candidate_1, cand_2, ... to sp1, sp2 ... - I have 4 overlapping triggers now and am unsure how to make it less ghetto 😆

//CONDITION
this && (candidate_2 in thisList)

//ON ACTIVATION
null=[]spawn { 
 
[0, "BLACK", 2, 1] spawn BIS_fnc_fadeEffect; 
uiSleep 3.5; 
player setPos (getPos sp2);
[1, "BLACK", 5, 1] spawn BIS_fnc_fadeEffect; 
 
};```
little raptor
#

also your trigger has locality issues

proven charm
#

if you have remoteExecCall ["createMarkers", _targetSide, true]; that is called several times and JIP person joins the server, will he also get createMarkers called several times or just once?

proven charm
winter rose
#

if you want to only have it happen once, use the same JIPQueueId

#

or have it run locally on join

proven charm
#

well it's supposed to show town ownership to clients, via marker

#

and the ownership changes

winter rose
#

and does it delete previous markers before?
honestly I wouldn't remoteExec that, have UI stuff locally executed

proven charm
#

the markers are local to each client

#

not global

winter rose
#

yes…?

#

that is called several times
I hope you clear previous ones

proven charm
#

hence sending marker creation to single side at the time

#

I'm going to just remoteExecCall ["", _updateJipId]; to clear the queue

winter rose
#

or, you know, don't add it to the queue??

proven charm
#

you mean dont use remoteExecCall ?

winter rose
#

you are piling up JIP stuff you won't need for JIP
so I don't get what you are trying to do blobdoggoshruggoogly

proven charm
#

just updating some local markers for JIP and all players of the same side

#

well I think I got it from here, thx for the help 🙂

serene rose
serene rose
little raptor
little raptor
serene rose
serene rose
little raptor
little raptor
buoyant totem
serene rose
#

based on the assigned variable name, i.e. candidate_1 through n

#

tpd to sp1 through n

buoyant totem
#

oh, do you still need help?
just code above i guess is the exact thing that you are looking for ;D

#

anyway, if done with this, i have question in here.
so i'm making code which is saving bohemian respawn time of player (based on UID) on server. This time should be applied back, if player rejoins from different slot.
But i didn't find function to return player's respawn time on sever (basically i don't think EH (event handler) would help with playerRespawnTime, due player can alt+f4 and remoteExec wont execute if i'm not wrong).
I'm making possible solution with -

EH looking for player entity to be killed.
saving time of kill
creating EH player disconnect
find time difference
save corresponding UID and time to server
sleep for respawn time (taken from description of mission)
delete EH player disconnect

wondering, if other, better, solutions exist?

granite sky
#

Assuming that the respawn time is a fixed, known value, I think you can do this purely on the server with EntityKilled and PlayerConnected mission event handlers.

#

oh, maybe you do need PlayerDisconnected as well in case they disconnect while unconscious.

buoyant totem
#

yea, just a bit changed scheme due in this i suddenly can create hundreds duplicates of EH) pretty sure that this script must be run on server, cuz anything can happen with connected player ;D

opal zephyr
#

Is the community.bistudio website not loading for anyone else?

meager granite
dire plaza
#

Hi, please help!

KE1 addAction ["Try Green keycard",{ removeAllActions KE1; KE1 say3D ["SCPsfxKCdec", 10, 1]; KEK1 setObjectTextureGlobal [0, _unsatisfied]; sleep 5; KEK1 setObjectTextureGlobal [0, _waiting]; execVM "Locker.sqf"; },nil,1.5,true,true,"","("|#|K_Keycard_Green" in Items _this)",5,false,"",""];

Marked the error, "Error: missing ]"
Asked several friends and it seems fine to them too

meager granite
#

"(""K_Keycard_Green"" in Items _this)"

#

quotes insides quotes need to be double quotes

dire plaza
#

thank you

opal zephyr
#

Are yall sure the website isnt down? I cant access it on any browser on my pc, and I cant access it on my phone, and I cant access it via data instead of through my modem.

winter rose
#

(and other pages on it I usually don't open, so it's not the cache)

opal zephyr
#

I've been using it all morning and then suddenly nothing

agile cargo
#

How can I force individual AI from a group to go to a XYZ position?

opal zephyr
#

"move" I think, but they will return to the group leaders location after reaching their destination

open fractal
#

doMove for individuals

opal zephyr
#

ah thankyou, missed part of it

agile cargo
#

I have setup CBA building positions for they to take, but it's not reliable

#

thanks, so basically just do doMove and use moveToCompleted to force them to hold there

opal zephyr
#

Lou it just started loading again, wacky lol

winter rose
opal zephyr
#

<3

tough abyss
#

How do I get the[] call BIS_fnc_garage; to actually spawn the vehicle?

#

I can get it to open, and allow me to select a vehicle, but when I close it again the vehicle disappears

#

OH

#

Nevermind, just gotta close it

opal zephyr
#

Im having trouble with scaling objects again... When this script runs it ends up with the objects being set to a scale of 1. I've checked the value of _cratersize with a systemchat there at the bottom and it comes back as 2.25. I don't make any changes to the object after its scale is set... Does anyone know what could be up with it?

{
    _pos = getPosATL _x;
    _pos set [2,0];
    _crater = createVehicle["CraterLong", _pos, [], 0, "CAN_COLLIDE"];
    _crater setDir (getDir _x);
    _crater setVectorUp surfaceNormal getPosWorld _crater;
    _crater setObjectScale _craterSize;
                
    deleteVehicle _x;
                
    systemChat (format["Size3: %1", _craterSize]);
} forEach craterArray;
opal zephyr
#

I need it to keep its collision

open fractal
#

cool

#

make a simple object

opal zephyr
#

The collision of a scaled simple object is not present

#

Let me rephrase, it is not present for anything apart from a human unit. All vehicles pass through as if its non existent

open fractal
#

If you're not scaling a simple or attached object then you probably have to scale it on each frame

opal zephyr
#

Its a static object and can be scaled just once. The script I posted above works fine everywhere apart from a dedicated server

opal zephyr
#

Singleplayer, and local hosted servers

open fractal
#

are other clients able to see it on local hosted servers?

opal zephyr
#

One moment, I need to confirm something for singleplayer, I forgot I updated part of the code since I tried it last

#

Ok, ya it works fine in singleplayer, if on a dedicated server all users see the same issue

open fractal
#

I think you're trying to use it for something that isn't supported.afaik you need to have it execute on every frame to make it update for non-simple/attached objects in multiplayer

#

If it'll work in multiplayer

opal zephyr
#

damn, that would be very unfortunate if its the case

#

I might have to make my own model then with scaled versions of it. Or just bite the bullet on it

open fractal
#

I distinctly recall having to replace a static object with a simple object before scaling it in multiplayer

#

though I'm not sure what you mean by collision not working

#

I didn't run into that

opal zephyr
#

I had this convo with the other day with Leopard, and we came to the conclusion that if it was static it was fine to do just once. But I might implied it being in singleplayer

open fractal
#

I think the rules are different for single player

opal zephyr
open fractal
#

3x?

#

player-controlled vehicle

opal zephyr
#

Do you happen to have that code still? Because im creating simpleobjects and they have 0 collision with vehicles

#

Maybe its just the object im using that has oddly scaled collision 🤷

open fractal
#

I just created a simple object from one of the altis wall gate arch things

#

and then scaled it

opal zephyr
#

Ok I tested it a little and it appears its the object im using that causes the issue haha

agile cargo
#

How can I differentiate a logic object from a building?

#

they are both synced to an unit, I need to iterate the synced objects and get only the building

opal zephyr
#

could use typeOf

#

sorry, I mean isKindOf

#

my bad, mixed them up

agile cargo
#

typeOf works, thanks

#

I had forgotten the name of the command lol

opal zephyr
#

typeOf just returns the type, isKindOf checks if an object is of a type

agile cargo
#

It's enough, unless you reckon that isKindOf is faster

opal zephyr
#

I have no idea what their speeds are

little raptor
#

neither typeOf nor isKindOf are reliable for that

#

logic is an object that getNumber (configOf _obj >> "simulation") == "invisible" (or its side = 7)

little raptor
hallow mortar
little raptor
#

I can write my own base class

#

without any regard to game's base classes

hallow mortar
#

Sure, and if you write your own base class a typeOf or isKindOf that specifies a different one still won't select your object

little raptor
#

that was an example

#

what if someone else wants to do it?

#

do they have to check what base class I use?

#

no

hallow mortar
#

I feel like you are somehow responding to a problem they didn't pose

little raptor
#

I'm responding with the general and correct solution

#

instead of a "sometimes works sometimes doesn't" one

tough abyss
#

Uhh? Test it?

hallow mortar
#

They want to select the building from an array that contains a logic and a building. TypeOf or isKindOf will do that 100% reliably. If you specify a building classname for typeOf or isKindOf, you will never accidentally select a logic. It's not a universal detector for any kind of logic but it is in fact a simple, correct, and complete solution to the actual problem

tough abyss
#

Got a question can you make AllMapMarkers run for only a group?

#

Pulling the data from the entire map is stressful for the game.

#

And that function itself is costly in terms of runtime.

little raptor
hallow mortar
#

You proved you can make a logic that's hard to target with typeOf or isKindOf but that wasn't the actual problem

#

typeOf or isKindOf isn't 100% reliable at telling you something is a logic but you can certainly reliably use it to select a known sort of object that is not a logic

#

And I really hate the way you're constantly rude to everyone. It doesn't cost anything to be nice.

little raptor
#

and I really don't care what you or anyone thinks

tough abyss
#

@hallow mortar Just test it.

#

If you don't know just test it.

opal zephyr
#

@tough abyss I don't know of any other method apart from using allMapMarkers. I couldnt find an event handler for them either

hallow mortar
little raptor
opal zephyr
#

Im about at the point Ill need to take a break on this project lol. I'm creating a number of craters when a plane crashes, i've tried running it on just the server and when its in a scheduled environment it spawns about a quarter of the craters its supposed to and their orientations are wrong. When I spawn it in unscheduled it just doesnt spawn anything. When I run the script on the clients instead of the server it spawns the correct number of craters, however their direction is not consistent from client to client. I've tried to remedy this using "_crater setPos getPos _crater" to no luck.... Anyone have any final suggestions before I move on?

opal zephyr
#
                    _i = vectorNormalized (velocity _plane);
                    _planeDeg = (90 - (((parseNumber(str(_i select 1))) atan2 (parseNumber(str(_i select 0))))+180)) + 180; //this line converts the vectorDir of the object into degrees out of 360
                                
                    _planePos = getPosASL _plane;
                    _planePos set [2,(getTerrainHeightASL _planePos)];
                    _crater = createSimpleObject ["CraterLong", _planePos];
                    craterArray pushBack _crater;
                    _crater setDir _planeDeg;
                    _crater setVectorUp surfaceNormal getPosWorld _crater;
                    
                    _crater setPos getPos _crater;
    
                    _crater setObjectScale _craterSize;
#

If you think it would be beneficial I can send you the whole thing via dm or something. But there really isnt much more than whats there apart from the event handler its called from

little raptor
#

my first question is why do you do parseNumber(str?

#

why convert to string only to convert back to number again? thonk

#

the second question is why do you use _crater setPos getPos _crater;?

#

it's a well known fact that it's wrong

opal zephyr
#

I think I used parseNumber originally because I was using a test for _i that required it. You're right it seems to be useless now, never noticed since the script appeared to be working fine.

I used setPos based on a note on the wiki as well as forum posts suggesting it would sync the direction. Wasnt aware that it was wrong

little raptor
#

from getPos page:

#

you should use setPosWorld getPosWorld instead

opal zephyr
#

ah, never checked the getPos page

little raptor
#

When I spawn it in unscheduled it just doesnt spawn anything
spawn in unscheduled is scheduled... meowsweats

#

did you pass the local vars?

opal zephyr
#

and yes I passed the local vars into it

little raptor
#

I don't see anything in that code that might break in unschd

opal zephyr
#

Ill try running it on the server unscheduled with the changes you recommended, one moment

little raptor
#

+180)) + 180;
that part means nothing meowsweats

#

angle + 360 is the same as original angle

opal zephyr
#

I was getting a negative version of the number I wanted, so I added 180

little raptor
#

wait it has a - behind it. it's being canceled out meowsweats

#

you have (90 - (bla + 180)) + 180 meowsweats

#

that's just 90 - bla

#

getting a negative version of the number I wanted, so I added 180
setDir works with negative numbers, if that's why you did it

opal zephyr
#

Ill mess with that after, it looks like its just redundant steps instead of something that could break it though right?

if I used a neg with setDir then the object would be facing the other way wouldnt it?

little raptor
#

idk what you mean by other way, but it would be mirrored around its front

opal zephyr
#

ok

little raptor
#

I still don't see why you said it doesn't spawn anything at all

#

in unschd

#

apart from the event handler its called from
EH codes are always unschd tho