Jump to content

Search the Community

Showing results for tags 'array'.



More search options

  • Search By Tags

    Type tags separated by commas.
  • Search By Author

Content Type


Forums

  • BOHEMIA INTERACTIVE
    • BOHEMIA INTERACTIVE - NEWS
    • BOHEMIA INTERACTIVE - JOBS
    • BOHEMIA INTERACTIVE - GENERAL
  • FEATURED GAMES
    • Arma Reforger
    • Vigor
    • DAYZ
    • ARMA 3
    • ARMA 2
    • YLANDS
  • MOBILE GAMES
    • ARMA MOBILE OPS
    • MINIDAYZ
    • ARMA TACTICS
    • ARMA 2 FIRING RANGE
  • BI MILITARY GAMES FORUMS
  • BOHEMIA INCUBATOR
    • PROJECT LUCIE
  • OTHER BOHEMIA GAMES
    • ARGO
    • TAKE ON MARS
    • TAKE ON HELICOPTERS
    • CARRIER COMMAND: GAEA MISSION
    • ARMA: ARMED ASSAULT / COMBAT OPERATIONS
    • ARMA: COLD WAR ASSAULT / OPERATION FLASHPOINT
    • IRON FRONT: LIBERATION 1944
    • BACK CATALOGUE
  • OFFTOPIC
    • OFFTOPIC
  • Die Hard OFP Lovers' Club's Topics
  • ArmA Toolmakers's Releases
  • ArmA Toolmakers's General
  • Japan in Arma's Topics
  • Arma 3 Photography Club's Discussions
  • The Order Of the Wolfs- Unit's Topics
  • 4th Infantry Brigade's Recruitment
  • 11th Marine Expeditionary Unit OFFICIAL | 11th MEU(SOC)'s 11th MEU(SOC) Recruitment Status - OPEN
  • Legion latina semper fi's New Server Legion latina next wick
  • Legion latina semper fi's https://www.facebook.com/groups/legionlatinasemperfidelis/
  • Legion latina semper fi's Server VPN LEGION LATINA SEMPER FI
  • Team Nederland's Welkom bij ons club
  • Team Nederland's Facebook
  • [H.S.O.] Hellenic Special Operations's Infos
  • BI Forum Ravage Club's Forum Topics
  • Exilemod (Unofficial)'s General Discussion
  • Exilemod (Unofficial)'s Scripts
  • Exilemod (Unofficial)'s Addons
  • Exilemod (Unofficial)'s Problems & Bugs
  • Exilemod (Unofficial)'s Exilemod Tweaks
  • Exilemod (Unofficial)'s Promotion
  • Exilemod (Unofficial)'s Maps - Mission Files
  • TKO's Weferlingen
  • TKO's Green Sea
  • TKO's Rules
  • TKO's Changelog
  • TKO's Help
  • TKO's What we Need
  • TKO's Cam Lao Nam
  • MSOF A3 Wasteland's Server Game Play Features
  • MSOF A3 Wasteland's Problems & Bugs
  • MSOF A3 Wasteland's Maps in Rotation
  • SOS GAMING's Server
  • SOS GAMING's News on Server
  • SOS GAMING's Regeln / Rules
  • SOS GAMING's Ghost-Town-Team
  • SOS GAMING's Steuerung / Keys
  • SOS GAMING's Div. Infos
  • SOS GAMING's Small Talk
  • NAMC's Topics
  • NTC's New Members
  • NTC's Enlisted Members
  • The STATE's Topics
  • CREATEANDGENERATION's Intoduction
  • CREATEANDGENERATION's HAVEN EMPIRE (NEW CREATORS COMMUNITY)
  • HavenEmpire Gaming community's HavenEmpire Gaming community
  • Polska_Rodzina's Polska_Rodzina-ARGO
  • Carrier command tips and tricks's Tips and tricks
  • Carrier command tips and tricks's Talk about carrier command
  • ItzChaos's Community's Socials
  • Photography club of Arma 3's Epic photos
  • Photography club of Arma 3's Team pics
  • Photography club of Arma 3's Vehicle pics
  • Photography club of Arma 3's Other
  • Spartan Gamers DayZ's Baneados del Servidor
  • Warriors Waging War's Vigor
  • Tales of the Republic's Republic News
  • Operazioni Arma Italia's CHI SIAMO
  • [GER] HUSKY-GAMING.CC / Roleplay at its best!'s Starte deine Reise noch heute!
  • empire brotherhood occult +2349082603448's empire money +2349082603448
  • NET88's Twitter
  • DayZ Italia's Lista Server
  • DayZ Italia's Forum Generale

