#arma3_scripting

1 messages · Page 516 of 1

tough abyss
#

Hello guys, quick question: How could I check if the player is in the copilot seat in a heli?

dim terrace
#

player isEqualTo (roflocopter turretUnit [0])

lapis jungle
#

@young current I pack it with Bohemia Interactive's Arma 3 Tools. I am making a build script that will use armake, but it's not working fully right now

young current
#

I dont know what kind of error debug info Armake gives, but Addon Builder gives none and lets through just about anything, so you could try Mikeros PboProject

still forum
#

Armake only prints errors that make it unable to build the pbo

lapis jungle
#

Right. In that case I may try Mikero to verify the files instead then

young current
#

worth to try

lapis jungle
#

Thanks for the suggestions

summer pelican
#

Is anyone having a problem getting addPublicVariableEventHandler to work correctly?

still forum
#

Haven't heard of that yet

summer pelican
#

This should run the systemChat, right?

"testVar" addPublicVariableEventHandler {systemChat "This is working"};

testVar = 5; publicVariable "testVar";
still forum
#

no

#

only if you do the publicVariable on a different client than where the eventhandler is added

#

publicVariable is not transmitted to yourself

tough abyss
#

`Please note:

  • EH will not fire on the machine that executed broadcast command, only on the machines that receive the broadcast.`
thorn saffron
#

Is it possible to re-run a script on every existing character during the scenario?

tough abyss
#

{_x call myscript} foreach allunits

austere silo
#

hi all! i need to get a mission scripted. there is already an old script but its OFP old. so my questions are: who are willing to help me? what would it cost?

tough abyss
austere silo
#

k thx

sturdy cape
#

short question:how would i need to alter this addaction here sqf _openMenu = _unit addAction ['<t color="#3748E3">Open Menu</t>', "path\to\script.sqf", [], 100, false, false, "", "driver _target == _this"];to call a fnc instead of a script without loosing any of the passed values? sorry if this seems like a noob question.just trying to convert an old script to functions

ruby breach
#

"path\to\script.sqf" > {[params] execVM "path\to\script.sqf";} or {[params] call tag_fnc_func}

sturdy cape
#

so i need to define the condition before the addaction instead?

#

the actual problem is this sqf _showList = _unit addAction [format ["use %1 (%2 left)", GET_ITEM_NAME(_itemIndex), _count], "bad\client\useItem.sqf", [_ItemIndex], _ItemIndex + 50, false, false, "", "vehicle player == player"];its an addaction in format and i am not sure how to edit this to be honest

wide hamlet
#

wdym

#

the only thing that is being formatted there is the title.

#

