Jump to content

Robustcolor

Member
  • Content Count

    214
  • Joined

  • Last visited

  • Medals

Everything posted by Robustcolor

  1. Is it possible to add a ADS sound from initPlayerLocal? I've been trying to solve it with the code below but it wont play any sound. initPlayerLocal.sqf (findDisplay 46) displayAddEventHandler ["MouseButtonClick", { params ["_control", "_button"]; if (_button == 1) then { if (cameraView == "GUNNER") then { playSound [ironsightsout, true]; }else{ playSound [ironsightsin, true]; }; }; }];
  2. Robustcolor

    Add ADS sound with a displayaddEH

    Any suggestion how i can disable the playSound if a player only zooms and not aiming down sights? I'm using !(weaponlowered) and !(Visiblemap) so it don't execute the code in those conditions. If a player has the weapon raised and zooms it executes the playSound, how can i prevent it from executing when doing this? If the weapon is lowered and the player zooms it don't execute as wanted. waituntil {!isnull (finddisplay 46)}; (findDisplay 46) displayAddEventHandler ["MouseButtonDown", { params ["_control", "_button"]; if ((_button == 1) && ((!(weaponLowered player) && !(visibleMap)) then { if (cameraView isEqualTo "GUNNER") then { playSound ["ironsightsout", true]; }; if (cameraView isEqualTo "INTERNAL" || {cameraView isEqualTo "EXTERNAL"}) then { playSound ["ironsightsin", true]; };}; }];
  3. Robustcolor

    Add ADS sound with a displayaddEH

    Thanks @gc8 and @Larrow it works now. Needed this for it to work. waituntil {!isnull (finddisplay 46)};
  4. Robustcolor

    Add ADS sound with a displayaddEH

    Thanks, yes i missed adding quotation marks. But my code still don't work.
  5. Robustcolor

    Add ADS sound with a displayaddEH

    Description.EXT class CfgSounds { class ironsightsin { name = "ironsightsin"; sound[] = {"\ironsights_in.ogg", 1, 1}; titles[]={0,""}; }; class ironsightsout { name = "ironsightsout"; sound[] = {"\ironsights_out.ogg", 1, 1}; titles[]={0,""}; }; };
  6. Hi, i'm trying to use the checkVisibility command to find out if any player present in the specific area can't see the location/object. The code below work but not as intended. if (allPlayers findIf { (_x inArea [_marker,550,550,0,false]) && ([objectParent _x, "VIEW"] checkVisibility [eyePos _x, (AGLToASL _marker) vectorAdd [0,0,1.5]] == 0) }!=-1) then { "x don't see the location" remoteExec ["hint"]; }; Seems to check only one player and not every player in the area? I want the code to execute when none of the players in the area can't see the location.
  7. How does lineIntersects work? Does it care for fog or smokes? If two units can see each other do i have to use !(LineIntersects) with a ! infront And only (lineIntersects without ! if they can't see eachother, or am i doing something wrong here? if !(lineIntersects [eyePos test1, eyepos test2, test1,test2]) then { hint "Test1 and Test2 see eachother" }; if (lineIntersects [eyePos test1, eyepos test2, test1,test2]) then { hint "Test1 and Test2 don't see eachother" };
  8. Hi, this variable below is an array including [positions,units,players] from using apply + sort command and it refreshes with new units,positions and players from time to time. i usually select either the unit or the player by doing _playertarget = _groupDistances #0#2; But the question is, if i would like to select all the units not the players or the positions inside this array, how do i do that? since _playertarget = _groupDistances #0#2 only gives me one object, in this case the player. _groupDistances = [[136517,O Alpha 1-1:6,Player1],[174721,O Alpha 1-1:5,Player2],[195925,O Alpha 1-2:1,Player3]]; I would like to do something like { _x doMove "somehwere"; } count "the units from array";
  9. Robustcolor

    Selecting all units from an array.

    Thanks @pierremgi, this is how i did now. _groupDistances = []; { _unit = _x; _groupDistances append (allPlayers select {_x distance2d _unit < 150} apply {[_x distanceSqr _unit, _unit, _x]}); _groupDistances sort true; _target = _groupDistances #0#2; _unit doMove _target; } forEach (allUnits select {side _x isEqualTo EAST}); Question, will the code _unit doTarget _target; only execute on those units <150 or closer or will it still execute it on allUnits side EAST in this forEach?
  10. Robustcolor

    Selecting all units from an array.

    @pierremgi Sorry, made the first post abit hasty. _groupDistances = []; { _unit = _x; _groupDistances append (allPlayers select {alive _x} apply {[_x distanceSqr _unit, _unit, _x]}) } count (allUnits select {side _x isEqualTo EAST); _groupDistances sort true; RESULT: _groupDistances = [[136517,O Alpha 1-1:6,Player1],[174721,O Alpha 1-1:5,Player2],[195925,O Alpha 1-2:1,Player3]]; Usually i use _playertarget = _groupDistances #0#2; Gives me in this case the first one, [Player1] Is it possible to select all those units in each [] that are not players and use them in a context of { _x dosomething } count
  11. Thanks, i could try that command. Do you know how to proper use a lineintersect command? Maybe something like this? (allPlayers findIf {lineIntersects [eyePos _x,eyePos (AGLToASL _markerpos) vectorAdd [0,0,1.5]], objectParent _x]});
  12. This code below seems to be almost working, but if two players is inside the radius it keeps locking only one of them even if one is further away. Suggestions? _pos = getMarkerpos "Marker1"; _group = [_pos, EAST, 7 ] call BIS_fnc_spawnGroup; _units = units _enemyGroup; _markerpos = getMarkerpos "Marker1"; private _playerDistances = (allPlayers select {(_x distance2d _markerpos < 800) && {alive _x}}) apply { private _plyr = _x; private _groupDistances = _units apply {[_x distanceSqr _plyr,_x]}; _groupDistances sort true; [_groupDistances#0#1, _x, _groupDistances] }; if !(_playerDistances isEqualTo []) then { _playerDistances sort true; _target = _playerDistances #0#1; { if (_x knowsAbout _target > 0) then { _x doTarget _target; }} count _units; }; I did try something like this below but it only select the last unit in each squad. _pos = getMarkerpos "Marker1"; _group = [_pos, EAST, 7 ] call BIS_fnc_spawnGroup; _units = units _group; { _unit = _x; _nearplyrs = (allPlayers select {(_x distance2d _unit < 800) && {(lifestate _x != "DEAD-RESPAWN")}} apply {[_x distanceSqr _unit, _x]}) } forEach _units; if !(_nearplyrs isEqualTo []) then { _nearplyrs sort true; _target = _nearplyrs #0#1; { if (_x knowsAbout _target > 0) then { _x doTarget _target; } count _units; };
  13. Could somebody help on how to spawn something near these bushes using NearestTerrainObjects and not spawning twice on same pos. _allBushes = nearestTerrainObjects [player, [Bush], 250, false]; for "_i" from 1 to 5 do _pos = selectRandom _allBushes _grp = createGroup east; _unit = _grp createUnit ["C_man_p_beggar_F", [0,0,0], [], 0, "FORM"]; _unit setPos _pos; };
  14. Robustcolor

    NearestTerrainObjects

    Thanks @gc8
  15. 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.
  16. Robustcolor

    Call sqf?

    How would you call this with an addAction from an editor placed object in a MP environment?
  17. Robustcolor

    moving marker in server

    This is great. Question, if i do this _mk setMarkerTextLocal name _x; forEach (allPlayers); is this the correct way if i would like to add it on every player when executing this in initPlayerlocal.sqf.
  18. Hm, can't seem to get it to work. _group = [getMarkerpos "respawn_east", EAST, 7 ] call BIS_fnc_spawnGroup; _destination = (getMarkerPos "Marker1"); private ["_group","_destination"]; while {true} do { uiSleep 5; if ((count (waypoints _group)) == 0) then { _group move _destination; }; }; Never executes the code.
  19. Related question, instead of UnitReady, maybe we could count the waypoint/s of the group using the doMove or move command and if waypoints == 0 execute something. if (count (waypoints _group) == 0) then { _group move _destination; or _group doMove _destination; };
  20. What does the extra curly brackets do inside this deleteVehicle _x code? Does Lazy evaluation work outside a if then? (allGroups select {side _x == EAST and {leader _x distance getMarkerpos "_marker"<60}});
  21. Hi, what am i doing wrong here with the selectRandom command? I'm trying to choose one random player and use it with a variable. It seems to skip the !(_player isEqualTo []) for some reason even if players are Incapacitated or not which will give a result of _player undefined variable later on. private _player = selectRandom (allPlayers select {(_x distance2d _markerpos < 450) && {(lifestate _x != "Incapacitated")}}); if !(_player isEqualTo []) then { something };
  22. Robustcolor

    SelectRandom issue

    Thanks @gc8 and @pierremgi. It works now. What is the reason for isEqualTo not working when using selectRandom inside this variable but isNil does? So i understand it for further scripting 🙂 private _player = selectRandom (allPlayers select {(_x distance2d _markerpos < 450) && (lifestate _x != "Incapacitated")}); if (!(isNil _player)) then { }; and here isEqualTo is working. _players = allPlayers select {(_x distance2d _markerpos < 450) && (lifestate _x != "Incapacitated")}); if !(_players isEqualTo []) then { _player = selectRandom _players; };
  23. Robustcolor

    SelectRandom issue

    This seems to work now. _markerpos = getMarkerpos "Marker1"; While {uiSleep 5; true} do { private _player = selectRandom (allPlayers select {(_x distance2d _markerpos < 450) && (lifestate _x != "Incapacitated")}); if (!(isNil _player)) then { something }; };
  24. Robustcolor

    SelectRandom issue

    Hm, Error count: Type Object, expected Array. private _player = count selectRandom (allPlayers select {(_x distance2d _markerpos < 450) && (lifestate _x != "DEAD-RESPAWN") && (lifestate _x != "Incapacitated")});
×