#arma3_scripting
1 messages ยท Page 735 of 1
yeah ik
it has lower precedence
_hm1 = createHashMapFromArray [[1,2],[3,4]];
_hm2 = createHashMapFromArray [["test1", _hm1], ["test2", _hm1]];
str _hm2;
```throws
14:45:50 Circular reference found in HashMap, this will cause a memory leak!
14:45:50 โฅ Context: Hash Key: "test1"
[["test2",[[1,2],[3,4]]],["test1",!!HashMap circular reference!!]]
I guess str does something that triggers the warning and the actual hashmaps are fine?
ran into that same issue a while ago but with arrays for a recursive linking system
because apparently you can also somehow get circular array references
even though just like that hashmap none of the references were actually circular
there were just multiple arrays with the same reference
Has anyone encountered an issue with creating particle effects with createVehicleLocal and sometimes not being able delete them with deletevehicle in multiplayer? Ofcourse I mean the clients deleting their own specific version of the particle vehicle
Because I keep getting this reoccurring problem where a particlesource is supposed to be deleted - and it will delete for most/some clients but not on others. Seemingly at random
if it matters the particlesource is attachTo'd a unit or vehicle
Is there a scripting command to add camo nets / slat armor / etc to the vehicles that have them available?
they're usually either texture sources or animation sources
texture sources are applied with setObjectTexture and setObjectMaterial (if it also changes the material)
animation sources are applied with animateSource
Got it, I'll investigate those functions next. I've been looking through the slammer cfg file to look for the references of the camo nets and slat armor, but only found references to the camo net. Let me pull up the cfg for the slammer up and see how it differs. Thanks for pointing me in the right direction!
slammer doesn't have slat armor tho 
Ah, you're right. Whoops. That might explain some things. I must have been thinking of the Rhino UP.
maybe. afaik only APCs have those 
Yep, Rhino UP has it. In the Cfg it seems to be listed in the animationList and the hiddenSelections / hiddenSelectionsTextures.
is there a way to lock a player out of picking up certain items?
like blacklisting (or whitelisting) weapons that they're allowed to pick up
https://www.youtube.com/watch?v=uthA1_lyNfo you can adjust this script or leave it as-is, pretty useful
hm does Take trigger for picking stuff "directly" off the ground? (e.g. when you get the "Take <weaponname>" option in the action menu)
or does the ground generally count as a container
every object on the ground exists in a groundWeaponHolder
which are containers too
so yes
your tank is a weapon holder ๐

do i remember correctly that if a unit is configured say west, and you createUnit it to a group that is east, the ai may be confused about that units side?
It's become better recently as it now has multithreading 
Parallel.ForEach(m_allObjects, func) ๐
Shouldn't be, ticket please
Array prevents circular reference by scanning through the whole array and all subarrays whenever you insert anything.
HashMap doesn't want to pay that cost and just doesn't check.
so why do it for array
Because the programmer who did that years ago decided that, and backward compat
i guess inventing a garbage collector is too much to ask
now yes
i mean when this cyclic array reference problem was first encountered
ah, ok
well anyway, not going to rewrite the past now, so it is what it is
well seeing as arrays already forbid cyclic references, and how bad of an idea it is to let scripts leak memory, it seems to me that maps should have followed suit
Maps focus was performance
that seems a bit silly when seen in context
If people want to leak memory and ignore the big warning in RPT that tells you exactly which script does it. Then people shall do that
but you don't get a warning, do you?
You do, its posted above
local _m1 = createHashMap;
local _m2 = createHashMap;
_m1 set [0, _m2];
_m2 set [0, _m1];
_m1 = nil;
_m2 = nil;
do you get a warning for this?
Why is
(_temp select ((_this select 3) select 1)) = 0;
causing a no semicolon error? Removing the assignment
(_temp select ((_this select 3) select 1));
fixes the issue, but I have no idea why.
You have a syntaxe error
use set if you want to set an array's or hashmap's value @pallid ravine
where?
Interesting. I'll do that, thanks for the quick answer!
local
oh that. whatever, replace it with private then
i'm just used to local
so much for backwards compatibility huh
or just remove it 
gniii
grumpy ๐
I guess whoever wanted it didn't think of isLocal ๐คฃ
A2 has both local _v = ... and if (local _object)
๐คฃ
i don't think there was any technical reason to remove local _v =
private was introduced in A3 1.54 I believe, and was a local rename because local was a command that never was advertised for such usage at the time
as far as I know, iirc from KK
yeah i think i literally never saw anyone else use local _v = in A2 scripts. everyone was using some smoothbrained private ["_v"]
yeah i shortened that for brevity. in actuality it's
private ["_cursorTarget","_onLadder","_isWater","_alreadyRemoving","_characterID","_objectID","_objectUID","_ownerArray","_dir",
"_realObjectStillThere","_upgrade","_entry","_parent","_requiredParts","_requiredTools","_model","_needTool","_displayname",
"_whpos","_wh","_object","_vector","_dis","_puid","_variables"];
well, still better than omitting it
sure. it's just worse than local _blah
yeah but local _stuff = value wasn't documented until 2015 ๐ฌ hard to grasp
why is that
ยฏ_(ใ)_/ยฏ
I script since OFP and never knew it was a thing in Arma 2 before it was too late
i guess i have to blame BI then instead of those poor scripters
on that, please yes
i could have sworn it was used somewhere in some BI SQF in A2 but maybe not
Yes. At least it was like that last I tried it
if i do g = createGroup east; unit = g createUnit ["B_RangeMaster_F", position player, [], 0, "FORM"]; then side unit will return WEST
worth a note or description fix then
i can even have g be a non-empty group of side east, the units will report different sides
wait, that's in the first note actually
I will try to make it more obvious in the description
I am always doing a joinSilent just after
as in
unit = myGroup createUnit [<blah>];
[unit] joinSilent myGroup;
``` ?
ok
Also when you check side, do side group _unit
side unit can return civilian if the unit is captive for example but with group it is safer
edited - better?
https://community.bistudio.com/wiki/createUnit
๐ฎ โค๏ธ
(and edited again, hop)
Hey guys I have another question, I created a mission with several SQF Files used. Now do I need to upload all SQF Files and the pbo or is it all compiled into the Mission pbo and uploading it is sufficient? We are having trouble connecting into the server with only the pbo uploaded but are not sure where the problem is.
Upload to my server ofcourse
everything in the mission directory is in the pbo yes ๐
the issue might come from missing or wrong mods
okay so might look into that again
Is this appropriate channel for requesting help with ORBAT creating in description.ext?
maybe a bit more about #arma3_config, but it may depend on the kind of issues too
So, when I get everything set up (paths and roofs included in ORBAT module in editor, and description.ext set up), I always get error with game not identifying type of ORBAT group upon launch of mission, and they always dissapear when I load into missions. When I decided to copy entire description.ext stuff from one YouTube video, it worked fine without any errors, yet upon smallest changes it gives me errors
Are textures for vehicles with more complex skins such as the CTRG Prowler or the various M-900 skins treated differently from normal textures? I've got a script that looks up the various vehicle definitions that share the same model as the current vehicle and gives the option to apply their textures (as defined in the vehicle class's hiddenSelectionsTextures array) to the current vehicle. It works great for most things, but for these seemingly special vehicles, it just applies a generic texture. Is there something I'm missing?
Edit: Alright, the issue with the CTRG prowler was just me being blind. Still working on the M-900 / Civilian Offroad textures
I requested help there on 9th December, but never got answer explaining what did I get wrong there, so I guess I will go there again.
I would say #arma3_config yes, with the details of what was changed ๐
For vehicles with the skin randomization feature, in the CfgVehicles class it claims that you can set the texture of the vehicle by using this setVariable ["color",X];, where X is a number within a defined range and 'this' is presumably the reference to the object. However, testing this out with the local Exec in the debug menu, I can't seem to get it to work. Does anyone have any experience with this?
Disregard, I've figured it out. That's for setting the texture from the editor, not once the game has already started.
Hey i want to dynamicly (unlock / lock it on conditions like progress) disable a door during a mission,
inGameUISetEventHandler came in my mind, the enginename triggered is UserType.
Is there some other action where UserType will be triggered?
Did you try setvariable bis_disabled_Door_1 ?
i cloud create a list of all doors, could disable / enable it for every client when a condition changes, but this would mean i have to maintain it vs i could set an condition on a door, ask with inGameUISetEventHandler if this door can be unlocked and this central in one file
2nd. version would be better IMO
{
titleText ["You are the killer, kill all the survivors." , "PLAIN"];
sleep 5;
titleFadeOut 5;
}; ``` this script is in my init. sqf. When I run the mission I'm getting an error with this if statement. Am I using it correctly?
(command) If Type = if condition this is the syntax
playerSide = east
Need a double == for testing equality. A single = is for variable assignment.
ahhh. thank you!
Is it possible to modify the parameters of an addAction? Namely changing the priority?
negative, just change the text
Got it, thanks!
what do you mean?
can you change the playerspeed?
yes
what command is that?
The addAction function has a bunch of parameters that go with it, such as the radius, or the priority (how high it shows up on the scroll menu). I was wondering if there was a way to change the parameters of a currently existing action so that, for example, it could appear higher up on a list or be accessible from a different radius, etc. However, as per Lou's post, it is not possible (except for changing the name).
oh got it
So im trying to pull a script from a scenario, how does one get into eden to access the mission file
go into the eden editor in arma and open the mission?
Yea but I cant find the scenario
is the mission in your missions folder?
you have two folders: mpmissions and missions
if it is in either of those then you should be able to access it from eden
it has to be named in the format missionName.Map
See ik where to find those, but its not showing up which is weird
I got it off the steam workshop
what type of file did you get from there? is it a .pbo?
I figured it out lol, I had it put in the wrong spot
ok
I'm not going to complain but I've by accident found out that by using vestContainer <unitname> addItemCargoGlobal you can indeed add items to the divers rebreather. Once removed though you can't put em back in.
Might be interesting for the few people making such missions with vanilla assets
Hey guys, I built a ressource system for my MP mission using public variables for saving and cutRsc for displaying them. But I am currently encountering syncing problems, what is the best way to sync the ressource variables and displays for all my players?
do multiple simultaneous appends to a publicVariable list from different clients get properly synced?
so if i append then publicVariable from two separate clients simultaneously, will i end up with a list of two elements, or a list of just the one element from the more recent client
To give some more info on the current system: I init the variables in the ServerInit.sqf to only load them up once, then I have a shop system where ressources are paid to get units and changes are displayed. But this alone isnt enough so I added a trigger which is executed every second which updates the display of the variables, but this is buggy and sometimes some units in the shop are not paid
wait let me try that real quick
I tried it a few times and it seems to work okay
And I am not using lists, just 3 seperate public variables to be exact
Oh yeah I'm specifically worried about a list
And appending
I'm pretty certain that "normal" assignment operations will work
@plush novaThe most recent publicVariable will be what all clients are synced to
so ideally you want to append from one location and then broadcast
Is there a way to broadcast the public variable after assignment?
just publicVariable?
no automatic sync happens so you always need to broadcast after an assignment
So lets say I declare a publicvariable in my init, then after some time i change the value, do i need to put public variable again?
np
if you do want to "emulate" automatic sync you could use setVariable w/ the public param set to true
or make a wrapper function like so
Gotcha
That makes sense
Was kinda hoping there was some special case array diffing logic lol
It may be helpful to consider publicVariable a function as well, rather than a datatype (because it really is just a function). So you aren't really "declaring" a public variable, you're just broadcasting a normal variable with the function publicVariable.
SQF doesn't have a distinct data type for public variables afaik
it's all just whatever data type the var is and then broadcast
munitions = 500;
_munitions = (missionNamespace getVariable ["munitions", 0]);
_munitionsid = ["munitionslayer"] call BIS_fnc_rscLayer;
("munitionslayer" call BIS_fnc_rscLayer) cutRsc ["munitions", "PLAIN", 0];
_munitions = str (_munitions);
publicVariable "munitions";
_munitionsdisp = uiNamespace getVariable ["my_munitionsdisp", displayNull];
_textCtrlmunitions = _munitionsdisp displayCtrl 404;
_textCtrlmunitions ctrlSetText _munitions;
So this is the operation I call every time I change something
(substitute the 500 with whatever I do like add/subtract or whatever essentially)
But even after adding the publicVariable command it doesnt sync
Do you have any code to update the UI on the clients receiving the new value?
???
How would I go on and update it on client side
What I would do is
make this a function that each client has
_munitionsdisp = uiNamespace getVariable ["my_munitionsdisp", displayNull];
_textCtrlmunitions = _munitionsdisp displayCtrl 404;
_textCtrlmunitions ctrlSetText _munitions;
and remoteExec it after broadcasting the updated value
or just send the updated value as a param via remoteExec
and update it clientside
so like this
fnc_UpdateMunitions = {
params["_munitions"];
munitions = _munitions;
_munitionsdisp = uiNamespace getVariable ["my_munitionsdisp", displayNull];
_textCtrlmunitions = _munitionsdisp displayCtrl 404;
_textCtrlmunitions ctrlSetText _munitions;
};
then remoteExec that whenever you need to update clients
Sorry for asking again and where would I a) save that and b) execute that? I guess executing right after updating the munitions
You wouldn't even need to update the muntions beforehand with that
it'd update for all clients just by remoteExec'ing the function
but where you'd save it depends
if you're just using a mission then you could define it in the init
otherwise for a mod I'd say cfgFunctions
so for example
to do what your code above does
to update the munitions to 500
you'd just do ```sqf
[500] remoteExec ["fnc_UpdateMunitions"];
and that should update the munitions and UI for all clients
okay I got that but u wrote i wouldnt even have to broadcast the new value for munitions did i get that right?
yes you don't need publicVariable anymore
what I just wrote above handles broadcasting the new value and updating UI
Okay so the line munitions = _munitions, updates it globally because it is executed via remoteExec right?
yes
Hmm is there a way to give the client "hints" about an objects velocity so it doesn't glitch around
Perfect thank you very much I understand it much better now
A nonlocal client*
setVelocityTransformation and some other functions take velocity params to better sync clients
but it depends what exactly you need/want
Hmm well I have a scheme to constantly setvelocity every frame to make a man slide around
The velocity is largely unchanging
But I think the clients keep "syncing"/interpolating to the man's animation state offset which is 0,0,0 (since he is in a stand pose)
And therefore the man stutters and teleports about from the nonlocal pov
Ideally I want to let the client know that the man should continue sliding about at that velocity rather than... Not
I was thinking of also just calling setvelocity nonlocally every frame or something (since the velocity is basically constant and never changes so it should be known to all clients) but idk if that works
Doing setVelocity every frame is... not ideal
I would use setVelocityTransform with an identical start and end velocity for that
And another question concering that function, is it possible to implement locks on variables so that I dont have any anomalies like when two players use the shop at the same time and the method is executed at the same time?
You could emulate a mutex but you shouldn't need to
Is it important that I reuse the same "interval" here?
Like is it fine if I just call it with interval time 0 repeatedly but update the start and end points
@broken steppe it would be better to figure out how to avoid it being an issue in the first place
Or do I need to track the interval state
You could repeatedly call it but you don't need to
easy way of getting the real time in arma?
this is some new shit 2.0 โค๏ธ
Hmm the docs on biki recommend it tho
For continuous movement this command should be executed each frame while changing the interval value.
Oh yeah no you need to do that
I worded it poorly
I meant you don't need to repeatedly call with updated endpoints
Just the interval should be enough unless you're changing direction
Hmm alright thanks
This is wrong
Yeah I realized that a bit after writing it
I'll go back and delete it
should've used a string arg
If you do that on the clients it might not
hello! I've got a script, that works! It is a while{true}do{... loop and i guess , that it's executed every frame in game which is an unnecessary load to the server. I heard, that i can reduce it by adding sleep x; into it so the loop gets executed every x seconds. I would like to ask where/how to add the sleep into the loop to cause the desired effect and what is the ideal time for that (how to find out)? Thank you
can someone clarify me what the locality of
missionNamespace setVariable ["testVar",true];
would be?
I'm asking because according to wiki this is global but when being done by different clients they can have the exact same variable with different values on it and return correctly their own version in every single client. Also asking because I wanted to stop using
publicVariable "testVar";
as its not cool anymore according to some places and i'm using it alot.
Maybe i'm just misinterpreting the wiki again?
While {true} loops don't necessarily run every frame, but they do run much more often than is necessary for most tasks. A sleep in a loop such as that usually goes either at the beginning or the end, though it depends on what you're doing in the loop. As for what time to use, that also depends on what you're doing.
it's for traffic lights, the loop changes colours at them
setVariable is not publicly broadcast by default. A quick look at the wiki page for it will tell you this. You'd need to change your code to:
missionNamespace setVariable ["testVar", true, true];
So in that case your "sleep" would be how much time you'd want between each color update.
the shortest segment (when there's orange on its way from green to red) is 1 second >>> so the sleep should be also 1 second?
You're saying there's different times between different color switches?
You are right, thank you. Idk why i keep glancing over this important stuff so often haha.
yes, green or red is of course going to stay longer than orange
So if there's different delays one universal delay won't work for you
What would probably work better for you is using a while {true} with no sleep, but having it call a function that changes the color and then sleeps for different times according to the color its switching to
I'm not going to write the code for you because I'm busy, but that would work for what you want
ok thanks, i think i got the information i needed
event if it did, it would be (almost) no different than using publicVariable
stop using
publicVariable "testVar";as its not cool anymore according to some places and i'm using it alot.
the point is that you should just avoid sending variables over the network when there's no need
you should try to do as much as possible on client machine themselves
and when not possible try to reduce the frequency or amount of data sent
this are variables that are sent every 10/20/90 minutes
if they're not big then you have nothing to worry about
I always thought that it would be better to manage variables and most of the operations serverwise and not the other way around ๐ฎ
@kindred zephyr it generally is
and for that purpose you may find setVariable more convenient
But nothing wrong with publicVariable either
Quick question, I know I can get a players UID using getPlayerUID but how do I get just the very last number of that?
depends. if it has nothing to do with clients then yes
but doing "most of the operations serverwise" will just ruin the server performance and thus will ruin the game for everybody
last number?
last digit in the number
you mean 5 in 12345?
Yeah
_uid = getPlayerUID _unit;
_lastChar = _uid select [count _uid - 1, 1]; //as string
_num = parseNumber _lastChar; //as scalar
Awesome thank you, I tried using trim but kept getting messed up between the variable being a number vs string

Having a HC though... 
is there a way to name groups for the MP lobby now via Eden/sqf or still only this? https://github.com/CBATeam/CBA_A3/pull/667
Nothing new in that regard, only CBA method.
Hello, I've been trying to run a command through a trigger upon activation but I can't get it working
for some reasons I can't send images
nope, but you can send code
```sqf
// your code here
hint "good!";
```
โ
// your code here
hint "good!";
well in the trigger's expression menu I have ```sqf
// Condition
this
// When activated
deleteVehicle _unit2
the trigger seems to be working properly since it works with modules
_unit2 is undefined
variables that start with an underscore are local to their scope ๐
shouldn't it throw an error if it indexes an undefined variable?
not here
and _unit2 is a player
also I think you cannot delete a player
I saw that in a video, i'll try doing that with an actual vehicle
it worked, thanks @winter rose
i'm not familiar with arma3 mission making yet
don't worry, it will soon drive you mad!
also it works with units but only AI players
it works with AIs, not player-controlled units yes
well I know that a single unnecessary underscore drove me crazy for like 30 minutes lol
that's the spirit!
Hi I just started to make some script now, and I have some question.
_point = 400;
publicVariableServer "_point";
_pointMarker = createMarker [format ["Point: %1", _point], position wherePoint];
_pointMarker setMarkerType "hd_dot";
publicVariableServer "_pointMarker";
this is init.sqf. i ran this code but it only shows little black dot and there was no string. how to fix this?
(i'm not american. sry for my english skill)
you cannot publicVariableServer a local variable (underscored one) ๐
regarding the dot, you did not set a text
createMarker creates a marker and you provide a name
to set the text, use setMarkerText
It finally worked. thank you OwO
class Test123 : DefaultForceGroups
{
};
will forEach act on all items in an array. I've made an array for each of my players in a scenario. I want them to have a random spawn location.
Why does count (missionconfigfile >> "Test123") print 0 when DefaultForceGroups has classes that are inherited?
yes
Some config commands take inheritance into account, some don't.
ok seems to be the case here. how can I then loop through the class with inheritance? I've been using select & count
configClasses configEntries?
Config entries is wrong. configChildren?
configClasses exists
"true" configClasses (missionconfigfile >> "Test123")
gives me empty array
configProperties
that seems to work. thx terra ๐ thx dedmen
heyo, trying to make it so that if a player enters a building he would get full ace healed but im not too sure how to go about it. I found a method called inArea and this is what I came up with to test, in the mean time any ideas on how I would get this to work?
if (player inArea "Land_Medevac_house_V1_F") then {
[ player ] call ace_medical_treatment_fnc_fullHealLocal;
}
looks like if it's an object you're using, it needs to be a trigger
instead of a class name
You could just drop a rectangle trigger down name it something like "aceHealTrigger" then swap that out with "Land_Medevac_house_V1_F"
hmm, the thing is we have a build script allowing users to place the building with that classname. Maybe I can have a trigger created and placed in the same position they build the building?
or use the alternative syntax to check a rectangle where the building is placed
the documentation im looking at doesnt have an alternative syntax, is this the correct trigger?
https://community.bistudio.com/wiki/setTriggerActivation
the alternative syntax is for inArea
oh
if you use inArea I'm not sure you have to mess with the trigger activation... just create a trigger at the same location, dimensions, orientation, etc and feed the trigger name into the function
I'd go with either just placing a trigger down that runs the healing code directly
or, if you're using inArea, just use this syntax and bypass needing a trigger
position inArea [center, a, b, angle, isRectangle, c]
you can get rough dimensions of the object w/ boundingBoxReal for sizing them
im incredibly new to arma scripting so im not certain how I could even get the building pos each time its built, im trying to figure out how liberations build script works im trying to find that now to create triggers
Ideally lib's building runs some sort of event handler, but if it doesn't you could look into alternative options
In the meantime... I'm back to creating issues for myself. I have "nests" I place down that run this: ["createNest", [this, 1]] call STY_RVG_fnc_zedNest;
in the function...
https://sqfbin.com/jicocodovobutexotuti
the markerText is incremented properly however if I access missionNamespace getVariable "STY_RVG_nests" it always returns an empty array
So basically I'm not sure why it seems to be filling the array in the beginning and then it's emptied I guess?
I don't see anything in that code that would be causing that
are you modifying this variable anywhere else?
in init.sqf I run ["init"] call STY_RVG_fnc_zedNest;
Which, at this point, is just: ```sqf
missionNamespace setVariable ["STY_RVG_nests", [], true];
but I mean that should be running before the init fields on the nests so I can't imagine why that would cause an issue
So this code is in the init field for the nests
["createNest", [this, 1]] call STY_RVG_fnc_zedNest;
?
Yes
Is that set up in 3DEN or config
3DEN
... I promise you I looked at that earlier and would have sworn it was the opposite
no problem
been debugging this for an hour or more
On the bright side you shouldn't have to change much
lol nope... I guess if i needed to run an init on the function before everything else I could just do it via a placed logic?
Could possibly do that, alternatively you could set up cfgFunctions and do a preInit function
then again I assume this is a mission
so that's probably a no-go
ah yeah, that's the answer for sure
It IS a mission but I have my functions setup in descript.ext so that's still possible
Awesome, thanks man
no problem
is there a way I can export the class names from the arsenals so I dont have to keep tabbing from game to the file with class names, its incredibly annoying since the mods add a good amount of items
you could write an sqf script to dump cfgWeapons classnames
The ace arsenal allows you to export classnames from the selected item.
hate to ask, but any chance you know of an example script?
Let me rig one up quick
thanks man, I underestimated the amount of items in our arsenal
private _classNames = ("true" configClasses (configFile >> "CfgWeapons")) apply {configName _x};
Should do the trick
Then can just print them out somewhere
That will get everything in cfgWeapons, could filter it better if you know more precisely what you want
Rog thanks man this should work fine
Is there a way to access the current player mp face identity "config"
Does it show up under normal configs?
gen1 setPosATL (getPosATL selectRandom _glist);
_glist - getPosATL gen1;``` Is this code like written as good as it could've been. I'm trying to create an array of possible spawn locations, and then teleport an object to one of the possible spawn locations, and then remove that location as a possible spawn location, because I intend to run the code multiple times
first, this code won't work (1, it's a list of objects and not positions, 2 you cannot remove an array from another array this way)
use a temp var to store the selected item first, then remove that object ๐
you always manage to point the obvious out its crazy ๐ฅฐ
thank you
don't code when tired, it's a motto I myself cannot manage to follow ๐
Im not tired, im an idiot. When trying to write code on my own its like 
Good evening i want to make custom ranks icon for a mission (multiplayer mission) so players will have my custom rank insignia instead of vanilla but don't want to be server rank just the mission
_glist = [getPosATL g1, ...] something like this?
like a patch?
hey, it comes with practice. if you need good advices:
- write it in human language first if needed
- make it work
- make it readable
- then make it optimised ๐
thats going on my wall, i need those words in my life
like the vanilla icons that appear in top of players head in multiplayer mission
private _posObj = selectRandom _objArray;
_objArray = _objArray - [_posObj];
// do stuff with _posObj
private _gen1 = selectRandom _gslist;
_gslist = _gslist - (getPos _gen1);```
how do I make my code colourized?
You can add "sqf" after the three backticks
Like '''sqf (but with backticks)
No you add it to the beginning
there wego!
๐
is it possible to set a physical object's location to a private variable? i was thinking since its not tied to a real object how can it store a position
i want to replace the vanilla rank icon " rank Chevron " ( the one that appear over the players head in multiplayer ) with custom insignias
but as mission sqf not server sqf
_gslist = [gs1,gs2,gs3,gs4,gs5,gs6,gs7,gs8,gs8,gs9,gs10];
private _gen1 = selectRandom _gslist;
_gslist = _gslist - (getPos _gen1);
g1 setPosATL getPosATL _gen1;
private _gen2 = selectRandom _gslist;
_gslist = _gslist - (getPos _gen2);
g2 setPosATL getPosATL _gen2;
private _gen3 = selectRandom _gslist;
_gslist = _gslist - (getPos _gen3);
g3 setPosATL getPosATL _gen3;
private _gen4 = selectRandom _gslist;
_gslist = _gslist - (getPos _gen4);
g4 setPosATL getPosATL _gen3;
@winter rose ok this is what I have, not exactly optimized, but it works!
Sort of a best practice type of question... would it cause a problem to have several triggers - approximately 14 - checking for the presence of a player or should I pursue a different avenue?
is there a way to access the current player mp face identity "config"? does that show up anywhere under normal configs?
a way other than "read the face of the player's unit" i guess
gentest,
"Repair Generator",
"",
"",
"_this distance _target < 2",
"_caller distance _target < 2",
{_caller playMoveNow "Acts_carFixingWheel";},
{},
{
cutText [Generator has been repaired", "PLAIN", 2];
},
{
_caller switchMove "AmovPercMstpSrasWpstDnon";
},
[],
25,
0,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", 0, gentest];
whats wrong with this script? getting an error that it didn't expect the last semicolon, and when I run it it just says "Init: "
Are you trying to put this into an object's Init field ob Eden?
correct
Just don't. If you're doing a multi mission, this is a great way to break everything. Also that field is simply buggy
your saying i should move it into an sqf file and then call that through another script?
Perhaps. Or just put it in init.sqf or initServer.sqf
i put it in a separate sqf that is called at the beginning of the mission, but now it doesn't show up on the object? If I call it using the debug menu it shows up
Then it isn't called properly I'd assume. Or the gentest is not initialized as well
hmm
@warm hedge I found the line that was causing the issue...
{ _this call MY_fnc_hackingCompleted }, ``` this is the text in the biki
why doesn't it have a semicolon after the code?
You're not removing anything from that array
cutText [Generator has been repaired", "PLAIN", 2];``` this is my field for that
am I not removing the object's pos from the one in the array since I basically copy its pos and then remove it.?
Semicolon is to end a sentence, and the code has just reached to the end
so I should remove my semicolon in my field
im so confused atm. So when I remove the code and the semicolon, the error squigly goes away...
i dont understand if its code
this field
yes
you should remove the object itself
Also your sentence, it's broken. Put " in the Generator... part
how would I do that?
i think that was the issue... oop
_gslist - [_gen1]
the wat?
_gslist = _gslist - (getPos _gen1);```
that's not the problem
no
i figured out the issue with that
if you write that you would be removing a bunch of numbers. but your array doesn't contain numbers
it needs []. look again at what I wrote
creates an array
ohhh
this is wrong
you can even tell by looking at the syntax highlighting
i want to replace the vanilla rank icon " rank Chevron " ( the one that appear over the players head in multiplayer ) with custom insignias but as mission sqf not server sqf any script for that
oh POLPOX already told you 
I don't think it's possible via SQF at all
u mean add it to my mod ??
create a pbo file for replacing the vanilla chevron with my own and add it to my faction mod]
but question is how to do the replacing
ah, one more question. What should I use instead of sleep when I am working inside the init field of an object. I want the players to have an animation that plays on start, but the full animation is too long, so I am cutting it short. I need another command that makes a delay but I am not sure what to use
p5 switchMove "Acts_UnconsciousStandUp_part1";
sleep 30;
p5 playMoveNow "";
this is what I have in one init field for example
https://community.bistudio.com/wiki/Scheduler
The reason why your sleep doesn't work there
should I use execVM again...
Just spawn it
ok
Also why you do it in an object's init field?
so is their a template for config , for the replacing the rank chevron in the player nametag
for now just find where the icons are in the config. I guess CfgRanks
hmm
@little raptor im still running into the issue where the spawns aren't deleting themselves after a player spawning there, so there are instances where 2 people spawn at the same location.
_pslist = [ps1,ps2,ps3,ps4,ps5,ps6,ps7,ps8,ps9,ps10];
private _player1 = selectRandom _pslist;
_pslist - [_player1];
p1 setPosATL getPosATL _player1;```
thats the script i use just multiple times for all the different players
you forgot to put =
you're just deleting without saving the result
?
where would I put the =
_pslist - [_player1];
yes
thank you
@warm hedge im not sure why, but the script we were talking before, about the code. The hold action script still isn't working in context even though it worked before.
[
g1,
"Repair Generator",
"",
"",
"_this distance _target < 2",
"_caller distance _target < 2",
{_caller playMoveNow "Acts_carFixingWheel";},
{},
{
cutText ["Generator has been repaired", "PLAIN", 2]
},
{
_caller switchMove "AmovPercMstpSrasWpstDnon";
},
[],
25,
0,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", 0, g1];``` this code is in an sqf that is called at the beginning of the mission, and I've made sure that the names match
not working or not showing?
_caller
not defined
the holdaction isnt showing up when i go up to the object
its defined in the params of the function
you have no params
i thought they were optional?
[
_myLaptop, // Object the action is attached to
"Hack Laptop", // Title of the action
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Idle icon shown on screen
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Progress icon shown on screen
"_this distance _target < 3", // Condition for the action to be shown
"_caller distance _target < 3", // Condition for the action to progress
{}, // Code executed when action starts
{}, // Code executed on every progress tick
{ _this call MY_fnc_hackingCompleted }, // Code executed on completion
{}, // Code executed on interrupted
[], // Arguments passed to the scripts as _this select 3
12, // Action duration [s]
0, // Priority
true, // Remove on completion
false // Show in unconscious state
] remoteExec ["BIS_fnc_holdActionAdd", 0, _myLaptop]; // MP compatible implementation```
this is the BIKI example that im going off of
I'm not talking about that _caller
talking about _caller switchMove "AmovPercMstpSrasWpstDnon";
_caller is not defined there
only _this is
well, the script was working before
im not sure why it stopped
params ["_target", "_caller", "_actionId", "_arguments"];```
where have you put that code?
on the BIKI it says this is the param for that field
in an sqf that is called on mission start
I put it in the object's init but it still didn't work
params is a command. doesn't mean those are defined
you shouldn't put that in object init
if you want to put that in object init just drop the remoteExec
wait, would it make a different if I have it set as a simple object
yes
they're different things
ok
its a shame, I was using setObjectScale which requires it be a simple object, I see how they wouldn't be in conjunction with each other
Anyone have a config for a prop?
like a model that has exported from blender to arma 3 and I want the object to be a prop
this object will appear in the eden editor to be selected?
ok thank you
is there a way to make only certain AI in a team hostile to a player? example, make only 1 opfor in a group hostile to a civilian player, but the rest of the group is not
So I need some assistance, I am trying to use the tracer module, and it isnโt working, I canโt find any tutorials except one on how to place it in Zeus and I am trying to set some up to a trigger so there is ambient AA Fire. Can someone help me?
either setCaptive or setFriend are probably what you are looking for
Is there any documentation out there on which scripting commands are usable in a public zeus custom composition?
Has anyone ever only made a raffle mod?
I can only randomly select one item in an array to generate, I want the items in this can set the probability of generating items in it any friends have any good ideas?
there's a lottery mod for Exile mode, search for "exile scratchie" in google
what about BIS_fnc_arrayShuffle?
are we free to use the arma 3 base campaign scripts as we please?
because they're so cool, and useful that I wanted to use them
idk if it's possible to do that without broking the law
in Arma 3, sure thing! you can even reference them directly without having to copy/paste them
really? so I don't need to import them to my mission folder?
darn I'm so dumb I didn't notice it's loaded with the game
no, you can directly reference them with (for a one time usage) [arguments] execVM "\path\to\file.sqf
or declare them in CfgFunctions with @path\to\file.sqf iirc
oh
thank you very much Lou guy
XD I realised I don't actually need to read over 30 different scripts to use them
XP I just need to call them in CfgFunctions.
Das a big yeet (ignore this I'm just autistic XD) (not lying I really am)
not yeetin', only showing the wonders we have ๐
yes, by the way, contact DLC is weird, at the same time we get a lot of persistency functions that earlier we did not have
which is why I may be buying Contact DLC... sadly
if functions are only in Contact DLC, they will exist only if you loaded it!
don't buy it just for that ๐ and most of its functions are tailored for singleplayer
yeah, as the campaign I'm trying to make is for singleplayer
I'm still figuring out the Arma 3 base campaign Hub variables
so I can make the same stuff the base campaign made but for malden
How could i create a task where i would need to heal injured a.i? Could anyone point me in right direction ๐
I was thinking to create a pilot rescue task where i need to heal the pilot and extract him
if I put code to init field of object, it is called on all clients and server? Is it same as calling script via init.sqf?
// init of object
[this] execVM "script.sqf";
// init.sqf
[myObjectName] execVM "script.sqf";
yes, without the scheduler though
Kinda, init box is executed everywhere jip included. But it's executed way earlier than init.sqf (during object creation)
and what ^ he said ^-^
in addition to that, it is same as
// initServer.sqf
[[myObjectName], "script.sqf"] remoteExec ["BIS_fnc_execVM", 0, true];
How can I get the position of a rifle's muzzle, where the projectile will start?
create a simple object of the weapon model
find the muzzle end pos
find the weapon proxy pos in player's hands
get the muzzle end in model coords using the local muzzle end offset and selectionVectorDirAndUp
@digital hollow
onEachFrame {
_w = currentWeapon player;
//update weapon info upon weapon switch
if (_w != player getVariable ["last_weapon", "?"]) then {
_cfg = configFile >> "CfgWeapons" >> _w;
_m = getText(_cfg >> "model");
//if (_m select [0,1] == "\") then {_m = _m select [1]};
_o = createSimpleObject [_m, [0,0,0], true];
_off = _o selectionPosition [getText(_cfg >> "muzzlePos"), "memory"];
_off = _off apply {[_x]};
deleteVehicle _o;
player setVariable ["offset", _off];
player setVariable ["last_weapon", _w];
player setVariable ["proxy",
[
"proxy:\a3\characters_f\proxies\pistol.001",
"proxy:\a3\characters_f\proxies\weapon.001",
"proxy:\a3\characters_f\proxies\launcher.001",
"proxy:\a3\characters_f\proxies\binoculars.001"
] select (([1, 4, 4096] find getNumber(_cfg >> "type")) + 1)
];
};
_offset = player getVariable ["offset", []];
_proxy = player getVariable ["proxy", ""];
// using LOD resolution 1 (and lod index 0). This is not always reliable
// you should manually check allLODs and find the most suitable LOD (smallest res LOD usually has the best accuracy, but it might be slow too)
player selectionVectorDirAndUp [_proxy, 1] params ["_vy", "_vz"];
_pos = selectionPosition [player, _proxy, 0];
_vx = _vy vectorCrossProduct _vz;
_mat = matrixTranspose [_vx, _vy, _vz];
_pos = _pos vectorAdd flatten(_mat matrixMultiply _offset);
_p1 = player modelToWorldVisualWorld _pos;
_p2 = _p1 vectorAdd (player vectorModelToWorldVisual (_vx vectorMultiply -1000));
drawLine3D [ASLtoAGL _p1, ASLtoAGL _p2, [1,0,0,1]];
}
^ _p1 is the muzzleEnd in world
hotdamn
In zeus, when an object with a variable name is placed multiple times, are the subsequent placements' variable names the same as the original objects' but with an appended _#, just like in the editor?
Via custom compositions, yes, there are variable names.
What is the least intensive method to script a condition on a server that fires periodically ?
In my case: an ambient flyby every ~15 minutes.
there's no way but a loop
an onEachFrame with a global variable that checks time!
this but unironically
i only have one though, and it polls expiry on a priority queue of timers
there is no need because:
- period is approximate
- it's very long
scheduled and sleep will do
sleep (60 * 15);
precise timers are very useful for lots of things. you get the 15 minute timers for free on top
i imagine like CBA or some other library must already have this or equivalent
Yes it does.
CBA_fnc_waitAndExecute
CBA_fnc_waitUntilAndExecute
does it have repeating timers also?
yes
CBA_fnc_addPerFrameHandler
no i mean like execute this callback every 50ms
CBA Per frame handler supports interval in seconds
Thanks everyone. Just to be concrete: for non-CBA users, the loop is made with a for , not BIS_fnc_loop on initserver.sqf ๐ ?
Is there a way to either change a marker's name (not the displayed text), or a way to add a marker to the zeus interface as an editable object?
Markers in Zeus... I think are controlled by "creator"
If you create marker via script, you can put the Zeus logic as creator object, that might make it show in zeus
Alright, I'll give that a try and see if it works!
If that doesn't work.
Place a marker in Zeus, and check what it's name format is in allMarkers.
I think Zeus also has a special format
But don't know if that matters
I'm trying to make an icon above an object that is a), in the physical world (not on map), and b) is only visible to one side. I thought a way to maybe accomplish this was using the waypoints as a way to make it visible, but for waypoints, can you move them to a certain location through scripting?
nevermind, im using tasks now
You can use https://community.bistudio.com/wiki/drawIcon3D directly ๐
@willow hound so I switched to using tasks. With waypoints it only has 1 shown at a time. Tasks work better for it. The only issue im having is that the tasks don't want to move to where I want them to move...
im moving the task to the module position, which is moved to the object, but on mission start they are where I place it.
nevermind! I got it to work by changing the objects pos to the syncronised object
Guys so sorry. I need info on a script / command. Any one able to help? Ive got a awesome idea for my mission but cant do it without this issue resolved.
This is the place for questions, so go ahead and ask away.
Thank you.
So basically all i want is a OPFOR unit to wait for idk 10 seconds or something then move to a staging area to initiate an attack. Ive done some research on "sleep" , "wait unti" but i cant seem to find any solution. Is their a way to get this line of script into a trigger to make the unit move after a certain amount of time?
And is their a way to get units to move at a certain time in the game? For instance move at 12:00? (this method would be preferred)
Triggers run in an unscheduled environment, so if you want to use sleep or waitUntil, then you'll need to run your code with something like:
arguments spawn {"Code goes here";};
More info on spawn here: https://community.bistudio.com/wiki/spawn
Thank you however im really not good with scripting or coding. How would i use this in my game with a unit and what would i need to use to execute:(
@winged gull Basically you could just put this in the unit's init
this spawn {
params["_unit"];
// your code goes here
};
any code you put in that will run in a scheduled environment meaning you can use things like sleep and waitUntil
and you can use _unit to do things to the unit
Oo so it dont have to be in a trigger? And that is great! Could i please have an example? Im learning as i go on..
I'm not really able to write a full example for you at the moment, but I would take a look at this page to get started
https://community.bistudio.com/wiki/doMove
if you want more complex movement you'll want to look into the waypoint-related commands
Lovely i see. So if i wanted a tank to move at 12;00 is that easily executable in the script init you just given me?
just keep in mind any code you put in the unit's init will be run for every joining player
so if you only want it to happen once a trigger will work better
you could script that, yes
there are commands for getting the current time and such
Or wrap your code inside an if (isServer) if using an init is more convenient
^
Right okay... Ill have a look. Thanks guys
How do I get rid of errors of possibly undefined variable when I have the variable as an object name in the mission?
check if you wrote the variable name correctly? 
or rewrite your code, you're missing something probably.
hmm
_pslist = [ps1,ps2,ps3,ps4,ps5,ps6,ps7,ps8,ps9,ps10,ps11,ps12,ps13,ps14,ps15,ps16,ps17,ps18,ps19,ps20,ps21,ps22,ps23,ps24,ps25,ps26,ps27,ps28,ps29,ps30];
_kslist = [ks1,ks2,ks3,ks4,ks5,ks6,ks7,ks8,ks9,ks10,ks11,ks12];```
thats just an array tho
and both are in local scope, if you try to call them globally you will get errorrs.
remember all those variables NEED to be defined before the array is call, or you will get an undefined variable
hm, they are in game how would I do that
are they an object? like somthing you place?
because you need to place it in the variable space in the object (just double click on it)
One option is to change the array to an array of strings representing the variable names, and to get a reference to the object with that name, use the missionNamespace getVariable "Name"; command.
its how it happens
Guys ive had a play and so far ive got the time figured out (on what time to send AI) but how do i use it with the move commands??
daytime > 10.25 - how can i fit that with a move command?
use sleep
Yep, you'll need to calculate how much real time until 10.25 in game time with (10.25 - dayTime)*60/timeMultiplier, and then sleep for that much time, then run whatever scripting commands you want.
so im still ecountering a var issue. at the beginning of my sqf, there is
private _pscore = 0;``` and the part that the game doesn't like is
```sqf
_pscore + 1;```
i dont see the issue..
wait
does it need to be
_pscore = _pscore + 1;```
If you are trying to increment _pscore, yes.
i am, im still getting the error on the second one though, i have no idea why
private _pscore = 0;
if (_pscore == 4) then (escape setVariable["bis_disabled_Door_1",0,true]);
[
g1,
"Repair Generator",
"",
"",
"_this distance _target < 2",
"_caller distance _target < 2",
{_caller playMoveNow "Acts_carFixingWheel";},
{},
{
titleText ["Generator has been repaired", "PLAIN", 10];
_pscore = _pscore + 1;
g1 say3D "s2";
titleFadeOut 5;
},
{
_caller switchMove "AmovPercMstpSrasWpstDnon";
},
[],
25,
0,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", 0, g1];```
Those scripts inside your remoteExec are their own scope, you need to pass _pscore as an argument, or make it global.
might be easier to make it a global
ah
also _pscore in the way it is will alway be reset back to 0 when ever this script is called
depending on what you're doing, you probably need to be very careful about synchronisation here, if you care about correctly incrementing the score
this script is only getting called at beginning of mission
what does that mean?
right on
you're right tho I should probably move any global vars to init right
If this script is only called once, then keep in mind that the if is always going to be false since _pscore will never be 4 when it is called.
Also, depending on whether or not this is singleplayer, you might want to consider saving your variable to object scope of each player unit with setVariable. Not necessary, but it can be usefule to keep things organized.
instead of _pscore = _pscore + 1; you should probably RE on the server
whats RE?
remote execute
thats smart yea. I'll just move the if statement to another file thats called when the object action is finished
is the score shared among all players or does each player have their own score?
yeah no don't do that
i should use setvariable instead?
i take it the score is shared?
well no it doesnt have to be, because im not like showing it on the screen or anything
like it doesn't matter until the score is 4
pscore = 0; that should be all you need
yes, but semantically do you want to have different scores on different players, or is there only one score for the whole game?
for this there is only one score. Basically Im using it to check if the number of generators is 4, and if thats true than they win basically
okay. then when a generator is repaired you want to RE on the server
why though, i thought i could keep that private
then the server checks if that generator was already repaired, and if not it increments the score, and marks the generator as repaired
this value is shared by all clients in the game, there is no other way to increment it than for the central authority i.e. the server to do it
not correctly anyway
okk
so you give the server a global variable happy_pscore and in the RE function you increment it if the generator isn't already repaired, and mark the generator as repaired
so youre saying i should make another sqf with just the incrments
yes, on the server
What is your actual logic?
Does the generator need to be repaired 4 times?
no, there are 4 different generators that each need to be repaired
In your repair action.
In the "generator has been repaired"
Just set a variable on the generator (setVariable), make it public (like you did with the BIS_ thing at the top).
The variable says "generator is repaired"
In the holdAction condition put a check for if that variable is set, so that the hold action doesn't show for generators that are already repaired
ok
And then, also in your repair action, after all that, just have a list of all generators, and check if the variable has been set on each of them, if yes, they are all repaired and you can do that BIS_ setVariable thing that you did on pscore==4
but it doesnt need to be like _x generators are repaired, is that what youre doing
there's a race condition there, though it's probably pretty unlikely
^ that's what I'm doing here.
Each generator needs to be repaired
well yea, so I have that code I sent, but x4 for each different generator (g1, g2, g3, g4)
Or rather, each generator you put into that list to be checked at the end.
You can also do 4 out of 6 need to be repaired if you wanted to
Yeah my thing would mean you just add the same hold action, with the same code, to each generator
I think in holdAction you have the _target variable, which will be the generator the player is currently repairing.
Then you do
_target setVariable ["generatorRepaired", true, true]
on the when completed code?
Currently you have
"g1 say3D"
You can do "_target say3D" instead I think
Yeah
I can't look up the holdAction wiki page now
did you just make that?
yes
Yes awesome observation, but we don't care.
We are at beginner level here, doesn't care about advanced stuff.
to illustrate the synchronisation problems you will meet if you try to do this without involving a central authority
Please don't confuse a beginner with advanced stuff that will not actually matter, that's just confusing and counter productive
[
_myLaptop, // Object the action is attached to
"Hack Laptop", // Title of the action
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Idle icon shown on screen
"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_connect_ca.paa", // Progress icon shown on screen
"_this distance _target < 3", // Condition for the action to be shown
"_caller distance _target < 3", // Condition for the action to progress
{}, // Code executed when action starts
{}, // Code executed on every progress tick
{ _this call MY_fnc_hackingCompleted }, // Code executed on completion
{}, // Code executed on interrupted
[], // Arguments passed to the scripts as _this select 3
12, // Action duration [s]
0, // Priority
true, // Remove on completion
false // Show in unconscious state
] remoteExec ["BIS_fnc_holdActionAdd", 0, _myLaptop]; // MP compatible implementation```
this is what im going off of for that
hi, how can i loop a "playsound" ?
cause while + sleep doesn't work
i just think that this will be both simpler and more correct if the logic is all done on the server
Yeah.
In that code executed on completion, what is inside that _this?
It should have like, caller, target and stuff
params ["_target", "_caller", "_actionId", "_arguments"];```
while plus sleep does work.
Why does it not work?
Yes! You need that line of code.
Copy that into the first line of your "on completion" code
im doing execVm when the action is completed. In execvm, i have the if statement
initPlayerLocal.sqf
player addEventHandler ["InventoryClosed",
{
if ("G_AirPurifyingRespirator_01_F" in goggles player) then
{
if (!(gas_mask_effect_sound_playing)) then
{
gas_mask_effect_sound_playing = true;
"gas_mask" cutRsc ["RscCBRN_APR", "PLAIN", -1, false]; //Overlay on
while {true} do
{
gas_mask_effect_sound = playSound "gas_mask_effect";
sleep 15;
};
};
} else
{
if (gas_mask_effect_sound_playing) then
{
boucle = false;
deleteVehicle gas_mask_effect_sound;
gas_mask_effect_sound_playing = false;
"gas_mask" cutText ["", "PLAIN"]; //Overlay off
};
};
}];
And i have an error for my while
Then put that line into the first line of the script you're execVM'ing
yes
[
g1,
"Repair Generator",
"",
"",
"_this distance _target < 2",
"_caller distance _target < 2",
{_caller playMoveNow "Acts_carFixingWheel";},
{},
{
params ["_target", "_caller", "_actionId", "_arguments"];
titleText ["Generator has been repaired", "PLAIN", 2];
pscore = pscore + 1;
g1 say3D "s2";
titleFadeOut 5;
},
{
_caller switchMove "AmovPercMstpSrasWpstDnon";
},
[],
25,
0,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", 0, g1];```
like this?
Eventhandlers are unscheduled scripts.
The game freezes while that script runs.
So you can't sleep, you would literally just freeze the game for 15 seconds.
Put a
[] spawn {...}
Around your while loop
Yes.
Now replace "g1 say3D"
With
"_target say3D"
And then after they you can setVariable on _target to remember them it's been prepared
hm, is there a way to shrink it so i only need 1 copy of this code for all 4 generators
like this :
[] spawn
{
while {true} do
{
gas_mask_effect_sound = playSound "gas_mask_effect";
sleep 15;
};
};
Yes that's what I just told you with using _target
well yes, but what do I replace g1 at the beginning with, which identifies which object to add the holdaction onto
Keep in mind though that this will keep playing even after you take the mask off again. You probably want to check if the mask is still on, inside the while loop conditions
wait would it be
_this
Put your hold action add into a
{ ... } forEach [g1, g2, g3, g4]
Then use _x instead of g1 on the top of your holdAction thing
That will run the code inside the {} 4 times for each thing in that list, and set _x to the thing it's currently running
yes i have make a loop variable to check it. Do you think I would have problems in multiplayer with this type of variable?
params ["_player", "_didJIP"];
gas_mask_effect_sound_playing = false;
loop = true;
player addEventHandler ["InventoryClosed",
{
if ("G_AirPurifyingRespirator_01_F" in goggles player) then
{
if (!(gas_mask_effect_sound_playing)) then
{
gas_mask_effect_sound_playing = true;
"gas_mask" cutRsc ["RscCBRN_APR", "PLAIN", -1, false]; //Overlay on
[] spawn
{
while {loop} do
{
gas_mask_effect_sound = playSound "gas_mask_effect";
sleep 15;
};
};
};
} else
{
if (gas_mask_effect_sound_playing) then
{
loop = false;
deleteVehicle gas_mask_effect_sound;
gas_mask_effect_sound_playing = false;
"gas_mask" cutText ["", "PLAIN"]; //Overlay off
};
};
}];
okay..... my brain, i will try, but it wont be right
No that should work fine
{
[
_x,
"Repair Generator",
"",
"",
"_this distance _target < 2",
"_caller distance _target < 2",
{_caller playMoveNow "Acts_carFixingWheel";},
{},
{
params ["_target", "_caller", "_actionId", "_arguments"];
titleText ["Generator has been repaired", "PLAIN", 2];
pscore = pscore + 1;
_target say3D "s2";
titleFadeOut 5;
},
{
_caller switchMove "AmovPercMstpSrasWpstDnon";
},
[],
25,
0,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", 0, _x];
} forEach [g1, g2,g3, g4]```
and it's "performance friendly" ?
Doesn't matter, could be better but don't worry about it
is the params still in the right place for that??
so with around 30 players it's gonna be good
But Greg you shouldn't call your variable "loop", if any other script does the same, it will break yours.
Name it something unique.
Like "greg_gasmaskloop"
That's all correct.
got it i miss this part ๐
You don't need the pscore anymore but doesn't really matter
i think im going to move that to another file with the if statement. It will be a file thats called every time the generator is repaired so it will have like the text and stuff as well probably
The script only runs locally, for each player.
There is no multiplayer interaction really
And then add the setVariable that the generator is repaired to it.
And the check at the end if all generators have their variable set, to then set that BIS_ variable you wanted.
pscore = pscore + 1;
if (pscore == 4) then {escape setVariable["bis_disabled_Door_1",0,true]}; ```
isn't this also acceptable?
yes so all players get the sound playing but only on their machine so if i take off my mask my friend gonna have his sound ?
You'll put that escape setVariable stuff into your repair completed part.
And the other pscore part will go away
Yes, if i understand that code right
I assume playSound is not global, pretty sure it isn't
It's Local execution right
perfect
and how could I have improved it?
just to know how I could do better next time

ok @still forum
{
[
_x,
"Repair Generator",
"",
"",
"_this distance _target < 2",
"_caller distance _target < 2",
{_caller playMoveNow "Acts_carFixingWheel";},
{},
{
params ["_target", "_caller", "_actionId", "_arguments"];
titleText ["Generator has been repaired", "PLAIN", 2];
_target say3D "s2";
titleFadeOut 5;
_x setVariable ["repaired", true];
execVM "repaired.sqf";
},
{
_caller switchMove "AmovPercMstpSrasWpstDnon";
},
[],
25,
0,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", 0, _x];
} forEach [g1, g2, g3, g4]```
```sqf
if ("repaired" getVariable [g1, g2, g3, g4]) then {escape setVariable["bis_disabled_Door_1",0,true]}; ```
it's the best way ๐
Your else checks if gas effect sound playing, you don't need to check that.
You are already in the "else" part of your if, you can only get there if effect sound playing was already set to true.
You probably don't want to check if that classname is in goggles player, you want to check if it's equal to the goggles of player.
So isEqualTo instead of in
That spawn and while loop, do you have CBA? With CBA that can easily be made more efficient and more precise (looping exactly every 15 seconds, instead of +/- one second or so)
_numberOfRepairedGenerators = [g1, ..., g4] count { condition }
yes i have cba
In that condition, you do getVariable on _x.
And put a default value of false for your getVariable.
That will count the number of generators, that have the repaired variable set to true. And if that number is 4...
I'm on my phone i can't look up their wiki 
What you would do instead of that spawn and while loop, would be a CBA_fnc_waitAndExecute.
And in the code, restart the waitAndExecute again
I don't know the exact syntax of it
For the repaired variable? No.
Use true/false
Instead of numbers
very interesting i will check it out. I've deleted the condition in my else and i've change "in" to "isequalto"
generatorsrepaired would have to be global
thank you very much it's very interesting
Yes.
I think I wrote that above
you had a _
and I can't replace that with repaired var
Nono, doesn't need to be, what I wrote is right
where would I define _numberOfGeneratorsRepaired
You only replace the condition in what I wrote, with the correct getVariable.
At the end of your completed code, or inside your execVMed thing
if (_generatorsrepaired = count [g1, g2, g3, g4]) then {escape setVariable["bis_disabled_Door_1",0,true]}; ```
Nono
Just do this part first.
With correct condition
would the condition be the getVariable [g1, g2, g3, g4]
No
_x is your generator (like we did on the holdAction with forEach)
Count, counts the number of times the condition returns "true"
And you want to know how many generators have the "repaired" variable set to true
i found this :
[{delayed code}, [params], delay] call CBA_fnc_waitAndExecute;
[{condition}, {code}, [params]] call CBA_fnc_waitUntilAndExecute;
so i know how to play the sound one time but how can i do for the loop ?
So you just getVariable from _x, the "repaired" variable.
like
[{gas_mask_effect_sound = playSound "gas_mask_effect"; gasmask_loop = true;}, [params], 15] call CBA_fnc_waitAndExecute;
[{gasmask_loop;}, {gas_mask_effect_sound = playSound "gas_mask_effect";}, [params]] call CBA_fnc_waitUntilAndExecute;
Only the waitAndExecute, not theWaitUntil.
What does the wiki say how are the params passed to the code
dedmen im not gonna lie im lost chief
Description
Executes a code once in unscheduled environment with a given game time delay. Note that unlike PFEH, the delay is in CBA_missionTime not diag_tickTime (will be adjusted for time accl).
Parameters
_function The function you wish to execute. <CODE>
_args Parameters passed to the function executing. (optional) <ANY>
_delay The amount of time in seconds before the code is executed. (optional, default: 0) <NUMBER>
Passed Arguments
_this Parameters passed by this function. Same as โ_argsโ above. <ANY>
_function = {
play sound
[_this, _this, 15] call waitAndExec
};
[_function, _function, 15] call waitAndExec
Please write a getVariable line.
Get variable from _x, var name is "repaired" and default value is false
[{_this}, [_this], 15] call CBA_fnc_waitAndExecute;
[{gas_mask_effect_sound = playSound "gas_mask_effect";}, [_this], 15] call CBA_fnc_waitAndExecute;
???
No, just like what I wrote.
You are missing _function, and you are passing _this wrongly
oh
_function = {
playSound "gas_mask_effect";
[_this, _this, 15] call CBA_fnc_waitAndExecute;
};
[_function, _function, 15] call CBA_fnc_waitAndExecute;
Yes.
And add the gas mask effect sound =
Variable thing
That will then efficiently and timed exactly to the frame run every 15 seconds
if (!(gas_mask_effect_sound_playing)) then
{
gas_mask_effect_sound_playing = true;
"gas_mask" cutRsc ["RscCBRN_APR", "PLAIN", -1, false]; //Overlay on
_function =
{
gas_mask_effect_sound = playSound "gas_mask_effect";
[_this, _this, 15] call CBA_fnc_waitAndExecute;
};
[_function, _function, 15] call CBA_fnc_waitAndExecute;
};
if (_x getVariable "repaired" = true)```
And after it ran, it restarts and waits another 15 seconds.
That's where you want to add your if(loop) then waitAndExecute check, so you can stop it
No.
Without the if, only the bare get variable and it's arguments, and no = true stuff
ok
You have only [] brackets, one underscore, " quotes and commas and letters
:D
[g1, g2, g3, g4] getVariable "repaired"```
There is no g1, g2, etc in here
so ```sqf
_x getVariable "repaired"
Yes
can that go in the execVM file tho?
But missing default value.
Check the getVariable wiki page on how you add a default value
ok
Later, first we'll write the script, then we can put it somewhere
The default value is important, because before a generator gets repaired, that variable doesn't exist, so it needs a default to fall back to
Good so that's your condition, now insert that into ^
ohhhhhhhhhhhhhhh
Lightbulb moment :D
_numberOfRepairedGenerators = [g1, g2, g3, g4] count {_x getVariable ["repaired", false];}```
Yep.
So now you are:
Out of this list of generators, counting, which generator has their "repaired" variable set to true.
And result is, number of repaired generators which is put in a variable.
Now, after this line.
You can put a
If number of generators repaired == 4 then...
And put there your other BIS_ setVariable
_numberOfRepairedGenerators = [g1, g2, g3, g4] count {_x getVariable ["repaired", false];}
if (_numberOfRepairedGenerators == 4) then {escape setVariable["bis_disabled_Door_1",0,true]};```
i dont have another one..?
The bis_disabled door one i meant
oh so thats what you meant
You are missing one semicolon before the if
At the end of the count line
And that block you then put into your execVMed script.
And then it should be all done
No
ok
now the only problem i have is :
when i put if ("G_AirPurifyingRespirator_01_F" isEqualTo (goggles player)) then {code} nothing start but the condition is true...
with in goggles player it's working fine

and in the debogage console it"s return true to this : "G_AirPurifyingRespirator_01_F" isEqualTo (goggles player)
Try putting debugging stuff in your code.
systemChat or hint, so you can follow your code while it runs
i'm just stupid
_player_goggles = goggles player;
if ("G_AirPurifyingRespirator_01_F" isEqualTo_player_goggles ) then
{code};
that the problem
_player_goggles is local so the condition can't know it
so know it's working fine...
thanks
@still forum so
the code works except for _x
since its in another file it doesnt recognize it like it does in forEach
what do I replace that with
can I just replace it with [g1, g2, g3, g4]
Paste your code? I'm having trouble following where you're at so far.
{
[
_x,
"Repair Generator",
"",
"",
"_this distance _target < 2",
"_caller distance _target < 2",
{_caller playMoveNow "Acts_carFixingWheel";},
{},
{
params ["_target", "_caller", "_actionId", "_arguments"];
titleText ["Generator has been repaired", "PLAIN", 2];
_target say3D "s2";
titleFadeOut 5;
_x setVariable ["repaired", true];
execVM "repaired.sqf";
},
{
_caller switchMove "AmovPercMstpSrasWpstDnon";
},
[],
25,
0,
true,
false
] remoteExec ["BIS_fnc_holdActionAdd", 0, _x];
} forEach [g1, g2, g3, g4]```
_numberOfRepairedGenerators = [g1, g2, g3, g4] count {[g1, g2, g3, g4] getVariable ["repaired", false]};
if (_numberOfRepairedGenerators == 4) then {escape setVariable["bis_disabled_Door_1",0,true]};```
getting an error on _x setVariable ["repaired...

wait so replace _x with _target
ok
what about the other instance. its in the other file after count and before getvariable
it was _x but i replaced it with an array
im going to change it back to see if there is still an error
wait
@still forum
what do i do
The stuff inside the execVM was correct
so _x there?
The _x there is set by "count"
ohhhh
count and forEach and apply and select and findIf all iterate over an array, and set _x to the current element
Oh maybe i mixed it up
It's probably
{} Count []
Instead of
[] Count {}
Just swap the sides
huh
Check wiki page for which is right 
well
the alternative
defintifely isnt correct
_numberOfRepairedGenerators = {g1, g2, g3, g4} count [_x getVariable ["repaired", false]];
if (_numberOfRepairedGenerators == 4) then {escape setVariable["bis_disabled_Door_1",0,true]};```
[g1,...] Goes to the end (like forEach)
And {_x...} Goes to the left
One argument is the list of things.
The other argument is the condition code
ok
_numberOfRepairedGenerators = _x count [[g1, g2,g3, g4] getVariable ["repaired", false]];
if (_numberOfRepairedGenerators == 4) then {escape setVariable["bis_disabled_Door_1",0,true]};```
@still forum
shoot
_numberOfRepairedGenerators = [g1, g2, g3, g4] count {_x getVariable ["repaired", false]};
if (_numberOfRepairedGenerators == 4) then {escape setVariable["bis_disabled_Door_1",0,true]};```
The stuff inside the [] and {} stays there, untouched
The [] and {} blocks just swap sides
o
k
_numberOfRepairedGenerators = {_x getVariable ["repaired", false]} count [g1, g2, g3, g4];
if (_numberOfRepairedGenerators == 4) then {escape setVariable["bis_disabled_Door_1",0,true]};

^
so good?
Try it

the first number of generator var turned blue
so theres that
ok
got no error on generator repaired
im going to do all of them and see
works like a charm
๐
So now that it's all working, back to the thing Untelo talked about
hm?
If two players, repair the last two generators at EXACTLY the same time, it will not work.
First player will see the second generator as not being done yet and thus not get == 4 at the end.
Second player will see the first Generator as not being done yet, and also not get ==4 at the end.
Because that repaired variable being transmitted around takes a bit of time
ok
But they need to do that so exactly on time that.. you don't need to worry about that to happen.
I'd say it's so extremely unlikely that it doesn't matter
what fix is needed though?
But that's something to at least keep in mind
thats true
Actually now that i think about it, it's really easy.
You can remoteExec your execVM, and run that on the server
doesnt it already run on the server?
No this code all runs on the clients
You send the repaired variable via the server to other players, but the code itself runs on the client
oh k
You are sending the repaired variable to the server, and the remoteExec.
In the problem case where two players do it exactly at the same time, a couple possible orderings can happen.
P1 setVariable
P1 execVM
P2 setVariable
P2 execVM
In that case, at the last execVM, both variables have been set.
P2 setVariable
P2 execVM
P1 setVariable
P1 execVM
Other way around, same result.
P1 setVariable
P2 setVariable
P1 execVM
P2 execVM
The final ==4 condition will run twice, doesn't matter in this case.
P2 setVariable
P1 setVariable
P1 execVM
P2 execVM
Same thing just mixed.
P2 setVariable
P1 setVariable
P2 execVM
P1 execVM
Mixed again, still same result.
But in every possible case now, it will have the correct end result
got it
so it doesnt really matter
@still forum can I ask if d1 setVariable["bis_disabled_Door_1",0,true] this is correct
d1 setVariable["bis_disabled_Door_1",0,true]```
If D1 is a house building thingy then i think yes
i cant find bis_disabled_Door_1 on the wiki though
If you run the execVM on the server, then all is good.
If you run it on the clients, it's possible that both P1 and P2 run in parallel and don't see each other's setVariable
It's just
Bis_disabled_door_doornumber
That's probably why you're not finding it, it's probably written differently.
Or it's possible that it's just not documented on the wiki at all :D
ah
so this code still works?
if (_numberOfRepairedGenerators == 4)
then {
d1 setVariable["bis_disabled_Door_1",0,true];
d1 setVariable["bis_disabled_Door_2",0,true];
};
Ye, that would be two different doors then that you are disabling
Well if the fence has a door, it's still a door :D
also I plan for the "power" that the generators provide open a lot of escape routes so
You can do a lot more stuff with your script now.
You can turn off lights n stuff
Not directly since triggers are an unscheduled environment. If you need sleep, then you need to put it inside a spawn code execution:
https://community.bistudio.com/wiki/spawn
ok
Is there some way to convert a string into something hintable?
Hint A; ```
works fine, but
```A = 1;
B = 2;
C = B+A;
hint C; ```
Gives a generic error (As C isnt surrounded by "")
and
```A = "1";
B = "2";
C = B+A;
Hint C;
Hints "12"```
So is there a way to convert these, so the math works and so does the hint?
check maybe