title = [format ["use %1 (%2 left)", GET_ITEM_NAME(_itemIndex), _count]
script = "bad\client\useItem.sqf"
arguments = [_ItemIndex]
priority = _ItemIndex + 50
showWindow = false
hideOnUse = false
shortcut = ""
condition = "vehicle player == player"
Edit as such @sturdy cape

tough abyss
#

How can I get the velocity of a round being fired in arma? I'm trying to calculate the mortar bombs speed at different charges to properly build a rangetable for the RHS mortars. Does anyone know how gravity works or can I just go for ~9.8m/s?

sturdy cape
#

yeah but i cant put [] call xxx_fnc_function inside of that addaction simply,no?

#

@wide hamlet

warped moon
#

Hey, does anyone know what I need to put in my remoteexec.cfg? I'm getting this error: BattlEye Server: RemoteExec Log: #0 illu (fee0d6b062b1a61e2f6b67132d9dc954) - #0 "vcm_serverask ["Vcm_Settings"]"

wide hamlet
#

{[params] call tag_fnc_func}@sturdy cape

sturdy cape
#

just as simple as that?

wide hamlet
#

afaik

sturdy cape
#

@warped moon in first line "vcm_serverask ["Vcm_Settings"]"

wide hamlet
#

tbh i would have some misc clientside shit in a script and have that script also run the func. Up to you

warped moon
#

@sturdy cape ok will try thank you

sturdy cape
#

needs to be a server side addon unfortunately.for a plugin system

wide hamlet
#

just try that line. Trial and error

high marsh
#

@tough abyss

player addEventHandler["FiredMan",
{
    _velocity = velocity(_this # 6);
    hint format["The velocity blah %1",_velocity];
}];
warped moon
#

@sturdy cape didnt work 😦

sturdy cape
#

i think now it will

jagged field
#

in descriptions.ext does indenting matter?

wide hamlet
#

indenting is good coding practice no matter what file or script

jagged field
#

alright

#

but does it actually matter?

wide hamlet
#

imma go with yes just so you do it

young current
#

it matters if you want to have people help you later when you run into problems and have to show them your code

jagged field
#

alright

#

ty

#

trying to make an ace description.ext but its not working

#

I'll post in the correct channel if I cant figure it out.

#

WITH indenting

young current
#

ACE slack is also a good place to ask ACE related things I've heard

tough abyss
#

@high marsh
@bronze basin
Thanks! Had to search through the configs for them I guess but it seems like all the charges use made up numbers. Would be a lot cooler if this (https://i.imgur.com/Vo8k2Zz.jpg) bad boy would've worked.

high marsh
#

lol, no I think all the config values might be coefficients

tough abyss
#

Yeah

frigid raven
#

Can anybody link me to the biki for 3D markers? Like a cylinder object

tough abyss
#

wait what?

#

you mean trigger area?

#

there isn't 3d marker this is just engine drawing it in editor

frigid raven
#

I mean like a 3D object - shape of a 3D cylinder

tough abyss
#

the only cylinder you can use is object called safe area or something

frigid raven
#

which is visible ?

#

sorry forgot to mention that I am talking about a visible 3D marker/object in a cylinder shape

tough abyss
#

ProtectionZone_F

#

massive though

frigid raven
#

is it scalable? like having a scripted dynamic radius?

tough abyss
#

don't think so

#

you can make a mod and add those cylinders by the truck load

frigid raven
#

hmm bummer

#

I wanted some kind of debugging objects

#

making some cycle areas visible for me for testing

tough abyss
#

personally I think Eden should have had a bunch of them, cylinders of many sizes, cubes, pyramids and what not

#

cost nothing to make

#

but

dusky pier
#

is possible to run script on server not from game? Maybe console or something like that

#

I need that for use on server console app

tough abyss
#

what do you exactly mean not from the game

dusky pier
#

I want to run the script through an event in the MySQL table, when the value is updated - the server immediately sees it and loads a new one.

high marsh
#

extDB3, or write an extension

dusky pier
#

as far as I know - extDB3 accepts requests only from the arma

high marsh
#

Right, I wasn't sure. So probably write an extension.

frigid raven
#

What is the best practise to have a function handle array params the same regardless of the size of the array?

#

atm I have to wrap the param when calling the func with []

#

to be 100% safe it will not strip a ["value"] array differently to ["value1", "value2"]

astral dawn
#

yes that's how you do it

#

@frigid raven

#

because if you need to add one pore parameter you just add it to the array of parameters

#
mine_fnc_setDammageOnTheseUnitsPlease = {
  params ["_arrayWithVehicles", "_dammage", "_alsoDammageHumans"];
};
[[player, vehicle player, thatOtherGuy, vehicle thatOtherGuy], 9000, true] call mine_fnc_setDammageOnTheseUnitsPlease;
frigid raven
#

@astral dawn ok thanks dude - sorry for the late reply but I fell in depres... sleep

astral dawn
#

It's fine 😄

#

Is there some command like canMove which doesn't get affected by the vehicle's isTouchingGround state?
The problem with canMove is that if the vehicle is not touching ground but healthy, it returns false.

rancid pecan
#

hello

#

How do I set the focus of the map?

copper raven
rancid pecan
#

@copper raven thank you but i can try ```sqf
_ctrl ctrlMapAnimAdd [0, 0.5, player];
ctrlMapAnimCommit _ctrl;

#

but its not working

copper raven
#

🤷

#

Might be worth reading the wiki page again, instead of straight up copy paste.

rancid pecan
#

@copper raven i don't understand i read still 😦 😦

west grove
#
    (findDisplay 37 displayCtrl 51) ctrlmapAnimAdd [1, 0.05, markerPos "m_aaf_attack"]; 
    ctrlmapAnimCommit (findDisplay 37 displayCtrl 51);
};```
#

this is how i do it

#

in the briefing code

modest temple
#
this addAction["Firing position 1 Targets","popup.sqf",[[tar1,tar2,tar3,tar4,tar5,tar6], 0,1,true]]; 

how do i convert this into using remoteExec

west grove
#

so when you start the mission, the screen will focus on the marker named m_...

#

nevermind, missread 😄

modest temple
#

ok 😄

#

like i see the wiki

#

but i dont know where to put all the parameters

rancid pecan
#

@copper raven ? can u help me ?

tough abyss
#

@modest temple remoteExec is not something you must use or other kids will make fun of you. If you don’t understand wiki then you probably don’t need to use it.

west grove
#

hmm do hit and HandleDamage EHs not work on buildings?

#

ok, seems to work with bigger weapons

spark turret
#

where in the config is the rate of fire for a weapn stated? its not reload time, thats always at 0.15

tough abyss
#

For anything config related you’re better off asking in #arma3_config

tame portal
#

@west grove what weapon were you firing with at the building?

west grove
#

normal rifle

tame portal
#

afaik it doesnt fire if no damage is inflicted

west grove
#

yeah, i figured it has something to do with penetration or such

spice flame
#
addMissionEventHandler ["Draw3D",
{
    if !(player == vehicle player) then 
    {
        player exitWith {};
    }
    else
    {
        if (currentVisionMode player isEqualTo 2) then
        {
            if (isNil "A3W_thermalOffline") then
            {
                "A3W_thermalOffline" cutText ["THERMAL IMAGING OFFLINE", "BLACK", 0.001, false];
                A3W_thermalOffline = true;
            };
        }
        else
        {
            if (!isNil "A3W_thermalOffline") then
            {
                "A3W_thermalOffline" cutText ["", "PLAIN", 0.001, false];
                A3W_thermalOffline = nil;
            };
        };
    };
}];

Why I get an error ? Anyone can tell me?

robust hollow
#

player exitWith {}; thats not how exitWith works

still forum
#

!(this == that) wat? You know that there is a != operator?

mortal wigeon
#

Does setVectorDirAndUp work in render time or simulation time?

astral dawn
#

I guess if it doesn't have *Visual at the end of its name, it's not in visual time

#

even more, I don't think that there are commands to set any object property in visual time, you can only get properties in visual time

cursive whale
#

I've been wrestling with setvectordirandup in a Draw3D handler and the result always seems a frame delayed.

young current
#

how does one use setvectordirandup with draw3D?

cursive whale
#

lean correction for pip scopes

#

(rotate the camera the opposite direction to negate the lean)

young current
#

soo you setvectordir for the camera?

cursive whale
#

yep

young current
#

I think you should use the actual camera commands for that

#

is the camera script created?

cursive whale
#

yes

#

i'm all ears (have put on he back burner because i wasn't happy with the result - got really close by predicting the frame delay but not quite perfect)

young current
astral dawn
#

I was about to say 'maybe if you interpolate your data one frame ahead' 😄

young current
#

but yeah PIP is always a little behind

cursive whale
#

i was inspired to mess with it because of this video;

#

at the time i've linked to it he demonstrates lean correction and i don't know if it's a YT thing but i see no sign of a delay

#

but damned if i can nail it despite using far more direct manipulation (i.e. a single setvectordirandup call where he appears to have used multiple bis_fnc calls to read and then set up)

#

@hasty frigate

young current
#

😄 not bad idea to go to the source

tough abyss
#

I want to make AI play an animation when they get near an object that the player places, how would I attach the script to the object? Let's say its an "Weapon_arifle_MX_GL_F" for argument's sake

astral dawn
#

you would have to periodically poll the unit's position until he's close enough to your object

#

how do you make him move here in first place?

tough abyss
#

I don't want it to rely on waypoints, I basically want players to drop distraction items like in Metal Gear

#

I've got the trigger working and all, just not sure how to spawn the trigger with a particular item that's dropped

astral dawn
#

well you'd have to spawn a script per every AI unit or per every group at least

#

which would search for such things around

#

or when you drop the distraction, you search for nearby AIs and notify their spawned script about the object

#

so that they all don't have to check for the same thing periodically...

tough abyss
#

Right now it's on a trigger area, I just need to create a trigger area whenever that item is dropped which I'm not sure how to do with an existing item

tough abyss
#

This is mostly doing what I want, but how can I terminate the script if the unit gets damaged during it?

_unit = _this select 0;
_object = _this select 1;
_occupied = false;
_pos = getPos _object;

if isPlayer _unit exitWith {};
if (behaviour _unit == "AWARE" or behaviour _unit == "COMBAT") exitWith {};

if ((behaviour _unit == "CARELESS" or behaviour _unit == "SAFE") && !(_occupied)) then {
_occupied = true;
doStop _unit;
_unit lookat _object;
_unit playAction "gestureFreeze";
sleep 2;
_unit lookat _object;
_unit forceWalk true;
_unit doMove _pos;

waitUntil {(getPos _unit) distance (_pos) <= 1};
if isPlayer _unit exitWith {};
_unit setDir (_unit getDir _pos);
[_unit, "SIT_LOW", "ASIS",_unit,true] call BIS_fnc_ambientAnim;
};

waitUntil {((behaviour _unit == "AWARE" or behaviour _unit == "COMBAT") && (_occupied))};
if isPlayer _unit exitWith {};
_unit playMove "AmovPercMstpSrasWrflDnon";
sleep 2.5;
_unit call BIS_fnc_ambientAnim__terminate;
_unit switchMove "";
_unit lookat objNull;
_unit forceWalk false;

sleep 5;
_occupied = false;
_unit = nil;
tough abyss
#

also having trouble activating a script with a trigger,

_distractionTrigger setTriggerStatements [this,_distractedMan = thisList select 0;
_distracter = [distractedMan,thisTrigger] execVM "distraction.sqf"; ];
robust hollow
#

that second array element needs to be a string doesnt it?

sage flume
#

so I want to port my mission to be played strictly with ww2 assets. I have created various blacklists. I have been tooling with these commands, shuffling them around but I cannot stop default ArmA assets from showing in game.

#

if ((toLower _class) in _myWeaponBlackList) exitWith {};
if ((toLower _class) in _myAmmoBlackList) exitWith {};
if (_lowClass in _myVehBlackList) exitWith {};
if ((toLower (configName _class)) in _myGroupBlackList) exitWith {};
if ((toLower _fc) in _myFactionBlackList) exitWith {};

#

could someone steer me in the right direction?

robust hollow
#

why not just whitelist the ww2 assets u want instead?

sage flume
#

I thought of that but many of the IFA3 assets classnames are hidden

#

or at least I don't know how to find them but according to kju I think they are hidden by design

robust hollow
#

what, classnames for the blacklists you listed above? it would all be listed in the config somewhere 🤔

sage flume
#

When I go into Editor and find , lets a soldier, the soldier does not expand to allow me to view the config

#

thus the hidden feature by kju

tough abyss
#

Got it closer

_distractionObject = "ItemMap";
_player = _this select 0;
_objectPos = _this select 1;
typedropped = _this select 2;

if !(typedropped == _distractionObject) exitWith {};

_distractionTrigger = createTrigger ["EmptyDetector", _objectPos, true];
_distractionTrigger setTriggerArea [5,5,0.5,false];
_distractionTrigger setTriggerActivation ["ANY", "PRESENT", true];
_distractionTrigger setTriggerStatements ["this","[thisList select 0,_objectPos] execVM 'distraction.sqf';","" ];


hint format ["trigger created at pos %1", getPos _distractionTrigger];;
#

This is coming from the PUT eventhandler

robust hollow
#

@sage flume is it for specific units or any unit? i just tried it and it loaded fine 🤔

sage flume
#

ya I'm wanting to stop all ArmA assets from showing in my mission

#

units weapon vehicles,..etc

robust hollow
#

no i mean this the soldier does not expand to allow me to view the config

sage flume
#

oh I think for IFA3

#

or maybe liberation

#

Im away from PC ATM

robust hollow
#

I dont think its IFA3, im not having the issue ur describing.
take another look at it when u return to ur pc, afaik if the object has a classname itl be listed in the config somewhere.

tough abyss
#

Is this right? It doesn't seem to be passing the second variable to my other script

_distractionTrigger setTriggerStatements ["this","[thisList select 0,getPos _distractionTrigger] execVM 'distraction.sqf';","" ];
robust hollow
#

_distractionTrigger wont be defined in the string

tough abyss
#

So make a separate variable outside of the string for it then?

robust hollow
#

just use thisTrigger?

tough abyss
#

Worth a try

sage flume
#

@robust hollow take another look at it when u return to ur pc, afaik if the object has a classname itl be listed in the config somewhere.

robust hollow
#

as in itl already be defined in the string for u, same as thisList is

sage flume
#

ok THanks!

#

oops I didn't "quote"

#

😫

tough abyss
#

Worked like a charm

#

How can I kill the script in the middle if the AI is injured while doing his little animations

robust hollow
#

if (condition) then {terminate _thisScript};

#

_thisScript will be defined automatically (assuming its a scheduled script)

tough abyss
#

what if he was injured before the script started though?

robust hollow
#

then have a condition at the start too to prevent the script running

tough abyss
#

The script can start with him injured, but if he's injured in the middle it should start. It's very stupid. I guess check if condition is same as it was at the beginning

tough abyss
#

I'm guessing I'm passing something wrong here

'... "x\cba\addons\settings\fnc_init.sqf"

|#|params [
["_setting","",[""]],
["sett...'
Error Params: Type code, expected Number, Bool
File x\cba\addons\settings\fnc_init.sqf, line12
#

here's my config.cpp

#include "BIS_AddonInfo.hpp"
class CfgPatches
{
    class AB_Distraction_main
    {
        name = "Distraction";
        author = "Axebeard";
        requiredVersion = 0.1; 
        requiredAddons[]=
        {
            "cba_keybinding",
            "cba_main",
            "cba_main_a3",
            "cba_settings",
            "extended_eventhandlers"
        };
        units[] = {};
        weapons[] = {};
    };
};

class Extended_PreInit_EventHandlers
{
    class AB_Distraction
    {
        init="call compile preprocessFileLineNumbers 'DistractionByAxebeard\XEH_PreInit.sqf'";
    };
};
class cfgMods
{
    author="";
};

#

and my XEH_preInit

[
"AB_Distraction",
"EDITBOX",
["Distractable items", "Separate items with a comma (,)"],
"Distraction",
'"ItemMap"',
    {
        params ["_value"];
        [_value] execVM "initDistraction.sqf";
    }
] call cba_settings_fnc_init;

What am I missing here?

ruby breach
#

Hence, Error Params: Type code, expected Number, Bool

tough abyss
#

I thought I set it to true, I must have overwrote it

#

true needs to go after ItemMap then, right?

#

Okay, now it's saying my "initDistraction.sqf" script is not found. That just needs to be in addons right?

#

Or rather in the folder with everything else

lost copper
#

Hello everyone! How i can enable ACE3 debug info logging in rpt file?

#

Info from code like that:

TRACE_5("ACE_DEBUG: HandleDamage Called",_unit, _selection, _damage, _shooter, _projectile);
tough abyss
#

add an eventHandler for Damage?

proud carbon
#

Hello. So how do I find the nearest objects in an array?

tough abyss
#

In concept, make the array, then sort by distance to object. In practice, I couldn't tell you a "good" or efficient way to do it but someone here can

proud carbon
#

yeah. been trying that but it doesn't accept my array. I am a complete noob at this

robust hollow
#

it doesn't accept my array what are you doing? paste example.

proud carbon
#

_PoToMo = nearestObject [leader _Newgroup1, AreasToLand];

robust hollow
#

what does AreasToLand look like?

#

assuming its a valid string, is the nearest object further than 50 meters away?

proud carbon
#

AreasToLand = [LZ1,LZ2,LZ3] each LZ is a "Sign_Arrow_Green_f"

#

yeah. about 10 times 50m

robust hollow
#

oh, yea ok what ur doing isnt how to use nearestObject.

Considering the array is small I would just go with @tough abyss 's suggestion.

private _landZones = [LZ1,LZ2,LZ3] apply {[leader _Newgroup1 distance _x,_x]};
_landZones sort true;
private _nearestLZ = _landZones#0#1;
proud carbon
#

I thank you for this.

tough abyss
#

how do you cancel out a unit's waypoints? Just delete them all I mean

#

Or pause them maybe?

#

How would I reference this parameter in a different script? param "AB_Distraction" select 0?

[
"AB_Distraction",
"EDITBOX",
["Distracting items", "Separate items with a comma (,)"],
"Distraction",
'"ItemMap"',
true,
    {
        params ["_value"];
        //[_value] execVM "distractionSetup.sqf";
        //_distractableItem = _this select 0;
        {
        
        _x removeEventHandler ["Put", 0]
        _x addEventHandler ["Put", {[_value,_this select 0] execVM "DistractionByAxebeard\placeDistraction.sqf";}];
        } forEach allPlayers;
    }
] call cba_settings_fnc_init;
robust hollow
#

im no expert of CBA so wont help you there, though i am sure _value wont be defined in that event

_x addEventHandler ["Put", {[_value,_this select 0] execVM "DistractionByAxebeard\placeDistraction.sqf";}];```
tough abyss
#

reference the value I mean

#

Suprisingly it worked

#

the way I had it I mean. When I changed the value in game though, it sort of bugged out and got confused

#

So instead of passing the value in the eventHandler right there, I'd rather have the "placeDistraction" script just pull the value directly because it might change for whatever reason

tough abyss
#

I may be wrong, can't get it to work now. How do you think _value should be defined @robust hollow?

#

I was thinking something like this might work but it throws an error for the whole XEH_PreInit thing

[
"AB_Distraction",
"EDITBOX",
["Distracting items", "Separate items with a comma (,)"],
"Distraction",
'"ItemMap"',
true,
    {
        params ["_value"];
        {
        _x addEventHandler ["Put", {[params select 0, _this select 1, _this select 2] execVM "DistractionByAxebeard\placeDistraction.sqf";}];
        } forEach allPlayers;
    }
] call cba_settings_fnc_init;
robust hollow
#

params select 0 thats wrong...

tough abyss
#

Yeah, that's the change that broke it, I figured that much out. Not sure how to pass the var

robust hollow
#

the event code is executed in its own scope or instance (not sure of the right word), so _value wouldn't be defined in it.

anyway you could have something like this

_x addEventHandler ["Put", format["['%1',_this select 0] execVM 'DistractionByAxebeard\placeDistraction.sqf';",_value]];
#

im assuming value is a string 🤔

tough abyss
#

Yeah, the default value is "ItemMap"

robust hollow
#

ok good, ^ should work then

tough abyss
#

Okay, now the errors have moved onto other places, namely the placeDistraction script. Is my IF line screwy? It worked as a standalone script I thought

_distractionObject = _this select 0;
_objectPos = _this select 1;
_typedropped = _this select 2;

if !(_typedropped == _distractionObject) exitWith {};
robust hollow
#

you dont provide a third array element...

also why not use !=?

tough abyss
#
[
"AB_Distraction",
"EDITBOX",
["Distracting items", "Separate items with a comma (,)"],
"Distraction",
'"ItemMap"',
true,
    {
        params ["_value"];
        {
        //_x addEventHandler ["Put", {[params select 0, _this select 1, _this select 2] execVM "DistractionByAxebeard\placeDistraction.sqf";}];
        _x addEventHandler ["Put", format["['%1',_this select 0,_this select 1, _this select 2] execVM 'DistractionByAxebeard\placeDistraction.sqf';",_value]];
        } forEach allPlayers;
    }
] call cba_settings_fnc_init;
robust hollow
#

_objectPos = _this select 1; is this meant to be an object or position (array)?

#

not entirely understanding ur placeDistraction variables when compared to the array ur giving it from the eventhandler

tough abyss
#

Well I'm using the Put eventHandler, and I need to pass the location of the object and the type of object

robust hollow
#

yea i still have no idea.

These are the arguments Put gives you, either im misunderstanding something or you havent got the order of these arguments right... 🤷
params ["_unit", "_container", "_item"];

unit: Object - Unit to which the event handler is assigned
container: Object - The container into which the item was placed (vehicle, box, etc.)
item: String - The class name of the moved item
tough abyss
#

it worked earlier with container as the position, I pulled the snippet off Armaholic

#

I think if the container is "world" or whatever, it just returns a position

#

anyway, I'm getting a generic error with this

if (_typedropped != _distractionObject) exitWith {};
robust hollow
#

as in dropping it on the ground? it creates a weapon holder and returns that object

tough abyss
#

yeah, I dunno

robust hollow
#

yea ur generic error is because the data types dont match

tough abyss
#

I'm open to suggestion

robust hollow
#

['%1',_this select 0,_this select 1, _this select 2] -> ['%1',getPos(_this#0), _this select 2]

tough abyss
#

Okay so select 0 and select 2 are not the same type of data?

robust hollow
#

yea. ur select 2 was the container object

tough abyss
#

I thought that was select 1?

robust hollow
#

in the Put arguments it is select 1 but your event puts the _value from the CBA script before it, pushing the Put arguments up an index

tough abyss
#

OhhhH I think I'm trackin

#

So typedropped should be select 3 then?

_distractionObject = _this select 0;
_objectPos = _this select 1;
_typedropped = _this select 2;
robust hollow
#

if ur still using ur argument array for execvm, yes

tough abyss
#

Ok

still forum
#

@cursive whale I've been wrestling with setvectordirandup in a Draw3D handler and the result always seems a frame delayed.
Draw3D is called at the end of the frame, after simulation, but before rendering. EachFrame handler fires before simulation.
@lost copper you need to build the ACE pbo's yourself and set the #define to enable debug mode.

tough abyss
#

Now it's telling me _typedropped is undefined

robust hollow
#

did u swap ur execvm argument array to the one i suggested?

tough abyss
#

Yeah I think so

_x addEventHandler ["Put", format["['%1',getPos(_this#0), _this select 2] execVM 'DistractionByAxebeard\placeDistraction.sqf';",_value]];

and

_distractionObject = _this select 0;
_objectPos = _this select 1;
_typedropped = _this select 3;

if (_typedropped != _distractionObject) exitWith {};
robust hollow
#
ConnorToday at 6:07 PM
if ur still using -->ur<-- argument array for execvm, yes
                           

ur array -> ['%1',_this select 0,_this select 1, _this select 2]
#

🤦

tough abyss
#

huh?

still forum
#

Btw you really should not use execVM inside a eventhandler. That kills your performance because the script needs to be reloaded and re-preprocessed and re-compiled every time the eventhandler is executed. You should really use CfgFunctions but you can solve that one later.

@tough abyss
['%1',getPos(_this#0), _this select 2] -> [0, 1, 2]
You have 3 parameters. 0, 1 and 2.
_this select 3 won't work, the highest you have is 2

tough abyss
#

Oh MYYYYY argument array

#

well Connor's telling me I have 4 because Put has 3, plus I'm inserting 1

still forum
#

Also I'd recommend you use params. That's easier to use for you I guess.
params ["_distractionObject", "_objectPos", "_typedropped"] replace all your _xxx=_this select... stuff with that one line

tough abyss
#

so which is it? 3 or 4 arguments being passed?

robust hollow
#

look at ur array?? does it have 3 or 4 elements?

tough abyss
#

From what I got from you, I was inserting one before Put's args

#

which would mean 3 args being passed, but Put can pull it's own shit?

#

That's what I read anyway

cursive whale
#

@still forum Thanks man, good to know, will give it a whirl.

tough abyss
#

But I think I see what you're saying now actually

still forum
#

You are adding one argument yes. But you are also removing one argument from the Put values.

tough abyss
#

it should be

_x addEventHandler ["Put", format["['%1',getPos(_this#0), _this select 3] execVM 'DistractionByAxebeard\placeDistraction.sqf';",_value]];
``` and 
```sqf
params ["_distractionObject", "_objectPos", "_typedropped"];
still forum
#

You only take 0 and 2 from Put. You removed 1.

#

_this select 3 no

#

Put has 3 arguments. That's 0, 1 and 2. There is no 3

tough abyss
#

Ok, I'm confusing myself I think I got it

#

Ok, so no errors, but it's also not doing anything. I suspect the object types are still mismatched data types

robust hollow
#

more like just not matching strings

tough abyss
#

well, distractionObject is still undefined

still forum
#

what type do you expect in _distractionObject? Variable name sounds like an object. But you are clearly putting a string with a number string inside in there

tough abyss
#

shouldn't be a number

#

"ItemMap" should be it

still forum
#

yeah missremembered your code

robust hollow
#

log the argument array in placeDistraction and see what it says?

tough abyss
#

how do I do that? I tried setting them to globals but that just wrecked everything

robust hollow
#

diag_log _this

still forum
#

diag_log _this in the first line
Aww me slow

tough abyss
#

no ";"?

robust hollow
#

it would be a good idea

tough abyss
#

where's it gonna log? the rpt?

robust hollow
#

yes

tough abyss
#

Is it adding a shitton of """?

1:36:15   Error Undefined variable in expression: distractionobject
 1:36:15 File DistractionByAxebeard\placeDistraction.sqf, line 4
 1:36:20 ["""ItemWatch""",[2053.62,4015.7,0.00143909],"ItemMap"]
 1:36:20 Error in expression < "_typedropped"];
still forum
#

You have "ItemWatch" inside your string. Instead of ItemWatch

#

In your CBA setting

#

'"ItemMap"'

#

You have duplicate quotes

tough abyss
#

Ok

#

It looks like it wants ItemWatch to be the value from my parameter, which isn't right for one

1:44:07 ["""ItemWatch""",[2056.18,4013.78,0.00143909],"ItemRadio"]
 1:44:11 ["""ItemWatch""",[2055.96,4012.67,0.00143909],"ItemMap"]
still forum
#

that comes from the CBA setting

#

Remove the quotes in there

tough abyss
#
[
"AB_Distraction",
"EDITBOX",
["Distracting items", "Separate items with a comma (,)"],
"Distraction",
"ItemMap",
true,
    {
        params ["_value"];
        {
        //_x addEventHandler ["Put", {[params select 0, _this select 1, _this select 2] execVM "DistractionByAxebeard\placeDistraction.sqf";}];
        _x addEventHandler ["Put", format["['%1',getPos(_this#0), _this select 2] execVM 'DistractionByAxebeard\placeDistraction.sqf';",_value]];
        } forEach allPlayers;
    }
] call cba_settings_fnc_init;
still forum
#

The setting has probably still saved the old value

#

check your settings ingame

tough abyss
#

Good idea, but I never set it to watch I don't think

#

let's find out

#

Okay yeah, I had the setting as "ItemWatch", I took out the quotes and it worked as expected

#

I'm still a little vexed about what's going on with "_value" and _value here though

params ["_value"];
        {
        _x addEventHandler ["Put", format["['%1',getPos(_this#0), _this select 2] execVM 'DistractionByAxebeard\placeDistraction.sqf';",_value]];
        } forEach allPlayers;
#

I want to add in a few more parameters

#

As well as get all the items the server inputs in "Distracting Items" into an array

#

I'm done for the night anyway, thanks lads

still forum
#

From commy, I think you'll find this interesting too. This code is executed in a init script of a unit.

this = 1;
0 = this spawn {
    cutText [str _this, "PLAIN"];
};

What does this code print?

queen cargo
#

1 i guess? if it does not, it would be kinda worrysome

still forum
#

it doesn't. Maybe it helps if I say that this from a init script is a local variable
I think besides you noone here could solve that besides guessing. Too many internals
If you don't guess that right you might've something to fix on sqf vm :D

Although it shouldn't matter as there are no local variables called this in the vm

queen cargo
#

noooo ... nooooooooo .... noooooooooooooo

#

please do not tell me that arma actually checks the global variables on the local stack first

#

please

#

and that this only works, because this automatically (and correctly) assigns the global one

#

whilst the get operation of this checks first the private, then the global stack

#

please do not tell me that this wizard craft of spagetthi code is true

still forum
#

yeah they do. getter looks up locals first. Setter checks for starting _ and decides where to look based on that.

queen cargo
#

and that you actually try to fool around here and this is in fact: 1 as it should be

#

omfg 🤦

#

then it is whatever was in this first

#

and the glbal variable this then has a 1 inside of it

still forum
#

init box of a unit. So some Alpha: 1-1 unit name thingy

queen cargo
#

ye ..

#

this is horrible

#

no pun intended

still forum
#

And I have another one for you

#
[1,2] params ["_args,_handle"];
isNil "_args,_handle"
queen cargo
#

should i really add that broken garbage into sqfvm? (the this thing, not that isNil crap)

still forum
#

You don't need to because you won't have local variables without _ in there.

queen cargo
#

that one though is easy ... they forgot to add checks for the whole string
this actually might "work" SQF-VM too

still forum
#

besides triggers and unit init boxes there are no locals without _

That works same as you can set a missionNS variable with name "_1%&78()"

queen cargo
#

yup, it does work in SQF-VM

#

gonna add a warning when i am back home

still forum
#

Okey no.. I guess you have to do that this thing.

"lul" params ["this"];
this = 1;
0 = this spawn {
    cutText [str _this, "PLAIN"];
};
queen cargo
#

wait ... that is actually working?

still forum
#

Well. I don't know. I assume params is not checking for starting _, can't try now

queen cargo
#

they do not check if the variable in params starts with an underscore?

#

wtf

#

WTF

#

should not share punches so early on though ...

#

guess who also forgot to add that check 🤦

still forum
#

Okey I got report back from commy. Params does check for _, although with a kinda obscure error Error local variable in global namespace
The error is the opposite. A global variable where only a local one is allowed

lost copper
still forum
#

The script component ones. debug mode full

lost copper
#

@still forum thx!

ebon ridge
#

Hi, anyone could tell me please how to add launcher ammo direct into the launcher? I am trying to add missiles to the RHS USAF Javelin but it won't work. My search so far has indicated that maybe the normal addMagazine command requires storage space in the uniform, and with the Javelin that is a problem...

winter rose
#

@ebon ridge addMagazine should be used before addWeapon ; if you already have the weapon try to remove/add it

#

But regarding the storage issue, idk

ebon ridge
#

actually I think I found it: addSecondaryWeaponItem, didn't try it yet though

slim oyster
#

In a MP game, moving from "BRIEFING SHOWN" client state to "BRIEFING READ" aka pressing the continue button, will broadcast information to other clients. Can I emulate that behavior somehow? I want to broadcast that information (mainly about gear which is being set through 3den attribute expressions and is after the mission init) between clients. A hacky workaround has been to just wait til the continue button for non-admins is active then activating it, which works for all clients other than the admin. Is there 1) A better way to sync player gear set after mission init to be available before the "BRIEFING READ" client state? 2) A way to push clients in "BRIEFING READ" clientstate and broadcast their info without starting the mission? Thanks guys.

tough abyss
#

"_args,_handle" it is a string starting with _, nothing unusual, just won't pass parser but will work with set/getVariable

#

a kinda obscure error Guess what kind of error ```sqf
private ["this"];

produces? @still forum
#

It is just generic namespace error, why not just say wrong namespace? sqf localize "STR_EVAL_NAMESPACE"

astral dawn
#

I am wondering, if I am doing general data processing in SQF, what wastes my CPU cycles most? The VM itself? And can Intercept potentially hack around some statements to improve performance?

still forum
#

@tough abyss none

#

if not none then guys in ace slack told wrong stuff

#

@astral dawn the vm probably

astral dawn
#

The whole thing that reads bytecode, decodes operations, etc, so there's probably nothing to be done here? 🤔

still forum
#

stuff can be done intercept wise. That's what I once tried with fastscript.

#

not that much tho

astral dawn
#

SQF needs JIT compilation like Java :p

still forum
#

possible. Feel free to do it 😄 I certainly won't

tough abyss
#

if not none then guys in ace slack told wrong stuff you've been duped

astral dawn
#

So you're saying it's not impossible with intercept-level hacks?

still forum
#

yep. atleast I don't see anything stopping you from doing that. It's ALOT of work tho 😄

#

actually.. Depends on how deep you wanna go. If you wanna just inline the VM stuff and keep the SQF commands still as seperate calls, then not thaat much work.

astral dawn
#

parse, convert everything to Java, use Java compiler 😄

spark turret
#

_reloadTime = (getNumber (configFile >> "Cfgweapons" >> _gun >> "FullAuto" >> "reloadTime"));
returns 0
idk why but it doesnt work. if i access the reloadTime in the main gun class it works.

edgy dune
#

is it possible to see all variables attached to a certain unit? like say ive done

_unit setvariable ["name","bob"];
_uint setvariable ["somethingElse",5];

without knowing the variable name can i display them all?

tough abyss
#

allVariables

edgy dune
#

oh okay thanks

ebon ridge
#

What is the best way to implement something like a struct in sqf (if there is any way)? I want to make an array of structs that can be used as templates for instancing squads using content from different mods. e.g. If I want to generate an outpost using BAF I can look up templates["BAF"].basic_soldier_class_name, or templates["BAF"].mortar_class_name

obtuse cosmos
#

Hey, quick question, having a bit of a brain fart lmao - How to get control width/height to string length. I am thinking ctrlTextWidth/ctrlTextHeight but am stuck really. Can use count to get the string length but example output from one is like 1051. I am using ControlsGroup container. Any ideas?

{
    _message = _display ctrlCreate ["RscText", (100 + _forEachIndex), _logsContainer];
    _message ctrlSetText _x;
    _message ctrlSetPosition
    [
        0,
        (0.04 * _forEachIndex),
        ???,
        ???
    ];
    _message ctrlCommit 0;
} forEach messagesArr;
#

Each text's text height will vary depending on the string.

still forum
#

@ebon ridge no there is not a way

ebon ridge
#

@obtuse cosmos I don't know sqf libraries at all, but it does appear the examples at https://community.bistudio.com/wiki/ctrlSetPosition do something like that? They appear to create the control, apply the text, then get the width of the controls text and resize the control

#

Okay thanks @still forum

#

I have seen in the code I look at people using const variables as lookups into multidimensional array to achieve the same effect, I guess that is the best I can do!

obtuse cosmos
#

@ebon ridge Yeah but even if I do that, which I did try, I need to apply the default h value first?

#

RscText doesn't automatically adjust... Or am I missing something?

tough abyss
#

@ebon ridge you can make custom class in mission config and read it from mission, will be read only though

ebon ridge
#

Okay thanks, that sounds promising

daring vault
#

will magazinesAmmoFull return pylon ammo?

obtuse cosmos
#

@still forum any ideas? 😄

still forum
#

obtuse cosmos
#

😦

#

😢

#

Is it possible?

still forum
#

Don't know. Didn't read

obtuse cosmos
#

LOL

#

😦

#

Thanks, great help 😄 😛

ebon ridge
#

Actually your problem isn't solvable Haz 😃

#

Although maybe I don't understand, you want to size the control to the predicted size of the string right?

obtuse cosmos
#

yes

#

So easy with JS, web dev, etc

#

god damn SQF

ebon ridge
#

Without wrapping?

obtuse cosmos
#

It can go to next line, etc

#

but then next time after that needs to be after

#

if that makes sense, lol

ebon ridge
#

Yeah it won't work like that, to get wrapping you need to constrain the control in the horizontal direction right?

obtuse cosmos
#

It will be forced full width

#

Only want the h value to adjust dynamically based on text string length

ebon ridge
#

My guess: you should enable wrapping (if it isn't enabled, looks like it needs ST_MULTI flag somewhere or something, I don't know), then set the control width to whatever your fixed max size is, set the control height to some large value so the text will definitely fit, then commit that, then use ctrlTextHeight to get the height of the text in the control and resize the control back to that height. Did you try this?

obtuse cosmos
#

I even tried RscTextMulti

#

ah

#

so set huge value as default

#

I was trying to do it backwards 😄

#

by trying to get height first which was confusing me 😛

ebon ridge
#

Yeah constrain the width of the control first, then ask for the height

#

I would guess

obtuse cosmos
#

Just to confirm, I am getting ctrlTextHeight of _message? _height = ctrlTextHeight _message;

ebon ridge
#

Just to clarify I have never written a line of sqf UI code in my life (lots of other UI), I am just guessing from reading the docs right now 😃

#

But yeah I guess the same as in the example in the link I gave but set the width to a fixed value instead of the height, and call ctrlTextHeight instead

tough abyss
#

At least someone on this discord reads docs

obtuse cosmos
#

I did read the docs.

#

Even though I already knew the commands. I was just getting confused hehe.

#

Happens when switching between full stack and SQF

#

@ebon ridge RscTextMulti doesn't seem to use full width 😒

#

And RscText just goes all the way across.

ebon ridge
#

As in RcsTextMulti control doesn't use full screen width?

tough abyss
#

Best way to do a waitUntil X happens OR a time has elapsed?

astral dawn
#

waitUntil {([X] call fnc_happens) || (time > time_has_elapsed)} ?

#

:DDD

#

why don't you like this?

tough abyss
#

Didn't know you could do time > time, I was only aware of sleep and for _i

astral dawn
#

well time returns a number (of seconds)

tough abyss
#

makes sense lol

astral dawn
#

so you decide the time threshold, like _timeThreshold = time + 10; // 10 seconds after now

golden storm
#

Hello guys, quick question:

So, i've used:

tablerob setObjectTextureGlobal [0, "pics\tablero1.paa"];

on a Whiteboard, and the image does displays, yet it stretches out and the borders are cut out, any ideas as to why?

Resolution of pictures is n^2 (1024x512) and .paa format

robust hollow
#

(assuming its the vanilla whiteboard) the height and width should match (BI uses 2048x2048) and the top and bottom borders are blacked out. heres what i mean
https://i.imgur.com/a0sdenN.png

tough abyss
#

I'm getting this error on line 47 apparently:

14:48:44 Error in expression <aram [2, "ASIS", [""]];
_cond         = _this param [3, {false}, ["",{}]];

here's the relevant code

_nearestunits = nearestObjects [getPos _unit,["Man"],200];
        _nearestfriendlies = [];

        if((side _unit) countSide _nearestunits > 0) then{
          {
             if ((side _x == side _unit) && !(isPlayer _x) && (behaviour _x != "COMBAT")) then {_nearestfriendlies = _nearestfriendlies + [_x]};
          } foreach _nearestunits;
        };

        //turn to look at them and wave
        _calledTroop = _nearestunits select 0;
        _unit lookat (getPos _calledTroop);
        _unit setDir (_unit getDir (getPos _calledTroop));
        _unit playMove "Acts_PercMstpSlowWrflDnon_handup2"; //wave SOS, over here

        //troop 2 approaches
        _calledTroop forceWalk true;
        _calledTroop doMove _objectPos;

        //both turn to object
        waitUntil {(_calledTroop) distance (_objectPos) <= 1};
        _unit setDir (_unit getDir _objectPos);
        _calledTroop setDir (_calledTroop getDir _objectPos);

        //troop 1 points
        _unit playMove "HubBriefing_pointAtTable";
        [_calledTroop, "STAND", "ASIS",_calledTroop,true] call BIS_fnc_ambientAnimCombat;
robust hollow
#

what does it say after that error? there should be a reason why it errored

#

also side note, you dont need to use _this with param, it will work the same
_this param [3, {false}, ["",{}]]; -> param [3, {false}, ["",{}]];

tough abyss
#

Type object expected string, code

robust hollow
#

oh is the error coming from BIS_fnc_ambientAnimCombat?

tough abyss
#

apparently, but it says line 47 which doesn't line up

#

line 47 is if ((side _x == side _unit) && !(isPlayer _x) && (behaviour _x != "COMBAT")) then

robust hollow
#
[_calledTroop, "STAND", "ASIS",_calledTroop,true]
[object,string,string,object,bool]
[0,1,2,3,4]

index 3 is an object but it should be a string or code

tough abyss
#

I see what it's saying, but I don't understand why _calledTroop is NOT an object

#

now that you point it out anyway

robust hollow
#

it is an object, the script doesnt want an object in index 3 though

tough abyss
#

Ohhhhh

#

It wants a position I think

robust hollow
#

no?????

#

the error told you what it wants, and i just did too

#

a string or code. its a condition

#
_unit           = _this param [0, objNull, [objNull]];
_animset     = _this param [1, "STAND", [""]];
_gear           = _this param [2, "ASIS", [""]];
_cond         = _this param [3, {false}, ["",{}]];
_behaviour     = _this param [4, "COMBAT", [""]];
tough abyss
#

Ohhhh

still forum
#

params :U

tough abyss
#

I copied this over from BIS_fnc_ambientAnim without checking the differences

#

is "COMBAT" a condition for param 3? because it's saying it's undefined

robust hollow
#

no it is not

tough abyss
#

wtf

#

It says string or code

robust hollow
#

the script converts the string to code, so "COMBAT" would turn into {COMBAT} and as COMBAT is not a defined variable, you get an error.

tough abyss
#

So string is useless in there then?

robust hollow
#

no?

tough abyss
#

if it gets converted to a not-string, then why put a string

robust hollow
#

because it is a condition

tough abyss
#

so it's a bool?

robust hollow
#

it needs to return one yes

#

however looking for combat is a waste of time because the function does that already
(behaviour _unit == "COMBAT")

tough abyss
#

so if I want the condition to be "unit is in COMBAT state"

robust hollow
#

if you have no additional conditions to add just put that element in the array as nil

tough abyss
#

the line you posted or literally just "nil"?

robust hollow
#

nil, no quotes

tough abyss
#

I don't understand how that's looking for the combat state, or is it because the behaviour param 4 is already defaulted to combat?

robust hollow
#

have you read the BIS_fnc_ambientAnimCombat file?

#
    //wait for unlock condition evals to true
    waitUntil
    {
        sleep 0.1;

        (behaviour _unit == "COMBAT") || {(damage _unit > 0) || {(_unit call _cond) || {(_unit call BIS_fnc_enemyDetected)}}}
    };
tough abyss
robust hollow
#

in the game files

#

a3\functions_f\ambient\fn_ambientanimcombat.sqf

#

i think you should read it if the wiki alone isnt explaining the arguments well enough

astral dawn
#

How do you guys handle writing code with lots of SQF functions?
I can barely remember all their names and parameters and looking them up even in the NaturalDocs database is quite time consuming.
Maybe there is some Eclipse plugin which can parse my files for special tags that tell this plugin 'hey look this is a function definition over there' and then help my by completing what I type?

tough abyss
#

Any idea what this means?
15:19:06 [man1,38: <no shape>]

#

I'm guessing it's from my nearestunits thing, but that's they guy who's searching for the nearest friendly unit

robust hollow
astral dawn
#

Yes it helps you with built-in SQF functions, I think
However I need support for my functions

robust hollow
#

ohh, idk then. i just look in my function file if i forget.

#

@tough abyss im assuming its an array from this line?

_nearestunits = nearestObjects [getPos _unit,["Man"],200];

["Man"] will return ambient life like snakes too, so perhaps that is what 38: <no shape> is 🤷

tough abyss
#

Ok weird

#

That explains why the second half of the script isn't working at least

#

How do I make sure it's a man?

still forum
#

Use CAManBase

#

instead of Man

tough abyss
#
if((side _unit) countSide _nearestunits > 0) then{
          {
             if ((side _x == side _unit) && !(isPlayer _x) && (_x == CAManBase) && (behaviour _x != "COMBAT")) then {_nearestfriendlies = _nearestfriendlies + [_x]};
          } foreach _nearestunits;
        };

Something like that?

robust hollow
#

no

#
_nearestunits = nearestObjects [getPos _unit,["CAManBase"],200];
tough abyss
#

_nearestunits = nearestObjects [getPos _unit,["CAManBase"],200];

#

Gotcha

#

but wait, there aren't any snakes in VR

robust hollow
#

ok, well u want to use CAManBase anyway

tough abyss
#
15:45:36 Error in expression <((count _nearestunits) < 1) then {
_             _unit playMove "HubBriefing_think";
} el>
15:45:36   Error position: <_unit playMove "HubBriefing_think";
} el>
15:45:36   Error Missing ;
15:45:36 File DistractionByAxebeard\distraction.sqf, line 46
15:45:36 Error in expression <((count _nearestunits) < 1) then {
_             _unit playMove "HubBriefing_think";
} el>
15:45:36   Error position: <_unit playMove "HubBriefing_think";
} el>
15:45:36   Error Missing ;
15:45:36 File DistractionByAxebeard\distraction.sqf, line 46
15:45:36 [man1,35: <no shape>]
#

line 46 is _unit playMove

        if((side _unit) countSide _nearestunits > 0) then{
          {
             if ((side _x == side _unit) && !(isPlayer _x) && (behaviour _x != "COMBAT")) then {_nearestfriendlies = _nearestfriendlies + [_x]};
          } foreach _nearestunits;
        };
        
        if ((count _nearestunits) < 1) then {
_             _unit playMove "HubBriefing_think";
        } else {
        //turn to look at them and wave
        _calledTroop = _nearestunits select 0;
robust hollow
#

_ _unit playMove "HubBriefing_think";
_ at the start of the line

tough abyss
#

shit, the stuff you see after you post this crap

#
_             _unit playMove "HubBriefing_think";
} el>
15:50:26   Error position: <_unit playMove "HubBriefing_think";
} el>
15:50:26   Error Missing ;```
#

Still giving me missing ; on 46, but it shows up by HubBriefing

robust hollow
#
ConnorToday at 8:46 AM
_             _unit playMove "HubBriefing_think";
_ at the start of the line
tough abyss
#

I deleted it, maybe I forgot to rebuild

#

Awesome, no errors, but the nearestunit never shows up

#

Is this adding into the array correctly?

_nearestunits = nearestObjects [getPos _unit,["CAManBase"],200];
        _nearestfriendlies = [];

        if((side _unit) countSide _nearestunits > 0) then {
          {
             if ((side _x == side _unit) && !(isPlayer _x) && !(behaviour _x == "COMBAT")) then {_nearestfriendlies = _nearestfriendlies + [_x]};
          } foreach _nearestunits;
        };
robust hollow
#

yea, though thats not how i would do it

tough abyss
#

hey if you want to pretty it up

#

Use nearentities

#

would I have to run nearEntitites, then nearestObjects from that array?

#

Instead of nearestObjects

#

like this?

_nearestunits = nearEntities ["CAManBase",200];
        _nearestfriendlies = [];

        if((side _unit) countSide _nearestunits > 0) then {
          {
             if ((side _x == side _unit) && !(isPlayer _x) && !(behaviour _x == "COMBAT")) then {_nearestfriendlies = _nearestfriendlies + [_x]};
          } foreach _nearestunits;
        };
robust hollow
#

_unit nearentities["CAManBase",200];

tough abyss
#

ahh

digital hollow
#

Is it possible to point a helicopter doorgun using animations?

#

Neither of these seem to work

_heli animate ["MainTurret", 1];
_heli animateSource ["MainTurret", 1];
shadow sapphire
#

Is there any simple thing I could drop into an 3den placed unit's init that would add it to a named headless client?

still forum
#

not really

#

init probably fires bef... mh

shadow sapphire
#

Ah, I see. That makes sense. What about a long sleep and then it fires?

still forum
#

"named hc" you mean you've put the ownerID of the HC into a variable? or put a variable onto the hc module?

shadow sapphire
#

In an 3den placed headless client module, I typed "HC1" into the variable name line.

still forum
#

dunno if module changes ownership over to the HC machine. So don't know if that's of any use

#

you somehow have to get the ownerID of the HC. Or find out if certain script is executed on the HC

shadow sapphire
#

OwnerID of the HC? Like it's number identification thing? Is there something I could run that could grab that?

still forum
#

yes. yes. That's what the question is.

#

do you only have one HC?

shadow sapphire
#

Okay, I see. Hmm... I've never had luck getting a headless client's ownerID. Been struggling with this on and off for a while.

#

Eh, oh, well. I guess I'll go with the old round robin headless client balancing script. I only don't like that script because it rebalances repeatedly on a timer, and for this specific case, that step is completely unnecessary. No AI are added throughout the mission.

still forum
#
this spawn {
sleep 60;
if (isDedicated && !isServer) then {
[(group _this), clientOwner] remoteExec ["setGroupOwner", 2];
};
}

that probably

#

should work if you only have a single HC. If you have more then this... will end up on a random one I gues

shadow sapphire
#

That LOOKS like exactly what I was hoping to get. I definitely will have multiple headless clients, but as long as the AI end up relatively evenly balanced across them, that should be enough.

#

I hate to ask for more, but would you know of a simple way to look at an AI and check their owner?

still forum
#

0 guarantee on balance. Basically the last HC to initialize will get all the units with that init script

shadow sapphire
#

Ah, interesting. Still better than having all these AI on the server!

still forum
#

objectOwner command. Or maybe just owner something like that. Though I think only works reliably on server?

shadow sapphire
#

Ah, bummer.

surreal vapor
#

Has anyone had any accuracy issues using modelToWorld with worldToScreen?

#

I'm using these to draw the joint locations of soldiers on the screen

#

It generally works well...but when the soldiers start running around, the drawn points move off the soldiers

surreal vapor
#

nevermind! Apparently there's something called modelToWorldVisual that appears to resolve the issue!

#

whewwwwwwww

sage yacht
#

is there anything wrong with this while ?

#

while {alive player && _captureStatus != true} do

sturdy cape
#
while {((alive player)  && ( _captureStatus != true))} do``` but thats just my opinion 😅
sage yacht
#

