usbstuck
Member-
Content Count
11 -
Joined
-
Last visited
-
Medals
Community Reputation
10 GoodAbout usbstuck
-
Rank
Private First Class
Profile Information
-
Gender
Male
-
Location
Utrecht, Netherlands
-
Interests
Games, Arma scripting, web development (javascript), climbing.
Recent Profile Visitors
The recent visitors block is disabled and is not being shown to other users.
-
Dynamic getVariable in setWaypointStatements
usbstuck posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
I would like to access a variable with getVariable in setWaypointStatements. However, the variable name is dynamic, because I don't know how many variables there will be set. Referring to this post I came up with the following: params ["_group", "_pos", "_type", "_additionalStatements"]; private ["_wp", "_ref", "_refString"]; _wp = _group addWaypoint [_pos, 0]; _wp setWaypointType _type; // Make sure chopper lands on the spot _ref = "Land_HelipadCivil_F" createvehicle (_pos); // Save reference to Helipad on group leader _refString = "land_"+ str random [0, 5000, 10000]; _group setVariable [_refString, _ref, true]; hint format ["Reference to helipad: %1", _refString, _ref]; // Use reference on group leader to clean up Helipad after landing call compile format ["_wp setWaypointStatements [""true"", ""deleteVehicle ((group this) getVariable '%1'); %2""]", _refString, _additionalStatements]; (_wp) This works. But I have 2 objections: 1) It's not super-easy to read 2) Adding another format inside the statement (eg: `hint format ["%1", _someVar]` ) will break it. Does anyone know a better way? Thanks! **Edit: Actually objection #2 does work :rolleyes: . It was a different error I got... So basically the only thing that remains of the question is if it can be done neater. But hey, maybe I should just get used to it ;)- 1 reply
-
- getVariable
- setWaypointStatements
-
(and 1 more)
Tagged with:
-
Hi, I'd like to make contributions to the wiki (https://community.bistudio.com/wiki) but I only see a login link. Nowhere a link to register. Anyone know how?
- 1 reply
-
- wiki
- contribute
-
(and 1 more)
Tagged with:
-
Detect players entering and exiting area
usbstuck replied to usbstuck's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Thanks that cleared things up. Well, writing all that code, even though I might not use it now, at least gave me a thorough understanding of sqf :) -
Detect players entering and exiting area
usbstuck replied to usbstuck's topic in ARMA 3 - MISSION EDITING & SCRIPTING
I did read the post on your blog. Your blog is a great resource btw, cheers. Your code above is awesomely simple, but do I understand it correctly if this will be executed on every users computer? The command reference states this: In terms of performance, wouldn't it be better to create all triggers on the server? Still, I might have focussed on this too much, especially since your code is written in a fraction of the time that I spend writing mine.. :) -
Detect players entering and exiting area
usbstuck replied to usbstuck's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Eventually got it to work using Schatten's suggestion. Still had to do a lot of coding though! Thanks all for the help If ur interested, this is the result: Referenced function arrayFindByFirstIndex.sqf: -
Detect players entering and exiting area
usbstuck replied to usbstuck's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hmm looks like that would considerably reduce my current code.. (still a lot to learn) triggerAttachVehicle seems to take an array, so I could add an array of all playables. Will this trigger deactivation for each? Well guess I find out tonight. Thanks Killzone_Kid! -
Detect players entering and exiting area
usbstuck replied to usbstuck's topic in ARMA 3 - MISSION EDITING & SCRIPTING
Thanks Schatten, I'll give that a try! It's probably best though to combine it with a trigger and onAct check if there's a player in the trigger/marker area. Otherwise I'd have to continuously do the check and that feels like a waste of system resources. -
Detect players entering and exiting area
usbstuck posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi all, I'm trying to figure out the best way to keep track of players (MP compatible) entering and exiting an area. When they are entering I want to add actions to the unit, when exiting i want to remove them. I've been fiddling around with triggers for the better part of yesterday :) but it's quite tricky. I wonder if a trigger is actually the best way to do this, because the onDeactivation will only fire if all units are out of the area.. To sum up, my questions: - Is a trigger the right tool? - If it is, how can I fire the deactivate trigger for units leaving the area? (see all the way below @ PROBLEM) More info: Currently I'm not at home so I can't share the code I have so far, but I'll write it down in pseudo code below: (the adding part works) UNITS_IN_AREA = []; RESET_TRIGGER = true; // this makes it repeatable areaTrigger = [Repeating trigger set in mission builder, so it has static position and triggerArea] areaTrigger condition = ({_x in thisList} count (playableUnits + switchableUnits) > 0) && RESET_TRIGGER areaTrigger onActivation = [thisList] call addScript.sqf; RESET_TRIGGER = false; // bottom of addScript sets RESET_TRIGGER = true; areTrigger onDeactivation = [thisTrigger] call removeScript.sqf; addScript.sqf - adds units in thisList to UNITS_IN_AREA - adds actions to the units removeScript.sqf - should remove units from UNITS_IN_AREA that are no longer in the trigger area - should remove actions from these units PROBLEM: Issue here is we don't have a thisList magic variable. A workaround is using nearestObjects with range of triggerArea, but range is circular and a trigger can be ellipse or rectangular -
how to pass _forEachIndex as parameter?
usbstuck replied to usbstuck's topic in ARMA 3 - MISSION EDITING & SCRIPTING
*crunch crunch*... aaah. That actually makes sense. Cheers! -
how to pass _forEachIndex as parameter?
usbstuck posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hi all, Can anyone tell me how I can get this to work? When using radio command "BRAVO" the expected result is a hint with "yada 1 yada". However, it seems _forEachIndex is not passed properly. What I'm getting is "yada any yada". When I try to get the typeName, the result is an empty string... eg: hint format ["yada %1 yada", typeName (_this select 0)]; showId = { hint format ["yada %1 yada", _this select 0]; }; // Triggers _triggers = []; { _tr = createTrigger ["EmptyDetector", position player]; _tr setTriggerActivation [_x, "PRESENT", true]; _tr setTriggerStatements ["this", "[_forEachIndex] spawn showId", ""]; _triggers = _triggers + [_tr]; } forEach ["ALPHA", "BRAVO", "CHARLIE", "DELTA"]; -
Hi all, I just signed up and accepted the Forum Rules. However, I'm not able to post a new thread! I'd like to ask a question in the Editing and scripting forum, but there's no "New thread" button.. Can anyone explain what I need to do? I must have missed something.. ##edit: maybe this just took time... the button is there now. strange.