Jump to content

Robustcolor

Member
  • Content Count

    174
  • Joined

  • Last visited

  • Medals

Community Reputation

14 Good

1 Follower

About Robustcolor

  • Rank
    Sergeant

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Robustcolor

    opinion about findif vs count

    Thanks @Grumpy Old Man The thing is i read here https://community.bistudio.com/wiki/Code_Optimisation that findIf could be slighlty faster then count depending on how you use it. _someoneIsNear = (allUnits findIf { _x distance [0,0,0] < 1000 }) != -1; // 0.0275 ms _someoneIsNear = { _x distance [0,0,0] < 1000 } count allUnits > 0; // 0.0645 ms
  2. Hi, what is your opinion about using findif vs count in context like these below. When is findif better to use vs the count command? waitUntil {uiSleep 300; ({_x distance2d _veh < 1000} count allPlayers == 0)}; vs waitUntil {uiSleep 300; allPlayers findIf {(_x distance2d _veh) < 1000} ==-1}; Here count seems to be slightly faster. waitUntil {uiSleep 5; (allPlayers findIf {(_x distance2d _marker) > 450} !=-1)}; vs waitUntil {uiSleep 5; ({_x distance2d _marker < 450} count allPlayers == 0)}; Here findIf seems slighlty faster. while {{alive _x} count (units _group) > 0} do {}; vs while {units _group findIf {alive _x} >-1} do {}; count slighlty faster.
  3. @pierremgi How does this work in a MP dedicated environment? Will it stack a bunch of waitUntils/code if alot of players getin a vehicle? Or should we use a different approach for this in a dedicated? initPlayerlocal.sqf player addEventHandler ["getInMan",{ params ["_plyr","","_veh"]; [_plyr,_veh] spawn { params ["_plyr","_veh"]; waitUntil {uiSleep 300; _veh != objectParent _plyr && _veh distance2D _plyr > 1000 && ((crew _veh) isequalto [])}; deleteVehicle _veh } }];
  4. Robustcolor

    Return value from function

    How do i fetch the returning value from second function Second function; Myunits = { params ["_marker","_group"]; group = createGroup [civilian, true]; _group createUnit [selectRandom ["C_Man_casual_1_F","C_Man_Fisherman_01_F"], _marker, [], 10, "FORM"] _group }; First function; _group = [""]; private _m1 = [_marker] call Units; waitUntil {sleep 5; (allPlayers findIf {(_x distance2d _marker) > 400} !=-1)}; {deleteVehicle _x;} forEach units _group; Error, expected units not an array.
  5. Hi, how do i fetch the _grp01 variable back to my first function? I want to use it later in my waitUntil. Can i fetch the return value only with call or does spawn work too? First function; private _m1 = [_marker] call Units; waitUntil {sleep 5; (allPlayers findIf {(_x distance2d _marker) > 400} !=-1)}; {deleteVehicle _x;} forEach units _group; Second function; Units = { _grp01 = createGroup [civilian, true]; _unit = _grp01 createUnit [selectRandom ["C_Man_casual_1_F","C_Man_Fisherman_01_F","C_man_p_shorts_1_F","C_Man_UtilityWorker_01_F","C_man_polo_2_F","C_man_polo_5_F","C_Man_casual_6_F","C_Man_casual_4_F"], _marker, [], 10, "FORM"]; };
  6. Robustcolor

    Remoteexec addaction + say3d

    Thank you for explaining and for the help @7erra
  7. Robustcolor

    Remoteexec addaction + say3d

    Thanks @7erra, worked with global variable. With local variable it causes an undefined variable with _veh when called. Is it possible to use it with local var? If i create several vehicles from the same functions and want each vehicle to play music. [veh, ["<t color ='#ffcc00'>Radio on</t>",{ [veh, [selectRandom ["music_one","music_two","music_three","music_four","music_five","music_six","music_seven"],2000,1]] remoteExec ["say3D"]; },[],1.5,true,true,"","driver _target == _this"]] remoteExec ["addAction", 0, veh];
  8. Hi, if i create a vehicle through a function and add a addaction command from it, will it be available for all players on a dedicated? is it possible to limit the addaction for only driver? also, is it possible to use selectrandom or similiar command to randomise which music will be played? music_one, music_two etc is defined in cfgSounds. private _veh = createVehicle [selectRandom ["O_G_Offroad_01_armed_F","I_C_Offroad_02_LMG_F"], _pos, [], 0, "NONE"]; _veh setVehicleVarName "Music"; Music = _veh; _veh addAction ["Music on",{ [Music,["music_one",2000,1]] remoteExec ["say3D"]; }];
  9. Ye i can't say it was any noticeably different from the switch when testing it. Using it with isEqualTo. params[ [ "_mode", "PATROL", [ "" ] ] ]; call { if (_mode isEqualTo "PATROL") exitWith { //code 1 }; if (_mode isEqualTo "GUARD") exitWith { //code 2 }; if (_mode isEqualTo "GARRISON") exitWith { //code 3 }; //default code };
  10. Robustcolor

    Script help

    waitUntil {sleep 5; allPlayers findIf {(_x distance2d _markerpos) < (250 + round (random 50)) && (ASLToAGL getPosASL _x)#2 < 2} > -1}; It did work, just some wierd error when testing it in debug. I did a test with the code below and it worked, not sure if it's better or worse compared to the above code, what you think? @pierremgi The debug test thing don't work when using these codes so not sure about the result. waitUntil {sleep 5; allPlayers unitsBelowHeight 20 findIf {(_x distance2d _markerpos) < (250 + (random 50))} >-1};
  11. For anyone using this script i added this code at the top, makes it only check for alive players and below height 20. The isEqualTo stops the script from running if no players is found. So no errors. private _markers = ["A1","A2","A3","A4","A5","A6","A7","A8","A9","A10","A11","A12","A13","A14","A15"]; private _markerdist = 350; while {true} do { private _allPlayers = (allPlayers - alldeadmen unitsBelowHeight 20); if !(_allPlayers isEqualTo []) then {
  12. Robustcolor

    forEach, count or apply

    Thank you for such a good explanation @pierremgi Changing forEach to count in these. { _x allowFleeing 0; _x EnableDynamicSimulation true; _x setBehaviour "COMBAT"; _x setCombatMode "RED"; _x setSpeedMode "FULL"; _x setFormation "LINE"; } count [_grp01]; { _x setSkill 1; _x setSkill ["AimingAccuracy",0.01]; } count (units _grp01);
  13. Robustcolor

    forEach, count or apply

    How about using select vs all the options above? [_grp01] select { _x allowFleeing 0; };
  14. Since a switch is kinda slow, is it possible to convert it into this call { if (PATROL) exitWith { //code 1 }; if (GUARD) exitWith { //code 2 }; if (GARRISON) exitWith { //code 3 }; //default code }; I also changed toUpper command into toUpperANSI since it could be 3x faster than toUpper.
×