#arma3_scripting
1 messages · Page 31 of 1
is there ever a reason with menus that it can work fine testing in editor but fail in MP?
I cant think of a reason why a menu/dialog script would fail in MP when it works fine in editor
same code compiled
this is a snippet
params ['_type'];
systemChat str _this;
if (_type isEqualTo 'init') exitWith {
missionNamespace setVariable ['QS_client_loadoutTarget',cursorObject,FALSE];
createDialog ['QS_RD_client_dialog_menu_inventory1',TRUE];
};
private _buttonCooldown = 0.5;
private _saveLimit = 10;
if ((getPlayerUID player) in (['S3'] call (missionNamespace getVariable ['QS_fnc_whitelist',{[]}]))) then {
_saveLimit = 20;
};
if (_type isEqualTo 'onload') exitWith {
systemChat '0';
_display = [findDisplay 19000];```
and config
idd = 19000;
movingEnable = 1;
enableSimulation = 1;
onLoad = "['onload',(_this # 0)] spawn (missionNamespace getVariable 'QS_fnc_clientMenuLoadout');";```
it is failing to enter the 'onload' scope
no errors ... ive checked all the syntax, no bracket/semicolon errors, works fine in editor
solved ... apparently _type doesnt work when called from UI context in multiplayer
params ['_type']; fails, while private _type = _this # 0; works
must be a secret reserved variable
any help?
your sorting method is not exactly correct. don't you want to know which player is first too?
select {!isNil "_x"} or filter argument of sortBy to get rid of non-existing elements of array 🤷♂️
_input = [nil,nil,nil,3,1,2];
_out = _input select {!isNil "_x"};
//_out == [3,1,2];
_out = [_input, [], {_x}, nil, {!isNil "_x"}] call BIS_fnc_sortBy;
//_out == [1,2,3]```
I recommend doing it as follows:
use setVariable to store finish times on the players:
_player setVariable ["FinishTime", time];
then simply read them back and sort:
[allPlayers, [], {_x getVariable ["FinishTime", 1e10]}, "ASCEND"] call BIS_fnc_sortBy
1e10 = 1 * 10 ^ 10
so a very large number
(for players that haven't finished yet)
Use servertime tho, time is different for every client ^^
it's local, so all times are the same
wat, seems nonsense 🤔
yes itwas quite frustrating
never had that one before
i still dont quite understand it, however its solved by simply using another private variable name
i guess it would be like in an event handler using params ['_thisEvent'];
perhaps params checks reserved/magic variables
in any case i now use a different var
if (_fuckyouarma isEqualTo 'init') exitWith {```
Arma is fun, isn't it ?
inb4 sudden game crashes with reason "NO_U"
I have a question when it comes to the internals of 'triggers'. I want to optimize a few things and trying to cut down on the amount of triggers I have. None of the trigger radius overlap, so I want to take a list of all relavant units/players, and check the most probably trigger areas for them to be first, then pruning them from the list when they are within a triggers range, and continuing down all the trigger areas. I'm curious if something like this is already done or if it would be worth my while to give a go.
Am i reaching with this.
if!(isServer)exitWith{};
waitUntil{!(isNil"dmpReady")};waitUntil{dmpReady}; //Wait for the mod to load first
sleep 60;
{!(_x isEqualTo objNull)} count _bomber; //Count all spawned Suicide Bombers
private ["_unit"];
_unit = _x;
// Only run where the unit is local and it isn't a player
if (((count _bomber) >0) && !isplayer _unit ) then {
// Remove bombers vest if equipped and replace it with bomb vest
if ("V_TacChestrig_cbr_F" in assigneditems _unit) then {_x assignItem "UMI_Bomb_Vest"};
} forEach allUnits;
cannot reproduce with your own code
something wrong on your side
perhaps you have a macro that messes with _type part (you put the varname in single quotes)
actually no, wouldn't make sense, you said it works fine in sp
yea, weird
my guess is reserved variable filtered by params, but that doesnt explain why it worked in editor
called from onload?
i copy pasted your code
i can restore to the broken state and send you everything for a repro
if youre interested
if you don't mind, sure 😄
ill put it together tomorrow
thank you, that's much easier.
[player,"Animation"] remoteExecCall ['switchMove'];
[player,"Animation"] remoteExecCall ['playMove'];```
is this necessary?
when I executed on myself
How do I make the phalanx cannon constantly fire at target?
i've used fireAtTarget and commandFire but it only fires once
do i have to put it in a while loop or would that break it?
Hello, I have an issue and I need help. I have made a DM with tanks, so they respawn when destroyed or abandoned. The problem is, that if some reason some one get in on a tank at the starting poing, and then get out, the new tank will spawn inside the old tank and blow them both. It seems to be due to a server lag, on eden test it does not happened. On eden, the old tank vanish first and the new tank respawn.
Is there anyway to delay the respawn of the new tank when they are abandoned? The delay only seems to work when they are destroyed.
Thanks
yes you need a loop
how have you set up the respawn? using veh respawn module?
it should have a variable for when to respawn. I should check it in the game. wait one
Thanks
It has a delay one, but due to the fact that the vehicle is abandon, as soon as it dissapiars, it spawns. On eden is no problem, but on server with a bit of desync, it spawns one milisecond before it vanish, and boooom
yeah the module function does check for getIn and getOut so the problem is not the delay but network desync as you put it
if you're comfortable with using scripts instead of modules you can turn that module function into a script and modify the respawn part to add a little delay before the vehicle reappears
ah, the usual module cycle. "Let me use the module" - "i need to change something, let me look at its code" - "it's easier to just rewrite it" 🤣
I dont know how to make scripts, I underestend them and modify them, but not to make them.
yeah, i figured it out
another question, i managed to set the VLS fire delay to 0 so that it shoots all its missiles almost instantly, but i can't find how to completely remove/reduce the VLS reloading time
i've tried using vls setAmmo [currentWeapon gunner vls, 18]; in an onEachFrame event but it doesn't seem to do anything
afaik it's not an ammo. it fires the whole mag
at least it seems to work with Slammer for me 🤣
so setAmmo or setMagazineTurretAmmo won't do anything
if setMagazineTurretAmmo doesn't work try adding a new mag, then set weapon reload time to 0
thanks mate, it seems to be working
here's my code if anyone wants to see
g1 setMagazineTurretAmmo [g1 currentMagazineTurret [0], 18, [0]];
or just sqf this addEventHandler ["Fired", { params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"]; _unit setMagazineTurretAmmo [_magazine, 999, _unit unitTurret _gunner]; _unit setWeaponReloadingTime [_gunner, _muzzle, 0]; }]; for universal fun
yep
unlimited fun indeed
one tomahawk missile gifted for each civilian
you can draw d-picks with it
lmao, how do you get your missiles to circle around like that
there are so much missiles that the particles almost don't render in anymore
an objetive in the air lol
Q: about cameras, how can I show or enable the XYZ axes indicator?
you can't enable them. you have to draw them yourself
What's the script that allows players to save their arsenal loadout while having access to a full arsenal
I have a try/catch structure that seems to catch the error in an IF statement, throw the appropriate exception when executed in the catch block at the end of the script but still executes a command within the try block AFTER the IF statement that caught the error. I didn't think that was possible. There are no errors being reported in the server or client RPT. Any idea why the try scope isn't being terminated?
doc says it's terminated and minimal try/throw/catch example terminates the scope 🤔
i dont think the try block throws at any script errors
Not at any error, but at the specific condition in the IF statement.
in this case :
if (count _position == 0) throw "Spawn position occupied!";
So I have something like:
try {
// ... some code that should populate _position with an array ... //
if (count _position == 0) throw "Spawn position occupied!"; // array is actually empty, so throuw error
if (1 + 1 == 2) then
{ hint str "Yep"; };
}
catch { hint str "Array is empty!"; };
And I'm getting both the exception when the array is empty AND the result of the second IF statement. I expected to get one or the other.
does forceUnicode work with callExtension?
Is there a way of getting the loadout of a unit as a string through variablename of the unit?
i mean you can grab the unit loadout with getUnitLoadout and then turn it into a string. Why do you want a string instead of just using setUnitLoadout with the loadout array?
it does nothing, if you mean that
I basically want to store it, so take the loadout from a player and keep it without them knowing, so that enemies in a different mission can use them.
can you grab and store the array itself instead of using a string?
then use setUnitLoadout? its really quick
So am I restricted to only receiving ANSI characters using callExtension?
or am I missing something more basic?
I should be able to do that, but I'd like to have it stored in a notepad for future use, so if possible, copyToClipboard would be nice, but I can always run the variablename through the extended debug console and copy each one after I've taken them
Since it's just a one time thing, I might end up doing that actually, sounds less complex
Ah, ok. My extension is written in c# and I've been marshaling using Marshal.PtrToStringAnsi((IntPtr)function);
but this should work as well? Marshal.PtrToStringUTF8((IntPtr)function);
if you do
copyToClipboard str ["item1","item2"]
it will paste in notepad as
["item1","item2"] not '["item1","item2"]'
you can then just paste the array directly without worrying about extra '
so just do
copyToClipboard str getUnitLoadout _unit
Alright, thank you! 🙂
That did it, thanks!
I can't seem to get the syntax right for cutRsc and remoteExec. Does anyone know what's wrong with my attempt? 😦
[["Jump", "PLAIN"]] remoteExec ["1 cutRsc"];
When activated via trigger it should flash an image on screen for about ~2 seconds but instead it barely shows it for a frame.
Normal usage, i.e.
1 cutRsc ["Jump", "PLAIN"] still works fine, just local to the person who activated it
see pins
Thank you 🙂
I don't see an animation source for them being stored. I think you might be out of luck with retracting them.
Q: re: inArea angle is that literally a direction, or do I have to do some math to figure that in terms of radians?
https://community.bistudio.com/wiki/inArea
It's degrees iirc
But getting radians isn't difficult either, can just use rad to convert
Sweet thanks.
okay so it is a decent enough start... I have a lasso selecting objects in a build engine mode.
now I want for the lasso to be orthogonal to the camera view window.
I suspect jumping to/from world to screen coords, interchanging some coord components, all four corners worth.
Also taking into account the camera direction for angle.
Currently oriented toward 0 (N), but the lasso is correct it appears, and the selection is also well behaved inArea.
For what it is.
I am trying to find RGBA docs on the wiki... IIRC, alpha indicate luminescence or intensity? i.e. when drawing lines and such 'in game'?
i.e. even full green seems rather dim... [0, 1, 0, 1] not sure what is going on there, maybe I need to increase its Z somewhat? or is there a line style I can set so that it is not masked quite as heavily?
What are you drawing exactly?
0,1,0,1 should be full green pixels in general.
Alpha means blending/transparency. 1 is solid colour, 0.5 is half foreground half background etc.
trying to draw a lasso rectangle. the line style appears to be dashes not solid, and the color is especially dim, not full green as I might expect.
maybe there is a line style I need to hit first of all...
Draw where and with what?
drawLine3D literally in a camera view
player mouse down event, hold and move to lasso.
Check whether it looks different at night.
as it happens it is at night, and it is rather faint looking. but again like I said, styled in dashes, etc. not a solid line...
Should be solid lines, are you are calling drawLine3D from within the draw EH?
Only reason I can think the line would be appearing dashed/faint is that you're either not calling it within a draw EH or there's z-fighting
{
_wp1 = _rfl addWaypoint [getMarkerPos (_x select 0), 0];
_wp1 setWaypointBehaviour (_x select 1);
} forEach _waypoints;```
i wonder if when `_wp1` gets overwritten, is the fromer waypoint gone then? 🤔
like would the group just end up with just one waypoint, no matter how long the _waypoints array is?
Overwritten in what sense?
like if I do ```
_wp1 = _rfl addWaypoint [getMarkerPos "markername1", 0];
_wp1 = _rfl addWaypoint [getMarkerPos "markername2", 0];
_wp1 = _rfl addWaypoint [getMarkerPos "markername3", 0];
will the `_rfl` group endup with just one waypoint?
or are these actually added?
No, will get three additional WPs
thanks!
_wp1 in this context is just an array to get the waypoint in scripting scope, nothing to do with actual existence of the wp
So yeah, nothing to worry
good to hear that!
within a PFH, yes. could be Z I guess, so how do I draw so that it 'could' be seen? add something greater than 0?
Just a tiny z offset should do the trick
0.01 or the like
Also PFH != Draw EH
There's an actual draw3D EH that ties into when the engine draws that you should be using
doesnt make any diff here
I've always seen that the draw related commands are better used with the draw EH
¯\_(ツ)_/¯
it's only better when you don't want to draw when e.g. the game is not focused (which you shouldn't ofc)
otherwise it's the same as per frame
I see, thanks
Still would recommend going for draw rather than PFH for the reason mentioned
Not to mention it's a trivial change
why not just use controls?
I mean RscLine
not familiar with that, and do what with it exactly?
you said you want to draw rectangles orthogonal to the camera
lasso selecting objects in a build engine mode.
if you mean a 2D rectangle, then you should use contorls
sounds interesting. and I can map that to screen coordinates as I receive mouse events?
map that to screen coordinates
you mean world coords?
I am trying to lasso objects in a rectangle. closest analog is the 3den editor selection feature.
it's mostly working, but the selection feels more like an ASL than an AGL at the moment.
well then you want to map screen coords to world
as I said here
right right, I understand how to manage all those jumps in units and so forth
anyway, yeah it's possible. screenToWorld
tho it doesn't work when you aim at the sky
that would be nonsensicle 😛
anyway, you can also do it the other way
i.e project the positions of all selectable objects onto the screen (using worldToScreen) and then simply do an inArea check to see which objects fall in the rectangle
I mean not that the control approach does not have merit. but the bottom line rubber meeting road I think, still I need to gauge some rectangle and objects in area.
not to mention distance between 'here' and getting there, introducing controls, ids, and all the rest.
don't you want to select those objects with the mouse cursor?
that is what I am doing now, more or less. but the in area seems a bit misbehaved
pretty sure all my positions before and after the screen transformations are AGL.
screenshot what I got so far. assuming all my coords are calculated correctly through to and including inArea (or inAreaArray in this case), but the shape of the selection seems a bit amiss.
https://pasteboard.co/eFU5VmBuo8eL.png
well here give this a test:
_disp = findDisplay 46 createDisplay "RscDisplayEmpty";
_rect = _disp ctrlCreate ["RscPicture", 123];
_rect ctrlSetText "#(argb,8,8,3)color(1,1,1,0.1)";
_disp displayAddEventHandler ["MouseButtonDown", {
params ["_disp"];
_disp setVariable ["ClickStart", getMousePosition];
}];
_disp displayAddEventHandler ["MouseButtonUp", {
params ["_disp"];
_disp setVariable ["ClickStart", nil];
}];
_disp displayAddEventHandler ["MouseMoving", {
params ["_disp"];
if (!isNil {_disp getVariable "ClickStart"}) then {
_oldPos = _disp getVariable "ClickStart";
_newPos = getMousePosition;
_oldPos params ["_x1", "_y1"];
_newPos params ["_x2", "_y2"];
_rect = _disp displayCtrl 123;
_rect ctrlSetPosition [_x1 min _x2, _y1 min _y2, abs(_x1 - _x2), abs (_y1 - _y2)];
_rect ctrlCommit 0;
_area = [[(_x1 + _x2)/2, (_y1 + _y2)/2], abs(_x1 - _x2)/2, abs (_y1 - _y2)/2, 0, true];
_units = [];
{
_scrPos = worldToScreen ASLToAGL aimPos _x;
if (count _scrPos != 0 && {_scrPos inArea _area}) then {
_units pushBack _x;
}
} forEach allUnits;
systemChat str _units;
};
}];
not tested
yeah well I have other mouse EH callbacks in the mix as well. bit more to chew off adapting this in than simply just dropping it in I think.
i.e. all the downs, ups, holdings, movings, etc.
and keyboard combinations as well for modifiers and such.
excusing the macro shorthands, the algo is basically this transforming the starting and current mouse inputs, transformed depending on the need, for "draw" or for "area".
private _zero = [0, 0, 0];
params [
[Q(_mode), Q(draw), [""]]
, [Q(_startPosAGL), LGVAR2(_lassoStartPosAGL,_zero), [[]], 3]
, [Q(_endPosAGL), LGVAR2(_lassoEndPosAGL,LGVAR2(_lassoCurrentPosAGL,_zero)), [[]], 3]
];
[_startPosAGL, _endPosAGL] apply { worldToScreen _x; } params [
[Q(_alpha), [], [[]], 2]
, [Q(_bravo), [], [[]], 2]
];
(_alpha + _bravo) params [
[Q(_ax), 0, [0]]
, [Q(_ay), 0, [0]]
, [Q(_bx), 0, [0]]
, [Q(_by), 0, [0]]
];
private _xmin = _ax min _bx;
private _xmax = _ax max _bx;
private _ymin = _ay min _by;
private _ymax = _ay max _by;
private _rectScreenCoords = [
[_xmin, _ymin]
, [_xmax, _ymin]
, [_xmax, _ymax]
, [_xmin, _ymax]
];
private _simpleScreenCoords = [
[_xmin, _ymin]
, [_xmax, _ymax]
];
private _rectWorldCoords = _rectScreenCoords apply { screenToWorld _x; };
switch (toLower _mode) do {
case Q(draw): {
_rectWorldCoords;
};
case Q(area): {
_rectWorldCoords params [Q(_tl), Q(_tr), Q(_br), Q(_bl)];
private _rectPos = _tl getPos [_tl distance _br, _tl getDir _br];
private _a = 0.5 * (_tl distance _tr);
private _b = 0.5 * (_tl distance _bl);
private _isRectangle = true;
private _camera = LGVAR2(_camera,objNull);
private _cameraDir = getDir _camera;
[_rectPos, _a, _b, _cameraDir, _isRectangle];
};
default {
_simpleScreenCoords apply {
screenToWorld _x;
};
};
};
It feels almost like the camera angle is an influence there...
at one point I had a rectangle drawing angle 0 (N), selection seemed appropriate to that however...
but I really want that rectangle orthogonal to the camera if at all possible, inArea(s) included
ofc it is
first of all a rectangle projected into world is no longer a rectangle (it would be if you looked from the top)
understood ofc, it just has to be accurate aligning drawn lines to selected objects
not sure what you mean "no longer a rectangle"
it's not a rectangle anymore
transform taking AGL pos in, to screen, doing the calcs there, then projecting back to world
if not a rect then what is it?
a polygon
a poly? of what? did you look at the mins and maxes in the code above?
in the world it's a polygon
not a rectangle
your mins and maxes are for creating the rect in UI coords
ok, of four points, or four edges. still a rectangle
no
maybe I could share my screen in VC, cuz I am really not comprehending what you are saying
just look at your own screenshot
in and of themselves the draw is just lines, edges. in that sense I suppose a polygon. but inArea takes X and Y differences, transformed from screen to world, and involving the a and b components, right... therein would lie the rub methinks.
well in any case just use this
it works
maybe just using inPolygon ...
https://community.bistudio.com/wiki/inPolygon
yes, but remember that screenToWorld may fail you
🔑 so inArea does not care whether world or screen; in fact it looks like you are using the screen coordinates there?
yes
ah okay... I understand now. yep, would be subtle, and not difficult to switch up.
thanks.
How can I check if the scrollwheel action menu is open
yea just found it , thank you !
I have a question. I tried using KillZoneKid´s PiP Script (http://killzonekid.com/arma-scripting-tutorials-uav-r2t-and-pip/) but I´m having the problem that the render to texture does not work. I´m always having a black screen (on the object). Also tried another script but same thing happened. any ideas?
//-> all Credit to KillZone_Kid
/* create render surface */
_bb = "Land_Billboard_F" createVehicle position player;
_bb setObjectTexture [0, "#(argb,512,512,1)r2t(uavrtt,1)"];
/* create uav and make it fly */
uav = createVehicle ["B_UAV_01_F", _bb modelToWorld [0,100,100], [], 0, "FLY"];
createVehicleCrew uav;
uav lockCameraTo [_bb, [0]];
uav flyInHeight 100;
/* add loiter waypoint */
_wp = group uav addWaypoint [position _bb, 0];
_wp setWaypointType "LOITER";
_wp setWaypointLoiterType "CIRCLE_L";
_wp setWaypointLoiterRadius 100;
/* create camera and stream to render surface */
cam = "camera" camCreate [0,0,0];
cam cameraEffect ["Internal", "Back", "uavrtt"];
/* attach cam to gunner cam position */
cam attachTo [uav, [0,0,0], "PiP0_pos"];
/* make it zoom in a little */
cam camSetFov 0.1;
/* switch cam to thermal */
"uavrtt" setPiPEffect [2];
/* adjust cam orientation */
addMissionEventHandler ["Draw3D", {
_dir =
(uav selectionPosition "PiP0_pos")
vectorFromTo
(uav selectionPosition "PiP0_dir");
cam setVectorDirAndUp [
_dir,
_dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]
];
}];
``` //-> does not put out any error, spawns the Billboard and drone correctly but leaves the billboard black. Maybe something changed in between Arma Versions?
It (kk's example) worked when i last checked. Do you have PiP active in game's video settings?
yes, high and redering up to 6000m
but it seems like the display is emitting a weird glow
@unique sundial maybe you can help me?
is the init event handler of objects executed on JIP clients ?
Hello, I'm trying to do an artillery barrage on a position.
I call a script.sqf with a trigger activation, works fine.
Script do return marker's position array, but BIS_fnc_fireSupportVirtual doesn't work.
Can anyone help me please ?
Here is my script :
_loc = getMarkerPos "trg"; [_loc, "32Rnd_155mm_Mo_shells", 100, 2, 10] spawn BIS_fnc_fireSupportVirtual; hint str _loc;
looks like the wiki is wrong
or at least confusing
mag: String - (Optional, default "Sh_82mm_AMOS") magazine (if left empty, first available magazine will be used)
Sh_82mm_AMOS ==> this is ammo, not magazine
32Rnd_155mm_Mo_shells contains Sh_155mm_AMOS ammo
if I try your line, nothing happens (and no error, which is weird)
if I try [getPos player, "Sh_155mm_AMOS"] spawn BIS_fnc_fireSupportVirtual, hell start to rain, as expected
so, when using this function, remember to understand the mag parameter as an ammo type name from CfgAmmo
@sand phoenix
@vernal mural Thank you very much !
I did mistake magazine for ammo.
you were absolutely right trying a magazine, according to the wiki
with a bit of experience, things like Sh_82mm_AMOS don't look like magazines, that's what hinted me on the right way
but when sticking to what is written, magazine type was a good try
Now I can see it was written down all along, but couldn't see it before knowing the difference you taught me, thanks again !
re-checked again, literally pasting the code from article (with comments removed) into the debug console works on my machine 🤷♂️
wft you´re right. i posted it in the debug console and it workt as well. but executing from a script didn´t work for me🤔
🤔
if u compile the sqf files into SQF bytecode do u still need the sqf files?
//i have a problem with the addAction in the initPlayerLocal.sqf. If I want to acces the player and add the Action to him how do i have to do it?
_cabingetinID = player addaction ["<t color='#FF0000'>MOC: Enter MOC trough cabin</t><br/>", tostring {
_pos = getPos interrior;
player setPos _pos;
}, [], 99, false, true, "", toString {vehicle player == MOC;}]; // so
params ["_player", "_didJIP"];
_cabingetinID = _player addaction ["<t color='#FF0000'>MOC: Enter MOC trough cabin</t><br/>", tostring {
_pos = getPos interrior;
_player setPos _pos;
}, [], 99, false, true, "", toString {vehicle _player == MOC;}]; // or so?
//or did i do something completely wrong?
when executing from a script it has black screen. when i the execute it from then debug menu it spawns a working one and makes the other one work as well
the second one is incorrect
_player is not defined in the action code and the condition
_bb = "Land_Billboard_F" createVehicle position player;
_bb setObjectTexture [0, "#(argb,512,512,1)r2t(uavrtt,1)"];
uav = createVehicle ["B_UAV_01_F", _bb modelToWorld [0,100,100], [], 0, "FLY"];
createVehicleCrew uav;
uav lockCameraTo [_bb, [0]];
uav flyInHeight 100;
_wp = group uav addWaypoint [position _bb, 0];
_wp setWaypointType "LOITER";
_wp setWaypointLoiterType "CIRCLE_L";
_wp setWaypointLoiterRadius 100;
addMissionEventHandler ["Draw3D", {
_dir =
(uav selectionPosition "PiP0_pos")
vectorFromTo
(uav selectionPosition "PiP0_dir");
cam setVectorDirAndUp [
_dir,
_dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]
];
}];
sleep 10;
cam = "camera" camCreate [0,0,0];
cam cameraEffect ["Internal", "Back", "uavrtt"];
cam attachTo [uav, [0,0,0], "PiP0_pos"];
cam camSetFov 0.1;
so it works for me even executed from a script 😱
so i need to pass the _player variable to the script and the nit will work? Since the first one doesn´t work either
no I don't think it'll work
the first one should work too
what's the problem again?
no action is added?
it won´t show the action when i´m in the vehicle (conditon) i haven't tested if it´s added or not
does it work if you execute it from console?
afaik no
but you might need them if the compilation fails
try a terminate effect before internal
yes it works when executed from debug console. But i used some hints to check... the code runs during the setup so it should work from the script as well 😭
then I guess player is not defined when the script runs
put a short sleep before the addAction
can't pass arguments to condition of addAction 
does this work now?
Fixed now, thanks for spotting
Cc @sand phoenix 🙂
It work just by attaching the camera last. Even without the sleep. Just changed the position in the script and now it works like a charm
Can someone help with script for AI rearming and drop/pickup weapons?
What you need help with? What do you have so far?
I have one script (originaly from A2) , it seems to be written well, but there are some problems. AI must pick up magazines and grenades from dead bodies when they needed and weapons when he unarmed. He picking up grenades , but he don't pickup weapon. Just goes to dead body and playing animation "take weapon" infinitely.
how can i put .sqf file here?
pastebin. com/GdU8XVvy
or use https://sqfbin.com if it is for some help
breakthrough, it works, fantastically I might add. so much better behaved after you clued me in to the screen v world thingy. cannot 👍 👍 👍 that nugget enough.
gonna bookmark that one, thank you!
Is there any way to maintain automatic offset with attachTo while having memory point too?
it already "maintains offset"... (?!)
but you have to specify an offset to specify a memory point..? just using [] doesnt work
[0,0,0]
you can use the BIS fnc
so, replicate BIS_fnc_attachToRelative but with attaching to a specific mempoint?
or bone?
I should be able to just get the difference between the player's pos and the object's pos and use that as the offset, right..? because that's not working
use worldToModel
private _orient = [this, player] call BIS_fnc_vectorDirAndUpRelative;
private _relPos = this worldToModel ASLtoAGL getPosASL player;
this attachTo [player, _relPos, "spine2", true];
this setVectorDirAndUp _orient;``` this seems to attach it in the wrong place, offset down and to the right of the player 
it also doesnt seem to be following the bone rotation up and down, im not sure if thats supposed to happen or not
you're attaching it to a point relative to the player himself, not his spine2 (both pos and vdup are wrong)
Am I not doing that..? Setting the offset to 0,0,0 with spine2 mempoint puts it at the players feet
offset is relative to bone
not object
if it puts it at the player's feet then your mempoint doesn't exist
try "head" for example to see what I mean
spine3 maybe
so i need to get the offset of the object from the spine3 mempoint 
private _orient = [this, player] call BIS_fnc_vectorDirAndUpRelative;
private _relPos = this worldToModel (getPosASL this - AGLtoASL(player modelToWorld (player selectionPosition "spine3")));
this attachTo [player, _relPos, "spine3", true];
this setVectorDirAndUp _orient;``` seems to work in my head but not in practice
ok, think i need help understanding
_playerPos = getPosASL player;
_spinePos = player selectionPosition "spine3";
systemChat str (AGLtoASL (player modelToWorld _spinePos));
systemChat str (_playerPos vectorAdd AGLtoASL _spinePos);``` in my head would print the same thing twice, but the top one is 5m below the bottom one, why is this?
because the AGLtoASL conversion is not in the right place
I've got it now, I just need to get the dirandup working 🙂
it should be AGLtoASL(_playerPos vectorAdd _spinePos)
you need to create a transformation matrix for that
i hear matrix and instantly lose what you are talking about
you can do it without matrices too 
looking at the function it just does
_obj2 vectorWorldToModel vectorDir _obj1,
_obj2 vectorWorldToModel vectorUp _obj1```
just measure the dot product of each component of dir and up by those of the bone's
surely i can just modeltoworld the selectionpos and do the same thing?
the function does something completely different from what you want
no
you need to use bone coords
not model coords
that sounds confusing
inb4 attaching invisible object to bone and then relatively attaching the target object to invisible one
what are you trying to do again? just trying to make sure I'm not unnecessarily complicating things
just trying to attach an object with rotation to the player with it remaining in the position
i explained that poorly
attach to bone while keeping relative offset
yes that
this one works too
it's simpler
and you don't need math anymore
tho you don't need to attach 2 objects
just attach one. measure the relative dir and up and pos. then delete the object
with the direction etc kept the same
messing with helper objects has given me tons of headache in the past so would like to be avoided
however i could just mess with the vectordirandup stuff until it looks good
as that part can be kept the same
basically at the moment the object is rotated too far forwards because it was doing diranduprelative to the player and not bone position
do it like this
getRelPos and getRelDir, right?
ok youve lost me now
oh wait just use the object in the BIS_fnc_vectorDirAndUpRelative function?
llll attachTo [player, [0,0,0], "head", true];
[hhhh,llll] call BIS_fnc_attachToRelative;```
ok yeah i got confused lol
or that yeah
llll being emty logic and hhhh being a hemmet. Can confirm it works XD
is there any specific helper object i should use
no need to attach 2 objs. just measure the relative axes and pos. then delete the logic
wait yeah logic works you just need to attach
meh
got confused because all my helper objects i just did for ropes and jfc i hate physx because of it
two attaches = two lines. Measuring = math with more possibilities for error 🤷♂️
this is probably a stupid question
but how do you create a logic? createVehicle?
well, for this specific test i've just placed it in 3DEN 🤷♂️
only if you're bad at math 😛
also two attaches -> constant waste of performance (because you don't need one at all)
well, i'm eventually good at it. Generally. Meaning i error up first 3 or 4 (or 12) times but end up doing it correctly
so that sort of works but the object gets shifted forwards
elLogic attachTo [player, [0,0,0], "spine3", true];
private _orient = [shotty, elLogic] call BIS_fnc_vectorDirAndUpRelative;
private _spinePos = AGLToASL (player modelToWorld (player selectionPosition "spine3"));
private _relPos = getPosASL shotty vectorDiff _spinePos;
shotty attachTo [player, _relPos, "spine3", true];
shotty setVectorDirAndUp _orient;```
rather than staying in place
measure the relPos using worldToModel
your current relPos is not in bone coords. it's in world coords
oh so just worldToModel the entire thing?
entire thing?
private _relPos = worldToModel (getPosASL shotty vectorDiff _spinePos);
elLogic worldToModel ASLtoAGL getPosASL shotty
tho I think it should be getPosWorld not ASL
gotchu i will try both
seems to give some spurious Z offset in my testing 🤔
of like -2 meters of world Z
private _relPos = elLogic worldToModel ASLtoAGL getPosASL shotty vectorDiff _spinePos; puts it at over 1km above the player 
private _relPos = elLogic worldToModel ASLtoAGL getPosWorld shotty; seems to work 🤔
it should if hemmet origins differ by that much
most likely this
I mean worldToModelVisual you had before
but obviously it should be getPosWorld
aha
as I said here
getPosWorld hhhh vectorDiff getPosASL hhhh gives [0,0,1.79925], which roughly matches the z offset 🤷♂️
elLogic attachTo [player, [0,0,0], "spine3", true];
private _orient = [shotty, elLogic] call BIS_fnc_vectorDirAndUpRelative;
private _spinePos = AGLToASL (player modelToWorld (player selectionPosition "spine3"));
private _relPos = elLogic worldToModelVisual ASLtoAGL getPosWorld shotty;
shotty attachTo [player, _relPos, "spine3", true];
shotty setVectorDirAndUp _orient;``` works for me
_spinePos isn't needed at all then. And elLogic can probably get detached and deleted
yup, does create/deletevehicle work in that instance?
And elLogic can probably get detached and deleted
well yeah that was the whole point here. not having 2 attaches
and worldToModelVisual/worldToModel both seem to work
my only issue is that the object seems to move differently to the backpack but i think thats just arma
talking about eventually correct
as in it clips into the backpack when stationary but not when moving etc etc
no big deal
try spine1 instead
ehm, wut
it does exist tho. but maybe not in mem LOD 
meh, its not a huge issue for me so
you can createvehicle a logic, right? or is there a specific command
you can
uh oh
better use local tho
createvehicle on the logic just broke it
as in broke the offset
To create objects of type "Logic", use createUnit. on createVehicle biki page
pretty sure createVehicleLocal works too
or, you know, just run the attach/get offsets/rotation once and save that in mission :3
it puts the offset further away for me
adding a delay doesnt rectify that either
eventually correct
try createSimpleObject too
retrying the question, though. Should that be changed during the mission? Or would getting offset/rotation beforehand and hardcoding it be enough?
im confused what you are asking
does the same thing
I mean try something other than the logic e.g. Land_Wrench_F
oh right
Place stuff in editor. Attach logic. Get _relPos and _orient, copy them to clipboard, then just run attachTo with those values
oh, want to be able to change it rather than hardcoding yeah
Nope, does the same
on the other side of the problem. The game seems to have a "launcher" mempoint 🤔
aim is to be able to throw shotgun offset position into config for a backpack to make it put there if player has shotgun in it, just trying to get the attaching working properly before anything further
...i might've been a bit silly
one moment
ok so it wasnt the issue but i wasnt passing the createvehicle one into the dirandup function
createVehicleLocal seems to work 🤔
...or the later stuff yes i was a bit silly hang on
ok yeah i was stupid
that does work 🤦
only difference is the offset is slightly different again
but a tiny amount so shrug
i'll just end up messing with rotation and shit
and the "laucher" mempoint seems to be synced to backpack pretty well https://cdn.discordapp.com/attachments/737175675818999898/1043966162930769970/image.png
actually causes more backpack clipping 😅
player selectionNames "MEMORY" gives all the mempoints if you intend to find anything more suitable
nah this one works fine just a matter of fine tuning really
next step is to figure out how to make the shotgun not able to be picked up by anybody 
so, between "if you're good at math" and eventually getting there we spent what? 5 screens worth of messages? 
all for me to probably abandon this soon
_mempoint = "spine3";
_elLogic = "Logic" createVehicleLocal [0,0,0];
_elLogic attachTo [player, [0,0,0], _mempoint, true];
private _orient = [shotty, _elLogic] call BIS_fnc_vectorDirAndUpRelative;
private _relPos = _elLogic worldToModelVisual ASLtoAGL getPosWorld shotty;
deleteVehicle _elLogic;
shotty attachTo [player, _relPos, _mempoint, true];
shotty setVectorDirAndUp _orient;
systemChat str getposasl shotty;
systemChat str getposasl player;``` final code if you want it
[hhhh, (unitBackpack player)] call BIS_fnc_attachToRelative; when standing near the hemmet. And then going prone. Causes me to slide forward at 50 km/h 🤣
also yeah, (unitBackpack player) returns the backpack object 🤷♂️
Ya I tried messing with that earlier but was too much of a pain in the ass
Now I just need to think of how to make this into something useable lol
and the relative offset passed through to it
i have a addaction in my mission and want to execute the code on the whole sever and not only locally. is that possible? and if it is then how?
https://community.bistudio.com/wiki/Multiplayer_Scripting in general and remoteExec specifically 🤷♂️
probably with JIP too :P
remoteExec does accept JIP parameter in it's, uhm, parameters
Is there anyway to define what unit switchCamera effects within a trigger?
can i just put all my code in the remoteExec?
you can. Be sure to check Example 5 at https://community.bistudio.com/wiki/remoteExec
although if you need to execute that frequently - storing the executed code as a function/global variable and just remoteExec-ing that would be preferable. Sending the whole code is more for one-off hack job
https://sqfbin.com/nesuwayujosahomuzopi so is this correct? -> not much code
wdym?
the first one ist the code i used to use, but i need to execute that globally so the second one is hopefully using the remoteExec correctly?
toString isn't actually needed, addAction can take code as code
but otherwise it´s ok?
other than questionable formatting choices seems OK at first glance. Please, consider formatting long parameter arrays like https://sqfbin.com/udoqirotugisarasasod (one extra tab, new line after every (long?) parameter) 😉
yeah the formating is a bit of since i´ve changed and copied a lot of stuff XD have around 10 addActions in the same script and dindn´t want to type everything new
so im attaching something to a players head and defining it in a trigger for the purpose of serving as a camerea, but I also cant put switchCamera into that trigger because then it effects all units, but i want it to affect a different unit than from the one with the thing attached to it
and i tried putting in init but doesnt work
shouldn't it be with "call": ```sqf
{} remoteExec ["call", 0];
there you go for trusting me to proofread your code 🤣
i want it to affect a different unit than from the one with the thing attached to it
well if it's a specific unit you can just use its variable name
i get the error "missing ;"
unless im formating wrong
player2 Cam switchCamera "Internal";
you are
not strictly scripting related but still function related, anyone know wtf im doing wrong here?
whats the proper way?
what did you mean by that code?
?
no cat
I mean what is it supposed to do?
switch the camera of 1 of the units to the sphere attached to my head
you seem to miss one more layer of subclasses?
adding category subfolder and class doesnt help it 😕
"KJW" comes up in function viewer and so does the function name but can't click it (using ADT)
define "doesnt help it"
and ADT complains of undefined variable KJW_fnc_attachToBoneRelative
then you need remoteExec
how can i use sleep in the {} remoteExecute ["call",0]; ? it always outputs: Suspending is not allowed in this context
you need to run it in scheduled code
[cam, "internal"] remoteExec ["switchCamera", player2];
this spawn {/*code here*/};```
i just need to wait a short amount of time
what is your config rn?
well you don't need a category folder
🤷 works now so
[] spawn
{
{
someCode;
sleep 1;
someCode;
}remoteExec ["call", 0];
};
thats how i did it, but it outputs an error everytime 😦
{} not []
it's ` not ´
```sqf
// your code here
hint "good!";
```
↓
// your code here
hint "good!";
where?
you can't use sleep there
{} spawn instead of what you have which is [] spawn
is there any other way to wait a specified ammount of time?
remoteExec spawn instead
or make a function and don't send the whole code over network
remoteExec should put the sent code into the scheduled space though 🤔
Anyone able to help me with a script? Have a few weapons on a ship with simulation turned off but want to have it where if the players mouse wheel on a laptop they can "turn on" the weapon system
So
W1, W2, W3, W4 would be the weapons, players mouse wheel on a laptop and get the prompt "Reboot Weapon Systems."
Functions are executed in the scheduled environment; suspension is allowed
https://community.bistudio.com/wiki/remoteExec withremoteExecCallbeing the unscheduled version, though
ah, i'm dumb and don't read the very next line. Thanks.
laptop addAction ["Turn On", {
{
[_x, true] remoteExec ["enableSimulationGlobal", 2];
} forEach [W1, W2, W3, W4]
}];
Thank you Very much friend
np. if you want to put it in the laptop's init (which is what you want to do I assume), change laptop to this, i.e it becomes: this addAction ["Turn On", ...
gotcha
Is there an event handler for contents of player's inventory changing? Can't seem to find it if there is one 🤔
no
you can only use inventoryopened/closed/put/take EHs
- maybe a helper loop in case the user "cheats"
inventoryput/take?
no just put/take 
ah 😅
i now have some addactions executing locally and some which use remoteExec to execute globally. But now everything gets executed globally 😦 I really don´t understand why
Q: concerning camera AGL Z component limiters...
I am creating a camera, map happens to be Altis, location the wind turbines south of Oreokastro. happens to be, I think, one of the more extreme locations in terms of position ASL.
The camera seems rather restricted Z wise; I'm not sure how to 'allow' for more of a fly over in that sense.
By contrast when I am in Zeus, there is no such limitation.
Is it a camera command I can issue that allows for that?
Thanks...
There's surely a smarter way to do this (check if shotgun has been added or removed from players inventory, cant use opened/closed EHs as other people can take and put into backpack) than hooking in to both put and take EHs
there's no limit on camera's Z
there isn't? it is behaving like there is... cannot zoom out beyond a certain feels like max ASL Z component.
i remember searching for a reliable way of detecting player inventory changes. I don't remember ever finding one.
yep. there is none
Yeah, certainly seems to be the case... Probably an engine limitation if its not been added by now?
the most reliable way is a loop
with storing loadout and checking for changes? Oof
no. I guess perf concern (inventory changes even when you fire)
loop of inventory searches? 
BIS_fnc_hasItem in a while true just to make the optimisers sad
my shotgun must be removed i n s t a n t l y
how do you zoom?
"x" in flatten getUnitLoadout player was like 10x faster than BIS_fnc_hasItem iirc
actually
I guess both put and take makes sense? Put for checking for adding the shotgun, take for checking for removing?
because why bother with walking a tree in SQF? 🤣
uniqueUnitItems is a thing...
i would also need to check its not equipped too 
but returns an array of arrays and using in would be a hassle 🤷♂️
uniqueUnitItems returns a hashmap
is there a shotgun in the inventory?
does the backpack have config values for the position for the shotguns?
does the shotgun support this?
inb4 getWeaponCargo backpackContainer player;
i'm not reading again
I am using the 'normal' camera controls, navigation with WASD, mouse, scroll wheel back. does NOT zoom out. seems limited by max world ASL...
like I said, by contrast, the same gestures in Zeus 'work'...
oh that. idk
so I wonder there is some primitive, cam command, etc, I need to tell the camera a new limit.
I personally always make my own cam controls... 
there's an example on wiki:
private _camera = "CamCurator" camCreate [0,0,0];
_camera camCommand "maxPitch 89";
_camera camCommand "minPitch -89";
_camera camCommand "speedDefault 0.1";
_camera camCommand "speedMax 2";
_camera camCommand "ceilingHeight 5000";
_camera camCommand "atl off";
_camera camCommand "surfaceSpeed off";
maybe one of those "commands" controls it
ceilingHeight I guess
seems like the natural fit, the one command I do not have accounted for.
I shouldn't need to worry about anything locality wise for this in MP, right?
is ceilingHeight ASL or AGL?
dunno
see the wiki
doesn't say anything...
well if you find which plz let me know to put it on wiki
I would assume ASL since the environment is probably a very large cube including water.
Aaand Put and Take EHs don't seem to work as I want them to 😦
gonna go on the hunch, camCreate in terms of AGL, so maybe consistent?

test it on a hill
e.g. limit it to 100. then read the AGL and ASL heights as you go up the hill
ASL
which is a bit counter intuitive given camCreate
https://community.bistudio.com/wiki/camCreate
"position: Array - format PositionAGL - position to create the object at"
but whatever
thanks. I'll put it on wiki
may also include a blurb about cam ASL Z limits by default. seems like world ASL Z max.
what would be the correct way to iterate through here for the classes? im using this but im like 99% sure its not the right way to do it at all
private _uniqueUnitItems = uniqueUnitItems [player, 0, 2, 2, 2, false];
if !(_uniqueUnitItems getOrDefault ["sgun_HunterShotgun_01_sawedoff_F", false] > 0) exitWith{};```
"sgun_HunterShotgun_01_sawedoff_F" in _uniqueUnitItems
ah, thought you had to use special commands or something thx
i have a problem with an attached Object. I scaled an container and some lamps to other sizes (container x1.1, lamps x0.5) than i did some tests and my friend noticed that the container did not get scaled sometimes (e.g when I´m driving) and randomly jumped back to normal size, while the lamps where scaled perfectly. Does anyone has suggestions how to avoid that?
P.S. all objects where placed in the inventory and have the attachto and scale command in their init line
setObjectScale isn't intended to work properly outside of the editor.
therefor it did pretty good XD.
how to do it properly?
Any sort of updates/movement to the scaled object will unscale it
There is no clean solution for scaling objects consistently
Closest solution would be to scale it each frame, but that won't work well in MP
but damn setObjectScale worked pretty good in MP. For me it was perfect all the time (i´m the host) but for my friend it wasn´that good. Only the container had problems with the scaling. the rest worked like a charm as well
Yeah getting it to behave consistently is the issue
It isn't designed for it, unfortunately
Hopefully one day we get a proper mp-compatible scaling command
@torpid mica In the meantime, you can try the EachFrame solution, but be warned it may lead to weird behavior and/or performance issues:
addMissionEventHandler ["EachFrame", {
// Put code for scaling here
}];
Thank you. I'll try that for sure
👍
when I do
_Ctrl ctrlSetText (getText (configFile >> "CfgWeapons" >> (currentweapon player) >> "picture"));
is there a way to flip the image and make the gun point in the other direction?
from ︻デ═一
To ╾━╤デ╦︻
no
hey question for the youtubers (or video producers in general)... is there a mod that display key presses for things like modifier keys as I am pressing them, and display on the screen? that would be tremendous for this particular demo.
You don't really need an Arma mod for that, you can use something like this https://github.com/univrsal/input-overlay
will that work; I am using OBS to record in game. it will see the overlay as well?
ah says so in the release notes, v28+ ✅
Yes, things like that are designed to work with OBS because they're used by competitive streamers and such
huh interesting, is there a preset just for keyboard mouse inputs? otherwise, if I wanted to customize a subset of that for demo purposes, I need to do what? cook up some textures?
¯_(ツ)_/¯
I mean if you want to make something more specific it wouldn't be too hard to make an EH (https://community.bistudio.com/wiki/User_Interface_Event_Handlers) that does precisely what you want. It can output as a chat messages, or hints, or you can make a small custom UI...nothing too complex needed
Is there a way to add "fake" mass to the player's equipment? i.e add 10kg without having to have a 10kg object fill inventory space
[] spawn{
sleep 2;
private _Disp = findDisplay 46;
private _Ctrl = _Disp DisplayCtrl 666;
CtrlDelete _Ctrl;
_Ctrl = _Disp CtrlCreate["RscObject", 666];
_Px = safezoneX;
_Py = safezoneY;
_Pw = (600/1280)*safezoneW;
_Ph = (300/ 720)*safezoneH;
_Ctrl ctrlSetPosition [_Px, _Py, _Pw, _Ph];
_Ctrl ctrlCommit 0;
_Model = getText (configFile >> "CfgWeapons" >> (currentweapon player) >> "model");
_Ctrl ctrlSetModel _Model;
};
I'm testing out 3d controls
anyone know why the model wont show up?
is RscObject the correct class?
Not the same
then you probably want a custom config and change the mass property of the item in particular, something like:
class CfgMagazines{
class CA_Magazine;
class SatchelCharge_Remote_Mag: CA_Magazine;
class DemoCharge_Remote_Mag: SatchelCharge_Remote_Mag{
mass = 10;
};
};
_Ctrl = _Disp CtrlCreate["RscObject", 666];
hint str _Ctrl;
hints No control...
RscObject is working?
RscObject is not something you can add/remove on the fly, you need to define in a display config AFAIK. Also #arma3_gui
Is there a way to make a mod to run an SQF in the mod folder instead of adding the sqf to the mission folder?
or I should say just have a mod initialize an SQF?
Yes
make a CfgFunctions in the mod's config.cpp and set an sqf file as preInit or postInit
lemme give that a try
this should work right?
I'm not sure if that's broken or if the sqf is broken lol
oop I just saw what I did I think
forgot to close the postinit lol
lemme see if that works
hmm still seems to not work
@tough abyss this should work right?
perhaps, seems you're missing a tag though
and the path is likely incorrect
there's a few different ways to write a CfgFunctions, just check against that biki link and pick a way to do it
oh thanks
you are defining the category only here, no actual functions, a category also takes a folder path, not actual source file,
class CfgFunctions {
class MyTag {
class MyCategory {
file = "myFolder"; // category folder
class MyFunction {
file = "myFolder\myFile.sqf"; // explicit source file specification, otherwise it would look for a file in "myFolder\fn_MyFunction.sqf"
postInit = 1;
};
};
}
};
i just realised i missed the tag in my example, but yeah
it seems like maybe my file paths are wrong? cause it still does nothing lol
i don't know how you are packing your addon exactly so can't help you with that
but the \addons part seems wrong
also why name the file initPlayerLocal.sqf? it's missleading
I was just placing a different script in there that would be easier to tell if it works or not
keep in mind the sqf file name will have to follow the format
fn_whateverElse.sqf
like that page states
aaaaaaaaaaa
sorry
thats fine lol
fn_whateverElse.sqf
is the file name
and then to call it as a function it'll be TAG_fnc_whateverElse
(if you need to call it as a function)
also it's cleaner this way
you don't have to specify the exact file(s) for the functions
(what you currently are doing)
no
you don't need the file = in the most inner class
you named your function postInit (for some reason), so you would have to name the file fn_postInit.sqf it's basically fn_<classname>.sqf
is there a better way to do this?
Fnc_SHARED_bIsKindOf = {//call
//----------------------------------------------------------
params["_StrClass", "_aCfgClass"];
//----------------------------------------------------------
private _bRet = FALSE;
{//foreach _aCfgClass
ScopeName "FindLoop";
if(_StrClass isKindOf _x) then{
_bRet = TRUE;
breakOut "FindLoop";
};
}foreach _aCfgClass;
_bRet
//----------------------------------------------------------
};
_bVehicle = [_OBJ, ["LandVehicle", "Plane", "Helicopter", "Ship"]] call Fnc_IsKindOf;
fn_postInit.sqf not postInit.sqf, must be fn_ prefixed, also by
you don't need the file = in the most inner class
i meant entire thing
_aCfgClass findIf { _StrClass isKindOf _x } >= 0
ty
...
class Cat1 {
file = "\addons";
class postInit { postInit = 1; };
};
...
that'll run the postinit sqf?..
would it be easier to voice call and just stream what I'm doing lmao
yes, specifically addons/fn_postInit.sqf
you're right lol lemme fix that
sorry I'm just confused at this point I fixed that lemme see if it works
omg it works
holy cow
thank you
I have no idea how it works but it does lmao
the page goes into some detail regarding how it all works
tl;dr though the reason it works is because you're defining the contents of that file as a function by including it in CfgFunctions
and having postInit = 1 tells the game to automatically run that file after a mission finishes initializing
you can also do preInit = 1 to run it before missions finish initializing
and some other things
Mhm well thanks both of you guys
I didn't realize running an SQF from a mod would be so challenging for a newb like me lol
in missions its just with the initplayerlocal and whatnot
yup well now you know 👍
keep defining functions in their own files with CfgFunctions, much cleaner than spamming execVM or defining functions in an init file
Is it possible to disable the mouse steering via code?
nope
and disabling the mouse completely?
put your mouse away
Was trying to prevent the player from changing its direction
disabling the mouse could be done creating an empty display I guess
oh, thanks i will try that
Hi everyone
Im trying to set up my MARTA settings and im thrown this error when i name the module to BIS_marta_mainscope. I have tried to rename marta module to other things and refer to that name, use this and set marta variables to unit inits, group inits, and mission init. I also tried to fish out this file location to look closer whats wrong but could not find it. my A3 file does not have modules folder. Any tips on what to try next? Has anyone a working example of mission with modified MARTA settings so i could take a look? 16:01:54 Error position: <_targets - [objnull];
_targetStrings = >
16:01:54 Error Undefined variable in expression: _targets
16:01:54 File A3\modules_f\HC\data\scripts\HC_local.sqf..., line 97
16:01:55 Error in expression <e getvariable "enemygroups";
The core issue is that _targets is undefined, whatever that represents. I'm not familiar with MARTA, but I'd start by making sure you're not missing any target related settings.
Also, that file is packed into the base game, which is why you can't find the folder.
This only happens when marta module gets this name
oops meant to tag the first line
And why are you naming it that?
i was told here to name it that last time i asked, it threw the error then too but i thought i try to dig it up myself before bombarding question after question here 😄
According to this page https://community.bistudio.com/wiki/Military_Symbols
It seems like BIS_marta_mainscope is pre-defined for setting variables, which would explain why overwriting it causes issues
If you're using a module you should probably use the init method shown later on the page
I have tried that and it did not give any response
i also tried to referring to BIS_marta without naming the module
So you tried like this in the init?
this setVariable ["rules", [["o_", [0.00001, 1, 0, 1]], ["b_", [1, 0, 0, 1]], ["n_", [0, 0.7, 0, 1]], ["n_", [0.8, 0.8, 0, 0]]], true]
But with whatever your settings are?
No, i tried these 2
Try doing it the way I showed then
Hm
also tried putting the setting to mission init, inits of units and triggering the setting after mission starts
Not sure then, can't test anything on my end at the moment and not familiar with what this system even does
Sorry
Alright, it is th esystem that creates nato markers on map and in 3d when using high command
It can also display them without HC, and that i got to work but anything else doesnt seem to respond. Also just displaying the symbols command didnt refer to BIS_marta
but thanks anyway!
yeah, that was the only thing that worked
Is anyone aware of a way to run weaponsItems on just the primary weapon of the player? The array returned is in the order of which they were taken by the unit so is not consistent
That's what I'm using at the moment but doesn't have the array in the same format
Ok, so -- I've nearly got an array formatted properly, I'm just struggling to find out how I'd know what the player's secondary muzzle is?
_pWM = primaryWeaponMagazine player;
_arr pushBack [(_pWM select 0), (player ammo primaryWeapon player)];
if (count _pWM > 1) then {_arr pushBack (_pWM select 1);} else {_arr pushBack [];};``` is what I have atm
https://community.bistudio.com/wiki/weaponsItems should answer: no
inb4 filtering weaponsItems for element that matches player's primaryWeapon is actually faster than formatting the stuff by hand
Bruh moment
now how do i do that
(weaponsItems player) select {(_x#0) isEqualTo (primaryWeapon player)}?
Is there any way to get addon logo's path to .paa file?
I'm talking about logo that is shown in Arsenal in the items list
the .paa file..?
yeah, paa, my mistake
complains of syntax (with player in front) being Object select Code 
player is actually missing from weaponsItems, it seems. Oops 🤷♂️
select 0 it then 🤷♂️
the hitPart EH includes a param called isDirect, which indicates whether the hit in question was a direct hit or splash damage. Is it possible to make an equivalent check in a handleDamage EH, given that it doesn't have that param?
how do i pass variables in a spawn statement?
params ["this", "target2"];
(gunner this) commandArtilleryFire [getPosATL target2, "12Rnd_230mm_rockets", 12];
};```
i tried a couple different ways like this one but i can't get it to work
It's because you're using the wrong syntax for params
params creates local variables (indicated with a leading _underscore), not global ones; that's its purpose
Also, inside the spawn, _this is still a special variable (in fact, it's the special variable that params is interpreting - private _param1 = _this select 0 is the same as params ["_param1"]) and you shouldn't overwrite it. Use a different name for your first param.
I'm pretty sure that overwriting _this works and is proposed somewhere on biki
It might "work" but I would personally describe it as bad practice
In user comments, though, not in the main content. On the very params page
well i wasn't aware for _this
should've not given this sample as an example, since params shouldn't be needed in my case (i think)
i just want to pass the variable target2 which is a vehicle i defined in the 3den editor, and this which is the artillery battery
would something like this work?
(gunner _this) commandArtilleryFire [getPosATL target2, "12Rnd_230mm_rockets", 12];
};
Well, you don't need to pass target2 since it's a global variable already
uhm, the reason i'm passing it is because target2 isn't defined
in the spawn scope
No, because when you write it like this _this is an array containing target2. Inside the spawn, _this contains whatever you passed to it (in an array if you passed arguments as an array)
le confusion
If target2 is the Editor variable name of an Editor-placed object, it is globally available on all machines in all scopes
(unless overwritten by something else)
Even if it's not Editor-defined, it's at very least a global variable, which is available in all scopes on the machine where it was defined
oh well i think i got it
(gunner (_this select 0)) commandArtilleryFire [getPosATL (_this select 1), "12Rnd_230mm_rockets", 12];
};```
why did it throw an error then?
And params is just a syntactic sugar for _this select X
indeed haha, i mainly code in js and lua which makes sqf horrible to understand to me
yeah, as nikko said
I don't know. I don't think I've seen the exact code you used at the time, so it's hard to say. But you can clearly see it's a global variable which is available in all scopes by how it doesn't start with an underscore. And if it's defined in the Editor, its contents may change if overwritten but it won't become undefined.
i debugged it and it seems that target2 is indeed available in this scope but not this
which led me to think that both variables were not defined
my bad
Yes, this is a special variable. While it appears to be a global variable, it's not really, and it's specific to the current scope.
How do I detect when an animation has finished playing on the player? waitUntil animationPhase blah blah blah doesn't seem to work
animationState?
seems to complete automatically
What do you mean?
0 spawn {
player playMove "AmovPercMstpSrasWrflDnon_AmovPercMstpSnonWnonDnon";
waitUntil {animationState player != "amovpercmstpsraswrfldnon"};
systemChat "hi!";
};``` prints "hi" straight away
(used copied animationstate of player straight after running for the check hence difference)
playMove doesn't necessarily take immediate effect - the current animation needs to complete, the transition animation might have a different name - and you're checking on the very next frame. You might need to add a small delay.
tried that too, still does it
0 spawn {
player playMoveNow "AmovPercMstpSrasWrflDnon_AmovPercMstpSnonWnonDnon";
sleep(0.5);
waitUntil {animationState player != "amovpercmstpsraswrfldnon"};
systemChat "hi!";
};``` still doesnt wait beyond the sleep
Try having it output the animationState constantly during this process so you can see what it actually thinks is happening at what time
ah nvm
Also you don't need () on sleep
works now
0 spawn {
player playMoveNow "AmovPercMstpSrasWrflDnon_AmovPercMstpSnonWnonDnon";
sleep(0.5);
waitUntil {animationState player != "amovpercmstpsraswrfldnon_amovpercmstpsnonwnondnon"};
systemChat "hi!";
};``` works
just need to figure out how to play the animation without stopping the player from moving -- is this an animation specific thing?
Probably
Doesn't seem to be an animation specific thing, using the same one as ACE/EM -- whichever lets you hit 0 to holster weapon to back and still can't move 
Difference between gestures/actions and playing full-body moves.
https://community.bistudio.com/wiki/Arma_3:_Actions#WeaponInHand_.2F_WeaponOnBack
Just makes you point it towards the ground (i.e ctrl double clicked)
Trying to make it so the player will appear to change primary weapon with animations 🤔
You probably used WeaponInHand instead of WeaponOnBack ...
player action ["WeaponOnBack", player];
Ah, puts weapon on back but equips pistol -- which is what I'm trying to avoid too lol
player action ["SwitchWeapon", player, player, 100]```
Yes, that's the point. If you try to select a muzzle that doesn't exist you switch weapon to nothing
I know it works because I just did it
Hm... Are you running any mods?
Nope
I'll try unmodded then in case it's whichever mod adds the 0 functionality to check
Don't know if its EM or ACE
You should check what weapon indexes you actually have, I wouldn't be surprised if ACE adds up to 100 and you're just selecting some invisible thing. Might need to use a higher number.
Is there a quick way to do that?
weaponsInfo
Well, here's how ACE does it:
_unit action ["SwitchWeapon", _unit, _unit, 299];
Where is that? was looking for it earlier 😅
Ah, ty
Yeah that's working for me now, any easy way to figure out once it's finished?
currentWeapon would probably do it
Unless that part takes immediate effect I guess
I mean you should be able to just see roughly how long the animation is and wait that long, no need to check
it does from what testing I've just done
And yeah, would just be nice in case another mod changes it or smth 🤷
Well, about the worst that can happen is they stand there awkwardly for like a second or two, I don't think it would be a huge deal.
The previous animationState check would probably also work though.
Yeah, not like they're going to be stood in the middle of a field this way actually
Perfect, that works great now
Does anyone here have experience with ```sqf
BIS_fnc_slerp
It... does not do what I would expect it to do
Sorry I don't kiss and tell.
😉
I'd wager you do, you just want people to beg first.
I'll look into it when I get home. Didn't even know that function existed
Yeah I also only found it and there is no real documentation on it
Though I kinda solved my own question, as I entirely forgot again that it takes normalized vectors. duh xD
So it probably actually works the way it should. xD
But hey, now you learned of a new function
Or maybe not? It doesn't seem to actually slerp the vector, but rather lerp each individual value within the array
Did you check the code?
I'm not fluent enough in trigonometry to debug that.
Hence my asking.
I've tried this:
private _a = [-1,0,0];
private _b = [1,0,0];
private _slerpVertices = [0,0.1,0.2,0.3,0.4,0.5,0.6,0.7,0.8,0.9,1] apply { [_a,_b,_x] call BIS_fnc_slerp };
diag_log _slerpVertices;
which I'd assume would return a curve, but in fact:
[[-1,0,0],[-0.951057,0,0],[-0.809017,0,0],[-0.587785,0,0],[-0.309017,0,0],[4.37114e-008,0,0],[0.309017,0,0],[0.587785,0,0],[0.809017,0,0],[0.951056,0,0],[1,-0,-0]]
That looks like a non-normalized slerp to me.
So just normalize the result and you should be fine.
The result first and foremost does not actually produce a slerped vector from all I can tell, cause y and z are never touched
well, there isn't a unique valid slerp between your two inputs.
The two input vectors have to define a unique plane.
If you wanted a 180 degree curve then make two 90-degree curves.
That reduces the usefulness of the function a lot :/
You can't expect it to just guess which plane to use.
I guess not. But hence my asking. Might be a good tidbit to add to the wiki page.
Thanks either way!
Is there any telling from the outside whether slerp or just rotating vectors is faster?
It's 1 matrixMul, 2x cos, 2x sin vs 1x acos, 1xcos, 1xsin and a couple vector commands.
for anything O(1) in SQF you can get a good estimate by just counting the commands.
but are trig functions and vector functions both O(1)?
Disappointed that the function does not play a slerp sound, nor does it spawn me a slurpie.
Oh yeah, this one is over my head math wise lol.
how do you find if a vehicle has ammo or not?
probably needs magazinesAllTurrets for general cases.
thats what i was afraid of..
its a shame magazinesDetail doesnt really give you anything machine readable
Q: dealing with camera EHs, mouse down, mouse up, mouse holding, mouse button click...
I am finding more of a mouse holding event being triggered than a mouse button click (literally down+up, right).
Assuming button click does what I think it should do, that is a better place for things like object selection, clearing selections, ctrl toggling selections, and so on.
Which would free up mouse down I think for some other event combinations, shift append to selection, for instance.
But I am finding that instead of a distinct boundary between button click and holding, more of a holding procedure seems to be happening...
So I wonder how better to handle that.
I mean the only difference between clicking and holding should be a more extended delay between mousedown and mouseup
I totally agree, but it appears to be like direct opposite, button click then holding, no space in between or the line is just that blurred...
So it's registering as a click while still holding?
that's what it feels like to me. what I might consider 'button click', does not appear to isolate and contain that, moves straight into holding
Hm
maybe I need to signal button click was the last 'handled' EH of any import, and ignore the next holding
but it seems like kind of an EH kluge to me
Yeah or you may be better off just using the raw mousedown/mouseup EHs with timers for differentiating between clicks and holds
I do have downs, ups, holdings, movings, handled as well. that is true.
okay thanks.
👍
follow up question, what sort of timer might be appropriate the to isolate and contain the button click event?
reading a couple of unrelated (non A3) generally, 200 ms? 1 s?
otherwise it is kind of smh territory that would not be isolated by A3, but hey...
starting with something simple like [QMVAR(_mouseLeftTime), true] call BIS_fnc_deltaTime; and measure during the button click and/or holding events...
question for me is, to be consistent with the mouse button click, what is the time for that EH? that should be my boundary edge for holding concerns, I think.
I'm not sure, you'll have to do some testing
Ultimately you're going to be doing deltaTime checks mixed with timeouts to set and unset flags
The exact timeouts to go for I'm not sure
clear does not appear to be clearing anything. I am systemChat diagnostic measuring that, and the delta is definitely increasing no matter what I do.
// mouse down EH, capture _mouseLeftTime state
private _mouseLeftTime = [QMVAR(_mouseLeftTime), true] call BIS_fnc_deltaTime;
// button click EH, measures the delta
private _mouseLeftTimeNow = [QMVAR(_mouseLeftTime)] call BIS_fnc_deltaTime;
_mouseLeftDelta = abs (_mouseLeftTime - _mouseLeftTimeNow);
// _mouseLeftDelta increasing from 30s+ ... half expecting it should yield a 'new' boundary
// assuming Down always comes before Click
Leaving out that the state is stored and kept between EH invokes, it is.
https://community.bistudio.com/wiki/BIS_fnc_deltaTime
I see, somewhat expectantly, starting up the mission, from 30s+ into the mission, but is always increasing.
I expect that I should be clearing the variable but it is not.
Can we inspect the deltaTime code perhaps? i.e. is it a diagnostic bug?
Here's a simple test in the console, the base is always 0.001, okay, happy with that. but the delta delta appears to always be increasing?!
_timer = 'mytimer';
_a = [_timer, true] call bis_fnc_deltatime;
_b = [_timer] call bis_fnc_deltatime;
[_timer, _a, _b, abs (_a - _b)]
That is a bit disconcerting, because is it reliable then? Certainly does not appear to be even remotely deterministic.
It is not a true RTOS, of course, but I would expect at least some consistency there.
shouldn't clear actually clear it?
looks like the first run after clearing just returns time (or close to that). Sounds logical to function's description 🤷♂️
well the docs do warn time ... so looks like maybe we need to roll our own based on the diag_tickTime.
🤷♂️ what's the intended usecase?
er, maybe I misread the docs a bit... based on the example anyway, on second glance.
so left and right edges should look the same. call a third time with true for clear to reset.
call once, wait, call once more - you get time between calls
first ever call returns time - 0.001
"clear" makes it behave as if the next call is first call
well, I misread it, but not by far. even with this pattern, which is closer, if not following, the example, still is increasing...
_timer = 'mytimer';
_a = [_timer] call bis_fnc_deltatime;
_b = [_timer] call bis_fnc_deltatime;
[_timer, true] call bis_fnc_deltatime;
[_timer, _a, _b, abs (_a - _b)]
and _b should be 0, because no time passes between calls
run it for yourself. and repeatedly. tell me what it does.
here's the code sqf private _oldTime = missionNamespace getVariable [_id, SMALL_NUMBER]; missionNamespace setVariable [_id, time]; time - _oldTime;
now a couple minutes out, I am getting this, ["mytimer",195.163,0,195.163]
well, duh
["mytimer",220.394,0,220.394]
because _a is first call that returns time - 0.001, and _b is the second call that returns time between two calls that is 0
the timer should be reset. I should see very little delta, if any. but it is increasing! how is that "duh"?
I don't understand what you're expecting it to do.
but it is not _b from the very 'first' call. should be _b from the clear call, no?
according to the example.
no
I ran it again, ["mytimer",361.707,0,361.707]
well yeah?
I am blind okay, now I see it lol
361.707 - 0 = 361.707 :P
being literally start time, then delta
*time - 0.001
okay that is a much better measurement. about 0.5 s button click, probably not less than 1 s before responding to mouse holding.
distribution being anywhere from about 0.4 s but I saw as much as 0.6 also.
I wonder, as mouse EH goes, I should see mouse up before button click, yes?
You'd have to test it. I found recently that click is before doubleclick.
but one can't guess these things :P
that what is before what? well, that one seems obvious... or did you mean double click before click?
I need to gauge from down, up, holding, maybe also moving, button click...
clicks don't seem to affect "MouseHolding" in my testing 🤷♂️
how do you mean?
onMouseHolding
Fired on: Fires continuously while mouse is not moving with a certain interval.
and it seems like a common mouse EH issue, not exclusive to A3...
so "MouseHolding" is "mouse cursor is placed over this control and is not moving" or something like that
and has nothing to do with clicks 🤷♂️
I just need to delay responding to "and hold" gestures (or moving) events for a bit, time for the click to be digested.
assuming mouse down is my left edge...
wait for buttonUp, check the deltaTime 🤷♂️
yeah I could drop the button click altogether and just measure right edges around up/holding...
maybe a dumb follow up question... mouse button click occurs before mouse up?
so answer appears to be button click after mouse up, which would make some sense
this is interesting, click and hold then up, events go: mouse down, button click, mouse up... still get a button click in that... INTERESTING. would NOT have expected that.
mouseClick does fire 0.5s after mouseBtnDown even if there were no mouseBtnUp
it is funny in the above scenario I just described, button click fires off much SOONER than even that... like < 0.1
but is significantly delayed when the mouse went up in a typical down then up button click.
for me it's like 0.2-0.5 s between down and click if button is up, roughly 0.5 s if button is held down
input handling (and ui in general) is hell anyways 🤷♂️
sure, okay. it may depend on the system IO. mouse and keyboard are both connecting through USB 3.0 for me.
you got that right, sir ^^
anyway I think I have a little better handle on the dynamics involved I think. enough to sort out some better EH responses.
I store my initial fogParams as an array in variable msnFog and I want a trigger to setFog to the initial values if current fog values are different. But whatever I try, like comparing msnFog to fogParams or other variable that would have the array of current fog params, it always throws an error about condition == type array, expected bool, number etc. I am pretty sure I did something like that last year and worked as it should, now it doesn't
== doesn't work with arrays, you need isEqualTo
"MARTA_reveal" makes a group always visible and "MARTA_hide" makes it always invisible. Is there any way to hide a group so that it can still be revealed later?
Hello! I am looking to create a sqf script to execute the zen_modules_fnc_moduleExportMissionSQF every X minutes. The idea is to create an autosave system with a txt file created every X minutes.
Any idea on how to create it?
Yeah that threw a wrench into my plans, too
Can someone help me write a script?
To pull audio such as vehicle RPM out of the game so I can pair it up with another piece of software
you cant create txt files via script but you can use profilenamespace or alike to save your stuff
Trying to port a liberation scenario, however I'm getting this error:
I have no idea whats causing it as I have not edited that specific file
It's relying on a variable that's presumably supposed to be defined somewhere outside of that file, but that's not happening. I don't know enough about Liberation to say where that would be; possible locations might be init.sqf, initServer.sqf etc. or in one of the Liberation init/setup functions.
I would guess that militia_squad is composed of classnames from faction files that you have edited, and the first error is there and causes militia_squad to be undefined. Check the RPT.
could anyone guide me on how to make the ship move foward? (I don't want to make it "walkable") My guess would be to get the bis_carrierParts on the full model and increment the Y position in a foreach loop but i'm not sure how to do that
||also i'd like to add some foam at the front of the ship by maybe attaching some invisible speedboats to the Liberty||
I think I understand even better now how to arrange the "onMouseButtonClick" events with regard to "onMouseButtonDown" and "onMouseButtonUp". Especially gauging whether to handle a simple mouse click response; contrasted with a click and hold action, lasso, drag, rotate, whatever.
It is kind of a chick egg catch 22 relationship.
Simple button click sequence: down -> up -> click
Contrast that with, "and hold" gestures: down -> click -> up
So instead of measuring timers or whatever, I can scan for down, or having been up, during a normal click. If necessary also prohibit gesture states.
Contrast that with gestures, would watch for the 'open' button click, that is my gate before initiating and/or continuing gestures. Stoppage, of course, when up is discovered.
don't think you can, it does not have a pilot, no engine, etc.
tl;dr forEach with setVelocityTransformation on each constituent part
just keep in mind the movement of the pieces isn't guaranteed to be synced over a network which could result in some weird looking behavior if you're using it in MP
I guess you could attach each element to the other and only move one, then movement in MP would be smooth 
Still a bad idea to move such a huge object i guess 🤷♂️
I would guess that it's not a vehicle simulation, so update rate might be rubbish anyway.
In that case you'd want to attach all the pieces to a can or something :P
I think onEachFrame position setting would probably do it. I have doubts about setVelocity working since it's a static object without physics.
I believe they used Keyframe Animation to move it in the Art of War mission, but I kinda struggled with those modules when I tried them so...
it is really not designed for it. that and the Freedom.
even if you could inch 'all' of its LODs along, because some platforms are traversable by infantry and/or vehicles, gonna be a mess I think.
The original question mentioned that it did not need to be walkable.