Jump to content

RoryRothon

Member
  • Content Count

    56
  • Joined

  • Last visited

  • Medals

Everything posted by RoryRothon

  1. Im working on a mission using Ryans Zombies & Demons, and im sure you can guess what type of mission it is lol Im using the Proving Grounds map from CUP Terrains 1.3 and am spawning in 6 playable units at different locations on the map and ungrouped (well, not it a squad). What i am trying to accomplish is: When players get to below 10 meters from another player = Check is both are in a squad, if not create one and place both units in, or if one is a member of a squad then place the other unit into his squad. Sounds crazy when i type it out but hopefully you get my meaning... Im just unsure how to go about this... forEach / distance / join / createGroup / etc etc.... Any info regarding this would be greatly appreciated and placed into my pastebin once completed :) Kind regards Rory
  2. RoryRothon

    Group ID and Hunt

    This might be of help too. I have compiled an array of groups from cfgGroups that works with sidID for the above function.. RAZ_fnc_infantryConfigs = [ [], [], [] ]; _allConfigGrpSides = ("true" configClasses (configFile >> "CfgGroups") apply {configname _x}); { _cfgGrpSide = _x; _allcfgGrpFactions = ("true" configClasses (configFile >> "CfgGroups" >> _cfgGrpSide) apply {configname _x}); { _cfgGrpFaction = _x; _allcfgGrpCategories = ("true" configClasses (configFile >> "CfgGroups" >> _cfgGrpSide >> _cfgGrpFaction) apply {configname _x}); { _cfgGrpType = _x; _allcfgGrpCategories = ("true" configClasses (configFile >> "CfgGroups" >> _cfgGrpSide >> _cfgGrpFaction >> _cfgGrpType) apply {configname _x}); _eastConfigs = "getNumber( _x >> 'side' ) isEqualTo 0"configClasses( configFile >> "CfgGroups" >> _cfgGrpSide >> _cfgGrpFaction >> _cfgGrpType ); _westConfigs = "getNumber( _x >> 'side' ) isEqualTo 1"configClasses( configFile >> "CfgGroups" >> _cfgGrpSide >> _cfgGrpFaction >> _cfgGrpType ); _indepConfigs = "getNumber( _x >> 'side' ) isEqualTo 2"configClasses( configFile >> "CfgGroups" >> _cfgGrpSide >> _cfgGrpFaction >> _cfgGrpType ); RAZ_fnc_infantryConfigs select 0 append _eastConfigs; RAZ_fnc_infantryConfigs select 1 append _westConfigs; RAZ_fnc_infantryConfigs select 2 append _indepConfigs; } forEach _allcfgGrpCategories; } forEach _allcfgGrpFactions; } forEach _allConfigGrpSides;
  3. RoryRothon

    Group ID and Hunt

    I'm working on something similar. Ive thrown up my initServer.sqf code that you can look at and pull apart if it helps :) RAZ_fnc_spawnHuntingInfantry = { params [ "_unit", [ "_side", EAST ] ]; _sideID = _side call BIS_fnc_sideID; _faction = East; if ( _sideID == 0 ) then { _faction = _faction }; if ( _sideID == 1 ) then { _faction = West }; if ( _sideID == 2 ) then { _faction = Independent }; _pos = getPosATL _unit; _huntingGroups = _unit getVariable [ "RAZ_fnc_isBeingHunted", 0 ]; _huntingGroups = _huntingGroups + 1; _unit setVariable [ "RAZ_fnc_isBeingHunted", _huntingGroups, true ]; _spawnPos = _pos getPos [ 600, random 360 ]; _spawnPos = [ _spawnPos, 1, 1000, 1, 0, 45, 0 ] call BIS_fnc_findSafePos; _grp = [ _spawnPos, _faction, ( selectRandom (RAZ_fnc_infantryConfigs select _sideID) ) ] call BIS_fnc_spawnGroup; { _x setUnitAbility 0.1; _x setskill ["aimingAccuracy",0.01]; _x setskill ["aimingShake",0.9]; _x setskill ["aimingSpeed",0.01]; _x setskill ["Endurance",0.5]; _x setskill ["spotDistance",0.5]; _x setskill ["spotTime",0.5]; _x setskill ["courage",0.1]; _x setskill ["reloadSpeed",0.1]; if (side _x == east) then { _x unassignItem "NVGoggles_OPFOR"; _x removeItem "NVGoggles_OPFOR"; }; if (side _x == Independent) then { _x unassignItem "NVGoggles_INDEP"; _x removeItem "NVGoggles_INDEP"; }; _x removePrimaryWeaponItem "acc_pointer_IR"; _x addPrimaryWeaponItem "acc_flashlight"; _x enableGunLights "forceOn"; } forEach units _grp; { gm addCuratorEditableObjects [ [_x], true ]; } forEach units _grp; _searchWp = [ getPos _unit, random 500, random 360 ] call BIS_fnc_relPos; _wp = _grp addWaypoint [_searchWp, 0]; [_grp, 1] setWaypointType "SAD"; [_grp, 1] setWaypointSpeed "NORMAL"; while { ( { alive _x } count units _grp ) >= 1 } do { _timer = time + 10; if ( alive _unit ) then { _unit = _unit }; if ( !alive _unit ) then { _unit setVariable [ "RAZ_fnc_isBeingHunted", _huntingGroups, false ]; sleep 2; _unit = selectRandom ( allPlayers select { alive _x } ); while { ( count ( waypoints _grp ) ) > 0 } do { deleteWaypoint ( ( waypoints _grp ) select 0 ); }; _searchWp = [ getPos _unit, random 600, random 360 ] call BIS_fnc_relPos; _wp = _grp addWaypoint [ _searchWp, 0 ]; [ _grp, 1 ] setWaypointType "SAD"; [ _grp, 1 ] setWaypointType "NORMAL"; }; waitUntil { sleep 120; position _unit distance _spawnpos > 30 OR time > _timer OR ({alive _x} count units _grp) isEqualTo 0 }; deleteWaypoint [_grp, 1]; _searchWp = [ getPos _unit, random 300, random 360 ] call BIS_fnc_relPos; _wp = _grp addWaypoint [_searchWp, 1]; [_grp, 1] setWaypointType "SAD"; [_grp, 1] setWaypointSpeed "NORMAL"; }; sleep 1; _huntingGroups = _unit getVariable ["RAZ_fnc_isBeingHunted",0]; _huntingGroups = _huntingGroups - 1; _unit setVariable ["RAZ_fnc_isBeingHunted",_huntingGroups,true]; }; _spawningEnemies = [] spawn { _players = []; _spawnHunters = true; format [ "Operation Missdrop By [BZ] Pte R.Rothon" ] remoteExec ["systemChat"]; format [ "System Initialized" ] remoteExec ["systemChat"]; waitUntil {time > 0}; while { _spawnHunters } do { waitUntil { sleep 3; (count (allplayers - switchableUnits) > 0) }; _players = (allplayers - switchableUnits) select {(_x getVariable ["RAZ_fnc_isBeingHunted",0]) isEqualTo 0}; _players apply { _hunt = [_x,East] spawn RAZ_fnc_spawnHuntingInfantry; _hunt = [_x,Independent] spawn RAZ_fnc_spawnHuntingInfantry; }; }; }; // END GAME SCRIPTING ------------------------------------------------------------------------------------------------ _endGameTimer = 600; waitUntil { time > _endGameTimer && count (allPlayers select {group _x isEqualTo group (allPlayers select 0)}) isEqualTo count allPlayers; }; format ["All soldiers found. Receiving intel on extraction point, ETA 10 mins!"] remoteExec ["hint"]; sleep 600; // SPAWN EXTRACTION CHOPPER
  4. Hi, i am trying to get this working but keep getting a undefined variable error for _crew. Below is the function i am creating, i wonder if someone would be kind enough to point out something i may have overlooked? Error line has been marked at ( waitUntil ) Kind regards Rory RAZ_fnc_spawnHuntingVehicle = { waitUntil { time > 0 }; params [ "_unit" ]; _pos = getPosATL _unit; _huntingVehicles = _unit getVariable [ "RAZ_fnc_isBeingHuntedByVehicle", 0 ]; _huntingVehicles = _huntingVehicles + 1; _unit setVariable [ "RAZ_fnc_isBeingHuntedByVehicle", _huntingVehicles, true ]; _spawnPos = _pos getPos [ 3000, random 360 ]; _spawnPos = [ _spawnPos, 1, 50, 1, 0, 35, 0 ] call BIS_fnc_findSafePos; _randomArray = selectRandom[0,2]; if ( _randomArray == 0 ) then { _faction = east } else { _faction = independent }; _patrolVehicle = [ _spawnPos, 180, ( selectRandom (RAZ_fnc_vehicleConfigs select _randomArray) ), _faction ] call Bis_fnc_spawnvehicle; _veh = _patrolVehicle select 0; _crew = _patrolVehicle select 2; { gm addCuratorEditableObjects [ [_x], true ]; } forEach units _crew; gm addCuratorEditableObjects [ [ _veh ], true ]; { _x setSkill 0.25; } forEach units _crew; while { ( { alive _x } count units _crew ) >= 1 AND alive _veh } do { if ( !alive _unit ) then { _unit setVariable [ "RAZ_fnc_isBeingHuntedByVehicle", _huntingVehicles, false ]; _unit = selectRandom ( allPlayers select { alive _x } ); }; _searchWp = [ getPos _unit, random 1000, random 360 ] call BIS_fnc_relPos; _wp = _crew addWaypoint [_searchWp, 0]; [_crew, 1] setWaypointType "SAD"; [_crew, 1] setWaypointSpeed "NORMAL"; _timer = time + 60; waitUntil { time > _timer OR ({alive _x} count units _crew) isEqualTo 0 OR !alive _veh }; deleteWaypoint [_crew, 1]; }; waitUntil { ( { alive _x } count units _crew ) isEqualTo 0 OR !alive _veh }; <<<<<< ERROR! _huntingVehicles = _unit getVariable ["RAZ_fnc_isBeingHuntedByVehicle",0]; _huntingVehicles = _huntingVehicles - 1; _unit setVariable ["RAZ_fnc_isBeingHuntedByVehicle",_huntingVehicles,true]; _waitTime = time + 10; waitUntil { time > _waitTime }; }; _spawningEnemies = [] spawn { _players = []; _vehiclePlayers = []; _spawnHunters = true; waitUntil {time > 0}; while { _spawnHunters } do { waitUntil { sleep 3; (count (allplayers - switchableUnits) > 0) }; _players = (allplayers - switchableUnits) select {(_x getVariable ["RAZ_fnc_isBeingHunted",0]) isEqualTo 0}; _vehiclePlayers = (allplayers - switchableUnits) select {(_x getVariable ["RAZ_fnc_isBeingHuntedByVehicle",0]) isEqualTo 0}; _players apply { _hunt = [_x,east] spawn RAZ_fnc_spawnHuntingInfantry; _hunt = [_x,independent] spawn RAZ_fnc_spawnHuntingInfantry; }; _vehiclePlayers apply { _hunt = [_x] spawn RAZ_fnc_spawnHuntingVehicle; }; }; };
  5. Hi. I currently have a variable check and assign for all players on the dedi, example below: _huntingGroups = _unit getVariable [ "RAZ_fnc_isBeingHunted", 0 ]; _huntingGroups = _huntingGroups + 1; _unit setVariable [ "RAZ_fnc_isBeingHunted", _huntingGroups, true ]; _players = (allplayers - switchableUnits) select {(_x getVariable ["RAZ_fnc_isBeingHunted",0]) isEqualTo 0}; _players apply { _hunt = [_x,east] spawn RAZ_fnc_spawnHuntingInfantry; _hunt = [_x,independent] spawn RAZ_fnc_spawnHuntingInfantry; }; Would it be possible to select only half of the current players? And a maximum number of players is the count is odd? cheers :)
  6. All fixed! Still some little tweaks to make though. My script spawns (per player) 1 chopper, 1 vehicle and 2 fire teams to hunt down the player whilst also fighting eachother. Thanks for your help! Just need to ties it all together now with my loot and end game scripts :) #include "scripts\hunting\huntingArrays.sqf"; mapCenter = [ worldSize / 2, worldSize / 2, 0 ]; RAZ_fnc_spawnHuntingInfantry = { params [ "_unit", [ "_side", EAST ] ]; _sideID = _side call BIS_fnc_sideID; _faction = East; if ( _sideID == 0 ) then { _faction = _faction }; if ( _sideID == 1 ) then { _faction = West }; if ( _sideID == 2 ) then { _faction = Independent }; _pos = getPosATL _unit; _huntingGroups = _unit getVariable [ "RAZ_fnc_isBeingHunted", 0 ]; _huntingGroups = _huntingGroups + 1; _unit setVariable [ "RAZ_fnc_isBeingHunted", _huntingGroups, true ]; _spawnPos = _pos getPos [ 600, random 360 ]; _spawnPos = [ _spawnPos, 1, 10, 1, 0, 45, 0 ] call BIS_fnc_findSafePos; _grp = [ _spawnPos, _faction, ( selectRandom (RAZ_fnc_infantryConfigs select _sideID) ) ] call BIS_fnc_spawnGroup; { _x setUnitAbility 0.1; _x setskill ["aimingAccuracy",0.05]; _x setskill ["aimingShake",0.9]; _x setskill ["aimingSpeed",0.1]; _x setskill ["Endurance",0.1]; _x setskill ["spotDistance",0.5]; _x setskill ["spotTime",0.5]; _x setskill ["courage",0.1]; _x setskill ["reloadSpeed",0.1]; } forEach units _grp; { gm addCuratorEditableObjects [ [_x], true ]; } forEach units _grp; _searchWp = [ getPos _unit, random 500, random 360 ] call BIS_fnc_relPos; _wp = _grp addWaypoint [_searchWp, 0]; [_grp, 1] setWaypointType "SAD"; [_grp, 1] setWaypointSpeed "NORMAL"; _grp setFormation "LINE"; while { ( { alive _x } count units _grp ) >= 1 } do { _timer = time + 10; if ( alive _unit ) then { _unit = _unit }; if ( !alive _unit ) then { _unit setVariable [ "RAZ_fnc_isBeingHunted", _huntingGroups, false ]; sleep 2; _unit = selectRandom ( allPlayers select { alive _x } ); while { ( count ( waypoints _grp ) ) > 0 } do { deleteWaypoint ( ( waypoints _grp ) select 0 ); }; _searchWp = [ getPos _unit, random 500, random 360 ] call BIS_fnc_relPos; _wp = _grp addWaypoint [ _searchWp, 0 ]; [ _grp, 1 ] setWaypointType "SAD"; [ _grp, 1 ] setWaypointType "NORMAL"; _grp setFormation "LINE"; }; waitUntil { sleep 120; position _unit distance _spawnpos > 30 OR time > _timer OR ({alive _x} count units _grp) isEqualTo 0 }; deleteWaypoint [_grp, 1]; _searchWp = [ getPos _unit, random 300, random 360 ] call BIS_fnc_relPos; _wp = _grp addWaypoint [_searchWp, 1]; [_grp, 1] setWaypointType "SAD"; [_grp, 1] setWaypointSpeed "NORMAL"; _grp setFormation "LINE"; }; sleep 1; _huntingGroups = _unit getVariable ["RAZ_fnc_isBeingHunted",0]; _huntingGroups = _huntingGroups - 1; _unit setVariable ["RAZ_fnc_isBeingHunted",_huntingGroups,true]; }; RAZ_fnc_spawnHuntingVehicle = { params ["_unit"]; _huntingVehicles = _unit getVariable [ "RAZ_fnc_isBeingHuntedByVehicle", 0 ]; _huntingVehicles = _huntingVehicles + 1; _unit setVariable [ "RAZ_fnc_isBeingHuntedByVehicle", _huntingVehicles, true ]; _randomSide = selectRandom[0,2]; _faction = east; if ( _randomSide == 0 ) then { _faction = east } else { _faction = independent }; _pos = getPosATL _unit; _spawnPos = _pos getPos [ 1500, random 360 ]; _spawnPos = [ _spawnPos, 1, 50, 1, 0, 35, 0 ] call BIS_fnc_findSafePos; _patrolVehicle = [ _spawnPos, 180, ( selectRandom (RAZ_fnc_vehicleConfigs select _randomSide) ), _faction ] call bis_fnc_spawnvehicle; _veh = _patrolVehicle select 0; _crew = _patrolVehicle select 2; { gm addCuratorEditableObjects [ [_x], true ]; } forEach units _crew; gm addCuratorEditableObjects [ [ _veh ], true ]; while { ( { alive _x } count units _crew ) >= 1 AND alive _veh } do { if ( !alive _unit ) then { _unit setVariable [ "RAZ_fnc_isBeingHuntedByVehicle", _huntingVehicles, false ]; _unit = selectRandom ( allPlayers select { alive _x } ); while { ( count ( waypoints _grp ) ) > 0 } do { deleteWaypoint ( ( waypoints _grp ) select 0 ); }; _searchWp = [ getPos _unit, random 1000, random 360 ] call BIS_fnc_relPos; _wp = _grp addWaypoint [ _searchWp, 0 ]; [ _grp, 1 ] setWaypointType "SAD"; [ _grp, 1 ] setWaypointType "NORMAL"; }; waitUntil { (count (allplayers - switchableUnits) > 0) }; _unit = selectRandom ( allPlayers select { alive _x } ); _timer = time + 180; while { ( count ( waypoints _crew ) ) > 0 } do { deleteWaypoint ( ( waypoints _crew ) select 0 ); }; _searchWp = [ getPos _unit, random 1000, random 360 ] call BIS_fnc_relPos; _wp = _crew addWaypoint [_searchWp, 0]; [_crew, 0] setWaypointType "SAD"; [_crew, 0] setWaypointSpeed "NORMAL"; waituntil { time > _timer }; }; waitUntil { ( { alive _x } count units _crew ) isEqualTo 0 OR !alive _veh }; while { ( count ( waypoints _crew ) ) > 0 } do { deleteWaypoint ( ( waypoints _crew ) select 0 ); }; sleep 300; _huntingVehicles = _unit getVariable ["RAZ_fnc_isBeingHuntedByVehicle",0]; _huntingVehicles = _huntingVehicles - 1; _unit setVariable ["RAZ_fnc_isBeingHuntedByVehicle",_huntingVehicles,true]; }; RAZ_fnc_spawnHuntingAir = { params ["_unit"]; waitUntil { time > 60 }; _huntingAir = _unit getVariable [ "RAZ_fnc_isBeingHuntedByAir", 0 ]; _huntingAir = _huntingAir + 1; _unit setVariable [ "RAZ_fnc_isBeingHuntedByAir", _huntingAir, true ]; _randomSide = selectRandom[0,2]; _faction = east; if ( _randomSide == 0 ) then { _faction = east } else { _faction = independent }; _spawnPos = mapCenter getPos [ random worldSize / 2, random 360 ]; _spawnPos = [ _spawnPos, 1, random worldSize / 2, 10, 0, 35, 0 ] call BIS_fnc_findSafePos; _patrolVehicle = [ _spawnPos, 180, ( selectRandom (RAZ_fnc_airVehicleConfigs select _randomSide) ), _faction ] call bis_fnc_spawnvehicle; _veh = _patrolVehicle select 0; _crew = _patrolVehicle select 2; _searchLight = [_veh] execVM "AL_searchlight\al_search_light_ini.sqf"; { gm addCuratorEditableObjects [ [_x], true ]; } forEach units _crew; gm addCuratorEditableObjects [ [ _veh ], true ]; while { ( { alive _x } count units _crew ) >= 1 AND alive _veh } do { if ( !alive _unit ) then { _unit setVariable [ "RAZ_fnc_isBeingHuntedByAir", _huntingAir, false ]; _unit = selectRandom ( allPlayers select { alive _x } ); while { ( count ( waypoints _grp ) ) > 0 } do { deleteWaypoint ( ( waypoints _grp ) select 0 ); }; _searchWp = [ getPos _unit, random 1000, random 360 ] call BIS_fnc_relPos; _wp = _grp addWaypoint [ _searchWp, 0 ]; [ _grp, 1 ] setWaypointType "SAD"; [ _grp, 1 ] setWaypointType "NORMAL"; }; waitUntil { (count (allplayers - switchableUnits) > 0) }; _unit = selectRandom ( allPlayers select { alive _x } ); _timer = time + 60; while { ( count ( waypoints _crew ) ) > 0 } do { deleteWaypoint ( ( waypoints _crew ) select 0 ); }; _searchWp = [ getPos _unit, random 1000, random 360 ] call BIS_fnc_relPos; _wp = _crew addWaypoint [_searchWp, 0]; [_crew, 0] setWaypointType "SAD"; [_crew, 0] setWaypointSpeed "NORMAL"; waituntil { time > _timer }; }; waitUntil { ( { alive _x } count units _crew ) isEqualTo 0 OR !alive _veh }; while { ( count ( waypoints _crew ) ) > 0 } do { deleteWaypoint ( ( waypoints _crew ) select 0 ); }; sleep 300; _huntingAir = _unit getVariable ["RAZ_fnc_isBeingHuntedByAir",0]; _huntingAir = _huntingAir - 1; _unit setVariable ["RAZ_fnc_isBeingHuntedByAir",_huntingAir,true]; }; _spawningEnemies = [] spawn { _players = []; _vehiclePlayers = []; _spawnHunters = true; if ( debugScript ) then { format [ "Operation Missdrop System Initialized" ] remoteExec ["systemChat"]; }; waitUntil {time > 0}; while { _spawnHunters } do { waitUntil { sleep 3; (count (allplayers - switchableUnits) > 0) }; _players = (allplayers - switchableUnits) select {(_x getVariable ["RAZ_fnc_isBeingHunted",0]) isEqualTo 0}; _vehiclePlayers = (allplayers - switchableUnits) select {(_x getVariable ["RAZ_fnc_isBeingHuntedByVehicle",0]) isEqualTo 0}; _airPlayers = (allplayers - switchableUnits) select {(_x getVariable ["RAZ_fnc_isBeingHuntedByAir",0]) isEqualTo 0}; _players apply { _hunt = [_x,east] spawn RAZ_fnc_spawnHuntingInfantry; _hunt = [_x,independent] spawn RAZ_fnc_spawnHuntingInfantry; }; _vehiclePlayers apply { _hunt = [_x] spawn RAZ_fnc_spawnHuntingVehicle; }; _vehiclePlayers apply { _hunt = [_x] spawn RAZ_fnc_spawnHuntingAir; }; }; }; ///////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// // END GAME SCRIPTING --------------------------------------------------------------- ///////////////////////////////////////////////////////////////////////////////////// ///////////////////////////////////////////////////////////////////////////////////// _endGameTimer = 600; waitUntil { time > _endGameTimer && count (allPlayers select {group _x isEqualTo group (allPlayers select 0)}) isEqualTo count allPlayers; }; format ["All soldiers found. Receiving intel on extraction point, ETA 10 mins!"] remoteExec ["hint"]; sleep 600;
  7. *Untested... 0 = [ "<t color='#FF0000'>AmmoboxInit</t>", [ this, true ] ] spawn BIS_fnc_arsenal;
  8. I'm currently working on a loot script ( done before i know, but i enjoy learning )... And all seems to work correctly. Player distance from "House" is checked, each building in range is selected and depending on the variable assigned will start to spawn loot in building positions and debug markers created.... What im struggling with, is the ability to run a check for loot deletion.. I want to check that (1) the player is at least (say 100m) away from building position, and time since the loot was spawned has passed a certain amount, but only de-spawn loot when both are true.... Hope that makes sense.... Here is what i have thus far: if !(isServer) exitWith {}; RAZ_fnc_lootArray = [ [ // Uniforms "U_C_IDAP_Man_cargo_F" ], [ // Backpacks "B_AssaultPack_blk" ], [ // Vests "V_PlateCarrierGL_blk" ], [ // Headgear "H_HelmetSpecO_blk" ], [ // Items "FirstAidKit" ], [ // Survival "ItemCompass" ] ]; RAZ_fnc_spawnLoot = { _spawnDistance = 80; // Set the distance to building for loot spawn... _spawnChance = 5; // Set the % chance of loot spawning ( 0.5 - 5 is recommended)... _enableDebug = true; // Enable debug loot markers... _buildings = player nearObjects [ "House", _spawnDistance ]; // Get buildings close to player... { if ( ( _x getVariable ["hasLoot", 0] ) == 0 ) then { _buildingPositions = [ _x ] call BIS_fnc_buildingPositions; // Get positions in buildings if variable is false... { if ( player distance _x <= _spawnDistance && _spawnChance > random 100 ) then { _lootSelection = floor ( random 7 ); if ( _lootSelection == 0 ) then { _rifleConfigs = "getNumber( _x >> 'scope' ) isEqualTo 2 && { getNumber( _x >> 'type' ) isEqualTo 1 && getText( _x >> 'cursor' ) == 'arifle' }"configClasses( configFile >> "CfgWeapons" ) apply { configName _x }; _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _itemHolder addWeaponCargoGlobal [ (selectRandom ( _rifleConfigs ) ), 1]; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _markerText = format [ "%1", _lootSelection ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText _markerText; } }; // Spawn weapon loot if ( _lootSelection == 1 ) then { _rifleConfigs = "getNumber( _x >> 'scope' ) isEqualTo 2 && { getNumber( _x >> 'type' ) isEqualTo 1 && getText( _x >> 'cursor' ) == 'arifle' }"configClasses( configFile >> "CfgWeapons" ) apply { configName _x }; _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _item = ( selectRandom ( _rifleConfigs ) ); _mags = getArray ( configFile >> "CfgWeapons" >> _item >> "magazines" ); _mag = ( selectRandom ( _mags ) ); _itemHolder addMagazineCargoGlobal [_mag, (random 4)]; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _markerText = format [ "%1", _lootSelection ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText _markerText; } }; // Spawn ammo loot if ( _lootSelection == 2 ) then { _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _itemHolder addItemCargoGlobal [ (selectRandom ( RAZ_fnc_lootArray select 0 ) ), 1]; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _markerText = format [ "%1", _lootSelection ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText _markerText; } }; // Spawn uniform loot if ( _lootSelection == 3 ) then { _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _itemHolder addBackpackCargoGlobal [ (selectRandom ( RAZ_fnc_lootArray select 1 ) ), 1]; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _markerText = format [ "%1", _lootSelection ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText _markerText; } }; // Spawn backpack loot if ( _lootSelection == 4 ) then { _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _itemHolder addItemCargoGlobal [ (selectRandom ( RAZ_fnc_lootArray select 2 ) ), 1]; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _markerText = format [ "%1", _lootSelection ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText _markerText; } }; // Spawn vest loot if ( _lootSelection == 5 ) then { _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _itemHolder addItemCargoGlobal [ (selectRandom ( RAZ_fnc_lootArray select 3 ) ), 1]; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _markerText = format [ "%1", _lootSelection ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText _markerText; } }; // Spawn headgear loot if ( _lootSelection == 6 ) then { _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _itemHolder addItemCargoGlobal [ (selectRandom ( RAZ_fnc_lootArray select 4 ) ), 1]; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _markerText = format [ "%1", _lootSelection ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText _markerText; } }; // Spawn item loot if ( _lootSelection == 7 ) then { _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _itemHolder addItemCargoGlobal [ (selectRandom ( RAZ_fnc_lootArray select 5 ) ), 1]; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _markerText = format [ "%1", _lootSelection ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText _markerText; } }; // Spawn survival loot }; // End spawn distance and chance check... } forEach _buildingPositions; // End for each building position... _x setVariable ["hasLoot", 1]; // Set the building variable to true... }; // Enf building variavble check... } forEach _buildings; // End for each building... }; // End RAZ_fnc_spawnLoot... //====================================// // LETS CALL THE FUNCTION FOR TESTING // //====================================// _spawnLoot = [] spawn { _spawnLoot = true; while { _spawnLoot } do { _lootSpawner = [] call RAZ_fnc_spawnLoot; sleep 1; }; };
  9. RoryRothon

    Random Loot Script

    I figured as much. I currently have initPlayerLocal running the building checks locally and once returned true then fire remoteExec to server for all clients. Im still learning sqf but getting better as the days roll by. Thanks for you help :)
  10. RoryRothon

    Random Loot Script

    Coming back to this script after working on something else. I would like to set this up for multiplayer... This code will be run on the dedi server and i was just wondering if Player is referenced on dedi? I have a feeling it is not. Would it be advisable to wrap this up with: _players = allPlayers - switchableUnits; { // Loot code }forEach _players; Kind regards Rory
  11. Is it at all possible to get the objectID of a players map from their inventory? We are wanting to save array of markers to the map object so that each map has a different set of markers that are user created. Any help or a point in the right direction would be greatly appreciated... Kind regards Rory
  12. RoryRothon

    Get objectID of players Map (MP)

    Just to expand a little: Scenario: Player 1 marks their map Markers are saved to that map only. User then places map on the ground and player 2 picks map up. Player 2 now sees the markers saved to player one's map. Player 1 picks up player two's map and only see'e markers created by player two. Rather than saving markers locally, we would like to be able to save markers to individual maps. You can only see markers created by another player by picking up their map....
  13. Hey there. I am working on a custom coded mission called "Operation Missdrop" where players have jumped out of a struck airframe and are scattered across the map. All the while, players have East and Guer hunting them down which includes vehicles... Although i have everything working great, i have hit an issue regarding vehicles and crews.. _eastPatrolVehicle = [ _spawnPos, 180, (selectRandom (RAZ_fnc_groundPatrolVehiclesEast)), East ] call bis_fnc_spawnvehicle; _veh = _eastPatrolVehicle select 0; _crew = _eastPatrolVehicle select 2; Currently i have a waituntil holding the script until the _veh is destroyed. I want to create a check that checks if the vehicle is destroyed or all crew members are dead... You can see my attempted commented below haha waitUntil { !alive _veh }; //waitUntil { ({!alive _x;} forEach crew _veh;) or (!alive _veh) }; if ( debugScript ) then { format ["East vehicle has been destroyed, or all crew members are dead!"] remoteExec ["systemChat"]; }; deleteWaypoint [_crew, 0]; { deleteVehicle _x } forEach units _crew; deleteGroup _crew; sleep 300; So to clarify: Check to see if either the vehicle is destroyed or all crew are dead if all crew are dead, do nothing to the vehicle and leave it on the map If vehicle empty but crew are alive, do nothing and wait until the crew or vehicle are dead I hope this makes sense lol Kind regards Rory
  14. Let me explain it simply. I would like to pause my code until either: _veh is destroyed or immobilised OR the crew of _veh have left the vehicle OR crew of _veh are dead. Using waitUntil Does that explain it a bit better? Kind regards Rory
  15. Sorry for being a pain, but how would one call the function within my vehicle spawn / hunt script? _spawnEastGroundVehicle = [] spawn { waitUntil { time > 10 }; while { spawnVehiclePatrols } do { _spawnPos = mapCenter getPos [ random worldSize / 2, random 360 ]; _spawnPos = [ _spawnPos, 1, random worldSize / 2, 10, 0, 35, 0 ] call BIS_fnc_findSafePos; _eastPatrolVehicle = [ _spawnPos, 180, (selectRandom (RAZ_fnc_groundPatrolVehiclesEast)), East ] call bis_fnc_spawnvehicle; _veh = _eastPatrolVehicle select 0; _crew = _eastPatrolVehicle select 2; _veh setPilotLight true; { gm addCuratorEditableObjects [ [_x], true ]; } forEach units _crew; gm addCuratorEditableObjects [ [ _veh ], true ]; while { alive _veh } do { sleep 2; waitUntil { (count (allplayers - switchableUnits) > 0) }; _unit = selectRandom ( allPlayers select { alive _x } ); if ( alive _unit ) then { _unit = _unit; sleep 2; }; if ( !alive _unit ) then { sleep 2; waitUntil { (count (allplayers - switchableUnits) > 0) }; _unit = selectRandom ( allPlayers select { alive _x } ); }; deleteWaypoint [ _crew, 0 ]; _wp = _crew addWaypoint [ position _unit, 0 ]; if ( debugScript ) then { format ["East vehicle has switched target to %1", name _unit] remoteExec ["systemChat"]; }; [_crew, 0] setWaypointType "SAD"; [_crew, 0] setWaypointSpeed "NORMAL"; sleep 10; }; waitUntil { !alive _veh }; if ( debugScript ) then { format ["East vehicle has been destroyed, or all crew members are dead!"] remoteExec ["systemChat"]; }; deleteWaypoint [_crew, 0]; { deleteVehicle _x } forEach units _crew; deleteGroup _crew; sleep 300; }; }; And one would assume i can use the function on various instances of the above script? Kind regards Rory
  16. lol Grumpy i swear your stalking me! The BIS forums should knight you! Thanks again buddy, i shall give it a whirl!
  17. Just to point out, my commented code was used without the waitUntil above it.....
  18. RoryRothon

    Random Loot Script

    This is what i have so far & all is working fine! But, is there any advice as to optimization etc for my code? I'm learning to code in Arma3 and am loving the experience and learning curve... I also need to start looking into *multiplayer - izing* it if anyone has any pointers? RAZ_fnc_lootArray = [ [ // Weapons "arifle_MXC_F" ], [ // Uniforms "U_C_IDAP_Man_cargo_F" ], [ // Backpacks "B_AssaultPack_blk" ], [ // Vests "V_PlateCarrierGL_blk" ], [ // Headgear "H_HelmetSpecO_blk" ], [ // Items "FirstAidKit" ], [ // Survival "ItemCompass" ], [ // Weapon attachments ] ]; _RAZ_fnc_spawnLoot = [] spawn { _runScript = true; _spawnDistance = 30; // Set the distance to building for loot spawn... _spawnChance = 100; // Set the % chance of loot spawning ( 0.5 - 5 is recommended)... _deletionTime = 1 * 60; // mins before loot deleted ready for respawn (will only delete when player is ?? far away and timer is over ??) (30 mins recommended)... _deletionDistance = 500; // Remove building variable when player >= 500m away... _buildingCoolOff = 1 * 60; // Time between fresh loot spawning / replacing into a building (1 hour recommended) _enableDebug = true; // Enable debug loot markers... _spawnedLoot = []; // Array- netId of spawned item holders _buildingsArray = []; // Array of all buildings checked... while { _runScript } do { _buildings = player nearObjects [ "House", _spawnDistance ]; // Get buildings close to player... { if (_x getVariable ["buildingEmpty", true]) then { _coolOfPeriod = time + _buildingCoolOff; _buildingsArray pushBack [_x call BIS_fnc_netId, _coolOfPeriod]; _buildingPositions = [ _x ] call BIS_fnc_buildingPositions; // Get positions in buildings if variable is false... { if ( player distance _x <= _spawnDistance && _spawnChance >= random 100 ) then { _lootSelection = Ceil random 8; if ( _lootSelection == 1 ) then { _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _item = ( selectRandom ( RAZ_fnc_lootArray select 0 ) ); _itemHolder addWeaponCargoGlobal [ _item, 1]; _timer = time + _deletionTime; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText "Weapon"; }; if !(isNull _itemHolder) then { _spawnedLoot pushBack [_itemHolder call BIS_fnc_netId, _timer, _x] }; }; // Spawn weapon loot if ( _lootSelection == 2 ) then { _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _item = ( selectRandom ( RAZ_fnc_lootArray select 0 ) ); _mags = getArray ( configFile >> "CfgWeapons" >> _item >> "magazines" ); _mag = ( selectRandom ( _mags ) ); _itemHolder addMagazineCargoGlobal [_mag, (random 4)]; _timer = time + _deletionTime; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText "Ammo"; }; if !(isNull _itemHolder) then { _spawnedLoot pushBack [_itemHolder call BIS_fnc_netId, _timer, _x] }; }; // Spawn ammo loot if ( _lootSelection == 3 ) then { _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _itemHolder addItemCargoGlobal [ (selectRandom ( RAZ_fnc_lootArray select 1 ) ), 1]; _timer = time + _deletionTime; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText "Uniform"; }; if !(isNull _itemHolder) then { _spawnedLoot pushBack [_itemHolder call BIS_fnc_netId, _timer, _x] }; }; // Spawn uniform loot if ( _lootSelection == 4 ) then { _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _itemHolder addBackpackCargoGlobal [ (selectRandom ( RAZ_fnc_lootArray select 2 ) ), 1]; _timer = time + _deletionTime; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText "Backpack"; }; if !(isNull _itemHolder) then { _spawnedLoot pushBack [_itemHolder call BIS_fnc_netId, _timer, _x] }; }; // Spawn backpack loot if ( _lootSelection == 5 ) then { _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _itemHolder addItemCargoGlobal [ (selectRandom ( RAZ_fnc_lootArray select 3 ) ), 1]; _timer = time + _deletionTime; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText "Vest"; }; if !(isNull _itemHolder) then { _spawnedLoot pushBack [_itemHolder call BIS_fnc_netId, _timer, _x] }; }; // Spawn vest loot if ( _lootSelection == 6 ) then { _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _itemHolder addItemCargoGlobal [ (selectRandom ( RAZ_fnc_lootArray select 4 ) ), 1]; _timer = time + _deletionTime; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText "Headgear"; }; if !(isNull _itemHolder) then { _spawnedLoot pushBack [_itemHolder call BIS_fnc_netId, _timer, _x] }; }; // Spawn headgear loot if ( _lootSelection == 7 ) then { _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _itemHolder addItemCargoGlobal [ (selectRandom ( RAZ_fnc_lootArray select 5 ) ), 1]; _timer = time + _deletionTime; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText "Inventory Item"; }; if !(isNull _itemHolder) then { _spawnedLoot pushBack [_itemHolder call BIS_fnc_netId, _timer, _x] }; }; // Spawn item loot if ( _lootSelection == 8 ) then { _itemHolder = "WeaponHolderSimulated" createVehicle [0,0,0]; _itemHolder setPos _x; _itemHolder addItemCargoGlobal [ (selectRandom ( RAZ_fnc_lootArray select 6 ) ), 1]; _timer = time + _deletionTime; if ( _enableDebug ) then { _markerID = format [ "%1", _x ]; _debug = createMarker [_markerID, _x]; _debug setMarkerType "mil_dot"; _debug setMarkerColor "ColorRed"; _debug setMarkerText "Survival Item"; }; if !(isNull _itemHolder) then { _spawnedLoot pushBack [_itemHolder call BIS_fnc_netId, _timer, _x] }; }; // Spawn survival loot... }; // End spawn distance and chance check... } forEach _buildingPositions; // End for each building position... _x setVariable ["buildingEmpty", false]; // Set the building variable to false... }; // End building variable check... } forEach _buildings; // End for each building... { _obj = _x select 0 call BIS_fnc_objectFromNetId; _getMarkerName = _x select 2; _markerName = format [ "%1", _getMarkerName ]; if ( player distance _obj > _deletionDistance && time > _x select 1 ) then { deleteVehicle _obj; deleteMarker _markerName; _spawnedLoot deleteAt (_spawnedLoot find _x) }; } forEach _spawnedLoot; // Foreach loot item in array... { _building = _x select 0 call BIS_fnc_objectFromNetId; if ( player distance _building > _deletionDistance && time > _x select 1 ) then { _building setVariable [ "buildingEmpty", true ] }; } forEach _buildingsArray; // Foreach building in array... hint str _spawnedLoot; sleep 2; // Time between spawn checks... }; // End while loop... }; // End RAZ_fnc_spawnLoot...
  19. I am working on a custom Zeus module and all is ok and working fine, but im going about things the long way... My module enable the user to place down a group (defined in cfgGroups) and assign different parameters to the group upon spawn. Like i say, it is working but i am having to create an array like so: array = [ [ // Name of group "OPFOR - Recon Patrol" ], [ // Group config "configfile >> "CfgGroups" >> "east" >> "OPF_F" >> "Infantry" >> "OI_reconPatrol"" ], [ // Group Speed "Limited", "Normal", "Full" ], [ // Group Formation "Wedge", .............. ............. ] ]; // etc etc etc........ My question is: Is it possible to grab an array from "cfgGroups" that i can access key => value from? I would like to get the name in my first array, and the config into my second array....... Coming from php i would love to know if the key => value thing is possible too.. I have been playing around and read the wiki but just cannot seem to find a solution for the life of me! I hope this makes sense lol As always, thanks for any and all help i receive... Regards Rory
  20. RoryRothon

    Compile array from cfgGroups

    You know what, that never even crossed my mind! Thanks, i'll look into it.....
  21. RoryRothon

    Compile array from cfgGroups

    Last one i swear! Would someone be willing and able to help me format the array into this: array =[ [ "Side", [ "Faction", [ "type", [ "Group", [ "GroupName", "GroupConfig" ] ] ] ] ] (Side) = Array of sides (Faction) = Array of factions per side (Type) = Array of types per faction per side (Group) = Array of groups per type per faction per side (Name And Config) = 'Name' and 'Config Path' per group in (Group) array. One would assume i can access values inside the array like so: ?? array select 0 (Side 1) //East array select 1 (Side 2) //West array select 2 (Side 3) //Indep array ( select 0 ( select 0 ) ) //East - Faction1 etc........ The plan is to populate the dropdown menu via array, and depending on the selection result, populate the second dropdown with an inner array, so on and so forth....
  22. RoryRothon

    Compile array from cfgGroups

    lol i know, i know! And hello again Grumpy! I just read you PM thanks... This, although excellent, is not quite what im wanting to do. I want to create and array of ALL groups not sorted by side... The idea is to populate a drop down menu with all available group names that also has the config path: group1 -- name --config path group2 -- name -- config path etc etc So menu would be group1 (name) and spawn script would contain group1 (config path)
  23. RoryRothon

    Compile array from cfgGroups

    Right, getting closer lol I can access information from a group so long as i include the CfgGroups path like so: _name = getText (configfile >> "CfgGroups" >> "east" >> "OPF_F" >> "Infantry" >> "OI_reconPatrol" >> "Name"); But if i need to include the full path for every group this is going to take some time haha & i can only pull info, not the config path... I have tried getArray but that always seems to return empty: array = getArray ( configFile >> "CfgGroups" ); If i could pull a complete array of CfgGroups, that would make my life so much easier. I have even tried this with no joy (undefined variable in expression _x): array = getArray ( configFile >> "CfgGroups" >> _x >> _x >> "Infantry" >> _x ); As you can see, i am trying to grab info like this: SIDE >> FACTION >> INFANTRY >> GROUP >> (NAME & CONFIG PATH) I hope this clears things up a little?
  24. RoryRothon

    Compile array from cfgGroups

    Im not using php, maybe did not explain correctly. I simply want to know if there is a way i can grab an array of all groups of all factions & sides from configFile >> "cfgGroups" so that i can access names and configs from the array into my code...
  25. Hi (again), i have setup a loop to add alive players into an array and remove dead. Want i'm struggling to grasp, is how i can in-fact access variables from further down in my sqf file? I'm trying to learn SQF, and i am really enjoying it! But this is confusing the hell out of me lol As always, i am extremely grateful of any and all help.. Kind regards Rory... This is what i have setup: _loopCheck = [] spawn { _displayResults = true; while { _displayResults } do { _alivePlayers = []; { if ( alive _x && isPlayer _x ) then { _alivePlayers = _alivePlayers + [_x] }; if ( !alive _x && isPlayer _x ) then { _alivePlayers = _alivePlayers - [_x]; }; } forEach allPlayers - switchableUnits; _aliveCount = count _alivePlayers; sleep 2; }; };
×