Search the Community
Showing results for tags 'sqf files'.
Found 1 result
-
Patrol Script - Need to pass Object as a param
MrGamer100 posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hey there! I've begun learning SQF scripting around a week ago, so still quite the newbie. I've been reading through the Fockers tutorial series (which I have yet to finish), and decided to try and get some practical experience making something, since that's the best way I learn code. My friend, who makes missions and does zeus stuff, suggested I make a patrol script. I liked the idea, and went along with trying to make a patrol script callable by execVM, accepting the calling unit and an array of Markers as parameters. The script works by sending the entire group to those markers assuming the group still exists and there's at least one unit alive in it. If the marker they are about to head to does not exist, the marker is deleted from the array and the loop starts from the beginning until a valid marker exists. Irrelevant at this point as I can't test to make sure that actually works, since I can't seem to get an object param passed to the file. It looks like it only accepts arrays, which I am having trouble understanding. So I need to solve this one of two ways: I need to find a way to pass an object as a parameter and keep it intact when it reaches the function. Or, I need to find a way to take the array sent as the unit, and turn it back in to the object, which I don't know how to do. This script is meant to be multiplayer friendly (despite me not having the slightest clue of how to code it for multiplayer) so please keep that in mind with the solution. My goal is not to just come to a solution to fix my issue, but to understand why it works, since I'm trying to learn SQF and understanding what the code is doing and why will help me advance in that goal. I appreciate the help and can try to give as much information as I can when asked. This is in the team leader's init box: patrolArray = [patrolMarker1, patrolMarker2, patrolMarker3]; PatrolScriptHandle = [this, patrolArray] execVM "Patrol.sqf"; This is the Patrol.sqf: // Patrol.sqf // Parameters: // 0: (Object) Unit // 1: (Array) Markers params ["_unitObject", "_markerArray"]; debugPatrolRunning = True; // Use this only for debug purposes to see if the script is still running. _unitMarkerPatrolArray = _this select 1; _patrolArrayCount = (count _unitMarkerPatrolArray) - 1; _unitGroup = group _this select 0; _shouldRun = True; while (_shouldRun) do { scopeName "patrolCheck"; sleep 0.1; for "_i" from 0 to _patrolArrayCount do { _unitsAlive = {alive _x} count units _unitGroup; _curMarkerSelection = _unitMarkerPatrolArray select _i; if ( isNull _curMarkerSelection ) then { _tempA = [_curMarkerSelection]; _unitMarkerPatrolArray = _unitMarkerPatrolArray - _tempA; _tempA = nil; breakTo "patrolCheck"; }; if ( _unitsAlive >= 1 && {!isNull _unitGroup} ) then { // I don't think I can use the Marker object itself in getMarkerPos, so let's convert it to string first. _curMarker = format ["%1", _curMarkerSelection]; _unitGroup move getMarkerPos _curMarker; sleep random [3, 5, 10]; } else { _shouldRun = False; debugPatrolRunning = False; breakOut "patrolCheck"; }; }; };- 5 replies
-
- scripting
- troubleshooting
- (and 4 more)