Well I keep getting this error and I dont know why

#

I cant post image :/

sturdy cape
#

Just try it out. Have all multiple conditions in whiles like that and they work

sage yacht
#

thats the error I get

robust hollow
#

cant use != == operators to compare bool, and doing so like that doesnt make sense anyway

#

change _captureStatus != true to !_captureStatus.

#

this is assuming you redefine _captureStatus in ur loop tho, otherwise itl never change

sage yacht
#

wait I cant use != or == to compare bools

#

.>

robust hollow
#

yes. the wiki tells you this. and as i said in this case it doesnt make sense anyway.

true will never not be true so doing what u have is like this

_captureStatus != true
false != true
!false
true

if that makes sense

#

if you were comparing two bool variables that could both be modified then it makes sense, like _bool1 isEqualTo _bool2 but in this case it isnt soo

sage yacht
#

ok

#

so if _isCaptrued was set to true

#

and I did while {(!_isCaptrued)}

#

would that mean while its not false?

robust hollow
#

while it is false

sage yacht
#

ok

robust hollow
#

!false is true

sage yacht
#

so its the opposite of what its initialized to?

robust hollow
#

ye

sage yacht
#

Ok thanks lol

mortal wigeon
#

What are the differences between CBA_fnc_addPerFrameHandler and addMissionEventHandler ["Draw3D", . . . .?

robust hollow
#

CBA_fnc_addPerFrameHandler is an EachFrame event not Draw3D.
Draw3D will not fire if tabbed out of the game, EachFrame will.
here is a more noteworthy difference Dedmen posted not too long ago:
Draw3D is called at the end of the frame, after simulation, but before rendering. EachFrame handler fires before simulation.

mortal wigeon
#

OK, thanks. I'm trying to R2T a camera view from a moving object but the view from the camera jitters a lot. I'm wondering if my implementation of Draw3D is the problem and am trying to work out the CBA syntax.

#

Currently getting deep CBA errors because I think I formatted the CBA_fnc_addPerFrameHandler bit wrong

#
    ST_Cam_Handler=
    [
        {
            if (isNil "ST_cam") exitWith
            {
                [ST_Cam_Handler] call CBA_fnc_removePerFrameHandler;
            };
        
            _TGPPovPos = ST_v modelToWorldVisualWorld (ST_v selectionPosition "TGPPos");
            _TGPDirPos = ST_v modelToWorldVisualWorld (ST_v selectionPosition "TGPDir");
            
            _TGPDir = _TGPPovPos vectorFromTo _TGPDirPos;
            
            _TGPDirFar = _TGPDir vectorMultiply 1000;
            _TGPTarget = _TGPPovPos vectorAdd _TGPDirFar;
            
            ST_cam camSetTarget (ASLtoAGL (_TGPTarget));
            //ST_cam camSetTarget [4000,4000,0];
            
            ST_cam cameraEffect ["internal", "BACK", "screen"];
            ST_cam camCommit 0;
            
            hintSilent str (ASLtoAGL (_TGPTarget));
        },
        0,
        [ST_cam, ST_v]
    ]
    call CBA_fnc_addPerFrameHandler;```
#

It complains about undefined variables

#

ST_cam is a camera created and attachTo'd a plane. screen is the surface of the MFD inside the cockpit.

robust hollow
#

well, if variables arent defined the easiest fix is to define them...

mortal wigeon
#

Yes but I'm not sure what's not defined

#

screenie inbound

robust hollow
#

also i see you defining these as arguments [ST_cam, ST_v] but then using their global variable anyway (making them being in the argument array pointless).
not sure exactly what to say about that error, are you running ur code in the editor debug? i dont know if perframe would be running in editor 🤔

mortal wigeon
#

No it comes from the plane's config.cpp on init

#

it's called from the config.cpp I should say

robust hollow
#

does the script work when you load into the mission?

mortal wigeon
#

Yes, though the camera view still jitters so using the CBA handler instead of Draw3D didn't solve my problem

robust hollow
#

what, running CBA_fnc_addPerFrameHandler in a Draw3D event?

mortal wigeon
#

no no sorry

robust hollow
#

oh lol, misread that

mortal wigeon
#

instead of Draw3D

#

Basically I'm trying to put the turret view (not pilot camera) onto the cockpit MFDs and the view jitters at a very high frequency and it's been driving me nuts

#

Can't solve it

robust hollow
#

i wouldnt expect the perframe handler to work in editor, so you may need to work in some check to exit the script if the perframe init hasnt executed.
as for the jittery camera i dont know what to do about that.

mortal wigeon
#

Well, right now the CBA function has the same result as Draw3D but adds mod dependency so I'll just go back to Draw3D

robust hollow
#

it wont help the jittering at all but you would probably want to use EachFrame instead of Draw3D otherwise itl look a frame behind. that was an issue someone else was having earlier.

mortal wigeon
#

That indeed did not solve the jittering but I'll keep it with eachFrame for now

#

One solution would be to smooth the data, but I have no idea how to do that

cursive whale
#

I've been dealing with something similar (that was an issue someone else was having earlier) but EachFrame doesn't work as I need to set the camera position based on the current visual state. I would say though that I only get jitter when trying to correct for lean (with insufficient accuracy available for those inputs), otherwise I've found the RTT camera source rock solid. I'd look again at how you're setting the camera position/direction.

mortal wigeon
#

The camera position is set with attachTo, and in the feed the position appears rock solid. It's the orientation that jitters

#

Which is all controlled by the code I pasted above

cursive whale
#

Mmmm... not sure I understand the context, is this like a gun feed? Wouldn't attachTo negate any need to fiddle with the camera pos/dir via script?

mortal wigeon
#

I'm making a Super Tucano, which has a backseater (gunner) who controls a sensor ball (turret) under the fuselage. I have the gunner's turret view displayed on MFDs in the cockpit for both pilot and gunner.

cursive whale
#

I'd have thought it was one or the other; attachTo or per-frame positioning in script.

mortal wigeon
#

I create a camera and attach it to the turret pov position with attachTo, then update it's orientation with the above

#

attachTo doesn't keep it oriented with the turret

#

Same problem with setPos

cursive whale
#

well don't you want to just bin attachTo and set pos/dir purely in script? might be why you're getting jitter.

mortal wigeon
#

setPos has the same behavior

cursive whale
#

Camera SetPosATL _o;
Camera SetVectorDirAndUp [_v, [0,0,1]];

#

gives me no jitter, i only get it when I try to fix lean (up) with insufficiently accurate inputs

tough abyss
cursive whale
#

should add, i think you'd want setPosASL given you're getting the selection pos in world coords

frigid raven
#

asked that before but forgot the answer. I can't skip a forEach iteration with exitWith right?

#

aye

tough abyss
#

You can if you include inside of the loop in another scope like {call {if true exitwith {}}} foreach array

mortal wigeon
#

I solved it!!!!!!!!

#

It works if I do everything in modelspace until the last moment, then take that resulting point, convert it to worldspace, and point the camera at it

#

That seems reasonably steady and usable

#

I can do extreme zoom from high up and the camera doesn't give me a seizure

#

It doesn't point at exactly the right spot, but the MFD crosshairs and the actual turret view crosshairs are only about a meter apart when zoomed in like 30x from 10,000'

#

So good enough

#

I'll shift the MFD crosshairs over slightly if I have to lol

ebon ridge
#

Question: private _x = 0; or private "_x"; _x = 0; Docs don't explain why I would need quotes to declare a private variable. It seems to imply you need quotes unless you are initializing the variable in the same statement. Is this the case?

cursive whale
#

yes (both are correct afaik, but the first is better for obvious reasons)

tough abyss
#

first private is keyword , second is command, does it not say that?

ebon ridge
#

Yeah I missed the significance of the word "command" in the https://community.bistudio.com/wiki/Variables section. Because why would that be a thing when there is a keyword, and not be called out in more explicit terms. The docs aren't clear there. In fact it says you should use the private command. Then in a further section transitions to using the keyword without calling out the difference.

#

Anyway thanks for the answer

#

Ah, it is editable wiki!

tough abyss
#

Private keyword was introduced later (the biki says so BTW) and some of the references contain old usage examples

ebon ridge
#

I might clarify it on that page

tough abyss
#

Actually the keyword existed for years, it was misleadingly called local and no one knew it existed

#

then it was renamed into private and made public

sudden yacht
#

Looking for a script that in this case randomly sets damage of 1, to one of three units. If anyone could provide a finished example it would be appretiated. Variable Name of units are: P1, P2, P3

tough abyss
#
selectRandom [P1,P2,P3] setDamage 1;
sturdy cape
#

👆 😆

tulip smelt
#

Can somebody help me out here. I'm running a mission as Zeus for some friends, and I want to play some music in helicopters while they are getting ferried around. I've got some code that works for one person apparently, but not for the rest of the group.

#

this addEventHandler ["Engine", {
params ["_vehicle", "_isEngineOn"];

if !(player in _vehicle) exitWith {}; 

if (_isEngineOn) then { 
    5 fadeMusic 1; 
    playmusic "music2"; 
}; 

}];

this addEventHandler ["GetIn", {
params ["_vehicle", "", "_unit"];

if (_unit != player) exitWith {}; 

if (isEngineOn _vehicle) then { 
    5 fadeMusic 1; 
    playmusic "music2"; 
}; 

}];

this addEventHandler ["GetOut", {
params ["", "", "_unit"];

if (_unit != player) exitWith {}; 

playMusic ["", 0]; 

}];

astral dawn
#

Event handlers added with addEventHandler fire only on the machine this code was executed at

still forum
#

it says this. Thus init box of a vehicle. thus firing globally. thus eventhandlers added everywhere, thus eventhandlers fire everywhere

astral dawn
#

Even with JIP?

#

I mean it won't add them to JIP queue, or will it?

dim kernel
#

the accessories button doesn't work with modded guns?

still forum
#

yes init stuff runs at JIP too

#

no it doesn't add it to the queue, doesn't need to

astral dawn
#

well it would be same in this case anyway

#

should work then 🤷

tulip smelt
#

I've been adding and editing it with zeus, but it seems to only work for one player at a time.

astral dawn
#

'one player' - you or some other guy?

tulip smelt
#

Other people. Or the first one in the heli

astral dawn
#

Just to be sure, you execute this before everyone gets into the helicopter, right?

tulip smelt
#

Yep

still forum
#

adding and editing it with zeus explain what that means?

tulip smelt
#

Adding the code to the heli's init. And editing to change between 6 different songs. During gameplay that is.

tough abyss
#

@dim kernel what accessories button?

still forum
#

"during gameplay" how?

astral dawn
#

zeus has this init box if you click on unit like in the normal editor

#

but I couldn't find if it runs the code locally or globally in a reasonable amount of time on wiki... so 🤷

tulip smelt
#

What he said @astral dawn

astral dawn
#

I guess if it runs on another guy's computer then it's global though

tulip smelt
#

Yeah, but it only seems to work on the first player in the heli.

#

And I can change it while no one is in it, and that works. But again only for the first person in.

cursive whale
#

first player in makes the heli local to that player?

dim kernel
#

@tough abyss the weapon shop

tough abyss
#

what weapon shop?

dim kernel
#

altis

tough abyss
#

There is weapon shop on altis with accessories button?

dim kernel
#

ye?

tough abyss
#

Where?

young current
#

Altis life...

#

Likely

tough abyss
#

What's Altis life?

dim kernel
#

can someone else help me?

still forum
#

Yes I'm here. What do you need help with?

tough abyss
#

the car script

still forum
#

@tough abyss I asked him, not you.

dim kernel
#

when u select modded guns in the weapon shop

still forum
#

what weapon shop?

dim kernel
#

the accs button gets disabled

#

altis life

still forum
#

which accs button?

tough abyss
#

@still forum And I'm not talking to you 😂

dim kernel
#

1 sec

#

i use this to check for attachments that work on guns

#

isArray (configFile >> "CfgWeapons" >> _item >> "WeaponSlotsInfo" >> "PointerSlot" >> "compatibleItems")

#

but doesnt work for cup

spark turret
#

@tulip smelt try to get an array of all units in the vehicle and then play the music foreach of the passengers

dim kernel
#

@still forum ^^^

spark turret
#

might be a workaround for music playing locally

still forum
#

don't see what that has to do with some accessories button on altis 🤔

dim kernel
#

i checked in cup cfgweapon its different from arma guns

still forum
#

It's probably using CBA jointrails

tulip smelt
#

Yeah, that might be worth a try

spark turret
#

@tulip smelt just make sure you dont have 20 songs playing at the same time lol

tulip smelt
#

You bet 😄

dim kernel
#

dedmen can i speak to u in private so i can explain my self?

spark turret
tulip smelt
#

@spark turret TY

spark turret
#

npö

#

np*

dim kernel
#

@still forum can we talk in private?

still forum
#

nah

tough abyss
#

@tulip smelt looking at Zeus object placement dialog, where is the init you edit exactly?

spark turret
#

double click on unit, paste to init @tough abyss

#

might be an ares / achilles thing idk

tulip smelt
#

Achilles

tough abyss
#

Achilles?

spark turret
#

its a mod that gives more zeus options

#

check it out, makes things a lot easier

tulip smelt
#

Yeah

tough abyss
#

Right, so it is a modded init, that doesn't fire like normal init. Problem solved

spark turret
#

no it does fire normally

#

problem is more likely the code itself

tough abyss
#

Well @tulip smelt should have mentioned this at the beginning that it was a mod

#

No the code is fine

#

it would have worked for normal init

tulip smelt
#

Didn't really know why it would make a huge difference

tough abyss
#

because init is engine processed

#

the one in the mod is scripted piece of shit

spark turret
#

are we aware that the eventhandler starts a new song for every player getting in the heli?

tulip smelt
#

I have it in the init of the heli in eden too. Still doesn't work as it ought to.

spark turret
#

i dont see a remove eventhandler so i guess every new passenger restarts the song.

tough abyss
#

what same symptom, works for the first player only?

still forum
#

playMusic isn't global. @spark turret

tough abyss
#

^^^ this

spark turret
#

alright thats okay. that means the music is executed for the heli not the player getting in tho

tough abyss
#

it is local so it is executed for the player

still forum
#

no it's not @spark turret

tulip smelt
#

The music is only supposed to play after a player get in and the engine is turned on.

spark turret
#

hm is that even possible if the music cant be global?

tough abyss
#

yes your code is kinda trying to do that and I dont see any problem with it

spark turret
#

tho i admit i dont fully understand local/global differences

#

rabbits are local units are global

tough abyss
#

hm is that even possible if the music cant be global? yes you can play soundfile with playSound3d

spark turret
#

thats all i know

tulip smelt
#

So I need to use playSound in place of playMusic?

tough abyss
#

I don't know, the mod init is broken, I guess no one knows what is best

#

BTW you can make sure that person joining the heli later will have the song started from the same time as the rest

velvet merlin
#

any suggestions about meaningful approach for bagpipe songs playlist (you can play when you have it as weapon in your hands)

#

like radio menu, comms menu, action menu, etc

#

GUI dialog

#

other means of interaction

astral dawn
#

Star Citizen interaction menu with the bagpipe :DD

edgy dune
#

lol

velvet merlin
#

@astral dawn have a video?

astral dawn
#

trying to find it... but it was a joke really
it has a fancy interaction menu with 3D icons, you look at your gun and it shows a list of available actions you have to click on

tough abyss
#

@velvet merlin make them as weapons that play sound when you fire

#

then you can change muzzles with normal muzzle selection

velvet merlin
#

@tough abyss its about the selection from different tunes

tough abyss
#

yeah make tunes as different magazines then

#

unless you want to add a bunch of soundfiles and let user press keys for notes @velvet merlin

vagrant urchin
#

Hey, I'm trying to use attachTo in order to attach an object to a vehicle interior.
When I'm outside of the vehicle the object is there, however when I get inside it disappears.

exotic tinsel
#

is there a way to execute code on arsenal close that does not require using the missionnamespace arsenalClosed method?

astral dawn
#

@vagrant urchin vehicle interior is rendered OVER the outside world

#

the attached object belongs to the outside world

vagrant urchin
#

So there's no way to make it show from the interior?

young current
#

@vagrant urchin no

astral dawn
#

🤔 maybe if you use the vehicle-in-vehicle built in functionality? How does stuff get rendered with veh. in veh. things in arma? Or it it also broken?

young current
#

I doubt viv stuff shows any better if you go to a cargo seat and look at them

#

But I also don't think there are such vehicles you could see the viv attached vehicles from cargo seat

astral dawn
exotic tinsel
#

@astral dawn yes

astral dawn
#

hmm and why don't you like it?

exotic tinsel
#

i have my reasons hence the request for help. dont want to write a whole doc on it. just doenst work for what i need to do.

#

any other ways you can think of?

astral dawn
#

I guess you could manually poll for creation/destruction of the arsenal display or something like that?

#

IDK how the arsenal is implemented, is it creating another display probably?

tough abyss
#

Maybe add ui event handler to the arsenal display and see if it fires on close

mint kraken
#

So... Preprocessor failed with error - Invalid file name (empty filename) Not sure how to solve this.

#

What is this caused by?

high marsh
#

Obviously a preprocessor command was used, and a invalid file name was used

mint kraken
#

All of mine looks fine, The only thing I have added is #include "\A3\Functions_F_Exp_A\EGSpectatorCommonDefines.inc"

still forum
#

I just found a gem in my 5 year old script collection

if (isNil "dedmenfnc_execOnPlayerName") then {
    dedmenfnc_execOnPlayerName = {
        _index = round(random 50);
        call compile format["dedmenfnc_execOnPlayerName_name%1 = _this select 0;publicVariable ""dedmenfnc_execOnPlayerName_name%1"" ", _index];
        call compile format["dedmenfnc_execOnPlayerName_fnc%1 = _this select 1;publicVariable ""dedmenfnc_execOnPlayerName_fnc%1"" ", _index];
        call compile format["[-1, {_result = [name player, dedmenfnc_execOnPlayerName_name%1] call CBA_fnc_find; if (_result != -1) then {call dedmenfnc_execOnPlayerName_fnc%1}}] call CBA_fnc_globalExecute;", _index];
    };
};
publicVariable "dedmenfnc_execOnPlayerName";

["dedmen",{[player] join grpNull;}] call dedmenfnc_execOnPlayerName;

Isn't it beautiful?

crystal schooner
#

I'm making a NFZ script that will toggle map color from Green to Red and opposite but after the GUI action it will not execute the script

_Action = ["Are you sure you would like to enforce a NFZ","Toggle NFZ in Kavala","Toggle NFZ",true] spawn BIS_fnc_guiMessage;

if (_Action) then {
    if (markerColor "NFZ_Kavala" == "colorIndependent" && markerColor "NFZ_Border_Kavala" == "colorIndependent") then {
        "NFZ_Kavala" setMarkerColor "ColorOpfor";
        "NFZ_Border_Kavala" setMarkerColor "ColorOpfor";
    }
    else
    {
        "NFZ_Kavala" setMarkerColor "colorIndependent";
        "NFZ_Border_Kavala" setMarkerColor "colorIndependent";
    };
};
robust hollow
#

you need to call BIS_fnc_guiMessage so that whole script needs to be in a scheduled environment

#

to explain further: spawning BIS_fnc_guiMessage returns the script thread, calling it will return the true/false button click but that uses waituntil which is why you need to spawn that whole snippet

crystal schooner
#

Ahh ok ty

#
_Action = ["Are you sure you would like to enforce a NFZ","Toggle NFZ in Kavala","Toggle NFZ",true] call BIS_fnc_guiMessage;

if (_Action) then {
    if (markerColor "NFZ_Kavala" == "colorIndependent" && markerColor "NFZ_Border_Kavala" == "colorIndependent") then {
        "NFZ_Kavala" setMarkerColor "ColorOpfor";
        "NFZ_Border_Kavala" setMarkerColor "ColorOpfor";
    }
    else
    {
        "NFZ_Kavala" setMarkerColor "colorIndependent";
        "NFZ_Border_Kavala" setMarkerColor "colorIndependent";
    };
};
#

Now action isnt working

robust hollow
#

is there an error?

crystal schooner
#

Fixed it had to put it in a [] Spawn { in here };

robust hollow
#

ahh, yea i did mention that 😦

random estuary
#

Anyone know the actionKeys name for switching to secondary weapon?

robust hollow
random estuary
#

Thanks, will give that a go

grizzled spindle
#

is running a SetVariable public pretty much running a RemoteExec on all clients?

still forum
#

not really

#

depends on what you mean by "pretty much"

#

technically the answer is "No absolutely not"

grizzled spindle
#

Okay, sorry for not really specifying.

#

What im talking about is will if affect server performance as much?

robust hollow
#

itl have some kind of impact, its being sent across the network. a single call wouldnt be noticeable (depending on the size of the data) but spam the command and you will lag ur server out.

its more like using publicVariable(client|server).

grizzled spindle
#

The reason for my question is im trying to find out whats more efficient for a inventory, setting variables when the inv is edited and initialised and broadcasting to everyone(public) or grabbing from a database on demand

#

As currently when a player joins our server (rp) it loads houses then for each house it has crates, each crate has a inventory. For for example one person has 3 houses and each house has 3 crates thats 9 variable sets then at peak times we have 120-130 players so its a lot of variables for the server to keep track of and when someone edits that inventory it has to send the new variable to every player again

astral dawn
#

Also I think you can't remoteExec setVariable on missionNamespace publicly 🤔

robust hollow
#

in theory only sending the data when someone asks for it is better. you will just need to set it up properly otherwise itl end up sending more often than just using a public variable.

still forum
#

Also I think you can't remoteExec setVariable on missionNamespace publicly I don't know a reason why you couldn't

robust hollow
#
[missionnamespace,["test",4]] remoteexec ["setvariable"]

👌

astral dawn
#

Ideally server should always know what's the inventory state of each crate, to account for condition when player crashes while messing with his crate.
then you can broadcast it to clients with different frequency depending on how far they are from crate 🤔
So, maybe try it like this: always send to server, send to clients when they really need it?

grizzled spindle
#

I was meaning the serVariable[“var_name”,”value”, true];

robust hollow
#

i assume its a virtual inventory so you would only need to send it to those who open the container. issue is keeping it updated (say you edit it then leave, then i edit it then you come back). sending the full inventory over and over could be worse in the long run

astral dawn
#

Or serialize crate access, only one player can mess with a crate at once 😄 so you only transmit data when player leaves the crate

grizzled spindle
#

Thats how it is but like you said if they crash or something happens

#

The proposed idea was: When open a crate grab data from DB, when when store and retrieve set in the DB(account for crash)

#

How it currently works, the inventory is loaded into a variable set publicly on the crate when the player joins

#

when the player stores or retrieves it sets the variable publicly(SetVariable["Inv", "Contents", true]) thus broadcasting to all players, If i remember correctly it sends to db on close dialog

#

I just feel setting the variable globally is a bit pointless and can cause quite a bit of lag, especially when 120+ people online

astral dawn
#

How many items are there? You could estimate traffic 🤔

grizzled spindle
#

What do you mean by items?

#

Inventorys?

astral dawn
#

I meant, in every inventory, how big is the 'Contents' variable

#

So that you could estimate the average traffic on your server, in bytes per second, you know

#

and then you might see if it occupies too much bandwidth or not 🤔

grizzled spindle
#

Interesting, hard to say really it depends on the player. But that a solid point though, didnt think of it like that. So if say one player had a huge inventory sending that to everyone via SetVariable would be quite a bit more expensive than just retrieving from a database

astral dawn
#

So let's say you have 32 items in each inventory in average, one item is a 64-byte string, you have 32 players accessing the inventory at a time in average, and every player takes/adds an item once per second, how much traffic that would be 🤔

#

that's 64 kbytes a second

#

from server to all clients

#

I guess modern PCs can handle that?

#

although... yeah, that's quite enough of BW

grizzled spindle
#

Well

#

Only one player can access a crate at a time, however players can edit multiple crates at a time

#

But yeah it is quite a lot, but 64Kb just for that, not to mention everything else going on

#

I think its fairly safe to say that its more efficient to pull and send to the database rather than setting public variables

robust hollow
#

im thinking so too, though you may still want to use some global method of marking the last time the crate was edited so you dont fetch the inventory if you already have the most up to date version of it.

dim kernel
#

how do i check if my inventory is full

#

i want to make a function that if my inventory is full it hints me

robust hollow
#

a possible quick way would be to do player canAdd "someItemWith1Mass", longer way would be to add up the mass of all items on u and see if it is equal to the max capacity of ur clothing.

oblique vale
unborn ether
#

If you want to get how loaded are you, you should use loadBackpack|loadVest|loadUniform which is 0..1 coeff value of total load. So if three of them are close to 1 - you are loaded to top. To determine this in mass values to make exact calculation you can use getContainerMaxLoad, multiply this value over stated coeff to get actual mass loaded and then count if mass of next item will fit into it. Also you might want to determine if there are equipment slots left, like headgear if its headgear you adding, etc.

#

Mostly this is easier just by canAdd and canAddItemToBackpack etc.

robust hollow
#

@oblique vale uniformItems appears to take a global argument

unborn ether
#

Depends on your application

robust hollow
#

his paste is a .bat tho 🤔

unborn ether
#

Oh sorry then, this is SQF channel, not PS

stray creek
#

Sorry, moved it now

tough abyss
#

pulling data from DB or broadcasting it I fail to see how this even comparable, 2 completely different operations

grizzled spindle
#

@tough abyss I wasn't trying to explicitly compare pulling data from DB and broadcasting, I was trying to compare what would be more heavy on the server, interacting with a database via getting and setting public variables OR interacting with ExtDB and modifying the database on each action.

tough abyss
#

Sorry what you are asking makes no sense to me

vale halo
#

This is a topic for both #arma3_scripting and #arma3_scenario actually. I'm working on a small mission where i want to use the restrict zone module. Although I can't get it to work at all. I opened the zone restriction fsm function to search for the way it triggers that the player is out of the 'zone' and it shows that it interacts with synced triggers.

The issue is that no mather how i sync a trigger, the player is always out of the "zone" and gets punished.

#

Anyone got this module working?

spark turret
#

@vale halo how about a normal Trigger zone detecting players, placing it at the Border and make it hint "youre leaving, Return or die" and then kill if triggered for 30 seconds

#

would give more dynamic fields anyways as the form is not restricted

vale halo
#

Yeah that would be a work around but I don't see why a module BI made is not working :P. The module actually gives quite a lot of freedom.

#

I might get it tho

#

it sais restricted area, might need to inverse it

#

😛

#

With the inversed value set to true it doesn't trigger at all 😦

#

Anyway, the script behind the module:

fn_moduleZoneRestriction.fsm

https://pastebin.com/ietyGRLV

So it seems to me that there needs to be a trigger set up in some way.

polar gull
#

Does anyone know why this script, when ejecting me from my heli, is setting my altitude to 450m in the air

#

I'm looking around line 53, but changing that 450 doesn't change anything.

tough abyss
#

player setpos [(getPosASL _heli select 0),(getPosASL _heli select 1),(getPosASL _heli select 2)+4]; setPos is AGL not ASL

vale halo
tough abyss
#

Oh god, no

#

use setPosASL

polar gull
#

ahh, ok. It's an old script snagged from the forums 😛

tough abyss
#

this will put player 4 meters above heli is that what you want?

polar gull
#

yes

#

thank yu

tough abyss
#

you could also write

player setPosWorld (getPosWorld heli vectorAdd [0,0,4]);
vale halo
#

Why actually not use getPos? I get its better to define the type of position you want to get/set but are there any other reasons?

tough abyss
#

Its broken

vale halo
#

Oh, oof, didn't know that 😛

#

Thanks

polar gull
#

@tough abyss Do i need to change line 61?

tough abyss
#

it gets really confused when there is a surface underneath and not the ground

polar gull
#

waitUntil {isTouchingGround player or time > _startTime or ((getPosASLW player) select 2) < 1};

#

change the ASLW to ASL?

tough abyss
#

That script is FUBAR

#

I dont really want to look at it feels dirty

#

and yeah this line is bad

#

you better write your own

polar gull
#

ok, because at the moment, it all works as planned.

#

until I hit the ground and then im put into the ACE3 incapcitated screen

tough abyss
#

doesnt mean it will always work

polar gull
#

which is what I'm trying to avoid, my scripting knowledge is shit.. so it's tricky for me

tough abyss
#

at least is has failsafe time > _startTime

polar gull
#

ok, well. it's not working anymore XD

tough abyss
#

isTouchingGround player is unreliable, getPosASLW is for when you land on water, if you land on water, so in the worst case you will be waiting for 10 seconds

frigid raven
#

Hey some question regarding tasks and completing them.
I just created a task for a sniper team. Just eliminate a fireteam sized enemy unit.
How does one actually make this task completed?
I thought about like having onKilled handler on those to-eliminate units and if all are killed I resolve the task as complete.
Is this the way to do it? Or is there some "framework" way?

spark turret
#

You can check the members of the enemygroup for being alive. If all are dead = task complete

frigid raven
#

yea gonna try that

#

I have a problem with Task namespace.
When creating a task with BIS_fnc_taskCreate and having that taskID it does not seem that I can access a namespace through this ID.
Does this has something to do with the "new" Task framework?

#

Do only tasks created by createSimpleTask own this Task namespace?

vale halo
#

Got the module working what I was talking about earlier, Put down a trigger with Any Player Present, Repeatable as condition and sync the module to the trigger. Although there is a bug that does not reset the punishment when you go back in the zone after a warning. Posted the bugreport in the feedback tracker - https://feedback.bistudio.com/T137065.

spark turret
#

@frigid raven idk about you, but i dont like task that tell me automatically if i killed the enemys nearby. how about a condition that sets to true only if you "confirmed your kills" by giving each enemy of the group a parameter "hasBeenConfirmedDead" and setting it to true when "if (!alive _enemyUnit && player canSee _enemyUnit)

#

so that the player must actually find and look at all the killed enemys to confirm the group has been killed

#

just an idea

frigid raven
#

@spark turret yea I rethought the idea as well. I don't want my mod to be too arcade. I decided to actually just track if the squad left the base, entered the task area, left it and reentered the base. That's all that should be tracked somehow to prevent exploiting a mission goal somehow

spark turret
#

i dont understand what that has to do with the enemy squad being killed being announced automatically

#

i dont think you could exploit my idea anyways, it actually keeps up tension bc the game doesnt tell you "area clear"

halcyon creek
#

Wondering if someone can help currently get an error when a script completes. it states that there is an undefined variable in the expression, however it still triggers what its supposed to, can anyone see what I have done wrong?


pistolIns sideRadio "nice";
["TaskSucceeded",["","Qualify on the Pistol Range"]] call BIS_fnc_showNotification;
_obj2 setTaskState "SUCCEEDED";}
 
 else {pistolIns sideRadio "testfail"; hint "You must requalify. See the Pistol Range Master";};
nopop=FALSE;```

Task Variable Name: obj2
Task ID: obj2

Error on Line 49 - Undefined Variable ``` Line 49 - _obj2 setTaskState "SUCCEEDED";}```
radiant egret
#

obj2 != _obj2 and the error msg already tells you what the problem is

halcyon creek
#

For someone who cant quite see it can you dumb it down?

west grove
#

you reference _obj2, and i'm pretty sure your script at this point doesn't know what that is

#

anyone around who can tell me the most efficient way of checking if (and what) the player is dropping from his inventory?

#

ok, found it just now. "put" EH is what i'm lookig for

halcyon creek
#

I see, but even when I just leave it at obj2 It still fires the same error

still forum
#

where is obj2 supposed to be coming from? your code doesn't show where that variable is set

halcyon creek
#

That would be because I havent set it

west grove
#

but you need to, otherwise the game doesn't know what it should set the task state to

#

'''myNewTask = player createSimpleTask ["NewTask"];

#

myNewTask setTaskState "SUCCEEDED";}

#

though, to be honest, i havent used these commands in ages. i'm only working with BI functions 😄

#

anyone can tell me the most efficient way to delete all dropped items from a mission?

#

like, everything a player might have dropped anywhere

velvet merlin
#

is there a way to make a display blocking (like a dialog), or use ctrlCreate with createDialog by some means?

mint kraken
#

I really want to know how EG spectator makes its camera move (wasd)? Can anyone help me out on this one. Been looking for a while

tough abyss
#

@velvet merlin blocking on what way

velvet merlin
#

_display = findDisplay 46 createDisplay "RscDisplayEmpty";
_listBox = _display ctrlCreate ["RscListBox",4711];

#

with this mouse wheel for example still activates action menu

frigid raven
#

@spark turret Ah alright then we just miscommunicated here. No offense

tough abyss
#

@velvet merlin looks like you need to create it with createDialog to block action menu

velvet merlin
#

ok was rather simple

createDialog "RscDisplayIntro";

_display = findDisplay 47;
_listBox = _display ctrlCreate ["RscListBox",4711];

exotic tinsel
#

are respawn event handlers stackable?

still forum
#

all addEH's are stackable

tough abyss
#

If you pass position as last statement, only position from the last one will be considered probably, otherwise you can have tonnes of them

exotic tinsel
#

cool thanks

burnt cobalt
#

is there a way I can check if a mission has ended on dedicated server? such as I would use isNull (findDisplay 46)

#

for a client

still forum
#

There is a MissionEnded eventhandler

burnt cobalt
#

haha i was hoping to avoid that but maybe there's no way around it 😄

#

thank you 😃

mortal nacelle
#

Question regarding the GUI editor, why on earth, even after I have set my layers up correctly can the RscText not be above the RscPicture that I have set from a paa

west grove
#

not that i know much about gui editing, but probably wrong layer order.

#

:>

#

i think the one created last is always above the others, no?

mortal nacelle
#

that wouldn't matter as I have redone my layers

#

the test should be above the card right

#

Or does the image have to be slightly transparent?

west grove
#

nah, then it'll just shine through

mortal nacelle
#

mmm

#

I tried it with transparency and it still doesn't allow text to show through it lol

astral dawn
#

Taking my words back, indeed it's possible to remoteExec a setVariable on missionNamespace with [missionnamespace,["test",4]] remoteexec ["setvariable"], just tested it
It failed on me once and I thought that missionNamespace is non-serializable 🤔

tough abyss
high marsh
#
#include "\a3\editor_f\Data\Scripts\dikCodes.h"
if(canSuspend) then
{
    waitUntil{!isNull (findDisplay 46)};
    (findDisplay 46) displayAddEventHandler["KeyUp",
    {
        params["_display","_key","_shift","_ctrl","_alt"];
        if(_shift || _ctrl) then
        {
            if(_key == DIK_MINUS) then
            {
                if(player call maas_fnc_isDragging) then
                {
                    _obj = attachedObjects player # 0;
                    _obj setDir (getDir _obj) + 1;
                };
            };
        };
    }];
};

Why exactly does this rotate the object in an insane amount? Nearly in intervals of 100

#

I thought it might reduce this effect with just leaving the rotation to happen when the key is released. But it keeps rotating an insane amount as if it's being constantly executed.

tough abyss
#

The code is fine, the problems is elsewhere

high marsh
#

Like what? change the direction by one in the debug console on a object, and it's smooth and perfect.

#

Nearly the same code, just no UI EH

#

When I log the old and new number, it's fine. The only thing that stops it from getting on spot is when it actually sets the direction

#

Old Dir: 310,
New Dir: 311

tough abyss
#

Oh I see, attached object, you get dir of attached object

high marsh
#

Wait.

tough abyss
#

and set it in relative coordinates

high marsh
#

Yes.

tough abyss
#

You see the problem?

high marsh
#

Not clearly so no, what's the issue?

tough abyss
#

when you setdir 0 it will be 0 relative to the object you attached to, but not necessarily facing north

high marsh
#

How does that explain the direction going from 170 to like 330?

tough abyss
#

when you getdir you get the global value where 0 is facing north

high marsh
#

So it's not really relative to the object?

tough abyss
#

if player is facing north then it works fine

spark turret
#

isnt setDir an absolute direction, 0 = north etc?

tough abyss
#

if player is not then you get crazy offset

#

not if object is attached @spark turret

#

crazy shit is that if you face west you get negative rotation

high marsh
#

Okay, just to made sure I set the direction to zero after attaching. Still no dice

tough abyss
#

You dont get it do you? you read global direction then set it relative to the player

#

so it is direction player + your global direction

#

turn player to look at the north and voilà, problem solved

robust hollow
#

this is doing the trick for me.

_obj setdir (getdir _obj - getdir player + 1);
tough abyss
#

direction player will be 0 so set dir will be global dir + 0

high marsh
#

Wow. I'm dumb, thanks for the explanation. Makes a lot more sense considering the attached object is now moving and rotating relative to whatever it's attached to (the player)

#

Thanks for the example Connor, got something similar now.

#

Another question, is it possible to override player controller keybinds like Q and E with UI EH? Seems like it'll still work, but just won't override.

tough abyss
#

unbind controller from Q and E maybe

high marsh
#

I meant the anim controller for soldierd

harsh sphinx
#

What is the exact syntax for an AND condition then an OR on the same line? if (thing && (thing2 || thing3))

robust hollow
#

that would work ^

high marsh
#

Alright, so I am in a bit of the same situation as my above problem except that it's with setting the position

#

getting relative model position to world space with modelToWorld doesn't yield any results

#

Ex:

_box = (attachedObjects player) # 0;
_pos = player modelToWorld (getPos _box);
_box setPos[
    _pos # 0,
    _pos # 1,
    (_pos # 2) + 10;
];
robust hollow
#

not entirely sure what ur trying to achieve there, are you looking for something like this?

_box = (attachedObjects player) # 0;
_pos = getPosASL player vectorAdd(getPosASL _box vectorDiff getPosASL player);
_box setPosASL (_pos vectorAdd [0,0,10]);

edit:
i assume this isnt it cause it just elevates the box 10m above its original position, which can obviously be done just using the box position...

high marsh
#

That's just it! When attached to the player, it has zero effect.

robust hollow
#

yey 👏

high marsh
#

That's not exactly what I meant by that. Neither work.

#

It just sort of "shakes" ??

robust hollow
#

r u trying to adjust its elevation while attached?

high marsh
#

Yes.

robust hollow
#

tried reattaching it with a new offset?

high marsh
#

That's kind of janky, but I'll try it

#

I don't think it would be really feasible either. It's simply to increase or decrease elevation on keypress

robust hollow
#

didnt think you could change the position of an attached object 🤷

#

as in, with setpos commands