-
Content Count
648 -
Joined
-
Last visited
-
Medals
-
remoteExec addEventHandler
mrcurry replied to Robustcolor's topic in ARMA 3 - MISSION EDITING & SCRIPTING
@RobustcolorFrom the biki: So short answer is yes you need to add it to all pcs to cover all possible shooters- 1 reply
-
- 1
-
Neat! You know, you could just say that it's the users responsibility to verify that the trigger exists before it's defined like that... 😛 But incase you don't wanna go that route I'd go with requesting the variable name of the trigger or target as a string instead and then at the start of your loop where you validate the list read from missionNamespace to get the reference and update the input array with the correct value. Any code after won't know the difference. Example: Assume _inputArray contains the list to validate. { if( _x isEqualType "" ) then { if( isNil _x ) then { // It's not a valid variable name, either throw an error or handle it as regular string } else { // It's a valid variable, get the value private _val = missionNamespace getVariable _x; // Here you could do further validation that _val contains an expected value i.e. it's an Object. _x = _val; // set local ref for further validation in the loop _inputArray set [_forEachIndex, _val]; // set array ref for use later in the script }; }; // Handle _x == Object and _x == Number after } forEach _inputArray;
-
Now we're getting somewhere. The error message is quite clear. It's not your condition checking that's the problem. It errors on this line: [BLUFOR, [CSWR_spwnsBLU], CSWR_group_BLU_light, _form_BLU_2, _be_SAFE, [_move_ANY], [this_trigger_doesnt_exist]] call THY_fnc_CSWR_add_group; cause when you "set the trigger" you build an array like this: [this_trigger_doesnt_exist] This essentially does two operations in order: Read value from variable "this_trigger_doesnt_exist" Create an array and insert said reference in the first index. In step 1 if the variable is nil (undefined) you will be reading the value from an undefined location in memory. In essence you are asking "What's in the box?" and the game goes "What box?" and throws the error. You simply cannot do that directly. So what to do? That depends on what your requirement is. Do you know what the trigger will be named? Great. Just use getVariable to retrieve the value with a reasonable default e.g. objNull. Use isNull to verify the quality of the input. Is the trigger input by the user? Have the user input a string instead/as well and parse it, getVariable is your friend here too. Is the value set by another script? Prior to creating the array verify that the expected variable is actually defined using isNil "variable_name".
-
This is why describing the whole scenario from the get go is useful. There are many ways to skin a programmable cat. 🙂 Hmm, isNil "_x" should work... Try just checking if the value is undefined using: isNil { _x } as the condition. Just curly brackets and no stringification needed. If that fails I'm gonna have to boot up the game for some tests. If you're parsing "user input" to your function you can use param to retrieve the value instead like so: _x = _spwnDelayMethods param [_forEachIndex, objNull]; This way _x will fall back to objNull if its undefined. Put that at the start of your loop and you can just check isNull _x and do comparisons with isEqualX commands etc. Nice and clean.
-
Either: _array = ["this_trigger_doesnt_exist"]; { if( isNil _x ) then { // Trigger doesn't exist, do what you must } else { // Trigger exists, we can get the reference using: private _trigger = missionNamespace getVariable _x; }; } forEach _array; Or: _array = ["this_trigger_doesnt_exist"]; { private _trigger = missionNamespace getVariable [_x, objNull]; if( isNull _trigger ) then { // Trigger doesn't exist } else { // Trigger exists }; } forEach _array;
-
profileNameSpace shenanigans
mrcurry replied to dupa1's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Correct, the described behaviour is the main difference between reference types (arrays and hashmaps) and value types (scalars). This actually a pretty common feature in many languages and is not unique to SQF. -
profileNameSpace shenanigans
mrcurry replied to dupa1's topic in ARMA 3 - MISSION EDITING & SCRIPTING
This has nothing to do with profileNamespace specifically. This is cause you are setting the profileNamespace-variable "saveData" to the same data in memory as scoresArray points to. Remember: array variables are just reference holders to sequences of data. set updates the data inplace. In your second version your are creating a new array in memory using _tempArr = []; and then you essentially copy the data to it, hence the problem disappears. An example: a = [1]; // "[]" creates the array in memory and returns the address to it, then "a =" defines the variable "a" and assigns the address to it. b = a; // "b" now contains the same adress as "a", both variables point to the same data b pushback 2; // adds an element to the data, "a select 1" would return 2. Edit: Note that since profileNamespace is essentially a loaded copy of the contents of the profile-file on the harddrive you would still have to use saveProfilenamespace again after you update the scores to save the changes to harddrive. -
createUnit alternative syntax init broken?
mrcurry replied to dragonmalice's topic in ARMA 3 - MISSION EDITING & SCRIPTING
this should be doing nothing at best or throw an error at worst. Have you enabled -showScriptErrors on your A3 launcher / startup parameters? -
Question: When knowsAbout is high - AI won't follow WP?
mrcurry replied to scottb613's topic in ARMA 3 - MISSION EDITING & SCRIPTING
@scottb613https://community.bistudio.com/wiki/forgetTarget -
Behaviour of ceil after 2.18 random "fix"?
mrcurry replied to krzychuzokecia's topic in ARMA 3 - MISSION EDITING & SCRIPTING
This depends entirely on the use case. If a uniform distribution is required, meaning all outcomes have equal chance to occur, you need a different approach. For a proper uniform random range use: _rand = _min + floor random (_max - _min); Above _max is exclusive and won't be included, if you need inclusive _max use: _rand = _min + floor random (_max - _min + 1); These are both guaranteed to never generate value below _min. It's ofc ok to precompute the brackets into a variable and use that as input to the random call. -
BIS_fnc_holdActionAdd not working in Multiplayer?
mrcurry replied to MajorBlunderbuss's topic in ARMA 3 - MISSION EDITING & SCRIPTING
If this fixed the issue one of the logic tests in the previous conditions obviously failed. To know for sure you'd have test them individually and see which one returns false. I'd do that before attempting a further fix. -
How to get an array of enemy groups spotted by a side
mrcurry replied to Blitzen88's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I can think of two ways. Method 1: For each group of detecting side, command: groups playerSide Call command targets on the current group Use the result to create your marker Method 2: For each group of the detecting side Add an "EnemyDetected" event handler In the event handler add your marker If you need information on the enemy you can use _groupLeader targetKnowledge _target These methods doesn't include how you track markers, check if an object has a marker or delete markers that are no longer relevant. If you want it, here's how I'd solve that: Edit: Oops, just realized you wanted groups, but the logic should be easy to extend to manage detected groups instead of individual units. The key is to remember that AI doesn't see groups, they see units. Groups are just an abstract composition, so you have decide what it means to "create a marker on the group". Do you mark the group leader's position or the average position of all units in the group? Do you include units that aren't detected yet? Do you interpret clusters of units as s group or rely on the game's predetermined groups. -
A question about using either player selected face or force unique face on player in a large scale single player mission
mrcurry replied to MrPibb47's topic in ARMA 3 - MISSION EDITING & SCRIPTING
My 2 cents: Tell the story you want to tell. Make the mission you want to play. If your goal is a specific narrative then a given character makes more sense. The vanilla and Laws of War campaigns are good examples of this. This requires some solid writing though and I would recommend running any script or story by a trusted friend or partner for feedback. -
scripting Help! My script should be working! Various errors with "variable undefined"
mrcurry replied to Justin Bowes's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I've been doing SQF since Arma 2... Hundreds if not thousands of hours spent looking on the BIKI... and today I learned the BIKI has dark themes... F M L Edit: Right maybe I should contribute something useful... Only thing I see is that _unit isn't defined in what you posted.Something like: params["_unit"]; at the start of EliteOrNot.sqf should do the trick.- 15 replies
-
- 2
-
- errors
- new to scripting
-
(and 1 more)
Tagged with:
-
Spawning units that show up in the lobby
mrcurry replied to Luft08's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I'm fairly sure that lobby slots are derived from the mission sqm, so No... but I also haven't tried. If someone has succeeded please do tell. In the meantime your best bet is to place playable units and move them into the correct seat as the player loads in (initPlayerLocal). You can hide it behind a loading screen if you wish, the player won't know the difference if you do it right.