#arma3_scripting
1 messages ยท Page 92 of 1
Yup
GUI or such only exists locally AFAIK, so if everyone needs to see the same thing, you need to execute on every machine
Thats good to know thanks a lot!
I'd like to make some of the params of my script optional. I'm currently executing it this way:
[[p1,p2,p3]] execVM "scripts\someScript.sqf";
And then in someScript.sqf:
params ["_vehicleArray"];
But the [p1,p2,p3] array is not always needed.
How can I check inside the script whether the array was passed as one of the arguments in the execVM?
Have a look at the params wiki page. It shows how to use default values for params that aren't received.
Note that because params are interpreted in the same order as passed, optional parameters must be after all the mandatory parameters, and aren't optional if you want to pass one that comes after it.
Thanks Nikko, this seems to work
params [["_vehicleArray", ["_vehicleArray", []]]];
nil works as a placeholder for optional value that's not passed 
[nil, 1] params [["_one", objNull], ["_two", objNull]];
[_one, _two] // gives [<NULL-object>,1]```
HC icons are defined in CfgGroupIcons. You can look this up in the in-game config viewer to see what's available
Awesome!
it can also be nicely paired with assert to provide context on errors or catch unwanted data types
Does that actually do what you want?
This is how I would write it based on your original question: (you can remove the spaces, they are there to make it more readable)
params [ ["_vehicleArray", [], [ [] ] ];
One parameter name "_vehicleArray", a default value of [] (empty array), and acceptable types of only [] (type array).
And the condition would be something like:
if (count _vehicleArray != 3) then { /* do something else */ };
If im interpreting your code right, (rewrote below):
params [["_vehicleArray", ["_vehicleArray", []]]];
One parameter of "_vehicleArray", and a default value of ["_vehicleArray, []]
What you wrote VERSUS what I wrote based on how I interpreted what you wanted in your original question (#arma3_scripting message) have different behaviors.
How do you not specify a soundPosition for playSound3D but still access the volume and such? 
@KJW default [0,0,0] 
that plays the sound at 0,0,0
Lets say you provide nil for the position to say you didnt define the position. It defaults to [0,0,0].
if you dont provide a position but provide a soundsource it plays from that
which is what i want
Yep, it did work as intendex. Ill check your example later tho.
["filename",soundSourceObject,isInsideBool,nil,volumeNumber] EDIT: This is wrong (shouldnt nil cause it to default?)
is the same as
["filename",soundSourceObject,isInsideBool,[0,0,0],volumeNumber]
So do you want it to play from [0,0,0]?
If so, it doesnt really matter whether you define it as 0 or as nil.
no its not because using nil returns an error
i dont want it to play from [0,0,0] it needs to play from the sound source
I see what you want. You have to define position to define volume. What you need to do is provide the position of the object manually.
_pos = getPosASL soundSourceObject or something like this and pass that to position. It will result in the same thing. Read KillzoneKid's second comment at the end of https://community.bistudio.com/wiki/playSound3D
Is this right?
No problem. Happy to help ๐
really are you sure, why would it do that?
because you tell it to
maybe the command ignores that location
Position overrides object position.
sure but there maybe exception
oh?
test it ๐
you tell it to play at [0,0,0] so it plays at [0,0,0]
did u test?
yes
ok
that has always bothered me too
nil won't work iirc
it only plays at a position anyway, so provide soundSource's ASL pos?
yeah it doesnt actually matter i was under the false impression source meant the sound would follow it
guess i have to get creative with say3d
yeah say/say3D, otherwise attachTo
attachto? que?
ah
don't really want to use createSoundSource as it's another thing to attach to this
say3d will probably be fine
course, i forgot about the sound limit meaning i can't stack say3D 
well you can stack them and they will say thingsโฆ one by one ๐
its for an engine loop for my capital ships project so needs to be uh
substantially loud ๐
I guess I just need to find a super short loop then so it's not as noticeable as increasing volume in the file causes problems
i suppose if i stack them and attach them to where the engines physically are it could work? 
stack?
. . .
createSoundSource? CfgSFX too
ya got it all already thanks
GL! it's not complex, it's just one initial setup and it's entirely autonomous after that
i think all i need is sound0[] in cfgsfx? not clear whether empty[] is required or not 
oh wait yes it is
is there any reason a sound source would stop playing when moved a fairly big distance quickly? 
I'm hearing it on occasion when the ship (which source is attached to) is spawning but when its position is set the sound source just doesn't play
try with a setPosWorld loop?
thing is, it works 100% fine when I run nearly the exact same code (just changing how I reference the same object) in debug console after its position has been set 
the sources are being moved properly, but just not playing the sounds 
surely that'd persist when doing it through debug console though
- Does the sound actually stop or does it continue to play at the original location?
- Does the sound update its position when moved a short distance?
- Does this happen when the sound source is moved a large distance independently, without attaching it to anything?
dont know, will checkcreated at debug corner, sound isnt present there- when done on debug console it does (as im eachframing setposasl)
- worked fine with attaching to a quadbike from creation at [0,0,0] but will check with same as this
it does not happen without attaching
however i do a lot of movement so im going to rework a function then come back to this
So apparently if you set camSetTarget to a position / target directly below the camera, it simply points up to space. Is there anyway in achieveing this?
revamping the function that moves the ship after its spawned did not help weirdly
offset by 0.001
much like my previous relationship, ignoring my problems did not fix them
Yea even still its not exactly a top-down view of the target. I've found a work around by adjusting the offsets further but it now looks more like a drone view than a straight-down satellite view.
putting a waitandexecute in worked fine, dunno why
seeing as other things were being attached etc just fine
Also whats the difference between camconstruct and camera in the camcreate type?
How can I check if a given string is the name of a item class?
Think I've figured out the root of the issue
if i go far away (cant figure out how far, its not object render and its not sound distance as ive set that to 50km) from a soundsource the sound stops playing and doesnt start again 
you can set sound distance?
yeah but is created at [0,0,0] and setting sound distance changes the volume from what i can tell as someone who is hearing impaired
(im referring to the distance in cfgsfx)
not been able to find the precise cause but just going to have to deal with waitandexecuting it and having it sound shit
...i can just make the object itself have a sound ๐คฆโโ๏ธ
no i cant because thats the same thing
Ahh that sound distance. I was thinking of like video settings
ya, not that lol
this is a huge pain in the ass and i am no further with it lol
basically i just need to loop a somewhat long sound from an object while its moving, ideally with the ability to increase volume above 5 lmao
Heya all, possibly dumb question. I am working on a mod with ace, however I can't really find out the variable names. Is there anyway to view the variables in use?
wdym?
an item class is already a string. so you can just use == to compare
or do you mean the item's display name?
how do I test if "aaa" is or isnt a item?
isKindOf? You might have to combine a couple depending on how broad your definition of "item" is
what would be on the right hand side? What is the generic item class?
Definition of item is any item equippable or storable in the inventory
Including backpacks or not?
Backpacks are in CfgVehicles. Everything else is in CfgWeapons.
["I_supplyCrate_f","arifle_MX_F","B_AssualtPack_blk","aasiuhdaiuhds"]
1st string is a supply crate. 2nd string is a rifle. 3rd string is a backpack. 4th string presumably doesnt exist, but a mod from Mr. Boogie might have added an item called "aasiuhdaiuhds". How do I test each string to see if it is a item class?
I feel like there's been a design screwup if you have that in an array.
Exactly. A more realistic case would be "arifIe_MX_F". Do you see how that isnt a reference to the MX rifle? the L has been replaced with an I.
This is why I want to test a string and see if it is an item
And yes, backpacks need to be included, but I also understand they might need a special test case
The way I am thinking would be a set of isKindOf checking against the highest-level parent for each type - e.g. itemCore, magazineCore etc. You'd need to do some config research to find all the possibilities.
I think i just found what I want.
BIS_fnc_itemType.
If you know it's not a backpack you can just do isClass (configFile >> "CfgWeapons" >> _item)
If you need to know exactly what type of item it is then itemType will do that. It is fairly slow, bear in mind.
What I found is about I what I wanted. It has a note at the top that concerns me a little.
https://community.bistudio.com/wiki/BIS_fnc_itemType
Something about mods modifying item categories. Does anyone have any context for this?
* and another one for magazines
oh yeah, magazines as well :P
Common issue with itemType is that mods will just spam almost all primary weapons into Rifle.
My primary purpose is to catch typos with a per mission inventory user config (script inventory config, not an actual arma config). A catch-all is fine.
Oh, if you're looking for typos then just isClass on CfgWeapons, CfgMagazines and CfgVehicles (for backpacks) is sufficient.
itemType does a lot more than that.
If I run into performance issues with itemType, ill use the other method
Hi I am making a convoy but I have a problem. when the first car gets blown up or cant drive anymore all the other cars stops behind it. I'm using a: Better convoy mod
evrything is working good but the only problem I have is what I explaind. Cant find anything on the internet.
when they are in one group they behave better. but it has minuses
yes
wait
ye I did seperate one truck from the cars but its hard to make all drive on its one while looking like a convoy
ye, no problem. I will try to make all cars drive on its one by making convoys for each others
But they act like children when I make them drive sepretliv. They always wants to be first on the road, so they tried to overtake everyone๐
yep
You can solve this stuff with a lot of scripting, but if your starting point is using a mod then you're a long way short of that.
Tip #1 for making a convoy: DONT!
AI are already stupid. AI mods, as nice as they are, are only a bandade to the problem. A convoy NEVER works.
For mission making, it is recommend to just not use an AI convoy. Unless it is on rails, it will likely break.
I encourage you to keep trying. Just know you are fighting an uphill battle.
Ye im not using that method any longer. I will see if this works, thanks for the tip
Put the fastest vehicles at the front and they won't trip over each other as much :P
how does antistasi do theirs? ๐ค
Wellll, the waypointing and initial vehicle placement are so complex that they're out of scope. The convoy in-motion management uses a spawn per vehicle that: a) Bumps to the next waypoint when sufficiently close, b) Adjusts limitSpeed base on the distance to the vehicle ahead and c) Detects whether the vehicle hasn't made enough progress towards the current waypoint and removes it from the convoy.
Without intermediate waypoints, C is hard to get right and B breaks down because some vehicles will take different paths.
And then if you don't get the initial vehicle placement right they'll just fall over each other getting to the first corner.
Hey everyone
Im trying to limit a vehicles speed to 5kph and the following works great
_this setCruiseControl [5, false]
However it doesnt limit the reverse speed and players being players will find this and exploit it.
How do I restrict the reverse speed to 5kph as well?
disabling reverse would also work for my intentions
Unless forceSpeed works, maybe nothing except config changes and dirty hacks (eg setVelocity looped).
cheers I will give that a go
Sadly doesnt appear to work
is there just a way to disable reversing?
Only positives values are valid, negative values will make the vehicle unable to move forward
see if that stops reverse
I did
And as it says when using a negative value it disabled forward movement and all reverse movement was still doable at all speeds
๐ซค
I wouldnt mind disabling forward movement if it limited reverse speed
Basically I just want to emulate a crippled vehicle that can only limp out of combat
breaks immersion a little if it can reverse at 40kph haha
a keyhandler to disable backwards?
How would I do that
ahh got you
CarBack
๐
not sure that's the correct EH for the actions though, I know there's a way to input action instead of key
Thanks I will will have a play and see if I get it working
ok have fun ๐
I may have bruises on my forehead at some point from head butting my desk haha
Im still learning how to work with configs, so if configs are required for this, please provide at least a basic example and explicit function to use.
How would I got about get all the items for a mod?
Essentially, I want to get all the items for Ace Medical, Ace Pharmacy, and ACE KAT
But not each may be loaded. I already know how to test if a mod is loaded.
addUserActionEventHandler, but it doesn't allow you to block the action
Does anyone know how to make a script that respawns a vehicle 5 seconds after it fires?
I'm playing with the s-75 missile but I can't do the infinite ammo script that I use on everything else the "This event handler fired select zero script" everyone knows. Does anyone know of a way I can modify that script to respawn the vehicle instead?
I tried this "this addEventHandler ["Fired", ((.this select 0) respawnVehicle [5,0]}]; but It didn't work
this addEventHandler ["Fired",
{
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
_unit_pos = getPosASL _unit;
_unit_type = typeOf _unit;
deleteVehicle _unit;
_new_unit = createVehicle [_unit_type, _unit_pos, [], 0, "CAN_COLLIDE"];
}
];``` untested but you get the gist though I'm not sure why you want to respawn every time you fire it
The s-75 once fired is just done
It's a single use missile holder from what I see
So if I respawn it, I don't have to keep going into Zeus and placing endless missiles
Do you have the predefined marker set to respawn this vehicle?
This should work
The respawnVehicle requires you to place predefined markers for respawn as mentioned in the wiki. https://community.bistudio.com/wiki/respawnVehicle
But you should be better off with BIS_fnc_spawnVehicle https://community.bistudio.com/wiki/BIS_fnc_spawnVehicle
this addEventHandler ["Fired",
{
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
_unit_pos = getPosASL _unit;
_unit_dir = getDir _unit;
_unit_type = typeOf _unit;
_unit_side = side _unit;
deleteVehicle _unit;
[_unit_pos, _unit_dir, _unit_type, _unit_side] call BIS_fnc_spawnVehicle;
}
];```
except the newly spawned vehicle wouldn't have this EH ๐ฟ
TAG_RespawnEvent = {
params ["_unit", "_weapon", "_muzzle", "_mode", "_ammo", "_magazine", "_projectile", "_gunner"];
_unit_pos = getPosASL _unit;
_unit_dir = getDir _unit;
_unit_type = typeOf _unit;
_unit_side = side _unit;
deleteVehicle _unit;
[_unit_pos, _unit_dir, _unit_type, _unit_side] call BIS_fnc_spawnVehicle params ["_veh"];
_veh addEventHandler ["Fired", TAG_RespawnEvent];
};
this addEventHandler ["Fired", TAG_RespawnEvent];
For once my code works as expected 
thou shalt still be smitten for _snake_casing_your_variables! ๐
Would it be possible to create a script that checks what kind of gear the player(s) got on and fills an inventory with the ammo/other stuff that people might need to resupply?
For instance? You want to add magazines they use in their gun?
Exactly, there's instances when the guys use a variety of different guns and ammo, making ammo resupply a bit weird for the zeus.
You could use
_mags = magazines player;
Then fill a box with like 10 of each unique type
That only works if they haven't already run out
Sure I guess I assumed that would be the case that they prep a resupply box.
There are only two ways then if that isn't the case. 1 is to preprogram a gun to ammo array to fill the box with compatible mags.
2 use BIS_fnc_compatibleMagazines, but then you get a huge list of compatible mags depending on modpack
You're supposed to readd the magazines and remove the reload time
You're probably just doing setAmmo. Missiles are mags not ammo (as in when you fire the mag itself is removed)
Plz no 
hey guys having issues with ghost riders classname puller script anyone able to have a look and figure out why its not working please?
oh, there is a problem, great
its doesnt pull anything what so ever
maybe you are using it wrong?
all the other scripts work now and previously artemoz on this discord fixed the weapons and magazines script like its actually broken
contact the author
Parameter(s):
0: STRING - item class
there are no considered parameters in here
Ideally I'd run it at the start of the mission and the script would 'check' the players' inventory and add a certain number of all the magazines it finds in the inventories of all connected players to a crate.
Sadly I don't really have any knowledge of stuff like this so I hope my explanation of the intended function makes it a bit clearer
is it possible to combine an image texture/icon with a procedural one? e.g to tint it
something like #(argb,1,1,1)color(1,0,0,1) * image (\Ca\ui\data\markers\gr_flag_CA.paa)
No
In structured text, the color attribute can be used on images, though I don't know how exactly it behaves outside of the NATO unit type markers.
_vehicle emptyPositions "" seems to return 4 when I'm calling it for some RHS vehicles in which there are: driver, gunner, 3 x passenger (which is 5 seats). Any ideas why?
Nevermind I think, one of the comments mention that I should use fullCrew instead.
Is there a way to remove the auto respawn by script? People are able to spawn on dead cars and people
You mean when you respawn on the position you just died in?
No there is a button that respawns you when the timer runs out. The issue is that bohemia devs are not smart. So it also works on dead respawns like a blown up respawn hemet
Vehicles can only be used as spawns if they've been added with BIS_fnc_addRespawnPosition. So when you do that, save the ID it returns, and use a killed event handler to remove it with BIS_fnc_removeRespawnPosition once the vehicle is dead.
So in a multiplayer environment, you as a zeus would want to check all player's inventories to find their loadouts (mags, smoke grenades, chemlights etc) and load them all into a single resupply box)?
๐ง create an Arsenal box with only magazines/grenades but without weapons/uniforms/whatevers
Yes, is that unfeasible?
untested, but you get the idea
arcresupply = [];
private _players = allPlayers select {!(_x isKindOf "VirtualMan_F")};
{
_mags = magazines _x;
arcresupply pushbackunique _mags;
} foreach _players;
supplybox = createVehicle ["B_supplyCrate_F", position player, [], 0, "CAN_COLLIDE"];
{
supplybox addItemCargoGlobal [_x, 10];
} forEach arcresupply ;
Things you need to edit:
position player => Position (Grid or another object) you want to create the supply drop
10 => Amount of magazines you want to load inside the supplybox
Thank you, I'll give it a try and I'll let you know how it works out
If you by chance are making your own zeus module for resupply, zeus additions includes a really nice resupply module that is already placed.
I'll have a look at that as well, thank you
scopes confuse me. Will this work? x3
// objs = array of objs.
// _buildingStr = string, ie 'Land_i_Addon_02_V1_F'
_building = _objs select (_objs findIf {_buildingStr == typeOf _x});
normally I'd just check, but I can't right now, sadly
wait no, I should maybe just iterate through manually, since I needa touch the non building objs anyway
if not found, findIf returns -1
and _array select -1 is apparently a supported way to get the last element now ๐ฎ
for future referance, scope wise that'd work right?
it can access the buildingStr
yup
With reference to this: https://community.bistudio.com/wiki/Profile#scripting
What constitutes a "Large amount of data"?
Are we talking 1GB here? 300MB?
Interesting
it's not just a matter of performance. with larger profile namespace the risk of corrupting it is greater
^
I change profiles according to what mode im gonna play if they save to profile
I'm gonna guess you might have some kinda "leak" or lots of unsued stuff?
oh you're the server ok
Mine's 20MB, I restart Arma dozens of times a day, often with alt-f4, and it never corrupted :P
This is why I was wondering
๐
Too many Antistasi test saves, a few Vindicta and an Old Man from before they fixed it.
in the olden days the biggest it went for me was a couple of MBs ๐
I recommend using a DLL instead (or an existing DB mod like exDB)
ok. Now, I am about to need to leave for something, so I'm put my plan here so I can come back to it.
Syncing items to a game logic. In logic's init, call a function with the logic and a string. Finds all objects sync'd, finds the first one that matches the string and makes that the building. The rest of sync'd objects will be saved. When building is damaged- idk how, but check if damage is a certain amount. If yea, make the objects- "fall"
why? the SQF is tiny
I think he means DLL for the saving
Way too much hassle and it's not exactly well documented
I mean, I'm likely to add a DB extension to this later.. but "simpler"
probably old mods saving settings
When building is damaged- idk how
event handlers
such as handleDamage
or hitPart if your building doesn't support damage (so you can implement a scripted damage system)
OH PFFT
ok, maybe I wanna clear some of the data in my profile ๐
We have extra namespaces now per mission, that can be used for saving stuff
that's the profile namespace?
or just the folder?
well it contains lots of saves. if you don't need them they're safe to delete
- missions you create in 3den
ye, it's mostly missions I think :P
Soo all I'm seeing here is that 4GB is workable ๐
ignore my screenshot
speaking of profiles. How does one fully remove data from the file?
Do I make the variable nil or...?
that should work yeah
then save it (saveProfileNamespace)
I mean, this is 4.8MB or so.
If you could create an alternate profile file? Not just the divider for missions
the other image was not of the file, but the whole folder
can be used for multiple missions too
Its a file per mission. Don't remember how that feature was called
there's a new namespace in script commands
I mean, in theory ya could make a txt file or no?
missionProfileNamespace?
missionProfileNamespace
yes
Interesting
with DLL yes. can't be done via SQF
but reading txt is meh (if it actually contains text)
Does that save to the MissionName? IE If you change the mission description.ext / mission.sqm would a new one be generated?
How to override a final compiled function?
its not mine tho
do you mean a cfgFunctions function?
Ok i'm going to test that, but still. 4GB file yeah?
yes, or one compiled using 'compileFinal'
well like I said compileFinal ones can't be overridden. but if you use allowFunctionsRecompile=1 in description.ext you can recompile cfgFunctions functions
I think it's enabled by default in 3den
how much info are you saving?
realistically speaking, even saving every single item position and state should be < 50mb per person, barely 1gb according to your 30 persons. But i dont really think you need to save the exact same data for every client so its even lower in the long run, maybe even a couple of hundred mb being bad
ye, that doesnt help me, I need to use mission only related stuff to override a function
Currently, per player, POS, Health hit parts, loadout and SteamID
If I could do it per flat file, I can split my mod up more effectively. But DLL
@little raptor or, if its possible to have an event which would trigger when a function is executed then it would help too
Well you can't, thats the whole point of final, to prevent you from overwriting it
no unless the function itself throws an event
I like hacking, at least I tried ๐
Everytime you use profilenamespace get variable, you hit the flat file for vars, right? There's no way to keep it in memory until flushed ?
Don't think so. https://community.bistudio.com/wiki/profileNamespace
The variables are loaded when the user profile is loaded or changed.
keeping it would only be detrimental, you would block writting access
How would it be detrimental. You're literally reducing seek times when it's in memory
well anyway the game keeps it in memory yes
Ok, so 5 minute flush to disk, using the save profile, but everything else is just done through memory space. Ok
Even saveProfileNamespace is typically well under a second :P
It does block though, so server can hang for a few frames.
I'm asking because someone's said that 400 players worth of information is too much for my mod to handle
shrugs
you can test it with missionProfileNamespace.
The storage format is... not efficient, but loadout saves aren't that large.
which is why I recommend a DLL that can do this async ๐
you can also make backups of the file in case it goes corrupt
you don't want the players to lose their "valuable info" (whatever it is)
I meant 5 minutes interval, or 15 ect
I can set a config option for that anyway, so the ServerAdmin can decide
in fact.. I can just switch it up. If the user wants to save to a separate flat file, AKA missionProfile, they can do
Anyone go experience with the QGVAR system?
I am trying to get a handle on this ACE eventhandler, however I have no idea how to translate this into a string I can grab
[QGVAR(knockOut), _unit] call CBA_fnc_localEvent;
what mod did you get it from?
ACE medical
GVAR is modName_addonName
so for ace medical should be something like:
ace_medical_knockout
check the script_macro file
Q for quotes, so "ace_medical_knockout" 
yes
Aah
I said GVAR is that. QGVAR is quoted
sweet thank you both!
Hi, is it possible to add like 500 magazines inside the player inventory regardless of the max capacity ? Because when i use "addMagazine", it check the max capacity and i can't go further.
you mean without loadCoef?
if you haven't tried that one: player setUnitTrait ["loadCoef", 0]
not sure if it'll allow you to store as many items as you want tho
Yeah i meant in general because for me it was possible to do that
I never tried so i will check thank you
another way is making your own backpack with infinite maxload 
I tried and sadly it's not working. I wanted to know if it was possible to ignore the limit like the "addItemToCargo" or these kind of commands.
https://community.bistudio.com/wiki/setMaxLoad
(note server exec)
Yeah i will probably do that but what is the value of the infinite ? Because if i remember, i did something like that but i put something lie 999999
you can't actually put infinity in there but a large number is good enough
e.g. 1e30
not sure if it'll crash the game or anything tho ๐
better keep it within a reasonable limit
forgot that existed 
oh ok thank you then i will try
it work perfectly ๐ so thank you too
You could also use a Reloaded EH to replace expended magazines
still waiting for the day we get the ability to add fake weight to containers 
{
_camfeed_1 = "camera" camCreate [0,0,0];
_camfeed_1 cameraEffect ["Internal", "Back", "uavrtt1"];
_camfeed_1 attachTo [cam_target_1, [1,1,1], "ruce"];
_camfeed_1 camSetTarget cam_target_1;
_camfeed_1 camSetFov 0.3;
_camfeed_1 camCommit 0;
[
"featureCamera",
{
_camfeed_1 cameraEffect ["Internal", "Back", "uavrtt1"];
}
] call CBA_fnc_addPlayerEventHandler;
} remoteExec ["call", [0, -2] select isDedicated, true];``` How'd I go on about having this camera be moved at a later point in time for all players?
uh
just setposasl it? 
Heya all, trying to execute my CBA Added Key. Getting no errors, my function name I am pretty sure is correct as I found it in the Functions Viewer with this name. An help would be great.
#include "\a3\editor_f\Data\Scripts\dikCodes.h"
[
"WELSHY_KAT", "MyKey",
["Tactical Recovery Position","Roll interface Key"],
{[_this] call WELSHY_KAT_fnc_RollPlayer},
{},
[DIK_NUMPAD1, [false, false, false]]
] call cba_fnc_addKeybind;
you lost all reference by remoteExec'ing it
better have a function
Do you know if it's possible to check if this has been set through SQF? missionGroup
I'd like to throw a warning that it hasn't been set in my logs
missionConfigFile >> "missionGroup"
Ah cool, so if exists
yeah
Cheers!
getText (missionConfigFile >> "missionGroup") != ""
if ((getText (missionConfigFile >> "missionGroup") == "") && (profileNamespace getvariable ["SPSavelocation", 0] == 1)) then {
[1, "SPSaveLocation is set to 1, however no missionGroup has been defined. Proceeding in this way will cause dataloss should the mission change."] call spp_fnc_log;
}
You want to tag your profilenamespace vars a bit more than that.
How do you make an Ai to not react with others? I have a Ai as a driver but when it sees a Ai it tries to overtake it and everything just goes downhill from that.
Hey guys, its sarting to bug me as I really can't seem to figure it out regarding why my function is not launching.
#include "\a3\editor_f\Data\Scripts\dikCodes.h"
[
"WELSHY_KAT", "MyKey",
["Tactical Recovery Position","Roll interface Key"],
{[_this] call WELSHY_KAT_fnc_RollPlayer},
{},
[DIK_NUMPAD1, [false, false, false]]
] call cba_fnc_addKeybind;
wdym?
There's a point somewhere on the WIKI that making excessively large namespace variables causes issues
yes, but making overly generic ones leads to conflicts between mods/missions.
if it becomes an issue, i'll deal with it. I've not come across any other mod that uses my variation of ProfileNamespace variables yet
Does it show up under controls > addon controls > Welshy?
Where are you calling it?
Have you tried using the DIK number instead of the name DIK_numpad?
Ye it works find just told it to hint on press and it appeared, and yes it does show up and configurable
Getting this as an error - _fnc_scriptNameParent
@quiet pagoda its going to depend on whether youre scripting for MP or SP, but the driver's init box is a good place to start.
Its Sp, I just want the Ai to not react to other AIs
Even with the function, how'd I go on about storing it so i can manipulate it later during different execution. Since it would be more than one cam.
a function within a function?
i initially setout with using publicvariables
pass the value to the function? then do x on one, y on another?>
the function itself stores it as TAG_fnc_cameraFunction_camera and works with it
a remote function setup I commonly use is
params ["_mode", "_arguments"];
switch toLowerANSI _mode do
{
case "start": { /* create cam, store in TAG_fnc_cameraFunction_camera */ };
case "move": { _arguments params ["_pos", "_dir"]; /* use stored camera */ };
case "stop": { /* destroy camera and set value to nil */ };
};
```thus, everything is local, yet everything is decided by the server
This is gold - so if I want to use 4 cams, ill store them in PEPE_fnc_cameraFunction_cam_1 through 4 and then use it to move? Sorry have a bit of a brain freeze 
what cam? PiP cam?
ye, it'll be projected via rtt
what if player doesn't have PiP enabled ๐
so at one point it will be at location_a targeting target_a and then later, location_b targeting target_b
but then yeah in _arguments use a number you can format ["myCamera_%1", _number]
So something like this? https://sqfbin.com/howigedubateqazukaro
Again for my dumb question - but what's the difference between this method and using non-sync publicvariable instead of the function?
Something like: https://sqfbin.com/cikujuzofelegemegise (I know its bad but im trying to understand, since even when using function, you are going to globalexec it so that all machines have the function to execute when called iirc)
ah apologies for the mistake should've been _functioncamName = _camName and used it so forth
I don't see any publicVariable
never used remoteexec in my life, never will ๐ฟ
you are going to globalexec it so that all machines have the function to execute when called iirc
you can define the functions locally, e.g. via cfgFunctions
why 2 remoteExecs?
what is the problem exactly?
what's the difference between setVelocityTransformation and setPosASL/setVectorDirAndUp oneachframe? 
based on what i am seeing my guess would be SVT is different network wise but would be nice if someone could confirm that
I'm not sure that there is any difference.
similarly, am i missing some sort of diagnostic command for ping or does it just not exist?
i use svt partially (capital ships project, svt gets used for warp) and that's perfectly fine on the server, just the movement which uses setPosASL and setVectorDirandUp on each frame is somewhat juddery
Well, you'd need setVelocity as well.
Isn't the issue with houses that they have a slow network update rate in general?
its a house attached to a cba target vehicle which has a high network update rate from what i can tell
So if you want to move them, you attach them to an object with faster network transfer rate.
like, it works fine aside from the juddering
i'll try grab a video in a bit but updating dedicated server with tcadmin takes a while ๐
Are you saying there's a difference between svt and setpos/setvector/setvelocity or not?
yes there is but im wondering if anyone knows what it is
-- though maybe not the setvelocity part, as setvelocity takes local args
yeah, all of this is run on server
but setposasl is global args so i feel it could be handled differently network wise which is why its ending up different to svt
but this is just guesswork on my part and i am here to try figure out if someone knows the actual answer ๐
Are these local objects or not?
they are local to where the setpos command is being executed which is the server
but they are not local objects in of themselves
..
i feel i may have misunderstood the question
oh i did i just gave an unhelpful response
the createvehicle is executed on the server
it is not a local object
the setposasl is executed on the server too
Let's get this straight. You have two otherwise-identical cases. In one you use setPosASL, setVelocity and setVectorDirAndUp. In the other you use setVelocityTransformation. The movement equations are identical. From a client perspective, the first one judders and the second doesn't?
I do not use setvelocity at all as they have none
I have two eachframe handlers which update the position and the vectordirandup according to its calculated velocity (which my code also handles -- looks identical to the other in SP). This is juddering, though not teleporting about -- just inconsistent movement in dedicated vs sp
I also have a setvelocitytransformation which is just from X to Y with interval increasing, which looks fine and smooth in MP
I do not use setvelocity at all as they have none
I don't understand this part.
running velocity on the object will always return [0,0,0] and setVelocity will do nothing; I am using the CBA target vehicles as logic objects, but for all intents and purposes are just houses with higher update rates
I'm trying to get videos but tcadmin is playing up
it is also not related to server FPS, I have tested that and it is more or less constant, +/- 1 or 2 fps, it still appears smooth down to 20fps in sp
tcadmin cooperating now, give me a sec
velocity doesn't exist for land objects
yeah, give me a sec to edit these together
hopefully that makes it clearer?
the jump out is where SVT is used -- jump in does too
but looks identical in dedi mp to sp so didn't include
im not asking for a solution to the issue as i can just do a 0.25 svt that loops -- but im trying to figure out why its happening in the first case, which is network i believe ๐
You have a missmatch between client and the server
The jumps in position are because you have different frame rate updates
On the client and server
but why does it look smooth on the svt instances? ๐
Single player, 300+ fps = smooth
it looks the same when i shift my fps down to 20
Multiplayer, 60 fps client but 45 fps server = jumpiness because the server is boardcasting position data to the clients cause the jump
Also remember arma is lock step
Meaning the the physics updates are tied to your fps
do you think changing it to setvelocitytransformation will cause any difference at all given the jump out is identical on dedicated to sp? 
Remember that video in fallout 76? Where you can run faster while looking at the ground?
i do not
but i understand what youre getting at
everything unrenders -> higher fps -> more physics updates
Yes
what im not understanding is the disparity between setposasl on each frame and setvelocitytransformation
like, it is completely identical between dedi and sp for svt and has been every time ive used the command
What
setvelocitytransformation is buttery smooth on dedicated and sp
eachframing svt for the jumping out, eachframing setposasl for the regular stuff because svt made me want to fucking die
You need to times your velocity by your delta time
i do
ive been working on this for 5 months, its basically finished aside for this ๐
I'm surprised John didn't notice
I never got to the point of being clear about what he's doing :P
John
mood af
ive been working on this project for 5 months with a newly discovered brain injury that is making me forget a lot of things
the fact its even running on a dedicated server is incredibly surprising
you need to do verlet integration rather than euler integration
Verlet integration (French pronunciation: โ[vษสหlษ]) is a numerical method used to integrate Newton's equations of motion. It is frequently used to calculate trajectories of particles in molecular dynamics simulations and computer graphics. The algorithm was first used in 1791 by Jean Baptiste Delambre and has been rediscovered many times since ...
your velocity times frame rate change is running into stability issues, hence the jumps
Now, I need food
John can tell you more about this lol
im not integrating anywhere ๐
i have target velocity and current velocity, current velocity is updated oneachframe according to acceleration variables and then the current velocity is used with diag_deltatime to calculate how far the object should've moved between frames ๐
yes you are integrating
getting food. BRB
does your path have very strong direction changes?
sec, I'll watch your video :P
its just going in a straight line in it ๐
i will also sqfbin the functions im using
yeah never mind then.
(integration method won't do that without major velocity changes)
https://sqfbin.com/rujefujujizokoqutuxe
no, i cannot make it into one pfh because for some reason it then breaks and i have zero clue why
ah, sqfbin once more refusing to syntax highlight this monstrosity
Did the new update change anything on how setDamage works? I have a addaction that use to work but now it does not and I don't know why.
_box addAction["<t color='#d85b55'>Reset Health</t>",
{
params["_target","_caller"];
_caller setDamage 0;},[],500,false,true,"","",5,false,"",""];
You're saying that the addAction is there, it just doesn't reset vanilla damage?
You didn't switch to ACE or something? :P
His straight line includes a large jump
At the end
That's a major velocity change
All I see in first part of the video is the submarine moving in a straight line at a fairly constant velocity with some random judder.
it's network related, and that arma has a lock step base physics engine
that's why it's happening
yeah, thats what im getting at, setposasl is juddering but svt is not ๐
At the end of this video, you may have a broad concept of how to implement a cloth simulation algorithm in your own game.
You can take a look at the webgl + js game engine I'm developing using the cloth simulation I implemented in the video: https://github.com/Fangjun-Zhou/White-Dwarf
I've also published all the code in the video to the reposi...
Don't be fooled by the cloth simulation in the name
probably best i dont watch at 2am while im not entirely conscious right now lol
ill give svt a try tomorrow regardless, it if works it works
you probably also, aren't going to get it smooth because the values of your "velocity" aren't being interpolated correctly
I wouldn't rule out svt dodging some networking/simulation rules wrt. velocity of objects that don't normally have velocity.
yeah, i think its probably the best ill be able to get over this -- probably just do a 0.25 second pfh that adds another pfh for a 0.25 second long svt
Whether it's by forcing faster updates or actually passing some internal velocity that you can't set by other means.
doesn't setPosASL also have a network propagation delay?
Everything has a network propagation delay :P
think 0.25s is a high enough update time for the vars given thats how often i network sync them
the piloting isnt actually working right now in mp but thats irrelevant
oh, its not going to be that simple actually given its not in modelspace stuff ๐
i could try use interval of 1 with svt instead of using setposasl etc and see how that goes, ill find out
I need to check that my dive bombing stuff doesn't look terrible on DS+client now :P
taking over the ais vehicle to stop ai making stupid decisions, i like it
the first one didn't
but I never check the second version
ugh, might need to rewrite it again actually.
I guess svt really does stuff that you can't do otherwise.
I had to add setPosASL to make airplanex work, which probably made the networking worse.
lol
Naw, using APS. setDamage use to be the way to do healing but now it does not work but APS did not update. Only Arma.
After the first one is executed, after like 15 - 20 mins the second one may or maynot be executed - but if it does, it should modify the camfeed_1 that was initially executed
Is there a way to script out a UAV so the players can look through the gunner's cam but not alter the flight path or anything
I'd like them to "capture" an intel feed
yea so this would work for all clients async while still allowing the possibility to change its attributes globally as publicVariable is not present
sorry, I mean they should be able to control the turret
this is not a possibility as everything has to be dynamic / in-game debug console so using any cfgFunctions or others is not an options
Is there a way to export deformer stuff to a script like with sqf?
Deformer uses https://community.bistudio.com/wiki/setTerrainHeight, so it is theoretically possible to use the same values with a non-mod script. However, whether Deformer provides a way to easily do that, or whether you'd have to go looking in the mission files and manually copy it out, is probably something you'd have to ask the Deformer devs about.
i got some issues with changing uav sides, so i have a server sided file:
_asset = createVehicle ["B_AAA_System_01_F", _pos, [], 0, "NONE"];
_asset setDir (direction _sender);
private _group = createGroup (side (group _sender));
createVehicleCrew _asset;
(crew _asset) joinSilent _group;
(group effectiveCommander _asset) deleteGroupWhenEmpty true;
For some reason the crew never goes to the east side, on zeus you can see the praetorian is on nato side but the crew is in an opfor group.
Now whenever i run (crew _asset) joinSilent _group; on a client after the praetorian is created the side of the praetorian does change
my main issue is that the side doesnt change right after the vehicle is created causing nearby praetorians wich have the east side to shoot the new praetorian
is there some lacality issue that doesnt allow the server to change the uav side?
same thing
suppose I have to find the object's destination in the next 0.25 seconds and then use that as its destination whilst changing the vdirandup and such still
really didnt want to have to 
Is there a way to have a combination of infinite and limited items in an arsenal, i.e. infinite rifle ammo but finite rockets for the launchers?
It was not an issue with how I was doing it, svt was just so fast I was unable to see it having the same effect, both look identical now, the issue is just much more evident at lower speeds. Not sure if there's anything I'm able to do about it, but thanks for the help regardless
cc @granite sky @simple trout
ofc if either of you find out anything new about svt please let me know but I've just slowed the warp stuff down and they are having the same juddering
Not without a custom arsenal. The only one I know of is antistasi's custom one. A work around would be to add the weapons, then have the magazines in a box next to it.
How would I invert an objects up/down direction, relative to an attached object's model up/down?
Also, position is gonna be offset so much downward relative to attached object
the way I am thinking about doing it, itd probably just be easier to try making a color picker in eden editor attributes xD
Is this correct syntax? [Michaelangelo] remoteExec ["addWeapon arifle_Katiba_F", 2];
aight thanks so [Michaelangelo, "arifle_Katiba_F"] remoteExec ["addWeapon", 2];
addWeapon already is an GE though
Ye should but it seemed only to have only local effect when i tried it yesterday but i might be mistaken
Possibly more of a #arma3_config question, but figure the people with more technical know-how will be here:
What does simulation config param change? Is it just how the engine treats the object? Can I turn a house to airplanex and have the engine interpolation between positions? ๐
@worldly snow Why DM me?
just a question about hiddenselectiontextures
as you have worked on them before
Oh wait, this isn't config xD
breh
I'm trying to add an ACE interact action to an object of specific class. I was able to make it appear, but I'm having a trouble getting the condition to work. Basically I want to add a separate action to an object for every grenade in the game. Managed to do that. However I want to add a condition that checks if the player actually that specific classname of grenade in the inventory. I just can't figure out how to get the currently evaluated grenade class from the for each statement, that creates the action, into the condition of that action.
Hey, is there any event handler that fires when a vehicle is destroyed, as well as after deletion by deleteVehicle? I am looking for a more performant solution for waitUntil 
Killed and Deleted
entity Event Handlers are listed here: https://community.bistudio.com/wiki/Arma_3:_Event_Handlers
mission Event Handlers are listed here: https://community.bistudio.com/wiki/Arma_3:_Mission_Event_Handlers
Ah perfect ๐
Do I understand it correctly that the ace interaction has no way to actually pass any parameters into the condition of the interaction, only to execution?
Im pretty sure things can be passed into it, the ace action doesnt call a function, it just calls the code in it. You coukd create a function, and call it through the code while passing your arguements, like {[_variable] call function}. Give that a try
@opal zephyr AFAIK if you put stuff in curly brackets it will not pick up _variable that was defined before.
How many loops of the forEach are you doing? Is it probable to pass it as a global statement? Or move the forEach into the interaction
All of the possible grenades in the game, including from whatever mods you have loaded. Each interaction is for the separate grenade type.
I'm making a tripwire mod that lets you place down a generic tripwire mine, then you can "attach" a grenade to it, that arms the mine. When triggered the mine spawns the grenade from of the "attached" class.
I got all of it working except for a condition that checks if the player has a the specific grenade in the inventory.
Problem is that the function that adds the action expects the code unlike the vanilla add action that takes string. If it accepted string then I would be able to pass the grenade class into the condition code with something like: _grenadeClassname + " in magazines _player"; as it stands now I just can't figure out how to pass the grenade classname to check if the player has it.
Hello peeps, I am trying to make a composition of a gear locker, how would I place a vest that will float (trying to make it look like its hanging) without it falling to the ground?
thought disabling sim does that, but doesn't work
@brisk lagoon You could create a simple object with the vest's mesh, if the vest does not need to interacted with.
It does not needs to be interacted, so just make it a simble object?
i cant figure out why my friendly praetorians shoot other praetorian this is my code:
// Executed on server
_asset = createVehicle ["B_AAA_System_01_F", _pos, [], 0, "NONE"];
_grp = createGroup east;
createVehicleCrew _asset;
[_asset] joinSilent _grp;
So the issue is that when i exec this code there is a small window where other praetorians, wich are assigned to east, start shooting at this created one. how can i avoid this/ why is it happening
is there a way i can change the side of the praetorian right after its created?
i've tried using spawnVehicle but there there is no difference, for 2 seconds nearby csat ai etc still shoots at it causing it to usually blow up before the side really switched
The UAV ai might be added separately from the vehicle
You're passing the vehicle itself to joinSilent, which isn't exactly how it's supposed to work. Try passing crew _asset instead of [asset]
Just disable its simulation in editor
@thorn saffron Is the variable you're trying to pass _x in the forEach loop?
same effect
it has like 2 seconds where all nearby csat things shoot at it and then if its not dead by then the turret of the praetorian lowers a bit and then other csat units stop shooting at it
but even in those 2 seconds the side of the praetorian returns east
this is all on a dedicated server btw, on eden it works fine
You can try using createUnit to directly create an O_UAV_AI and move it into the vehicle, rather than using createVehicleCrew. There seems to be some conflicting information on whether this works though.
Alternatively, wait for 2.14 and try the new alt syntax of createVehicleCrew
@opal zephyr Yes, its the grenade classname. And it works, because I'm using to also get the name and icon for the action.
Or create the turret somewhere else and move it into its true position once the hostility period is over :U
ill just give this a go for testing purposes
alr, is there a release date set for this already?
When was the last time we knew the release date of an Arma update before it happened?
@opal zephyr Here's the code I use to add actions to my tripwire.
{
// get the grenade info
private _grenadeMagClass = _x;
private _displayName = getText(configFile >> "CfgMagazines" >> _x >> "displayNameShort");
private _icon = getText(configFile >> "CfgMagazines" >> _x >> "picture");
//create action for the grenade type
private _addGrenadeAction = [
"Attach Grenade",
format ["Attach %1",_displayName],
_icon,
taro_tripwire_fnc_setTripwire,
{
true
}, // add a check here to see if the player has this paricular grenade magazine class in his invenotry
{},
_grenadeMagClass
] call ace_interact_menu_fnc_createAction;
["taro_tripwire_place", 0, ["ACE_MainActions"], _addGrenadeAction] call ace_interact_menu_fnc_addActionToClass;
} forEach _grenades;
is there anyway or anything that will let you place a uniform? like full uniform and not folded?
@brisk lagoon Sadly not the uniforms have arms and such modelled in
Sadge ):
@thorn saffron I havnt used them before, but you could try using the action parameters mentioned on the ace wiki, it looks like they get passed into the called code
@opal zephyr Only into execution, not the condition. I'm already using that to pass the grenade classname into taro_tripwire_fnc_setTripwire function.
hmm
this sounds like it has a high chance of working since you just create the vehicle and never create anything nato related.
goes from civ to csat right away nrmly
thanks
just how parallel are scripts executed with spawn? seems almost like it's multithreading because even without sleep or anything of the sort one spawn'ed script gets its instructions run in the middle of another
what i mean is, it looks like it doesn't schedule the whole of A to be executed before B, but rather runs some instructions from A, then some from B etc
In this case you can use compile:
private _condition = compile format ["%1 in flatten getUnitLoadout player", _x];
Me dum, the action params are totally passed into the condition. I just set up the params wrong in the script that checked them.
Progress has been made; the attached objects are not updating consistently
I have not got a clue why though as I was under the impression it is local
is there any kind of semaphores for this async hell
like a mutex
i have no clue what that means
explain it to me like i have spent the last 5 months almost exclusively scripting in sqf
you know, an ability to lock one's thread access to some resource so that another one can't access it
e.g script A is doing something with object B and until it lets go of it, script C can't touch it and has to either wait or move on
No such mechanism exists natively. If you have control of both scripts you could use waitUntil and object namespace variables to make one.
is setVariable and getVariable atomics by default?
when it's being set, it can't be being get simulteneously?
you can get variable just fine from anywhere you can access the namespace
setVariable shouldn't take enough time for anything else to happen (on the same machine) while it's in progress.
Bear in mind that SQF is not the engine language, it's another layer on top of it. Everything we write in SQF is just instructions for functions in whatever C variant Arma uses, and that's the layer where stuff like atomics would be handled.
i mean if i'm pushing a huge array of data via setVariable in script A, and script B does getVariable at an arbitrary moment, will it wait until the whole array is there
I'm pretty sure the array is compiled by the game before setVariable internally receives it, and setVariable just stores a memory reference to the array. I don't think setVariable has a "partially done" state.
i get that sqf is just scripting on top of the engine, and the whole scheduler machine was written beneath, but if it allows to do async stuff it should provide some guarantees like "this thing could never ever happen, because the engine is locking access to the variable for script getting/setting the variable for you"
Generally most things you'd put in one line are atomic.
It'll only interrupt on semicolons and loops.
You can also use isNil { some code } to force that chunk to run without interruption.
Bear in mind that there's no actual multithreading, so you can guarantee that only one piece of SQF is running at once.
ok that helps
Some funny things exist(ed) with the scheduler though (no idea if this got fixed at some point): http://killzonekid.com/arma-scripting-tutorials-scheduler-and-namespace-switching/
async is usually funny yes
Yeah, it tends to make things more complicated initially at least
i almost had another major "oh shit here we go again" moment with my code
because
between this script adding to list and calling event i didn't really expect the other script to do anything
all commands are "atomic" themselves
the only exceptions are commands that execute code blocks (the whole block may or may not run "atomically")
but when you read a var with getVariable and set it with setVariable, it won't be atomic
is this the only way to make them run without interruptions?
no need for if-then
yes, isNil runs unscheduled
if the code itself was already unscheduled there wouldn't be any need for isNil
e.g. if you run that inside an event handler, it'll always be unscheduled
welcome to sqf ๐
it was unscheduled relative to the script it's in, which is scheduled relative to other scripts lol
cause they start with spawn
if you mean you first spawn something which calls that code, then it's scheduled
so, between these 2 instructions, if they are inside the IsNil block, would another script still be able to execute an instruction of its own?
even if the isNil block itself is originally in a piece of code that was started with spawn
isNil forces the block to run unscheduled
(ofc if you spawn something inside the block, it'll "detach" and run scheduled)
does that mean that instructions that precede/follow it no longer execute in the same order relative to it? A->IsNil->B could now become A->B->IsNil
if A and B are in the same script, no it won't
you can assume the whole isNil block is "one instruction"
okay
it should also break the 3ms rule, so in theory you could abuse it to get more than 3ms/frame of SQF.
occasionally tempted to try this :P
it is sometimes helpful ๐
e.g. when you want to run a script that collects data but you neither want it to freeze the game, nor take too long
call doesn't create an unscheduled context, it just means "run the called code as if it was written out here". If you do it in a scheduled context, it will still be scheduled.
basically every context is explained on that Scheduler wiki page. you can just read that
@granite sky @simple trout issue was fixed thanks to sebsterbl:
I needed to setvelocitymodelspace for the engine interpolation, I had been under the impression that engine handled it based off of position updates. Now only shuddering is due to ping and can't do anything about that, thanks for your guys' help last night too ๐
(so you may not need to rewrite your dive bombing stuff john)
Hello, I need help correcting a script (18 lines) if you want to help please DM me
for every object i create i start a scheduled script with spawn
and i rolled my own event system to make them communicate
If you do that, make sure that you're using compiled functions at least. "Raw" SQF with spawn is very expensive (having done that too ๐ )
would that be compatible with all arma games or just arma 3
well depends what those "spawns" do.
if you use a loop in them, it's bad
if you do something with them for a short time then it is better but still not perfect
Not sure which games support it but I've done it in Arma 2
it's sometimes a loop with a delay from a fraction to several seconds
bad
you should only spawn 1 code, which iterates over all objects in a loop
instead of spawning a loop for each object...
i've been considering that lately
spawn 1 per module and make the module go over its objects
spawning 1 code that iterates over all modules, and then iterates over their objects is better
If you're not using Arma 3, say so now, because there are some major differences/important commands that may not be available
i play all of them and trying to make a mod that could work for all
cause it's tempting lol
that sounds like a bad idea
i guess i could define aliases in a separate script that would handle the differences?
e.g if some function is not present in Arma 1, it's called by the same alias but actually calls something else
well if you "abstract away" how things work internally using functions, you could do that
but it's better to just stick with 1 game, and only bother with others once you're done with that
I'd say just stick with A3 
Yeah, I loved how Benny created "interfaces" like this in his edition of the Warfare mission:
init.sqf: sqf GroupChatMessage = Compile preprocessFile "Client\Functions\Client_GroupChatMessage.sqf"; ````Client_GroupChatMessage.sqf`: sqf
player groupChat _this
``` (The point is to use GroupChatMessage everywhere in the code, so if you want to add e.g. logging later, you can add it in the abstracted function instead of going through 100 calls of groupChat in code and adding it to those manually)
//Gets what group will be used to put the player in.
_units = [_profile,"units"] call ALIVE_fnc_hashGet;
_group = group (_units select 0);
//List units in the group as an array
_aiUnits = units _group;
//and count them
_aiunitscount = count _aiunits;
//Join the player group to the ai group
_groupUnits join _group; {_x setposATL formationPosition _x} foreach _groupUnits;
//script to make room so that there is room for players in their assigned transport
if (_aiunitscount > 8) then forEach _groupUnits do {
private _randomUnit = selectRandom _aiunits;
// Check if the unit still exists and is not in a vehicle before using deletedVehicle
if ((!isNull _randomUnit) && (incargo _randomUnit)) then {
deletedVehicle _randomUnit;
} else {
_randomUnit = selectRandom _aiunits;
// Check if the unit still exists and is in defined vehicle before using deletedVehicleCrew
if ((!isNull _unit) && (isincargo _unit)) then {
private _veh = vehicle _randomUnit;
_veh deletedVehicleCrew _unit }};``` I'm not good enough in SQF to see all the errors and sometimes unsure how to correct them..
```sqf
// your code here
hint "good!";
```
โ
// your code here
hint "good!";
plz
looks like chat GPT stuff ๐
No I wrote it. ChatGPT is always full of errors, i have tried. I put the // for context
foreach is misplaced
quite funny that properly noting your functions in this game is considered a mark of ai ๐
{ } foreach _groupUnits;
commenting is fine but not every line 
It also helps me when I come back to my code since I am a beginner
i cant say much about commenting code properly seeing as i tend to remove my comments after ive written the code for some bizarre reason
I think comments are best when combined with self-documenting code. The code (like variable names) respond to questions "what" and "how", and the comments answer to question "why"
{
if ({!(isPlayer _x)} && {!(_x getVariable [""shopcheck"",false])} && { ({side _x isEqualTo civilian} count (_x nearEntities [""CAManBase"",150])) > round(150*OT_spawnCivPercentage) } ) then {
private _unit = _x;
[_unit] call OT_fnc_cleanupUnit;
};
}forEach (units civilian);
1:49:52 Error position: <&& {!(_x getVariable ["shopcheck",false]>
1:49:52 Error &&: Type code, expected Bool
what gives
Remove { } from the conditions
Yeah that'll fix it but why is it erroring in the first place, why doesn't it qualify for lazy eval
{ } && { }```
You can have Code on the right for lazy evaluation, but not the left
How's that so? Why is it allowed on the right? o.O
lazy evaluation
(isPlayer _x) && {time > 20};```
the right code will only be evaluated if the left returns true
But this does work, is it so that the first condition must not be "lazy", the rest can be? This should work, right?
(true && {false} && {false})
reminds of c++
Depends on how the order of operations shakes out
I guess it's some Arma 3 thing (having coded almost only Arma 2 recently) or then I've read the documentation badly ๐
Since A2 1.62
BOOL && CODE
BOOL && BOOL
not CODE && CODE
I kinda see what you mean now. It's hard to read the code flow with all the comments
i guess it depends on what types the operator is defined for
Use syntax highlighting and it isn't an issue anymore ๐
I do but I find it hard anyway. It's distracting
(cond1) && {cond2} && {cond3}```
in theory this could work if `(cond1) && {cond2}` is resolved before `{cond2} && {cond3}` because then it works out as `bool && {cond3}`, but I can't remember if the order of operations works out that way
exactly. basically imo if you name your variables right, you only need to explain the idea to yourself in one place and not do comments on each line
Comments are personal preference, but it's a pretty common rule that comments should not explain what is being done but why it's being done
I'll do this next time. I'll write a small paragraph explaining the script then post code without comments.
I will always explain what is being done if it's some complex hellcode that's difficult to read naturally
especially for me haha
Can I put then { if
Isn't the goal to write readable code though (but yeah, it can be hard sometimes) ๐
yes
or just do:
if (... && {
}) then
instead of 2 ifs
I'm such a simple being that I need to write readable code to be able to process it... ๐
(true && {true}) && {true} Speaking of readability... 
if (isNil {GLOBAL_DEFINE}) then { systemChat "GLOBAL_DEFINE set"; GLOBAL_DEFINE = 1; };
ok. if hundreds of spawned scripts ran that code, would there be any chance at all that the "GLOBAL_DEFINE set" message would show up more than once?
the () wasn't needed
you could also write true && {true && {true}} which imo is more readable (especially if broken into lines and indented)
yes
but very unlikely
That's probably faster as well
and if i rewrote it as
isNil { if (isNil {GLOBAL_DEFINE}) then { systemChat "GLOBAL_DEFINE set"; GLOBAL_DEFINE = 1; }; };
!code
```sqf
// your code here
hint "good!";
```
โ
// your code here
hint "good!";
no
okay
but like I said the first one probably won't happen either
you might at most see 2 messages
if one code runs past the 3ms limit before reaching the var assignment
yeah that's the issue, i can't allow any chance for it being done more than once or else all hell will break lose
i've had enough of "sometimes it breaks mysteriously"
also instead of isNil {GLOBAL_DEFINE} you can write isNil "GLOBAL_DEFINE"
it's more readable (since you commonly use isNil for unschd, or if you actually want to compute if a code returns nil)
What if he ran the guaranteed unscheduled code (with the isNil thingy) to set an "already run" flag in global variable and check whether it exists/is true?
that's what i'm doing
And only proceed from there if the flag hasn't been set
i'm doing that to initialize my module framework (ONCE!) and start initializing my modules and objects that belong to those modules from there
I think I need to go to sleep ๐
Anyone able to give me a pointer as to why all the objects are drifting downwards with this? Think it's due to modelToWorldWorld but vectorModelToWorld ends up shoving it pretty high in the air ๐
https://sqfbin.com/dolakifocuboquyosumo
(i know the two if statements arent properly optimised im doing that later)
effectively what is happening is there's a drift of ~5ms downwards when using this with Land_Cargo10_white_F object
Aye, so I've got a question, how would I script it so that I can remove a turret off of a BMP-2 and replace it with a ZU-23-2, I don't know if it's important to say the exact names, but I'm using the ones from RHS if that effects anything.
not possible, requires model modification which you do not have permission for
Ah damn
I didn't actually read all of it but:
- using modelToWorldWorld _velocity is wrong
- using getPosASL is wrong
should it be modeltoworldvisualworld? just found that command
and getposasl i have to use for setvelocitytransformation, no?
speed = distance/time
speed * time = distance
velocityworldspace is just the distance it needs to travel in the next second
_nextPos = _pos vectorAdd (_x vectorModelToWorld (_velocity vectorMultiply _dt))
anyway what you wrote would work but it's just confusing
anyway the real problem is getPosASL as far as I see
unless you were using super simple object
also using diag_deltaTime is wrong too
it should be diag_deltaTime * accTime
i know its confusing im just trying to not change things this late until ive got it 100% working in mp
is there any way i can use a setvelocitytransformation with getposworld? 
oh
oh wait of course it literally returns in asl ๐คฆโโ๏ธ
in customcenter param?
well yes but you should also change the center in svt
yeah that's what they call it I guess...
ya, thx -- wasnt sure what that was for
will test later on when i can be bothered with tcadmin again but fairly confident this should work, thanks leopard ๐
5 month project finally coming to a close and it's just a bunch of multiplayer stuff left before optimisations
are you making dogfights in space
i see i'm not the only one who makes a game inside another game
what i'm making is like urban fantasy rpg game
been SQFing for 2 months
kinda hard to switch to from C#/C++
you can still use C++
huh, how
is that arma3 only
yes
capital ships system but more or less yes
an entire movement system within sqf ๐
yeah i'm doing everything within sqf too. i'm currently finishing up a system for immersively spawning units on the map. like, it first creates transport (plane or convoy or boats) and delivers/drops them off at their bases
Visual Studio Code has really useful plugins for SQF if you want to use it. I think this is the most up-to-date: https://marketplace.visualstudio.com/items?itemName=vlad333000.sqf - you can find other plugins too by opening the extension search in VS Code and typing SQF in the search box
Extension for Visual Studio Code - SQF Language (ArmA game series scripting language) support for VS Code
good to know
How cursed is this and is there any smarter way to do this?
// Check if result is already known
if (isNil {call compile format ["DYNCAS_playerTextureCache_%1", _playerTex]}) then {
// Publish result
call compile format ["DYNCAS_playerTextureCache_%1 = %2; publicVariable %1;", _playerTex, _playerTexAvg];
};
Maybe slightly less cursed:
missionNamespace getVariable format ["DYNCAS_playerTextureCache_%1", _playerText];
Is missionNamespace synced over multiplayer?
Not unless you publicVariable.
generally missionNamespace setVariable ["varName", 1] is identical to varName = 1
(the default namespace is missionNamespace)
// Check if result is already known
if (isNil {missionNamespace getVariable format ["DYNCAS_playerTextureCache_%1", _playerTex]}) then {
// Publish result
missionNamespace setVariable [format ["DYNCAS_playerTextureCache_%1", _playerTex], _playerTexAvg, true];
};
Yeah that's definitely a lot cleaner
Hi, is it possible to get the direction like a "getDir" but of the head instead of the character ?
There's eyeDirection
- getCameraViewDirection
MAZ_EH_suppression = player addEventHandler ["Suppressed", {
params ["_unit", "_distance", "_shooter", "_instigator", "_ammoObject", "_ammoClassName", "_ammoConfig"];
if !(MAZ_EP_suppressionEnabled) exitWith {};
[_distance] spawn {
params ["_distance"];
private _supressedValue = .55 * _distance;
if(isNil 'MAZ_PP_SuppressionEffect') then {
MAZ_PP_SuppressionEffect = ppEffectCreate ["ColorCorrections",1500];
MAZ_PP_BlurEffect = ppEffectCreate ["DynamicBlur", 500];
};
MAZ_PP_SuppressionEffect ppEffectEnable true;
MAZ_PP_BlurEffect ppEffectEnable true;
addCamShake [17 / _distance, 0.5, 7];
player setCustomAimCoef 2.5;
MAZ_PP_SuppressionEffect ppEffectAdjust [0,1,0,[0,0,0,0],[1,1,1,1],[0.33,0.33,0.33,0],[.66,.66,0,0,0,0,_supressedValue]];
MAZ_PP_BlurEffect ppEffectAdjust [1.2 / _distance];
MAZ_PP_SuppressionEffect ppEffectCommit 0;
MAZ_PP_BlurEffect ppEffectCommit 0;
sleep 1;
MAZ_PP_SuppressionEffect ppEffectAdjust [1,1,0,[0,0,0,0],[1,1,1,1],[0.33,0.33,0.33,0],[.66,.66,0,0,0,0,.75]];
MAZ_PP_BlurEffect ppEffectAdjust [0];
player setCustomAimCoef 1;
MAZ_PP_SuppressionEffect ppEffectCommit 4.5;
MAZ_PP_BlurEffect ppEffectCommit 0.7;
};
}];
I'm trying to add a modifier based on caliber or damage to my suppression script.
I have these 3 parameters to build off of.
"_ammoObject", "_ammoClassName", "_ammoConfig"];
i dont want to create a list of every ammo type tho, just sort by calibeir, or damamage. where would i even start with the above params
yeah but it return a vector, not a direction.
You can just do a math
what exactly ?
(eyeDirection player) params ["_x","_y"] ;
((_x atan2 _y) + 360) mod 360```
oh it's that simple ? Ok then i will try thank you ๐
is there any method of increasing player's fov? plan is to do so as their velocity increases ๐ค
(in vehicle)
I have an AI unit alone in his group (he is his own leader) and i have set 6 waypoint to make he walk in circles around a city.
Eventually i want to make he go in the middle of the city and then back to run in circles arround the city.
With the 6 waypoints already set and he walking arround the city, can i use this code to make he tap the certer of the city?sqf _unit doMove _centerOfTheCity Looking at the wiki i believe he will reach the center and stay there forever.
Does exitwith in a function returning an empty array not work properly?
In debug I can do,
_array = [];
if (count _array == 0) exitwith {_array};
Which returns
[]
but when I stick this in a fnc call.
private _fncOut = call test_fnc_EmptyArray;
_fncOut
The debug stays empty
no issue reported
@slow brook You probably failed to define the function.
call nil tends to fail silently.
Nope it's defined
I've just changed it to pass back [""] and it works?
but then the array count is 1
aye but I changed the if to _fncOut IsEqualTo [""]
shrugs
Yeah... just weird
exitWith works fine. It doesn't matter what you put in the return value.
Oh I use it all over the place. Just for whatever reason that return [] was being dumb
_fnc_EmptyArray = {
_array = [];
if (count _array == 0) exitwith {_array};
};
private _fncOut = call _fnc_EmptyArray;
_fncOut
returns []
NO!
Not OSS parsing!
??
Hey, I run an Arma 3 server that often has over 100 players on it and quite a lot of scripts running both server and client side.
At times players have become invisible to one another, if you can't see a player then their bullets do not hurt you, however any scripted attacks such as melee still affect you.
Only fix so far is to relog, can anybody point me in the direction of what may be causing this? Is it script related or due to desync? I have no scripts running that purposely make any player invisible
hacker?
Well at the end you are parsing OssSQF to SQF
its like blueprint system it will never be a best thing for performance
if an array is acquired with getVariable, is it copied or referenced
It should be copied
oh forgot about making it air tight
now should be better
cause it's possible a queue could be pushed to and popped from different scripts
This is often a result of desync. One common cause is players' positions becoming desynced when they're ragdolled, although that's not the only cause out there.
it doesn't allow me to return nil as default value for _item
(in case the queue is empty)
and i cant use null either because if the object was deleted after being added to the queue it'll be null but that doesnt mean the queue is empy
used a flag
Use deleteAt
And write inline private instead of private array
More like just use params
Yeah and use params for those params instead of select
that aint backwards compatible
Ref
Isn't resize A3 only still?
iirc most important array commands were only added with A3
i need to stick to backwards-compatible code at least in the framework/backend side of things and use the new stuff in the specific-to-the-game side
Well I recommend using newer stuff since they tend to be faster
You can still add backward compatible stuff using macros
#ifdef __ARMA3__
#else
#endif
is that possible in sqf
Yes
does #define work like a c++ #define and i can #define SOMETHING ANYTHING
It won't work exactly like c++ tho
Pff its a minimalistic overhead for easier coding
How do you return ownership to server after setOwner? ๐
i'd assume 2 is the standard clientID of the server 
not so much now that we have RemoteExecโฆ these were absolute game changers, I tell you
remoteexec on each frame? no thx ๐
having juddering with my capital ships turning, fairly sure i need the system to be client authoritative rather than server
and unfortunately this isnt something i can fix in setvelocitytransformation as there is no angular velocity for client interpolation afaik
nobody said such things!
ah, simulating driving. well, yes, ownership may be a good idea
and the server gives or takes ownership, as it should be
i dont want client ownership because that ends up with arma'ing 
though tbf my code isnt that awful
I am playing around the conversations system and I noticed that the kbTell for player does not follow the head movement, so in vehicles when you look around the sound will be played "in front", and outside if player is doing any idle animation the voice is also played from a static place. I thought about using playSound with it but I'm stuck with how do I mute the kbTell. I can't get rid of the ogg from speech[] because the conversation automatically skips to next kbtell.
just need to get a friend online to help test the netcode because ive no way of doing it myself
Arma 3 supports running multiple clients in LAN loopback mode, but I'm not sure whether it's enough because LAN naturally has almost non-existent latency and e.g. packet loss and jitter compared to most WAN connections
Yeah needs to be on dedi as looks fine in LAN ๐
regardless of ownership
it's usable as is so if i cannot make improvements it's not the biggest of deals, but it'd certainly be nice to have completely smooth stuff ๐
You can run a dedicated server and connect to it with multiple clients AFAIK (but yeah, it's still LAN so...)
Need to do the math yourself I guess
Yeah I'm just not doing it and relying on pilots of 1km long vehicles to not be shit
Hey all. I'm looking for a way to get ai spawned groups to stop and throw smoke when a helo is within X meters. Any ideas
How bad would it be to send functions to clients over the network? I have a mod that currently works serverside and I don't want to add clientside as a requirement, but I need to get a single function running on the clients
What does the function do
depends on a project size
https://github.com/rekterakathom/DynamicCamoSystem/blob/c393c4ebddd40331d2aef275214530c7bda8d75d/addons/core/functions/fnc_clientLoop.sqf
Here is the whole function, I am not (right now) worried about the performance impact on the clients, more so about the network impact of sending the function
The entire thing in text is ~2KB, so I presume it's much less if compiled and then sent? So if I compileScript it on the server and then broadcast the resulting code with publicVariable, would the network impact be in any way significant
have the server publicvariable it during init and I doubt it'll get noticed?
Using rough math it's ~200KB of total data for 100 clients and I doubt that most servers will have that many
if it is a one time, it's "okay"
still not ideal ofc compared to a local function
I would do local, but it's for an update to my mod with a decent amount of subscribers who expect it to be serverside and I'd like to retain that functionality. If I am using compileScript with .sqfc, do comments have an effect on the size?
Use local objects
needs turrets etc sadly
So! BIS_fnc_findSafePos is not safe!
When position cannot be found at all, default map center position is returned, which will be in format [x,y,0]
Sometimes this will return [x,y, 100]. Is the third parameter actually supposed to stick 0 or does it gather that from somewhere in config
my excerpt.
params["_player", "_ppos", "_mid"]
// _player is object
// _ppos is getpos _player
// _mid is owner _player
[3, format ["Restoring position for %1 at %2", name _player, _ppos], _scriptName] call spp_fnc_log;
private _safepos = ([_PPos,0,10,5,0] call BIS_fnc_findSafePos);
// _safepos set [2, 0]; // Tads fix set ground height.
[3, format["It's safer here: %1", _safepos], _scriptName] call spp_fnc_log;
[_player, _safepos] remoteexec ["setPosATL", _MID];
On ALTIS if you set somewhere Out of Bounds.
"325.477: [SPP] | DEBUG | spp_fnc_setplayerpos | Restoring position for 2Lt. Tad at [9877.16,3971.51,0.00160217]"
"325.785: [SPP] | DEBUG | spp_fnc_setplayerpos | It's safer here: [10801.9,10589.6,100,0]"
You can specify a default position to use if no safe position can be found
Sure, but if you don't use that param, the "Find safe Spot" function can throw you into the air
which means that third value isn't always 0
as the wiki states
does ctrlSetText call onEditChanged? I assume yes x3
Yes
I placed a gunner in a vehicle with this doTarget wp_tgt_1; in his init so he can aim at a given target (in this case a sphere helper). Instead of doing that he is just making 360s. any idea why? Do I have to use something different to make the gunner aim at certain point and stay like that until threatened or whatever?
If there is an Arsenal enabled ammo box near my AI squad mates, I can select the unit, hit 6 key for actions, and find Arsenal action to get unit to use the Arsenal. Is there a single scripting command where I can launch Arsenal for a particular unit immediately? The following does not work (it gives an unknown enum value error):
(units group player #1) action ["Arsenal", box2];
Where is the sphere helper? I've had that problem if helper is at same position as unit (he spins in circles). But I have definitely used this technique to get a unit to watch a position correctly if sphere placed correctly.
it is still there, just texture made transparent.
Try putting it out 100 meters, it might be targeting relative to vehicle instead of unit.
How can I show a value of the variable in the displayed text? _variable=10; cutText ["Your variable is: ","PLAIN"]; Thank you
format
okay I think I figured it out - unit does these spins if dynamic simulation is enabled on the vehicle the unit is crew of
format, or concatenate strings like this:
_variable=10; cutText ["Your cover has been blown!"+str _variable,"PLAIN"];
concatenate requires it to be a string. format will accept anything, I think
bruh- "Ok, I've fixed all the errors... lets try it out!"
The game: "Oh yea, there's 2 composeTexts." (composeText (composeText [xyz]))
it's stil not working, but for different reasons now weeee
Your syntax on the first bit is fucked due to precedence. But in general:
["Open", box2] call BIS_fnc_arsenal
The unit doesn't matter. The arsenal UI is always opened for the player, even if you triggered it with another unit's action.
Then how do you arm an AI unit with Arsenal?
You'd need to select into it first (selectPlayer). Or do some loadout swapping scam.
Thanks. That blows for my needs though. I currently use a hidden ammobox, and have an action where I look at ai squad mate and my action appears. The action teleports the box to the cursorobject unit, and does the following to open the ammobox for that particular unit. I can then arm the AI. But Arsenal is superior UI for arming the unit...
_unit action ["GEAR",missionNamespace getVariable "jboy_SogAmmoBox"];
The loadout swapping might not be too bad. The arsenal generates open/close events that you can hook with [missionNamespace, "arsenalOpened", { // your code here }] call BIS_fnc_addScriptedEventHandler
I'll take a look at that. Thanks alot.
in MP it is ๐
Fug it. I'm going to keep my hidden ammo box approach, plus spawn a box with arsenal enabled. If player wants to use arsenal, he'll just have to use action menu to move AI unit there. It's a damn shame we can't call AI actions directly though (i.e., bypass selecting unit, scrolling thru actions, etc.).
you can do this:
[missionNamespace, "arsenalOpened", {
BIS_fnc_arsenal_center = ai;
BIS_fnc_arsenal_target = ai;
}] call BIS_fnc_addScriptedEventHandler;
["open", true] call BIS_fnc_arsenal
Hah! Where there's a will, there's a way!
ah nvm don't do that ๐คฃ
Nooooooooooo!!!!