#arma3_scripting
1 messages Β· Page 699 of 1
this is not defined in called code, u need to pass this as parameter ie.
this call {_this playMove....; _this disableAI ...;} or simply remove call bracket.
it is defined, if called from initbox
is it passing properly? Since it is special variable, Im not sure of it
its a local variable
nothing special about it, apart it not having the usual _ prefix
try switchMove maybe 
well yeah, when someone says "it doesnt want to work" I for some reason instantly assume they receive an error π
Where do i save a custom .sqf file?
https://community.bistudio.com/wiki/Introduction_to_Arma_Scripting
Check out the Basics section π
ok so my coding isnt doing what i want it to prject an image on a tv but my coding isnt working and just showing the camera as half way in the ocean
my sqf file
/* create render surface */
tv setObjectTextureGlobal [0, "#(argb,512,512,1)r2t(uavrtt,1)"];
uav lockCameraTo [tgt, [0]];
/* create camera and stream to render surface */
cam = "camera" camCreate [0,0,0];
cam cameraEffect ["External", "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 NVG */
"uavrtt" setPiPEffect [0];
/* adjust cam orientation */
addMissionEventHandler ["Draw3D", {
_dir =
(uav selectionPosition "laserstart")
vectorFromTo
(uav selectionPosition "commanderview");
cam setVectorDirAndUp [
_dir,
_dir vectorCrossProduct [-(_dir select 1), _dir select 0, 0]
];
}];
Are event handlers added with addEventHandler fired on the machine on which the object it is attached to is local, or are they fired on the server?
or only on the machine on which the event handler was added?
Depends
If its not MPeventhandler
Then it is local
(afaik EH is local to the machine that created it)
to the machine that created the event handler? Or to the machine on with the object it's attached to is local?
The machine that created the EH
(However I havent tested having one machine create an Object, then attach a EH using another machine)
Good night.
Anyone know how to make an expression where all alive players must be in an area for a trigger to activate
this is what i currently have
{alive _x} count players == {_x inArea ThisTrigger && {alive _x}} count players;
allPlayers findIf {alive _x && !(_x inArea thisTrigger)} == -1
Thank you!!
need some help with GetPos and SetPos
player setPos (getPos TP1) +0,+0,+10]
Trying to TP a player into a tunnel that's floating above the ground off map, they're teleporting to an item inside the tunnel but on the ground not inside the tunnel, So i want to increase their Z position when they teleport
how would I add the Z offset to the GetPos i'm using? Adding +0,+0,+10] doesn't work.
player setPos (TP1 modelToWorld [0,0,0]);
works well if anyone finds this message later
(getPos TP1 vectorAdd [0,0,10]);```^this is how to do that @torpid quartz
params ["_player", "_data", "_var"];
_id = owner _player;
_uid = getPlayerUID _player;
compile _var = ["read", [_uid, _data, nil]] call inidbi;
_id publicVariableClient _var;
i wanna make a function that receive some values and a string then store the result in a new variable whose name is the string received by params
will this work?
Test it Β―_(γ)_/Β―
If I'm trying to trigger a script or make a vehicle delete itself upon reaching a waypoint, should I be using setWaypointScript or setWaypointStatements?
Is the waypoint placed in the Editor?
It's spawned by the script
setWaypointStatements
Hello guys I am making a WW2 mission where a lot of planes go and people static line drop out like operation market garden. Thing is I can do it the reinforcement module but it will take time is there a way to do it using scripts. Than you in advance if I don't reply please dm.
I have knowledge of scripting just to be clear
Is there a command like player addMagazine ["30Rnd_556x45_STANAG", 15];
but usable for adding magazines with a specific amount of bullets to containers/groundholders ? π€
yes
addMagazineAmmoCargo
Uff thank you, i must be blind. I thought i checked all these commands π π
Does anyone have a good method of ensuring task state, creation etc is synchronized between clients and server I would much appreciate if you'd let me know. I have found so far that some people got it working but don't know how they did really.
sure, have this π
https://community.bistudio.com/wiki/Arma_3:_Task_Framework
sorry, I was not exactly redirecting you, I meant it as "scripting shalt save thee" π
Anyone here knowledgeable in CBA and ACE3 scripting?
Better to put your exact question beforehand
again
ACE has a Slack, available in #channel_invites_list π (if the question is still related to your earlier question)
class ACE_Medical_Treatment_Actions
{
class Morphine;
class compat_Pervitin: Morphine
{
displayName = "Pop a Pervitin Tablet";
displayNameProgress = "Time to have the time of your life!";
allowedSelections[] = {"Head"};
items[] = {"compat_Pervitin"};
treatmentTime = 4;
callbackSuccess = QUOTE("I work you retard!" remoteExec ["hint"]);
animationPatient = "";
animationPatientUnconscious = "AinjPpneMstpSnonWrflDnon_rolltoback";
animationPatientUnconsciousExcludeOn[] = {"ainjppnemstpsnonwrfldnon"};
};
};
Main thing to pay attention to is the callbackSuccess.
Now me any my friend at first tried to create a function and then put
QUOTE(call FUNC(pervitinEffect))
(The function is called pervitinEffect)
and within the function I have simply written:
"I work you retard!" remoteExec ["hint"]
(To test if it's able to call it)
but then I get an error about a "=" somewhere
and that's basically where me and him are at.
I'll give it a shot.
it's not e.g TAG_fnc_pervitinEffect?
class CfgFunctions
{
class pervitin
{
class myCategory
{
class pervitinEffect {file = "ThePharmacy\pervitinEffect.sqf";};
};
};
};
This is what I have rn.
Do I have to #include the .sqf in the config.cpp as well?
want to find nearest object from array, any ideas and suggestions welcome
TAG_fnc_findNearestObject = {
params ["_unit", ["_objects", []]];
private _object = objNull;
private _distance = 99999999999999999;
{
if ( _x distance2D _unit < _distance ) then
{
_distance = _x distance2D _unit;
_object = _x;
};
}
forEach _objects;
_object
};
private _mapped = _objects apply {[_x distance2D _unit, _x]};
_mapped sort true;
_mapped select 0 select 1
Trying to setup a way to re-spawn with the same load out as you die with specifically for MP missions though can't get it working (I've been away from scripting for some time now, out of touch) Here's what I've got so far: (Also please tag me if you've got an answer, I do try to read through the messages but after a couple days there's so many to filter through)
**onPlayerKilled.sqf:**
savedLoadout = getUnitLoadout[player, true];
**onPlayerREspawn.sqf:**
player setUnitLoadout[savedLoadout, true];
BIS_fnc_sortBy too (but @copper raven's answer seems to be sharp π as usual)
so your function's name is pervitin_fnc_pervitinEffect
Tried a few others I found though didn't work, ended up just deciding to make my own version but I'll have a look, thanks.
This definitely works.
Works like a charm. Many thanks revo
it has been made for a very specific reasonβ¦ basically, many unspecific requests π
a lifesaver indeed π
I see.
So incase we use it, would I need to write callbackSuccess = "call pervitin_fnc_pervitinEffect"
I am gonna change it, just wonderin.
yep
Ah, oki.
BIS_fnc_stalk
https://community.bistudio.com/wiki/BIS_fnc_stalk
are they "close enough" already?
other than that, the syntax seems right
try setting a bigger refresh value
e.g 20 (10 can be a bit short for long distance AI calculation)
I just looked at the function and it is really bad. just do your own thing
it doesn't do anything special anyway
running into most buildings will stop them from chasing
they just can't. buildings have special path LODs, which are just lines. unless the position you give them falls on those lines, no path can be generated to that building
also waypoints are inaccurate by nature
_stalkerGroup addWaypoint [(leader _stalkedGroup),_radius];
the default radius is zero, so the waypoint is no accurate
buildingPos is the only way
also only 1 AI can occupy a buildingPos
also not possible to make them go there via waypoints afaik (maybe they can if you set the radius to -1)
@little raptor Are you the same guy who is working on Super AI?
yes. 
Cool, I just watched the youtube video for it. Next time you make one, turn the music down so I can hear what you have to say. π
Any release date yet?
Β―_(γ)_/Β―
Awesome.
Are the code . . . parameters of BIS_fnc_holdActionAdd global or local?
local
Is there any way for a trigger to get activated once the Virtual Arsenal has been closed?
why are you so obsessed with triggers?!
xd
I need a task to be set to completed after the player closes the VA.
anyway, what you want are Event Scripts
you can do all that with scripting
no need for triggers
wait
not Event scripts
Scripted Event Handlers 
Right
Which one tho
Ive read somewhere that containerclosed or whatever its called isnt working with the VA
"arsenalClosed"
those are event handlers
not Scripted Event Handlers
Oh
@meager epoch
[missionNamespace, "arsenalClosed", {
["myTask", "SUCCEEDED"] call BIS_fnc_taskSetState; //complete the task
}] call BIS_fnc_addScriptedEventHandler
thank :)
@little raptor do i need to write smth instead of the missionNamespace or just leave it like that?
like that
Ok thanks
just change "myTask"
Yeye
hey there, I have some strange problems while trying to use filepatching :
my sources have a systemchat "hey"; when starting a game
I have an unpacked file properly named and placed which replace with systemchat "yo";
Let's say I start the game, then go in editor :
- function viewer says "yo"
- systemchat says "yo"
All work well.
Then I go back to my unpacked file and change it from "yo" to "bonk". Back to the game (no restart) :
- function viewer says "bonk"
- systemchat says "yo"
What is happening here ?
Then I restart mission, or go back to editor then reload mission :
- function viewer says "bonk"
- systemchat still says "yo"
@winter rose Are you knowledgeable in Post Process stuff?
Online doc says :
Ability to modify unpacked data during runtime. Readable; always possible
to modify a file's content (except configs); modifications available live
or via mission restart.
that does not seems to work properly π€
woops, sorry for crosstopics
I didn't pay attention while typing my stuff, my bad
What is your definition of "I have an unpacked file properly named and placed"
{ROOT}\fr\gsri\skydiving\functions\newton\fn_skydivingInit.sqf when {ROOT} is my game's main directory
and fr\gsri\skydiving is my addon prefix
if you do loadFile "fr\gsri\skydiving\functions\newton\fn_skydivingInit.sqf" ingame, do you see the contents of your new file?
did you enable allow functions recompile in CfgFunctions?
I assume you're using CfgFunctions?
I do
I saw there is some fiddling to do when using CBA but I'm not
did you enable allow functions recompile in CfgFunctions?
I can't find anything about that in doc
I only saw something about allowFunctionsRecompile = 1; in description.ext
doesn't this only apply to description.ext's CfgFunctions ?
no
lemme try that
I think I tried at some point
but not sure of what I did so safe to say I didn't
As a security measure, functions are by default protected against rewriting during the mission.
doesn't this mean that restarting the mission should recompile even without having the allowFunctionsRecompile flag ?
erhm, game crashes with access violation code
oof
if you want my advice just don't use filePatching
there are better ways to do what you want
make FT ticket with the crashdump (.mdmp file) or send me via DM
steps :
- have the unpacked file to
systemchat "value A"; - start game, load mission with allowFunctionsRecompile=1 in editor
- preview mission, displays "Value A"
- change unpacked file to
systemchat "Value B"; - open function viewer, can see Value B, click on "recompile selected", nothing happens but game is responding.
- close function viewer, restart mission ==> game crash
Ticket/Crashdump please, otherwise can't fix bug
better ways to avoid closing game/rebuild/relaunch game each time I want to try something ?
for now I develop stuff in a dev mission, which allow for some freedom
Never had issues with filePatching, I always use it
but I then need to sync sources with the addon folder for git and build pipeline
filepatching would be much better
if it's just scripts then yeah
I'm trying to run the command player selectWeapon primaryweapon player;
but instead of running it on the player I'm running it on a script on a different player so it'll look like _target selectWeapon primaryweapon _target;
It doesn't work if I do it like that and I think I have to use remoteExec but I'm not sure how. How do I do this?
as the wiki says the command requires Local Argument
so you need to remoteExec it on _target's PC
see the pinned messages for remoteExec examples
Is there a way to reset the script error dialog box (the black box) once it's been activated? it seems on my waituntil error it just never goes away...
I'm 'in mission'
it never goes away because waitUntil keeps on executing its code
so to prevent the box from permanently staying there, you have to fix the script error
Oh and restart the mission, there's no way to trigger the _handle by rerunning the code to get it to stop?
_handle = [] call PIZZA_fnc_revealToLocalUnits;
waitUntil { sleep 1; scriptDone _handle };
This is what I'm using. I copied it from another script that works but it seems like 1 out of 5-10 uses causes this error...
call doesn't give a handle
oh...
and you don't need waitUntil anyway
does PIZZA_fnc_revealToLocalUnits return a script handle even?
well it works most of the time π
i mean it depends on what that function does π
When running, it calls a function like BIS_fnc_typetext which spawns itself...
you might not even need to waitUntil like Leopard said
but I want to wait until the typetext is absolutely done before letting the script continue...
I think you're misunderstanding the concept of scheduled environment
call from scheduled environment is scheduled
sure but what if inside the call is ] spawn FRED_fnc_typeText; ?
Um, because calling it gave a HUGE number of errors π
and no need to wait for it
async text typing, like you see in Arma campaigns
You want to slowly write text letter by letter. But also wait for it to be done, thus scheduled
if the environment is scheduled, it'll also be scheduled
Β―_(γ)_/Β―
why spawn?
im some very rare case when you don't want to block the spawned script π (just what came to my head)
waitUntil { sleep 1;
the environment is (or at least should be) already scheduled
Seriously, spawning it instead of calling it caused a huge number of errors so like "don't do that"
maybe your environment is not even scheduled
which means you shouldn't be able to use sleep/waitUntil either
I'm pretty sure you're just doing it wrong
there's just no need for spawn/waitUntil here
post your full script and I'll tell you what's wrong
any part that's relevant
hmm, let me upload em somewhere
you can just dm them to me
Turns out I didn't have to do remote exec I was putting it in the wrong place and got it to work, however that brings me to my next issue.
Right now I'm using ```sqf
player selectweapon currentweapon player;
And that's not quite what I want. I want to select *no* weapon but there doesn't seem to be a built in command for that.
I've tried ```sqf
player selectweapon "";
but that doesn't work unfortunately. What I'm trying to do is run this command for a revive script so that if a player has a launcher out it'll switch weapons for them in the downed state so when they get revived it doesn't force them to stand up and pull out their launcher like it does now (the vanilla revive has the same issue might make a ticket about it). The currentweapon method does work, but not for the edge case of the player not having a primary weapon. I want it to simply bring out no weapon instead so it'll work even if the player only has a launcher. It's not super common, but if I can fix it I'd like to.
use action switch weapon maybe
I didn't have to do remote exec
according to the wiki you have to π€·
but anyway, as sharp said there's an action which you can use to switch to no weapon
I think it's because the new place I put it in was a different script file with the proper locality which I'm not sure if is the right way to describe. I still struggle with that stuff.
Which action? I found https://community.bistudio.com/wiki/Arma_3:_Actions#SwitchWeapon but there doesn't seem to be an option for no weapon.
iirc it goes:
_unit action ["SwitchWeapon", _unit, _unit, 100];
test it on player first
if it works then use it
I think you may need to remoteExec this
It does seem to work in local hosted multiplayer so hopefully it work on a dedicated server too. Thanks for the help.
local hosted multiplayer and you're the server?
if so, no guarantee. self-hosted MP = SP
think about how player will resolve
on local hosted mp calling player on the server will resolve to you
on a dedi player resolves to the server, not you
the same is true for script locality
found this BIS_fnc_nearestPosition
Yeah works on a dedicated server just fine. I'm guessing the script file is in the right context where I don't have to use remote exec for these particular commands. In this case _unit seems to be defined as the remote player so it's not necessary, at least to my understanding.
No
_unit is not defined unless you defined it
Yeah it looks like it was. Sorry if I'm confusing some of the terminology I'm just editing and testing to see what works.
is there a way to "shuffle" an array?
BIS_fnc_arrayShuffle iirc
can I unpack .ebo files with pbo manager?
no
which tool will allow it? need to dig deep into the tacops addons files to reverse engineer an idea
None
dang. I just want access to
A3\Modules_F_Tacops\Ambient\CivilianPresence\FSM\behavior.fsm"
just wondering how they ended up creating waypoints for agent civilians since an agent doesn't have a group/leader
Is it possible to check if a player can have an array of items added to their inventory. Since canAdd is only limited to a single item?
There ya go
canAdd can do multiples of one item, but not really
thanks brother. you're the best
You can accumulate the "mass" of all your items, and then find some object and count that accumulates to the same mass and pass that to canAdd
So read a units inventory and find the config mass? Then just use canAdd with another item that has something like 1 mass?
I'll give it a go, thanks.
ok, so they use setDestination for agent units. good to know
They use setDestination command:
https://community.bistudio.com/wiki/setDestination
That's what I just ripped out of my code
:
_hO setDestination [_destPos, "FORMATION PLANNED" ,true]; // "FORMATION PLANNED" seems to be give good results.
I don't recall the motivation for FORMATION PLANNED though 
oh I am a bit late
But do you know how to stop them???
nah feed me more info! lol
_hO setDestination [ getPos _hO,"LEADER DIRECT",true]; // Doesn't want to stop otherwise sometimes
doStop _hO;