Find results in...

Find results that contain...


Date Created

  • Start

    End


Last Updated

  • Start

    End


Filter by number of...

Joined

  • Start

    End


Group


Website URL


Yahoo


Jabber (xmpp)


Skype


Biography


Twitter


Google+


Youtube


Vimeo


Xfire


Steam url id


Raptr


MySpace


Linkedin


Tumblr


Flickr


XBOX Live


PlayStation PSN


Origin


PlayFire


SoundCloud


Pinterest


Reddit


Twitch.Tv


Ustream.Tv


Duxter


Instagram


Location


Interests


Interests


Occupation

Found 42 results

  1. Is any way to delete all links to array (for it would be removed from memory by cleaner) having only 1 link to it, ex: a=[0,1,2,3,4,5,6,7,8,9]; a1=a; //forgeting a; |delete| a1; isnil'a'==true
  2. I have a short question: Is there a new simpler way to use arrays with multiple values in preprocessor commands? The old way was: #define COMMA , #define EXAMPLE(farg,sarg) EXAMPLE2(farg, sarg) EXAMPLE("foo", ["bar" COMMA "othervalue"]); I would like to find a way to use the normal syntax with just EXAMPLE("foo", ["bar", "othervalue"]);. Is it possible with some tricks maby?
  3. Hello everyone, here is a really simple function that I put together: /* Author: Terra Description: Converts the elements of an array into a string Parameter(s): 0: ARRAY - array of elements of any type 1 (Optional): STRING - seperator between elements (default: ", ") Returns: STRING */ params [ ["_array", [],[[123]]], ["_seperator", ", ", ["123"]] ]; _str = format ["%1", _array select 0]; { private _addString = _x; if (typeName _addString != typeName "123") then {_addString = str _addString}; _str = _str +_seperator +_addString; } forEach (_array -[_array select 0]); _str Just some code that I wrote down while working on another project. Feel free to modify and comment.
  4. Edit: Nvm close this please. i just fixed the dedicated server issue (forgot to do an isDedicated check) so now putting the script in the vehicle init isn't required. Hey guys, i've been away from the ArmA scene for a while but it's all coming back pretty quick. I feel like ArmA is lying to me; in the init of a vehicle i have the following: nul = [this] execVM "scripts\mhq\respawnmhq.sqf"; and the first two lines of respawnmhq.sqf are: _mhqveh = _this select 0; _vehiclepos = getPos _mhqveh; So then when i launch the mission to test in the editor it has the gall to say respawnmhq.sqf has an: "Error getpos: Type Array, expected Object,Location". Correct me if I'm wrong, but there is no damn array in there right? [this] is an array with a single item from what i know but it's in the vehicle init not the script, _mhqveh is defined as the 'this' from within the array so is that causing it to think _mhqveh is an array? If so is there another way to execVM that script from the vehicle init? I'm doing this to avoid putting this script in the Init.sqf because really it doesn't need to go in there and if i do that it activates twice on dedicated servers but that's another issue entirely (which I'm pretending doesn't happen).
  5. Hi, i need to know if i can detect what player is executing the script, and then depending of the name of the player send it to the box. thanks for support!!! _fnc_group = [["player_1", box_1], ["player_2", box_2]]; _fnc_select = (_fnc_group select 0) select 1; if (cash< 100) then { hint "no money to buy this!" } else { cash = cash - 100; _fnc_select addWeaponCargoGlobal ["rhs_weap_m4a1_blockII_bk", 1]; _fnc_select addMagazineCargoGlobal ["rhs_mag_30Rnd_556x45_Mk318_Stanag", 1]; hintSilent parseText format["<t color='#00FF3C'>thanks for for you buy</t>"]; };
  6. I am trying to get a function to spawn from the init box of a logic unit that is created in front of about a dozen select enemy soldiers in a base. The idea is that the logic unit has a virtual box around it that set the players captive status from true to false to simulate an AI vision cone. The issue I am having is that the way the script is written is such that once it is called it spawns this logic unit for all units assigned to a given side. This isn't ideal because the stealth segment is only one objective in the whole mission and calling the stealth script has the effect of permanently handicapping all OPFOR in the entire operation. Since I haven't been able to figure out how to get the code to delete the logic units properly and return the AI to full "intelligence" I was hoping to just assign the function to certain units. I just can't seem to figure out how to get the array to work properly. The original code is: _enemyArray = []; _i = 0; {if (side _x == east) then {_enemyArray set [_i, _x]; _i = _i + 1};} forEach allUnits; _center = createCenter sideLogic; _group = createGroup _center; player setCaptive true; for "_j" from 0 to (count _enemyArray) - 1 step 1 do { "Logic" createUnit [position (_enemyArray select _j), _group, "this AttachTo [(_enemyArray select _j), [0,25,0.5]]; _anythi = [_enemyArray select _j, this] spawn _fex_fnc_patrol;"]; sleep 0.1; }; As you can see all the units on side == east are assigned an index in the array and then all of those index's have a logic unit spawned at a specific offset which then calls the function from it's init box. I figured that simply removing lines 2 and 3, which index all units from the opfor side in the array, then change the code to this: _enemyArray = [patrol1, patrol2, patrol3, patrol4, patrol5, patrol6, sentry1, sentry2, sentry3]; _center = createCenter sideLogic; _group = createGroup _center; for "_j" from 0 to 9 do {player setCaptive true; "Logic" createUnit [position (_enemyArray select _j), _group, "this AttachTo [(_enemyArray select _j), [0,14,0.5]]; _anythi = [_enemyArray select _j, this] spawn _fex_fnc_patrol;"]; sleep 0.1; }; would work. Unfortunately what seems to happen is that either the logic unit does not spawn at all which results in the player being permanently set to captive of the code throws an error that the "Logic" createUnit command requires 3 elements and I provided 0. Im super confused, can anyone help??
  7. Hello everyone. I don't know how to desribe my problem in the title, my English isn't good enough on that.. I want let the script to randomly pick a marker. My problem is that the markers are being created dependant on the amount of towns on the map. It detects all towns and creates an invisible marker at each, with name "Mark_1", "Mark_2", etc... I need to know how can I let my script at first count all created markers (as each map has a different amount of villages) and then randomly pick one of these markers. The markers are being created as follows (a part of the script): towns.sqf /* Location finder for towns, villages and cities Places triggers and/or markers at these locations */ // Get each locations of villages or cities and create trigger/marker // Original script for finding locations by BrotherhoodOfHam // Final script by Godis if (!isServer) exitWith {}; //#define MARK #define OFFSET 0 _locations = (nearestLocations [[0,0,0], ["NameCity", "NameVillage", "NameCityCapital"], 40000]); { _xy = size _x; _trig = createTrigger ["EmptyDetector", position _x]; _trig setTriggerArea [ (_xy select 0) + OFFSET, (_xy select 1) + OFFSET, direction _x, false ]; _trig setTriggerActivation [ "WEST", "PRESENT", true ]; _trig setTriggerStatements [ "this", "hint 'Entered Village: Watch out in this area';", "hint 'Leaving Village...';" ]; //#ifdef MARK _mkr = createMarker [format ["Mark_%1", _forEachIndex], position _x]; _mkr setMarkerShape "ELLIPSE"; _mkr setMarkerAlpha 0.0; _mkr setMarkerSize [ (_xy select 0) + OFFSET, (_xy select 1) + OFFSET ]; //#endif } forEach _locations; // Now place units I thought I could just add a counter to towns.sqf, so I would get the total amount of all created markers stored in a variable, like: all_markers = 0; // Content of towns.sqf here (create markers) all_markers = all_markers + 1; // count each marker and store number in 'all_markers' But this would need another check for this variable's value, and also another code to select one of them according to the amount of created markers. I think it's kind of inconvenient. There must be another easier way to archive that, I guess. Is there any code I can use to get that in only a few lines? At the end I just need to: 1. find the amount of markers with name Mark_1, Mark_2, Mark_3, etc, etc 2. Randomly select one of these (i.e. to make it visible by setMarkerAlpha or sth else) Thanks in advance.
  8. With @Larrow's assistance, I was able to hash out the program I wanted to manage my soldiers with addAction menus. I will create a mod thread when I have the vehicle assignment actions added. Full script: myGrps = []; myGrps resize 10; myGrps = myGrps apply { [ grpNull ] }; TAG_fnc_hasBlankHC = { _bool = false; { _x params[ "_HCGrp", "_HCActionID" ]; if ( isNull _HCGrp ) exitWith {_bool = true;}; }forEach myGrps; _bool; }; TAG_fnc_isLastHCMan = { _bool = false; { _x params[ "_HCGrp", "_HCActionID" ]; if (( Group cursorTarget isEqualTo _HCGrp ) && {{ alive _x }count units _HCGrp isEqualTo 1}) exitWith {_bool = true;}; }forEach myGrps; _bool; }; TAG_fnc_JoinFunction = { _unit = _this select 0; _grp = _this select 1; _str = _this select 2; //accepting variable "unit or from Group" and "target group" if (_str == "unit") then { [_unit] joinSilent _grp; }else { { [ _x ] joinSilent _grp; }forEach units _unit; }; _leader = Leader _grp; { if(!(_leader isEqualTo _x) && {(rankId _x) > (rankId _leader)}) then { _leader = _x; }; }forEach units _grp; _grp selectLeader _leader; }; TAG_fnc_createNewHCGroup = { params[ "_unit", [ "_create", true ], [ "_wholeGroup", false ] ]; _CompanyNames = ["CompanyXray","CompanyNovember","CompanyNovember","CompanyNovember","CompanyNovember","CompanyWhiskey","CompanyWhiskey","CompanyWhiskey","CompanyWhiskey","CompanyXray"]; _PlatoonNames = ["Platoon1","Platoon1","Platoon1","Platoon2","Platoon2","Platoon1","Platoon1","Platoon2","Platoon2","Platoon1"]; _SquadNames = ["Squad1","Squad1","Squad2","Squad1","Squad2","Squad1","Squad2","Squad1","Squad2","Squad2"]; { _x params[ "_HCGrp", "_HCActionID" ]; if ( !isNull _HCGrp && { { alive _x }count units _HCGrp isEqualTo 0 } ) then { deleteGroup _HCGrp; player hcRemoveGroup _HCGrp; if ( _HCActionID isEqualType 0 ) then { player removeAction _HCActionID; }; myGrps set [ _forEachIndex, [ grpNull ] ]; _HCGrp = grpNull; }; if ( _create && { isNull _HCGrp } ) then { private [ "_group" ]; if !( isPlayer _unit ) then { _group = createGroup side player; }else{ _group = group player; }; _group setGroupIdGlobal [ "%GroupNames %GroupCompany %GroupPlatoon-%GroupSquad", "Yankee", _CompanyNames select _forEachIndex, _PlatoonNames select _forEachIndex, _SquadNames select _forEachIndex ]; if !( _unit in units _group ) then { _oldGroup = group _unit; if ( _wholeGroup ) then { units _oldGroup joinSilent _group; }else{ [ _unit ] joinSilent _group; }; if ( count units _oldGroup isEqualTo 0 ) then { deleteGroup _oldGroup; }; }; _actionID = if !( isPlayer _unit ) then { player hcSetGroup [ _group ]; [ _group ] call TAG_fnc_joinHCGroup; [ _group ] call TAG_fnc_groupJoinHCGroup; }else{ objNull; }; myGrps set [ _forEachIndex, [ _group, _actionID ] ]; _create = false; }; }forEach myGrps; }; TAG_fnc_grpJoinMe = { player addAction [ "Group Join Me", { cursorTarget setCaptive false; {[ _x ] joinSilent group player;}forEach units group cursorTarget; [ objNull, false ] call TAG_fnc_createNewHCGroup; }, [], 1, false, true, "", " !(isnull cursortarget) && (_this isEqualTo _target) && { (cursorTarget isKindof 'Man') && { (alive cursortarget) && { ( side cursortarget isEqualTo side player || captive cursorTarget ) && { (leader group cursorTarget isEqualTo cursorTarget) && { ({alive _x} count units group cursorTarget > 1) && (({ alive _x } count units group cursorTarget) + ({ alive _x } count units group player) < 12) } } } } }" ]; }; TAG_fnc_joinMe = { player addAction [ "Join Me", { cursorTarget setCaptive false; [ cursorTarget ] joinSilent group player; [ objNull, false ] call TAG_fnc_createNewHCGroup; }, [], 1, false, true, "", " !(isnull cursortarget) && _this isEqualTo _target && { cursorTarget isKindof 'Man' && { alive cursortarget && { ( side cursortarget isEqualTo side player || captive cursorTarget ) && { !(group cursortarget isEqualTo group player) && { ({ alive _x } count units group player < 12) } } } } }" ]; }; TAG_fnc_groupJoinHCGroup = { params[ "_HCGrp" ]; _actionID = player addAction [ format [ "Group Join %1", groupID _HCGrp ], { params[ "_target", "_caller", "_ID", "_args" ]; [ Group cursorTarget, _args, "" ] call TAG_fnc_JoinFunction; if (Group cursorTarget in myGrps) then { [ objNull, false ] call TAG_fnc_createNewHCGroup; }; }, _HCGrp, 1, false, true, "", format [" _group = %1 call BIS_fnc_groupFromNetId; !(isnull cursortarget) && (_this isEqualTo _target) && { (cursorTarget isKindof 'Man') && { (alive cursortarget) && { ( side cursortarget isEqualTo side player || captive cursorTarget ) && { (call TAG_fnc_hasBlankHC) && { !(Group cursorTarget isEqualTo _group) && { !(Group player isEqualTo _group) && { (leader group cursorTarget isEqualTo cursorTarget) && { ({ alive _x } count units (group cursorTarget) > 1) && { ({ alive _x } count units (_group) > 0) && (({ alive _x } count units (_group)) + ({ alive _x } count units cursorTarget) < 12) } } } } } } } } }", str ( _HCGrp call BIS_fnc_netId ) ] ]; _actionID; }; TAG_fnc_joinHCGroup = { params[ "_HCGrp" ]; _actionID = player addAction [ format [ "Join %1", groupID _HCGrp ], { params[ "_target", "_caller", "_ID", "_args" ]; [ cursorTarget, _args, "unit" ] call TAG_fnc_JoinFunction; [ objNull, false ] call TAG_fnc_createNewHCGroup; }, _HCGrp, 1, false, true, "", format [ " _group = %1 call BIS_fnc_groupFromNetId; !(isnull cursortarget) && _this isEqualTo _target && { cursorTarget isKindof 'Man' && { alive cursortarget && { ( side cursortarget isEqualTo side player || captive cursorTarget ) && { !(group cursortarget isEqualTo _group) && { ({ alive _x } count units (_group) > 0) && ({ alive _x } count units (_group) < 12) } } } } }", str ( _HCGrp call BIS_fnc_netId ) ] ]; _actionID }; TAG_fnc_HCActions = { player addAction [ "Unit to HC Group", { [ cursorTarget, true ] call TAG_fnc_createNewHCGroup; }, [], 1, false, true, "", " !(isnull cursortarget) && _this isEqualTo _target && { cursorTarget isKindof 'Man' && { alive cursortarget && { ( side cursortarget isEqualTo side player || captive cursorTarget ) && { (call TAG_fnc_hasBlankHC) } } } }" ]; player addAction [ "Group to HC Group", { [ cursorTarget, true, true ] call TAG_fnc_createNewHCGroup; }, [], 1, false, true, "", " !(isnull cursortarget) && _this isEqualTo _target && { cursorTarget isKindof 'Man' && { alive cursortarget && { ( side cursortarget isEqualTo side player || captive cursorTarget ) && { !(hcLeader Group cursorTarget isEqualTo player) && { (call TAG_fnc_hasBlankHC) && { leader group cursorTarget isEqualTo cursorTarget && count units group cursorTarget > 1 } } } } } }" ]; player addAction [ "Dismiss HC Group", { player hcRemoveGroup group cursorTarget; { _x params[ "_group", "_action" ]; if ( _group isEqualTo group cursorTarget ) exitWith { player removeAction _action; player hcRemoveGroup _group; myGrps set [ _forEachIndex, [ grpNull ] ]; }; }forEach myGrps; }, [], 1, false, true, "", " !(isnull cursortarget) && _this isEqualTo _target && { cursorTarget isKindof 'Man' && { alive cursortarget && { ( side cursortarget isEqualTo side player || captive cursorTarget ) && { leader group cursorTarget isEqualTo cursorTarget && { group cursorTarget isEqualTo ( _x select 0 ) }count myGrps > 0 } } } }" ]; }; _null = [ player, true ] call TAG_fnc_createNewHCGroup; _null = [] call TAG_fnc_joinMe; _null = [] call TAG_fnc_grpJoinMe; _null = [] call TAG_fnc_HCActions;
  9. Hey guys in another topic it came to the question how pointers are handled in sqf. I know them from C and I know they are sometimes essential if u want to write fast code. The question is, how can I get a pointer of an array and how can I return it from and pass it to functions and how can I do the same with a complete copy of an array?
  10. Hey guys, I just crawled the wiki for usefull commands and found apply in it. Correct me if Im wrong but I think its doing nearly the same as forEach if u not need that _forEachIndex variable. Is there another difference which i ve not seen and did anybody measure which command is faster?
  11. I will start with putting function code because it's quite small, and for reference (starting description comment omitted). /// --- validate general input #include "..\paramsCheck.inc" paramsCheck(_this,isEqualType,[]) private _cnt = count _this; for "_i" from 1 to _cnt do { _this pushBack (_this deleteAt floor random _cnt); }; _this According to BIS_fnc_arrayShuffle: Now, what's wrong. As you can see, no new array is created, and instead passed array is shuffled in-place. Function itself fails to shuffle (at least for what I think shuffle is). What I think shuffle is: all elements of input array get fairly equal chances to appear in any position in output array. What we have in function? TL;DR. First elements are less likely to be shuffled than last ones. Let's say we have array of N elements numbered 0, 1, ... N-1. Fair probability for any element to take any position is 1/N. Line 24 removes element with random index M (all consequent elements moved one element towards the array front) and pushes it to array's back. Operation affects positions of elements in range [M, ... N-1] unless M == N-1 (in which case nothing is changed, but delete and insertion performed!). Position of M elements (numbered 0..M-1) is unchanged. For arbitrary M in [0, 1, ..., N-1] you have the probability (N-M-1)/N that first M elements will remain on their positions after this iteration. Entire loop lasts N iterations. So the probability of element not being picked up and not moved in entire loop is ((N-M-1)/N)N. Full probability of element to stay on its initial place also includes the cases when element goes to back and after some iterations shifts to its initial place. For 0th element probability of shifting back to 0th position is 1/N * (N-1)/N * (N-2)/N * ... * 1/N = (N-1)!/(NN). For the last exactly 1/N (simply probability of picking specific element; fair for this position, still not fair for others) -- if last element moved to array's back in last iteration. Assuming that , probability of 0th element staying in 0th position first falls and has minimum in N=5, then grows and asymptotically strives for 1/e, i.e. ~0.367879441, no matter what size array is. When in fact it should be exactly 1/N for any N. That is, having array of 10 elements, for first element (M=0) you will have probability (10-0-1)/10 = 0.9 (90%) that it stays on its place after first iteration. Probability 0.8 (80%) of that two first elements are not shuffled after first iteration (quite obvious). Probability of first element staying in first position after entire loop is 0.348714728 (~34.8%) when it should be 10%. Sorry, did not do the maths for other elements, but I think it's enough already to state that shuffle fails. The easiest way to fix the loop is to rewrite it like this: for "_i" from 1 to _cnt do { _this pushBack (_this deleteAt floor random (_cnt+1-_i)); }; Thus not picking any element second time and providing fair 1/N probability for all elements. However, I don't like this approach because of too many (unnecessary) deletes, causing multiple elements to shift towards array front, meaning worst case complexity of O(n2) (if random always returns 0). I don't know how arrays work inside. If shifting elements of arbitrary types is quite costly operation (very likely for vector-like containers filled with data structures itself, not pointers), it's better shift numbers (indexes of elements). Here's my implementation of function, fixing both issues: /// --- validate general input #include "..\paramsCheck.inc" paramsCheck(_this,isEqualType,[]) private ["_cnt", "_result"]; _cnt = count _this; _result = []; if (_cnt > 0) then { private ["_i", "_idxs"]; _idxs = []; _idxs resize _cnt; for [{_i = 0}, {_i < _cnt}, {_i = _i + 1}] do { _idxs set [_i, _i]; }; _result resize _cnt; for [{_i = 0}, {_i < (_cnt-1)}, {_i = _i + 1}] do { _result set [_i, _this select (_idxs deleteAt floor random (_cnt-_i))]; }; _result set [_cnt-1, _this select (_idxs select 0)]; }; _result It does multiple deletes from array too, but at least elements are always numbers. Whoever wants a fair shuffle, feel free to use. Having BIS_fnc_sortBy function discovered broken recently, I think there should be some review in arrays functions code. And I'll be digging too, hehe :icon_twisted: I see what you did there, KK There's hotfix coming soon, I wonder if BIS could fix this function too. Best regards.
  12. _fnc_Hp = { _this select _i from 0 to 2 do { round (((_this * -100) + 100)); }; }; _all = [_won getHit "motor",_won getHit "palivo",_won getHit "karoserie"]; hint format ["%1", _all]; sleep 2; hint format ["%1", _all call _fnc_Hp]; How do I take the array _all containing [_won getHit "motor",_won getHit "palivo",_won getHit "karoserie"] through the function _fnc_Hp
  13. Hi all, I am currently developing a system that will select random objectives then assign markers to that area so that it is visible. I have run into an issue with the "SetMarkerPos" command. The error I receive is "Error setmarkerpos: type string, expected Array". The reason it is setup below is due to the fact I have 3 objective types. Town Objectives Primary Objectives Secondary Objectives The script i have created for setting marker positions for Town and Primary objectives is simple as all that is required is that the markers for those are moved to that designated town. However, a secondary objective can only exist inside a primary objective and not all of the primary objectives have a secondary objective. The idea is/was to combine the name of the Primary objective (publicvariable of "mainmark") with secondary_%1 to create the names of the secondary objective markers. I am then able to see if there is a secondary objective nearby to the randomly selected Primary objective and if there is, move the marker to it to indicate such. however I receive the above mentioned error when trying to set the markers position. I was hoping I could receive assistance in fixing this error either via directing me on how to assign the string into an array so the error stops or by finding another way to achieve this goal. Thanks. Below is the script I am using to achieve this goal. null = execVM "obj\objective_controller.sqf"; _distm = getmarkerpos mainmark; _distt = getmarkerpos townmark; _dista = _distm distance _distt; if (_dista < 2200) then { execVM "obj\objective_controller.sqf"; }; if (_dista > 2200) then { _getmarkm = getmarkerpos mainmark; _showobjectivem = "mark_main_area" setMarkerPos _getmarkm; _showobjectivem = "mark_main_name" setMarkerPos _getmarkm; _getmarkt = getmarkerpos townmark; _showobjectivet = "mark_town_area" setMarkerPos _getmarkt; _showobjectivet = "mark_town_name" setMarkerPos _getmarkt; }; //----------------------------------------------------------------------------------------------- //Find secondary nearby _townsec = format ["secondary_%1",mainmark]; _dists = getmarkerpos _townsec; _secfind = _distm distance _dists; if (_secfind < 500) then { hint format ["placing %1 in %2 area", _townsec, mainmark]; _showobjectivesec = "mark_secondary_area" setMarkerPos _townsec; _showobjectivesec = "mark_secondary_name" setMarkerPos _townsec; }; if (_secfind > 500) then { };
  14. So I'm trying to make survival mission for me and my friends and I want empty vehicles to spawn randomly along the roads, mainly civ vehicles but also a few military ones. I've tried to search around but I suck at searching for arma editing stuff, I don't know why xD I ofcourse want it to be as nice on the fps as possible, aka only spawn vehicles close to the player, maybe 2.5km away? I know that you can use "createVehicle" and how to make it choose a vehicle randomly from an array but I don't know how to make them spawn along the road in a good fashion. Thanks
  15. Hi all, Have not found a function to change every occurrence of given string in deeply nested array to another string, so made it myself. Hopefully some one will find it usefull ;) Fill free to critic and/or improve, this way everyone wins :) Code will return positive number showing how many times string was replaced, zero if string was not found and -1 if input is wrong. This function WILL modify provided array, if this is not wanted, perform function with copy of array. Function will make CaSE SenSitivE check. Use showcase: myArray = ["BAD","fsgg",0,[0,5,3,"BAD"],"something",[[0,0,5,4,"BAD",["Bad"]]],["ddftest","BAD"],[],[]]; searchString = "BAD"; replaceString = "GOOD"; result = [myArray, searchString, replaceString] call fnc_replaceStringDeep; So here is output result == 4 myArray == ["GOOD","fsgg",0,[0,5,3,"GOOD"],"something",[[0,0,5,4,"GOOD",["Bad"]]],["ddftest","GOOD"],[],[]]
  16. hello, i have made some positions with setPosATL and setDir this setPosATL [16559.8,21846.6,1.13549]; this setDir 271.228; this setPosATL [16560.2,21848.7,1.10291]; this setDir 279.611; this setPosATL [16556.1,21847.2,0.573884]; this setDir 3.74775; this setPosATL [16556.8,21850.9,0.636226]; this setDir 268.757; how to make an array to use in this code for random respawn positions ? if (isServer) then { _randomPos = [,,,,] call BIS_fnc_selectRandom; player setPos (getPos _randomPos); }; i found a lot of answers for making an array but not for multiple setPos and setDir positions in one array !
  17. fn_arrayValues.sqf - v1.2 What? This script gives you the possibility to get, set, add and remove elements from and in an array by using unique IDs (strings) for each array element without having to worry about indexes. The logic behind it is totally simple. Why? TL;DR: I don't know if some people already created and use something like this, but either way, it's useful and took less than an hour to write. Slightly longer version: While developing some multiplayer missions now and then, I was moving data back and forth between client and server, sometimes using relatively large arrays. At some point, I found it annoying having to be careful about what value is at which index and when I somehow change the array, I had to double check again if the correct indexes are read and written. Coming from object-oriented programming languages, I always found it not satisfactory being unable to create custom objects in SQF. I know there is a „pseudo OO“ framework by code34, but that's just too heavy for my needs. All I wanted was being able to have one thing where I can get, set, add and remove values without having to care about anything but identifiers, just like the getters and setters in an object. And that's the idea of this script. How? This script MUST NOT be spawned, because it's got return values (no shit! ;)). Be aware of that when using remote execution. Every ID has to be a string and can only exist once throughout the whole array. Parameters and which are optional (or not) is described in the top of the script so I'll leave that out here. Examples: All examples are assuming “someId†exists, except if mentioned differently. //Creating a new array of this kind: _array = [[], []]; //Getting a value: _value = [_array, "someId"] call fnc_arrayValue; //Setting a value: _array = [_array, "someId", 123] call fnc_arrayValue; //Adding a value (assuming “someId†does not exist): _array = [_array, "someId", 123, true] call fnc_arrayValue; //Removing a value: _array = [_array, "someId", nil, false] call fnc_arrayValue; //Removing a value, only if it is 3: _array = [_array, "someId", 3, false] call fnc_arrayValue; //Setting a value explicitly to nil, instead of removing it from the array: _array = [_array, "someId", nil, true] call fnc_arrayValue; Kudos to Killzone_Kid for his SQF to BBCode Converter. It doesn't matter how much the array changes. You'll always get the desired value behind the same ID, independent from which index it currently has got. Unfortunately, last time I checked, SQF does not allow arrays like this: [123, , true] which is why there has to be a value (e.g. nil) even if you want to delete something from the array. If you did not pass the “isAdd†parameter, hence accidently try to set a value for an ID which does not exist, for instance due to a typo, the value won't be set. Some might consider it a feature if it would, some might not. I personally like my scripts in a way that only very few things happen implicitly, but I'd like to know what you think about that. Download the file here (SpiderOak)
×