well _hO is the agent of course
can I stack setDestinations or do I need to stop them in between?
while {alive _unit} do {
private _newPos = _area call BIS_fnc_randomPosTrigger;
_unit setDestination [_newPos, "LEADER PLANNED", true];
waitUntil {sleep 3; _unit distance _newPos < 10};
};
I don't remember that I had to stop them before giving a next destination, so I think that it should be fine
you can do a forEach loop inside another forEach loop, right?
Yes
If you wanted to use the outer _x inside the inner forEach, define outer _x as a variable
Separate as what context?
The _x will be overwritten inside, so you cannot access the outer one via _x
Is there a forceAdd option/equivalent for anything besides Uniforms? ie: helmets/vests ?
Just addHeadgear, addVest
So if I want a blufor unit to have a specific helmet/vest from opfor would I use setUnitLoadout instead?
oh hey on this note
is there an add-on that disables those restrictions
I don't actually know how it works internally
Uniform restrictions?
like how opfor can't wear blufor uniforms
It's defined in config
[true] call ace_spectator_fnc_setSpectator executing this in the init section of one of my kurator slots forced all sofar connected player clients to move into spectator upon player being initialized at spawn. Is that behaviour intended, am I misusing this the command?
0: Spectator state of local client <BOOL> (default: true) for what I see in the framework docs the argument is local to the slot from whichs initfield the fnc is executed.
the reason this happens is that the init slots in the editor are fired on EVERY machine and additionally when someone connects. Do you see the issue?
Well that does explain a lot
you can add a:
if (local this && isPlayer this) then {
[true] call ACE_spectator_fnc_setSpectator;
};
which will make it only fire where that unit is local
Thank you very much my dude, that just explained a bunch of other issues I had in the past as well.
everyone figures it out eventually. its typically when someone spawns 5000 of something when players join and rejoin causing crashes haha
Is there a command to check if an object or unit is synced to a module from the eden editor?
Thank you
I'm trying to get a script to repeat a section until an object is touching the ground. So far I have this as my test and I know I've done something wrong, I'm just not sure what. (_object is the object's variable name):
OnGround = false;
while {_OnGround = false} do {
hint format ["Not on ground."];
sleep 30;
};
if (isTouchingGround _Object) then {_OnGround = true; hint format ["On ground."];};
you aren't returning anything to the while condition, and just permanently assigning false to some variable, = is assignment, == is comparison, but even then comparing a boolean to boolean is non sense
but then also the rest of your code is wrong, if errors are fixed, that while loop will just loop forever
Ohh okay I understand
If I'm understanding correctly - presuming I have _Object set to the object's variable name, something like this would make more sense then right?
while {(isTouchingGround _Object) == false} do {*Stuff goes here*};
Or am I completely fubar
Success! @copper raven thank you β€οΈ
don't compare a boolean to boolean
true == true == true == true == true, is same as just true, and true == false is just !true https://community.bistudio.com/wiki/!_a
Oh okay yeah I see what you mean now
Is there any way to spawn the static guns with createvehicle without them getting destroyed or tipping over ?
I tried everything, even spawning it a bit above the surface and they still fall over or get destroyed 
Then I think it is a static-side issue, aka Mod issue
iam testing with vanilla static guns and mod guns, both same behaviour
What exactly is the situation then?
I assemble them with the normal function, send a command to server then getposATL, delete the "old gun" and spawn it again at [0,0,1] and then setposATL to the final position
Normal function?
vanilla assemble function
I put one of the backpacks on the ground, take the other one, aim on the one on the ground and use the action menu to assemble it
Ah that feature?
_OldStaticGunObject = objectfromNetID _StaticGunNetID;
_OldGunType = typeOf _OldStaticGunObject;
_OldGunPos = [getposATL _OldStaticGunObject select 0, getposATL _OldStaticGunObject select 1,(getposATL _OldStaticGunObject select 2) + 0.25];
_OldGunDir = getdir _OldStaticGunObject;
deleteVehicle _OldStaticGunObject;
_StaticGunObject = createVehicle [_OldGunType, [0,0,1], [], 0, "CAN_COLLIDE"];
_StaticGunObject setdir _OldGunDir;
_StaticGunObject setPosATL _OldGunPos;
I've been doing it forever and there's nothing wrong with them
Even on a flat surface it doesn't work 95 % of the time and it either breaks or falls over 
use setVehiclePosition instead of setPosXXX
weirdly enough this seems to work
_OldGunPos = getposATL _OldStaticGunObject;
_StaticGunObject setVehiclePosition [_OldGunPos, [], 0, "CAN_COLLIDE"];
If you feed it with a position array it doesn't 
nvm, just a few times lucky.....
it is your own fault
you're spawning it at [0,0,1]
that could be water
wrap it in isNil
We spawn 300 + vehicles (every server restart) that way and it never caused problems ^^
is the environment unscheduled?
the way I see it from that gif, the vehicle is already destroyed
it has nothing to do with the setPos stuff
also, not all vehicles are "water resistant"
UAVs and Turrets get destroyed immediately upon contact with water
Gonna try this then
_OldGunPos = getposATL _OldStaticGunObject;
_StaticGunObject = createVehicle [_OldGunType, [0,0,300], [], 0, "CAN_COLLIDE"];
_StaticGunObject setdir _OldGunDir;
_StaticGunObject setVehiclePosition [_OldGunPos, [], 0, "CAN_COLLIDE"];
wrap it in isnil
isNil {
_StaticGunObject = createVehicle [_OldGunType, [0,0,1], [], 0, "CAN_COLLIDE"];
_StaticGunObject setdir _OldGunDir;
_StaticGunObject setPosATL _OldGunPos;
};
no difference, breaks 95 % of my attempts
also, why do you use setVehiclePosition with "CAN_COLLIDE"?
that just means it does nothing
use "NONE"
its like that in the example in the biki (https://community.bistudio.com/wiki/setVehiclePosition)
Thanks for the help, i will try some more. Might work now this way (It did 10 times now, even on buildings etc)
_OldGunPos = [getposATL _OldStaticGunObject select 0, getposATL _OldStaticGunObject select 1,(getposATL _OldStaticGunObject select 2) + 0.25];
deleteVehicle _OldStaticGunObject;
isNil {
_StaticGunObject = createVehicle [_OldGunType, [0,0,500], [], 0, "NONE"];
_StaticGunObject setdir _OldGunDir;
_StaticGunObject setPosATL _OldGunPos;
};
If I'm using createVehicle to spawn a smoke grenade, is there any way to apply timeToLive to make it last longer?
Maybe making a separate variable/class for the smoke?
@elder sail Since timeToLive is a config option, you would have to essentially make a mod to do so.
Alternatively, you could use a loop to respawn the grenade every 60 or 55 seconds.
I currently have it on a loop doing just that - I was hoping I was doing it the hard way haha. Thank you for the explanation though, greatly appreciated!
np, short of making a mod, I think a loop is the best solution
_OldGunPos = [getposATL _OldStaticGunObject select 0, getposATL _OldStaticGunObject select 1,(getposATL _OldStaticGunObject select 2) + 0.25]; use https://community.bistudio.com/wiki/vectorAdd
Thanks for the help yesterday. I think everything is working smooth now...no script errors from my stuff anyway...
pls help, need respawn AI tripulate vehicles ,but idk how,only respawn empty vehicles heeeeeeeeeeelp π« π« π« π«
Managed to solve it differently, with the pro of avoiding all possible other problems.
I just attach the HMG to the player after creation and setPos. π
https://www.youtube.com/watch?v=W0enLDc20xE
english please?
):
or is there another solution I'm not thinking of?
what are you referencing?
I forgot to delete the second part of that message. The solution to my question was staring me right in the face so I deleted the post.
my bad
Trying the very simple below spawn & lambs rush scripts, I get the following error, has worked before but a bit unsure what I'm missing. Anyone have any quick suggestions what I need to change.
"Local Variable in Global Space"
`_grp1 = [getMarkerPos "spawn1", east, ["UK3CB_CHD_W_O_SL", "UK3CB_CHD_W_O_TL","UK3CB_CHD_W_O_MK","UK3CB_CHD_W_O_LAT","UK3CB_CHD_W_O_RIF_1","UK3CB_CHD_W_O_AT"],0] call BIS_fnc_spawnGroup;
[_grp1, 1000, nil, nil, getmarkerPos "rush1"] spawn lambs_wp_fnc_taskRush;`
you put this in a init box in the editor?
if so, local variable in global space is an old bug
sorry yes, slot in trigger bit on activation.
spawn marker & target marker
Only other bit is this so Zeus doesnt trigger triggers this && (thisList findIf { isPlayer _x } != -1)
that error won't go away. its a bug. take the script external from the trigger
ah fine, seems like an old bug but has worked before
annoying
Weird its only the rush piece that cause the error, spawning is fine.
I have a script with what I think is a global variable with an array full of classnames that looks like this.
classlist = [class1,class2,class3,etc]
What I'd like to do is add more arrays to that class list so it'd look something like this classlist = [ [array1] [array2] [array3] ]
Then I want to script it so it picks one of the arrays and only use classes from that array. So something like a switch case, but I'm not sure how to apply a switch case in this context.
I was overthinking it, got it to work with a simple switch floor random command.
Wouldn't selectRandom will do?
doesn't that only search within an array not between arrays?
What your array look like?
It's 3 separate arrays technically, but my current method looks like this
switch floor random 3 do {
case 0: {
a3e_arr_Escape_InfantryTypes = [
//Rifleman
"CUP_B_BAF_Soldier_Rifleman_DPM"];
};
case 1: {
a3e_arr_Escape_InfantryTypes = [
"CUP_B_BAF_Soldier_AA_DPM"];
};
case 2: {
a3e_arr_Escape_InfantryTypes = [
"CUP_B_BAF_Sniper_AS50_TWS_DPM"];
};
};
works well enough
Why you put a string into an array?
it's an array full of classnames, in this case infantry units. There will be a lot more but it's just a few to demonstrate.
So those a3e_ things had a LOT of classes not only one?
yeah each one has dozens and sometimes hundreds
basically trying to select between n different sets in this case 3
Well got the situation. Still this can be simplified by selectRandom like a3e_something = selectRandom [[classesA],[classesB],[classesC]]
that's what i mean though would select random only pick classes from one array or would it pick classes from all 3. I haven't used that command and the wiki's description and examples aren't clear for my use case.
One array. Even if the picked element is an array, it will return the array not a random element of it
Yeah looks like the example on the old "BIS_fnc_selectRandom" page shows that too. That is a bit neater, I think I might have an idea to expand my current switch case so I'll keep it like that for now but the simpler way is good too.
BIS_fnc_selectRandom is the same (exists only for backward compat) thing
Yeah, more meant that the example on the page showed that it'll pick one of the arrays and not the elements themselves.
You mean that, gotcha. I probably add an example there
selectRandom selectRandom [["Hello", "there"], ["General", "Kenobi"]]
```this? @torpid pewter
Hey i am currently working on an Loading-screen and ran into to problem that you cannot open 2 Dialogs and keep one as background.
Is there any work around for this?
I would need the loading-screen to be opened and an new dialog (lets say the spawn screen) to show up above it.
I think the only way is to merge them and to ctrlshow false the ones i dont wanna see right?
you could simply have a ControlBackground for the background image
if you really really really need two different dialogs, I believe createDialog does it well (but don't ask me how all this works though)
Q: is BIS_fnc_bitflagsCheck analog to saying x & y in a C/C++? i.e. does not matter which side, left or right, the operands occupy?
for instance, as it is written in the docs, I would expect flagset to be a super set of the flag, however, both of these return true:
[2+4+8,2] call BIS_fnc_bitflagsCheck; // true
// ^^^^^ flagset
[2,2+4+8] call BIS_fnc_bitflagsCheck; // true
// ^^^^^ flagset
Now, if flag is asking for a bit that is not in the flagset, that much does return false, which is otherwise expected.
https://community.bistudio.com/wiki/BIS_fnc_bitflagsCheck#Syntax
https://community.bistudio.com/wiki/BIS_fnc_bitflagsCheck
To check which flags are present in given flagset use https://community.bistudio.com/wiki/BIS_fnc_bitflagsToArray
was not my question, to be clear, but I appreciate the effort. I really just need the check as it were, clarifying along those lines.
ah mb then; then test and see, and let us know in #community_wiki so we can amend the page for clarity and future users!
I'm not sure that clarifies the question.
testing would (and a tiger as well)
yes
also, since it's a function, you can just open it and see for yourself:
it simply does: flags & flagset > 0
ah okay, that's brilliant, thanks!
wow, analyzing BIS_fnc_bitwiseAND, that's certainly taking the long way round the & operator isn't it. wow...
it seems ok
but I would personally use an array algorithm
_fnc_flags = {
_max = floor (log(_this)/log 2);
_flags = [];
for "_i" from _max to 0 step -1 do {
if (_this == 0) exitWith {};
if (_this >= 2^_i) then {
_flags pushBack _i;
_this = _this - 2^_i;
};
};
_flags;
};
_f1 = _num1 call _fnc_flags;
_f2 = _num2 call _fnc_flags;
count _f1 != count (_f1 - _f2)
Edit: looks like this is 25% slower (because it has 2 loops) 
Edit 2: no it's not! π
tend to agree. I was curious so I cooked this comparison up:
_a = 1+2;
_b = 2+4+8;
_t0 = diag_ticktime;
_abits = _a call bis_fnc_bitflagsToArray;
_bbits = _b call bis_fnc_bitflagsToArray;
_abarrint = !(_abits arrayintersect _bbits isequalto []);
_t1 = diag_ticktime - _t0;
_t0 = diag_ticktime;
_aband = ([_a, _b] call bis_fnc_bitwiseAND) > 0;
_t2 = diag_ticktime - _t0;
[_t1, _t2, _abarrint, _aband]
Result: [0,0.000976563,true,true], however, on the average, without a high perf measurement, not sure there is an appreciable diff.
that's the wrong way to measure code performance
over 1000 attempts each:
_count = 1000;
_a = 1+2;
_b = 2+4+8;
_t0 = diag_ticktime;
for '_i' from 0 to (_count - 1) do {
_abits = _a call bis_fnc_bitflagsToArray;
_bbits = _b call bis_fnc_bitflagsToArray;
_abarrint = !(_abits arrayintersect _bbits isequalto []);
};
_t1 = (diag_ticktime - _t0) / _count;
_t0 = diag_ticktime;
for '_j' from 0 to (_count - 1) do {
_aband = ([_a, _b] call bis_fnc_bitwiseAND) > 0;
};
_t2 = (diag_ticktime - _t0) / _count;
[_t1, _t2]
Result: [0.000148926,2.00195e-005], bis_fnc_bitwiseAND is performing better by a factor of 10x.
wat?!
just use diag_codePerformance
the debug console has an integrated code performance button too
Edit 2: oof, I had an extra +1 there. removed it and it's now just as fast as the BIS function 
it's even faster if the number of flags is too many (e.g. : [255, 255] call BIS_fnc_bitflagsCheck)
So I'm attempting to make something that takes anything Zeus spawns and sets the owner to the HC... but I think I might be slightly stupid
player addEventHander ["CuratorObjectPlaced", { call KPLIB_fnc_whateverthefuckwewanttocallthefunction]};
whateverthefuckthefunctioniscalled
private _HCs = entities "HeadlessClient_F";
if (_HCs isEqualTo []) exitWith {[]};
private _HC = owner (_HCs select 0);
curatorEditableObjects apply {
_x setGroupOwner _HC;
};
Not sure what this is telling me.
_count = 10;
_a = 1+2;
_b = 2+4+8;
_t1 = diag_codePerformance [{
_abits = _a call bis_fnc_bitflagsToArray;
_bbits = _b call bis_fnc_bitflagsToArray;
!(_abits arrayintersect _bbits isequalto []);
}, [], _count];
_t2 = diag_codePerformance [{
([_a, _b] call bis_fnc_bitwiseAND) > 0;
}, [], _count];
[_t1, _t2]
Result: [[0,1],[0,1]], seems a bit hamstrung by the documented caveats
it's telling you a and b are not defined. also the number of cycles is too small
at least 10000 is needed
I get the same result, which to me seems consistent with the MP security reasons caveats.
that too. but still _a and _b are not defined
_a and _b are fine. 'scope' defines them in this instance. same as saying.
_a = ...;
[] call _callback; // can see _a
for giggles, though, I used 1+2 and 2+4+8 literals. same result.
no
it's not the same
it's not a call
it is invoking code, which is the callback.
but like I said, I replaced with literals for giggles. same result.
it's the same as
_a = bla;
_b = blabla;
_s addEventHandler ["blabla", {
_a, _b
//more bla bla
}];
no, sir, no it's not. an event handler is deferred. obviously the scope will have vanished by that point.

not the case with an immediate invocation using diag_codePerformance.
it has nothing to do with being "deferred". it just doesn't execute here, like an event handler. that's what I meant
if you want proof, just go ahead and test this:
_a = 1;
diag_codePerformance[{_a = _a + 1}];
_a
I am using the variable scope trick with my LINQ functions, so I know it works as I described. this is the secret sauce for _x and _foreachindex, for instance. for example:
// LINQ_fnc_aggregate
private _onAggregateSum = { _g + _x; };
params [
["_start", 0]
, ["_values", [], [[]]]
, ["_callback", _onAggregateSum, [{}]]
];
private ["_i"];
private _count = count _values;
private _retval = _start;
for [{_i = 0}, {_i < _count}, {_i = _i + 1}] do {
private _x = _values select _i;
// ^^
private _g = _retval;
// ^^
_retval = [_g, _x, _i] call _callback;
};
_retval;
Works just fine: [[0, 0, 0], _someVectorValues, { _g vectorAdd _x; }] call LINQ_fnc_aggregate
The callback did not define _g or _x, the scope had them readily available.
Don't tell me that does not work, I know it does, I have proven it to be the case.
Now if you separate the concern with an event handler, all bets are off; you cannot rely on the wiring scope.
Now, in this case, I would guess, which _a are we talking about, right? the one in the parent scope? or the one in the callback private scope?
Why are you doing [_g, _x, _i] call _callback? You seem to be after [_i] call _callback 
_g and _x are already defined, they don't need to go through _this.
however, indeed, the parent scope _a was the original value.
_a = 1;
diag_codePerformance[{_a = _a + 1}];
// parent scope: ^^
_a
ya, good point, of course. for that matter, _i is also defined by the parent scope. I pass them as a courtesy, available via _this for the callback subscriber.
The way I understand it you are going for that magic variable feature, so I was just wondering why you were also passing them to _this π
no worries; as a courtesy.
thank ye gents, fascinating discussion. I think I have what I need re: bitwise.
CuratorObjectPlaced gets the passed object as parameter. Use that parameter, don't iterate over ALL editable objects everytime one object is placed.
Zeus has 1000 objects editable, zeus places one object, you iterate through 1001 objects. Thats probably not what you intend.
Yes. It is the case. diag_codePerformance doesn't carry over local variables.
So I guess I could change that to CuratorObjectPlaced _x setGroupOwner _HC;
also using apply there is pretty inefficient
apply allocates a new array, and collects all your return values inorder to return you the array of that
which you don't need or use at all, waste of performance
Gotcha
Hello, I am having problems setting up a script I've found. Here is the error: https://cdn.discordapp.com/attachments/656953401070059541/869254880206925864/Arma_3_26_07_2021_17_26_26.png
Here is my description.ext:
class Default {
idd = -1;
fadein = 0;
fadeout = 0;
duration = 0;
};
#include "LARs\LARs_searchLoot\LARs_lootUI.hpp"
};```
error is not in the code you posted
its in the hpp
potential fix
class RscTitles{
class Default {
idd = -1;
fadein = 0;
fadeout = 0;
duration = 0;
};
import RscText;
#include "LARs\LARs_searchLoot\LARs_lootUI.hpp"
};
but there will probably be many other issues
Thanks, this is the LARs_lootUI.hpp file:
class LARs_searchLootUI {
idd = 20000;
duration = 1e10;
fadein = 0;
fadeout = 0;
onLoad = "uiNamespace setVariable [ 'LARs_searchLootUI', _this select 0 ];";
class controls {
class SearchText: RscText
{
idc = 1000;
text ="Searching..."; //--- ToDo: Localize;
x = 0.44326 * safezoneW + safezoneX;
y = 0.555005 * safezoneH + safezoneY;
w = 0.0980062 * safezoneW;
h = 0.0220019 * safezoneH;
};
class ProgressBar: RscProgress
{
idc = 1001;
colorFrame[] = {1,1,1,1};
colorBar[] = {0.93,0.72,0.08,1};
x = 0.44326 * safezoneW + safezoneX;
y = 0.577007 * safezoneH + safezoneY;
w = 0.0980062 * safezoneW;
h = 0.011001 * safezoneH;
};
};
};
Yeah so import RscProgress too
and I see no reason for your class Default
You don't use that
Thank you this fixed the problem!
I noticed sometimes player uniform textures applied with setObjectTextureGlobal don't show for players logging in after this was executed on a certain player. It seems to be inconsistent but working most of the time. My current fix is a eachframe loop on the player that loops through all other players, and applies needed textures with setObjectTexture. Wondering how this will impact things performance wise, im guessing with a bigger amount of players online its not a good idea to loop through them each frame?
its probably sufficient to do a scheduled loop that checks once every 5 or 10 seconds
and if it only happens for new players, you can use playerConnected eventhandler to start it. Let it run for a few minutes and then exit it again
im guessing with a bigger amount of players online its not a good idea to loop through them each frame?
definitely. Generally it just doesn't seem needed to waste fps on that
Alright thanks that makes sense
Hello guys,
I have a syntax question if anyone has the answer i'm looking for:
I'm trying to use
https://community.bistudio.com/wiki/BIS_fnc_VRTimer
I can start a timer as the example tells with
[] spawn BIS_fnc_VRTimer;
But to stop it i'm trying to do:
[true] call BIS_stopTimer;
Is it not the good syntax ? Should i use a variable or something ? Thanks in advance
hi, did you read the linked page? π the first argument is the colour
so BIS_stopTimer is a parameter of the function ?
i don't care the colour here
i think BIS_stopTimer is another function right ?
BIS_stopTimer: set to true to stop the timer. Once stopped, the function must be executed again to restart the timer
I don't get how to set what to true
also tagging @still forum in this answer because I'm not sure - any reason to not use setObjectTexture with remoteexec and setting JIP to true?
more memory usage, more network usage, bigger JIP queue
no. it is
(a)
missionNamespace variable
remoteExec is bigger, short term
So i should do something like
BIS_stopTimer setVariable [true];
?
β¦more or less.
BIS_stopTimer = true will do
The timer throws out a global variable that gets updated. You can use that variable to stop it's "loop" etc
Hey everyone, quick question, does anyone have a "Loadout Box" script lying around that they wouldn't mind sharing?
Basically looking to interact with an object and get a prompt to "Get Loadout X" then when they hit space bar it gives them the loadout.
Full disclosure, I'm crap at scripting.
Arma2OA. Is it possible to get the current position of the camera? And is it possible to get a vector that points in the direction from the camera to the gun cursor?
Do you know if there's a way to get the position of the weapon crosshair as it appears on the screen?
none AFAIK
maybe with a "trick" with barrel direction/lineIntersects yeah
but not the cursor itself
I understand the question as "where the player is looking"
we don't have (yet? Dedmen *winkwink*) access to the cursor \|/ thingy
no just want to know the position of the crosshair on the screen
so the player can set a position on the landscape based on where the crosshair is overlapping terrain
I won't add script commands to Arma 2 :u
do you really need the exact position of the crosshair and center of screen is not enough?
I'll use center of screen if i have to. But ideally exact crosshair position would be best
i guess I could use the weapon's direction to project the position of the crosshair onto the screen
if the crosshair is drawn at infinite or near infinite distance that is
i don't suppose there's a function to draw an icon on the screen, so as to make it easier to test the accuracy of this sort of thing
Looks like worldToScreen will help me out here
ah yep, from Arma 3 only was it interacting with obstacles (up to⦠25m maybe?)
I don't know if in Arma 2 the crosshair center matches up with weapon direction? does it?
I hope it does π
yup
you guys know off the top of your head how to get the current world position of the gun?
Even in A3 though we only just (next update) added script commands to get exact weapon position and direction.
https://community.bistudio.com/wiki/weaponDirection hey that command exists in A2 too
π¦ you can't get weapon position in arma2?
what about position of head?
time to update to A3!
eyePos
is that camera position or position of character's eye?
https://community.bistudio.com/wiki/eyePos wiki says eyes
that'll probably be good enough
ok, i think i have all the pieces i need. Tha nks
What is the difference between position ATL and position AGL?
gniii sensitive and crazy topic π
getPos will return AGL - aka 0 if the unit is standing on top of a building
ATL will ignore the building and say "you are 12m above terrain"
@drifting sky β
for the setPos thoughβ¦ ask @little raptor π€£
god damn, why does worldtoscreen take position argument in AGL????
why do you need worldToScreen?
projecting cursor position onto the screen first, then that position onto the world
but
i guess i'll have to just do a collision from eye pos, in the direction of weapondirection
using i guess a binary search
since there's no function to return position of line intersection
how do you now find the cursor position on screen?
You want to do that by finding where the weapon points to, and then worldToScreen it back to screen?
But then it wouldn't make sense to do another "then that position onto the world" because you would've already had that before
i'm scratching my original plan
now i'm doing a line intersection between eyepos and eyepos + weapondirection * some distance
and wherever that line terminates will be my final position
for your binary search approach
you can just screenToWorld, then you get where the aiming position is in screen center
thats most likely very close to where the weapon aims
i'd like it to be more accurate than that
since there's no actual indication where the center of the screen is if the weapon crosshair isn't at it
weaponDirection + 50m is the "sphere" of the cursor iirc
can anyone figure out why this is causing a local variable in global space error? func_set_artillery_view = { private [ "_p", "_s", "_d", "_e", "_t", "_int", "ch" ]; };
just that?
"ch" does that not cause an issue?
the inclusion of this function is causing the error
ohhhh
oops
The projection seems to be really accurate. Thanks guys.
can you add an item to the start of an array like this: _array = [_item] + _array?
insertAt 0 yes
wait, no π€£
insert only π
https://community.bistudio.com/wiki/insert β index option
for arma2
[element0] + [rest of array] then π
see Example 3
https://community.bistudio.com/wiki/+#Examples
ARMA2OA. anyone know how to get weapons and magazines currently in a backpack?
https://community.bistudio.com/wiki/Category:Command_Group:_Containers
all backpack commands
let's hope it's A2OA
seeeeeems not
guess it's getmagazinecargo and getweaponcargo
yeah but⦠how to get the backpack itself? backpackContainer seems A3 1.04
HAH
unitBackpack of course
but I am not sure whether it will provide the "ammocrate" backpack or not
getmagazinecargo and getweaponcargo get the items in the backpack
from unitbackpack
then I wonder what is the difference between the two
Anyone know where I can find materials
ex:
"A3\Structures_F\Data\Windows\window_set.rvmat"
I am trying to make a vehicle see-trough but I have no idea of how to get it back to normal
@somber radish
https://community.bistudio.com/wiki/getObjectMaterials
use this to grab the original materials associated with an object
Thnx man! Unfortunately "Gets all custom materials associated with the object" Is what it does so I do not get the returnvalue I need
Because it only returns custom material not the original one
well then run it on an unmodified vehicle lol
or if you need to dynamically change the material of any given vehicle, get the material first, save it as a variable, then change the material
@somber radish
This is the return value when run on a unmodified vehicle (Which is what I want to do)
["",""]
Car and AA battery
what car lol
dang getObjectMaterial does behave that way
I would look up the hiddenSelectionsMaterials in the config viewer then for whataver object you want the original material for
Does anyone know how to use/setup these tabs? Could't find any documentation for it
https://imgur.com/a/qWYhe8l
Ah sorry
to be fair, it was 03:30 for most users at that time ^^
No worries
i want to get a number between 0 and 0.4 based on a percentage. example: 50(%) = 0.2, 75(%) = 0.3 etc, how can i do that?
pretty much like the map() function from p5.js
just random 0.4?
(at worst, 0.4 * random 1 but you get the idea)
i dont want it to be random though
0.4 * (percentage / 100)?
what do you want then?
50% chance of being exactly 0.2,
25% chance of being exactly 0.3, etc?
its not a chance, it's like remapping min and max values
function map(value, minA, maxA, minB, maxB) {
return (1 - ((value - minA) / (maxA - minA))) * minB + ((value - minA) / (maxA - minA)) * maxB;
}
i found this online which is the answer im looking for, but in js
I, huh, don't read that
but you can have the same in sqf, just adapt the code
which i found after asking for help here lol
i want to get a number between 0 and 0.4 based on a percentage. example: 50(%) = 0.2, 75(%) = 0.3 etc, how can i do that? #arma3_scripting message should do
i think i wasn't very clear on my initial message
seems to work, and it seems much simpler than the solution i found, thanks!
Looks like you want https://community.bistudio.com/wiki/linearConversion
unnecessary in their case
Nvm read that wrong
yep that's what I had in mind when I asked for 50% chance of being exactly 0.2 π
it is not what they wanted, but we went through the same process
If Iβm having trouble pulling stuff out of config into my code do I ask here or in config?
here
config is for config making, scripting is for config obtaining in that case ^_^
I'm new to using config and I'm trying to select a random "position" from the list in the spawnPositions[] and this is my best attempt. Any pointers?
ConfigPath : missionConfigFile >> "CfgLootTables" >> "positions" >> "spawnPositions"
class CfgLootTables
{
class Loot
{
...
};
class positions
{
spawnPositions[] =
{
"lootSpawn_1",
"lootSpawn_2",
"lootSpawn_3", ...
};
};
};
In script
try
{
if (!isServer) exitWith {};
_cfgLootSettings = missionConfigFile >> "CfgLootSettings";
if (isNil "_cfgLootSettings") then {throw "invalid settings";};
if !(isClass _cfgLootSettings) then {throw "invalid settings";};
_maxSpawnedItems = getNumber (_cfgLootSettings >> "maxSpawnedItems");
if (_maxSpawnedItems isEqualTo 0) then {throw "invalid settings";};
_lootPositions = getArray (missionConfigFile >> "CfgLootTables" >> "positions" >> "spawnPositions");
_random = selectRandom _lootPositions;
hint format ["RandomPos <%1>", _random];
//Using this to see if it works
}
catch
{
_exception;
};
(unrelated, but for good practice see https://community.bistudio.com/wiki/getMissionConfig
https://community.bistudio.com/wiki/getMissionConfigValue)
also, your try catch is "okayish" but useless if you don't use _exception π
I guess this CfgLootTables is wrapped inside a CfgLootSettings�
I didn't include it but it's like this
class CfgLootSettings
{
...
};
class CfgLootTables
{
...
};
and it doesn't work?
nope
This might be a thing under config now but this might possibly be the issue cause I can't think of anything else. Aka the arrays
class CfgLootTables
{
class Loot
{
ratio[] =
{
"weapons",3,
"backpacks",1,
"vests", 1,
"items",2
};
weapons[] =
{
common[] =
{
["Crossbow","KA_crossbow_wood",[["KA_arrow_mag",6,12]]],
["Glock17","rhsusf_weap_glock17g4",[["rhsusf_mag_17Rnd_9x19_FMJ",3,4]]],
["ISH-18 12Gauge","rhs_weap_izh18",[["rhsgref_1Rnd_00Buck",11,22],["rhsgref_1Rnd_Slug",13,22]]]
//aka ["weaponName","weaponClassname",[["ammoClassname",minAmmo,MaxAmmo],["ammoClassname",minAmmo,MaxAmmo]]]
};
...
};
};
};
};
β¦ that's not how you write a config array indeed
common[] =
{
["Crossbow","KA_crossbow_wood",[["KA_arrow_mag",6,12]]] // BIG NO
};
``````cpp
common[] =
{
{ "Crossbow","KA_crossbow_wood",{{"KA_arrow_mag",6,12}}} // more like it
};
```**PS:** KA mods are illegal as their content is **ripped**.
Thanks for the help
I'm having trouble getting a value from the config. Even when debug = 0; it still returns as 1 when I hintSilent the _debug value.
FPS Counter
private["_debug","_cfgLootSettings"];
try
{
_cfgLootSettings = getMissionConfig "CfgLootSettings";
if (isNil "_cfgLootSettings") then {throw "invalid settings";};
if !(isClass _cfgLootSettings) then {throw "invalid settings";};
_debug = getMissionConfigValue "debug";
hintSilent formatText ["Debug = %1", _debug];
/*
if (_debug isEqualTo 1) then
{
[] spawn
{
while {true} do
{
hintSilent formatText ["FPS: %1", str round diag_fps];
sleep 0.16;
};
};
};
*/
}
catch
{};
Config
class CfgLootSettings
{
maxSpawnedItems = 50;
debug = 0; //if 1 will create marker and helpers on the map
};
β¦don't use try/catch if you don't use the exception
also: getMissionConfigValue is not looking into CfgLootSettings but at the root here
@hushed tendon β
Do I need to make a path from the class to the value?
_debug = getMissionConfigValue "debug"; // no
// private _debug = getMissionConfigValue [_cfgLootSettings >> "debug", 0]; // WRONG - fixed below
private _debug = getNumber ((getMissionConfig "CfgLootSettings") >> "debug");
@winter rose @little raptor
#include "\x\alive\addons\sys_adminactions\script_component.hpp"
SCRIPT(markUnits);
private ["_m","_markers","_delay"];
[] spawn {
_markers = [];
_delay = 290; //Show for this length of time, then delete
_colorWEST = "ColorBLUFOR";
_colorEAST = "ColorOPFOR";
_colorGUER = "ColorIndependent";
{
_m = createMarkerLocal [format["mapcoloring_%1",str _x], position _x];
_m setMarkerSizeLocal [15,15];
_m setMarkerAlphaLocal 0.02;
_markers pushback _m;
switch (side group _x) do {
case west: {
_m setMarkerTypeLocal "mil_dot_noShadow";
_m setMarkerColorLocal _colorWEST;
};
case east: {
_m setMarkerTypeLocal "mil_dot_noShadow";
_m setMarkerColorLocal _colorEAST;
};
case resistance: {
_m setMarkerTypeLocal "mil_dot_noShadow";
_m setMarkerColorLocal _colorGUER;
};
};
if (isPlayer _x) then {
_m setMarkerColorLocal "ColorBlack";
};
} forEach allUnits;
// Sleep for the # of seconds listed in _delay and then delete the markers.
sleep _delay;
{
deleteMarkerLocal _x;
} forEach _markers;
};
Just as a thank you, this is some code I adapted from ALiVE to make an absolutely wicked heat-map of unit positions that disappears the more you zoom in. I will probably never use it in a non-alive situation but I thought you might like it.
not sure why you spawn that but ok...
Well it's run in the background and updated every few minutes...
thanks for the attention and intention nonetheless! π
doesn't it take a string?
it's always cool to see the end result on which we may have helped π
you passed config
I can DM lou a few pics of it, holdon
exactly, just do it in one code
argh
just double checked on wiki https://community.bistudio.com/wiki/getMissionConfigValue 
spawn the sleep only, most of your code doesn't need scheduled
the sleep and the delete markers you mean?
i think you meant to use missionConfigFile π
yes
Cause for a second I was like "if I just spawn the sleep then won't it just delete the markers right away...cause...I spawned sleep...only..."
no
@winter rose
I don't know why but the hint keeps showing up as "Debug = Scalar".
private _debug = getNumber ((getMissionConfigValue "CfgLootSettings") >> "debug");
hintSilent formatText ["Debug = %1", _debug];
try```sqf
getNumber (missionConfigFile >> "CfgLootSettings" >> "debug");
also, getMissionConfigValue β getMissionConfig, I made a mistake earlier
Debug FPS runs but when debug = 0; in the config, it still runs the if statement
if (_debug isEqualTo 1) then
{
[] spawn
{
while {true} do
{
hintSilent formatText ["FPS: %1", str round diag_fps];
sleep 0.16;
};
};
};
in the config it still runs the if statement
makes no sense
nothing runs in the config π¬
should have been "Debug FPS runs but when debug = 0; in the config, it still runs the if statement."
R u sure you are setting _debug = 0;
The script
private _debug = getNumber ((getMissionConfig "CfgLootSettings") >> "debug");
hintSilent formatText ["Debug = %1", _debug];
if (_debug isEqualTo 1) then
{
[] spawn
{
while {true} do
{
hintSilent formatText ["FPS: %1", str round diag_fps];
sleep 0.16;
};
};
};
getMissionConfig "CfgLootSettings"
this is wrong
look at what Lou wrote
Ok, did you get "Debug = 0" in the hint?
hintSilent formatText
why?!
Not my code so I can't tell you
well the point is, it's stupid
use format
not formatText
private _debug = getNumber (getMissionConfig >> "CfgLootSettings" >> "debug");
hintSilent format ["Debug = %1", _debug];
if (_debug isEqualTo 1) then
{
[] spawn
{
while {true} do
{
hintSilent format ["FPS: %1", round diag_fps];
sleep 0.16;
};
};
};
try that now
Btw is there any different between == and isEqualTo ?
do you reload or save the mission between checks? because config is not loaded on the fly
Yeah I'm restarting and backing out
everytime you enter the editor the description.ext file is loaded
Welp
It works but it sucks having to back out to the editor instead of just restarting the scenario like I'm used to
for some reason I have to go back to the editor
nothing I do during the scenario works
oh well
at least it is working
y e s
exit, save, restart
I thought you meant saving or restarting the scenario not in eden
makes more sense now
ah yep, "ofc" from my pov ^^
You don't want to do addons then I guess
Trying to activate a trigger when a all units in a specific group are dead using { alive _x } count units grp1 == 0
Where do i set the name of the group to be grp1 ?
double click on the group in eden, it's the same as setting variable name for a unit or vehicle
@digital pulsar Cool. Cheers worked
I have a trigger that contains ```sqf
supply1 in thisList
but when the vehicle with the name supply1 enters the trigger area nothing happens (Its supposed to set an objective to complete)
I also have another trigger this one containing
```sqf
!(alive supply1)
Which is meant to fail the mission if the truck is destroyed. I have a feeling i'm missing something obvious, any help?
the trigger might not be set to trigger on objects perhaps, or wrong side?
in the trigger which detects if it isnt alive the settings are as follows:
Type: None
Activation: None
Repeatable: β
Server Only: β
Condition: !(alive supply1)
Same thing but has a radius of 20:
Type: None
Activation: None
Repeatable: β
Server Only: β
Condition: supply1 in thisList
the description of None for the Activation says it will activate if a custom condition is set
imma switch it to game logic mabye?
you are detecting "nothing" so of course, it won't work
thislist is referring to the trigger's sensor rules
what you can do is sync the trigger to the object itself
For the first trigger activation should be PRESENT
the activation type is greyed out
after switching to anybody present it worked
Hi
I'm trying to shoehorn some code into an already existing mission
I'd like to force the players to wear another uniform and not be able to change it out
How should I best approach this?
I could make a script that checks the uniform the player has every n seconds and force adds a new uniform if needed
but that sounds tacky: is there a way to prevent removing the uniform after it has been given, and if not, can I get some uniform change event to react to if needed?
And finally, is there a way to force this to happen on only some missions?
For maximum reactivity you could do a CBA_stateMachine for whenever the uniform is changed for eventhandler-esque functionality.
does
{
_x enableSimulation false;
} forEach (getMissionLayerEntities "Layername" select 0);
affect sublayers aswell?
please try and tell so we can update the wiki
@cinder atlas here π
updated the biki
nice
Hey, I've problem with understanding issue that I have with setObjectScale command.
Command works fine in EDEN Editor and while hosted locally, but it doesn't work on dedicated server.
I read page about command on A3 Wiki but it didn't helped me.
I also tired to google the issue and checked if anyone else had same issue on scripting channel.
But no luck, so I thought I'm gonna ask someone knowledgeable people to help me resolve the issue.
I've tried both
this setObjectScale 3;
and```sqf
if (isServer) then
{
this setObjectScale 3;
};
Thank You in Advance
what is this?
the object has to either be simple or attached to something
it's call out to object, could be replaced with proper name actually
β¦ thanks, I know that
I meant "what kind of object" π
simple billboard sign
https://community.bistudio.com/wiki/setObjectScale
Must be either an attached object or Simple Object
@winter rose π
Hola guys,
something has been bothering me for two years and I figured I might just ask now.
I did a horror mission two years ago and sunk more hours into it than I'd like to admit. However, after a while a huge wave of desyncs started.
Given that I'm not exactly new to sqf/scripting in A3, I could not really figure out what it was. Not really anything critical in the code. But now I have a hunch.
There is an event in which a "chosen" player gets jumpscared. All teammembers around him get hidden and replaced with obscure versions of themselves with a custom animation and sound.
Those versions are created via createVehicleLocal in order to make them visible for the "chosen" player only. I didn't use createUnit because createUnit is obviously global and I'd have to hide the unit on the other machines, which would have resulted in them popping up for a second. createUnit also is signficantly slower.
I have the feeling that creating a character that is actually supposed to be a "unit" via createVehicleLocal causes something in the network to go boom. Anyone has had a similar experience or has an idea about my hunch? π
Hello, I am the new owner of a server and when I connect I have this message (after going to the lobby) Here is the translation of the message because I am French: sending the request to the server to obtain UID reader information
ok
but not a scripting issue I think
Idk it's new serveur
is it even possible to create units with createVehicle?
Yes, but they remain standing, AI-less
try #server_admins
Yup. You can apply pretty much any command on "units" created this way. They don't have any AI, though.
The question remains: Does creating a "unit" this way cause any network issues? πͺ
should not, as in "just an animated object" but devs may know more
can you spawn a Logic type object with a script?
I mean I'm sure you can
I just didn't see an obvious script for it
β¦?
basically, I want to place a "Logic" object
via script
if its not possible it's not that big a deal
i mean, it depends on the context
it is possible
in initServer
you can do this via multiple ways
I'm using a Logic type object as a mission object of sorts to pass data between clients/server
actually I can probably just change that to missionNamespace?
β¦yes
that'd make more sense anyway
are there any weird things I should watch for with using missionNamespace?
not overriding other variables by prefixing yours
e.g SPGT_myVar = 1;
yeah that's why I was using just a random logic var
but now I wanna make my mission as easy to port as possible
anyway thanks for the sanity check
You can also use remoteExecCall to update data between clients
Then you can notify them when data is updated and you can make them run some code when it happens
Well, it's just a remote call
but plain public setVariable is OK for the case when new data write and read don't need to be synchronized in time (like when you set a value now but the read will happen not now but some time later or may not happen at all)
How do you set a player as a respawn point? Like having a squadleader be able to have others spawn on him. I know it has something to do with addRespawnPosition or something, but idk how to expand on that.
hello, i been trying to make a safezone that holsters the weapons and not allow the usage of grenades
I got to
vehicle allowDamage false;
player action ["SwitchWeapon", player, player, 100];```
but i am not too sure about grenades, any hints?
use addAction and bind the key to the "Throw" button.
holsters the weapons
the player can easily undo that
yeah i figured that out, so i made it so that it switches to no weapon state
i am not too sure about how to addAction works, but i will check it out
the basics are the same as what Killzone_Kid explained here:
http://killzonekid.com/arma-scripting-tutorials-how-to-override-lmb/
he's overriding the "DefaultAction". you'll want to override the throwing action (not sure what it's called, check the wiki)
thanks, i will check it out
https://community.bistudio.com/wiki/Description.ext#Starting_Gear
I do not understand this section of the wiki article. Are the examples provided used in respawn equipment or the weapon pool system?
Thanks for the clarification. The terms "Starting Gear" seemed so distant from the terms "weapon pool system" that I thought they were different.
Is there a script for having a AI crewed blackfish fly to and fire on a marked area? Like how you can tell AI mortars with the command keys to fire on a spot can you do something similar with the blashfish
Im having a weird time trying to get vehicles to respawn with empty vehicles using the respawn module. Ive tried using "this;", naming the vehicle "h1" and using "h1;", I've tried using "vehicle;" but everytime it gives me "undefined variable"
eg
clearMagazineCargoGlobal this; clearWeaponCargoGlobal this; clearItemCargoGlobal this; clearBackpackCargoGlobal this;
Does anyone know how to make an arsenal that allows players to move boxes into it that they collect, like the one in antistasi?
Simple question (I think). How do I make it so if the player isnt in a group it hides all the units in the group. I figure you would have something like
While (group this != group player) [hideObject this]
Then you put this in the init of the possible ai squadmates of the player
I realize that "code" sucks but that is why im asking. Thanks ahead of time.
I want to have a long lasting sp alive scenario where i can become a new sl if I die. But i dont want a bunch of empty squads sitting around
Anyone know why ACE interaction menu actions attached to a spawned object would only be visible to the player who spawned said object?
can give more details if need be
you should primarily ask ace related questions in their slack https://ace3public.slack.com/ e:(well, not that I've seen anyone say you can't ask them here, but that's what ace slack is kinda for :D)
How do you spawn the object? Could be that you add(/attach) the interaction menu to it only locally
interaction menu actions are local execution. needs to be fired on every client
lots of ACE power users and devs are here as well. its fine
Ye, makes perfect sense with basic questions like this. But more specific the question, the less likely it's gonna get answered, imo. ACE being one degree more specific π
Most likely only did it locally issue is only with spawned objects not object actions set up in init
if a player is in his own group, there won't be anything to hide? Not sure what you are trying to do because it seems you've overcomplicated your solution
I guess the follow up is, is it worth it to run it on all machines? if its too much overhead then I won't bother thing still works
Yeah, I was also thinking spawning a new group every time the guy dies would be simpler & less performance-intensive, but I've done so little mission scripting I'm not entirely sure how exactly I'd do it :D.
Arma2OA: When a player goes to open a crate, is it possible to open a different crate other than the one they're interacting with??
post your code using sqfbin.com
I have ai in several groups set as playable. So when everyone in my original group is dead I can switch to the sl in another group. But i dont want the ai in the other group to show up untill im in they're group.
never used this before hope it works
these other groups you are just using as sort of a "reset" squad, and they are not part of the mission helping your other squads and stuff?
Yes. At least thats what I want
ah okay. i'm assuming all single player correct?
Yes. I would also want to make sure they cant shoot or anything if the enemy attacks.
so this code seems like you are running it on the player's machine that is placing the object.
ace_interact_menu_fnc_createAction - Local Execution
ace_interact_menu_fnc_addActionToObject - Local Execution
so if you want all players to see the actions, you want to remoteExec these functions to other player machines. since these are functions defined, they will already be present on the other machines making its overhead very small in comparison to sending the code over the network.
ahhh
okay i got a few ways you can do it. let me think about it for a sec for the best way. writing something
Thanks
https://sqfbin.com/epofoqitilokaqaxofow
this works fine for me. shouldn't be too taxing
Thanks bro... idk how u guys do this $hit
because the passed params is newVehicle and oldVehicle. include this at the top of your expression:
params ["_newVehicle", "_oldVehicle"];
clearmagazineCargoGlobal _newVehicle;
//etc
//etc
will function declared in functions.hpp with provided .sqfc file use it's sqfc automatically?
private _item243 = objNull;
if (_layer239) then {
_item243 = _item242 createUnit ["LM_OPCAN_FRI_Rifleman_DES",[2484.02,1595.97,0],[],0,"CAN_COLLIDE"];
_item242 selectLeader _item243;
_this = _item243;
_objects pushback _this;
_objectIDs pushback 243;
_this setPosWorld [2484.02,1596.02,50.0014];
_this setVectorDirAndUp [[-0.0329105,-0.999458,0],[0,0,1]];
if !(0 == ([0, 1] select (_this getUnitTrait 'engineer')) || {0 == -1}) then {_this setVariable ['s', 0, true]};
_this setVariable ["ace_advanced_fatigue_performanceFactor", 1, true];
_this setVariable ['ACE_isEOD', false, true];
if (0 >= 0.1) then {_this setVariable ["ace_medical_damageThreshold", 0, true]};
if (0 != -1 && {0 != (parseNumber (_this getUnitTrait 'medic'))}) then {_this setVariable ["ace_medical_medicClass", 0, true]};
_this setUnitPos "DOWN";
0 remoteExec ['setFeatureType', _this];
_this setname "Ismail Hakimi";;
_this setface "WhiteHead_14";;
_this setspeaker "Male04ENG";;
_this setpitch 0.99;;
parseSimpleArray "[[""hitface"",""hitneck"",""hithead"",""hitpelvis"",""hitabdomen"",""hitdiaphragm"",""hitchest"",""hitbody"",""hitarms"",""hithands"",""hitlegs"",""incapacitated"",""hitleftarm"",""hitrightarm"",""hitleftleg"",""hitrightleg"",""ace_hdbracket""],[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0]]" params ['_hitpoints', '_damage']; {_this setHitPointDamage [_x, _damage # _forEachIndex, false]} forEach _hitpoints;
if (true) then {_this disableAI 'PATH'};
_this setUnitTrait ['Medic', false];
_this setUnitTrait ['Engineer', false];
_this setUnitTrait ['ExplosiveSpecialist', false];
_this setUnitTrait ['UAVHacker', false];
_this addHeadGear "Mezara_Mask_White";
if (true) then { _this setVariable ['s', true, true]; };
};
Been trying to spawn units through sqf export but I need to give them a custom helmet
if I try this their default helmet disappears but the new one doesn't
am I doing something wrong?
everything is created through sqf export
_this addHeadGear "Mezara_Mask_White";
is my addition
can I add an event handler for when a player closes a virtual arsenal?
there doesnt seem to be an event handler for that. is there another way I could do something like that?
There are scripted event handlers for arsenal
thanks
will the event handlers for arsenal opened and arsenal closed only work for arsenals added with BIS_fnc_arsenal? or will they also work for virtual arsenals added in the editor?
They're the same thing
But it won't work with ACE arsenal
Don't crosspost (#rules) I removed your post from #arma3_scenario.
Hi guys, I have problems trying to figure out how to properly use "hideBody". Basically only problem is that I can use addAction for a unit and the action is hideBody of that unit but I can't figure out, how to show the action only when the particular unit is dead.
The action is basically available even when the unit is alive. Rest of the command works without problems. Thanks for help.
use "!alive _target" for the condition
or better yet, only add the action when the unit dies
using killed/MPKilled event handlers
I tried that, came up with this:
unit1 AddAction ["Bury corpse", "hideBody unit1", "!alive _target"];
But it still doesn't work, it still shows even when the unit is alive. I haven't tried the event handlers yet
did you even read the wiki?
because that syntax is not correct at all
I did read it, but guessing from your reactions, its not even close to being right π
object addAction [title, script, arguments, priority, showWindow, hideOnUse, shortcut, condition, radius, unconscious, selection, memoryPoint]
you're providing the arguments, not condition
I think I have the correct syntax (if not, i do not know what is wrong), however it tells me, that there is incorrect string and boolean is expected (i suppose its for the Condition) I checked the syntax and added default values for everything except Title, Script and Condition. I can't really figure out what to do.
this addAction ["Bury corpse", "hideBody player1", "nil", "1.5", "true", "true", "", "!alive _target", "50", "false", "", ""];
you're putting string everywhere
"" = string
oh damn, I see, thanks, you can probably tell that I suck at these things π Thank you anyway, it works now and I finally start getting how all this works
first time is always a b⦠hard. hard it is
but you are in the learning process, don't ever apologise for it π
wondering if someone can help me
I have a script on a hold action that makes a few VLS missile pads fire at some vehicles.
it works fine on LAN but on a dedicated server the missiles just head straight into the sky.
west reportRemoteTarget [target1, 300];
target1 confirmSensorTarget [west, true];
west reportRemoteTarget [target2, 300];
target2 confirmSensorTarget [west, true];
vls fireAtTarget [target1, "weapon_vls_01"];
vls3 fireAtTarget [target2, "weapon_vls_01"];
any ideas?
the commands you've listed all need local args
afaik
example of what?
....
that's a local variable
oh
thanks leopard
2bh im gonna say i have no clue lol
this command should happen where the vehicle is "local"
e.g who "owns" the vehicle, MP-wise
local just means which client the object "belongs to"
when a command takes local argument, you have to execute the command on the machine where the argument is local
ohhh
to do that you use remoteExec
right so execute on a server
no
AI is on server as its placed in the editor not via zeus?
you don't need to know where it is
just use remoteExec
it'll figure it out for you
oh okay
[_target1, 300] remoteExec ["reportRemoteTarget", _object];
?
no
i wish there was a remoteexec generator lol
I think for reportRemoteTarget you have to execute it where the AI is local
it makes no sense executing it where _target is local
although reportRemoteTarget takes a side
https://community.bistudio.com/wiki/reportRemoteTarget
im assuming there is no other way to make a VLS fire at something it has to receive data link etc?
yeah I was right
This command must be executed locally to the vehicle/turret you want to tell the target about.
not that I know of
west reportRemoteTarget [target1, 300];
target1 confirmSensorTarget [west, true];
west reportRemoteTarget [target2, 300];
target2 confirmSensorTarget [west, true];
vls fireAtTarget [target1, "weapon_vls_01"];
vls3 fireAtTarget [target2, "weapon_vls_01"];
playSound3D [getMissionPath "Sounds\zeus_sound_AlarmOpenAir.ogg", speakers11, false, getPosASL speakers11, 5, 1, 0];
playSound3D [getMissionPath "Sounds\zeus_sound_AlarmOpenAir.ogg", speakers12, false, getPosASL speakers12, 5, 1, 0];
playSound3D [getMissionPath "Sounds\zeus_sound_AlarmOpenAir.ogg", speakers13, false, getPosASL speakers13, 5, 1, 0];
bobhope setDamage 1;
sleep 33;
bomb3 setdamage 1;
west reportRemoteTarget [aa1, 300];
aa1 confirmSensorTarget [west, true];
vls fireAtTarget [aa1, "weapon_vls_01"];
sleep 3;
west reportRemoteTarget [aa2, 300];
aa2 confirmSensorTarget [west, true];
vls2 fireAtTarget [aa2, "weapon_vls_01"];
sleep 3;
west reportRemoteTarget [aa3, 300];
aa3 confirmSensorTarget [west, true];
vls3 fireAtTarget [aa3, "weapon_vls_01"];
sleep 13;
west reportRemoteTarget [aa4, 300];
aa4 confirmSensorTarget [west, true];
vls fireAtTarget [aa4, "weapon_vls_01"];``` thats the entire holdAction script
so:
[west, [_target, 300]] remoteExec ["reportRemoteTarget", [_vls1, _vls2]]; //report _target to west on _vls1 and _vls2's machines
actually I think remoteExec can take an array for its targets
just pass it into one array
if you don't know you don't know, there no workaround but to ask and listen about it!
if you were complaining you don't know and not listening, then yeah, nuke from orbit π
yeah i bet you get some shirty people on here sometimes lol
also I have no idea what kind of syntax highlighting you use...
you should use ```sqf
yes, shirty people that are totally pants
ah crap i used sql by accident lol fixed
muscle memory ^^
if you don't know you don't know
how can you know you should ask then?!
say "I don't know"
then someone nice will (hopefully) say "don't stress it, you can ask people"
that's part of education
learn to say "I don't know",
learn to learn,
learn to say "I was wrong",
learn to unlearn
(I know that's deeper than expected, but that's what she said)
lol I mean:
you don't know you don't know
means that either:
- you think you already know
- you don't care about it (i.e. never had to deal with it)
π
"curiousity killed the cat, but satisfaction brought it back!"
Dunning-Kruger effect, etc ^^
when you know you don't know, fix it
until then, you can't fix the problem if you don't know there is one π
hahaha
what would be the best way to check if user presses a key, considering that key maybe already mapped to some action by the user?
iirc a new event handler was added in dev branch
hmm im on profiler branch
then wait for the next update. anyway:
https://community.bistudio.com/wiki/addUserActionEventHandler
or add keydown EH to mission display.
im surprised that there isnt any existing commands to help?
or use CBA keybindings if you use CBA.
you can just detect the key (as long as it doesn't have a modifier, and isn't using mouse/controller) with actionKeys, and use a keyDown EH like veteran29 said
ok thx I'll see what I can come up with
when using doArtilleryFire
can i choose another magazine or does it HAVE to be a magazine in the artillery piece?
example using a MLRS to fire a VLS rocket lol
it just tells the AI to fire the arty.
It can't fire something that's not available.
I guess you could add the mag via script to the vehicle gun and then tell the AI to shot it.
thats true
0 = player spawn
{
_this forceAddUniform "FDF_sf_fat_maasto_sin_1";
_this addHeadgear "ffp_m05w_helmet_peltor";
_unif = uniform _this;
_hgear = headgear _this;
while {alive _this} do
{
sleep 0.1;
if !(uniform _this isEqualTo _unif) then
{
_inv = uniformItems _this;
_this forceAddUniform _unif;
{_this addItemToUniform _x} forEach _inv;
};
if !(headgear _this isEqualTo _hgear) then
{
_this addHeadgear "ffp_m05w_helmet_peltor";
};
};
};
This is what I came up with
(0 = unneeded)
Any thoughts on how to make it better?
Copy, I forgot the reason why some people add that everywhere, what was it?
it was that init fields and trigger fields said "I don't want return value"
so doing an = attribution tricked it
it has now (recently) been fixed
Thanks
But other than that, any thoughts on how to make it better? I suppose I could also waituntil to have it execute every frame
Hey man just want to say thanks, big help sometimes sqf is a tad bit confusing.
you could use the Put event handler described here
https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Put
Hmm that would be much better, yeah
So here _unit would be this, would _container be the target object and source would always be the inventory of the player? Or can the source also be an item on the ground that's dragged to the crate?
Though perhaps I could also just simply for each put even check if the player has their uniform and execute code, that does work, too
player addEventHandler ["Put", {
params ["_unit", "_container", "_item"];
_unif = "FDF_sf_fat_maasto_sin_1";
_hgear = "ffp_m05w_helmet_peltor";
if (alive _unit) then
{
if !(uniform _unit isEqualTo _unif) then
{
_inv = uniformItems _unit;
_unitforceAddUniform _unif;
{_unit addItemToUniform _x} forEach _inv;
};
if !(headgear _unit isEqualTo _hgear) then
{
_unit addHeadgear "ffp_m05w_helmet_peltor";
};
};
}];
Would this work?
hmm also with the alive test, too
Like so
How can I make a teleport between two things when one is not at ground level? I'm using markers and a script from a video online, but it spawns me at ground or sea level.
(_this select 1) setPos (getMarkerPos "Exit1");
{ _x setPos (getPos (_this select 1)); } forEach units group (_this select 1);
}];```
Would I have to use setPosASL instead?
Yeah you have to use the setPos that takes into account height
wat? all setPos commands take the height into account. the problem is the getPos
use setPosASL and getPosASL
hmm this is not enough
It doesn't prevent one from changing uniforms by dragging from your own inventory to it
Surely there's another event I could check?
Hmm, take is another one, but that still doesn't preven one from forcechanging it without a trigger
So I suppose the only way is to keep checking all the time
How would I add code that executes when player joins and has a unit?
Has unit?
it doesn't mention anything about the unit the player controls
how would I know which player to execute code on without that?
Like this
initPlayerLocal.sqf if it's a mission
Yeah, but the issue is that I have a readymade mission, in this case co10 escape
I want to force different uniforms for us, but I don't want to edit the co10 mission files
then use playerConnected, spawn a loop and check when player becomes available:
[] spawn {
waitUntil {!isNull player};
//now use player
};
thanks!
oh?
ah : /
I suppose I could, on the server, manage a list of players
and if it changes execute code on them
you can still use playerConnected
just not the way I said
how should I use it?
you can remoteExec the code on the new client's machine
addMissionEventHandler ["PlayerConnected", {
params ["_id", "_uid", "_name", "_jip", "_owner", "_idstr"];
[] remoteExec ["some_fnc", _owner];
}];
