WyBrator 10 Report post Posted October 14, 2017 I can't Figure out why my map marker isn't updating with my supply track position... Sort Version of my .sqf Spoiler _truck = createVehicle [_truckClassToUse, _spawnLocation, [], 0, "NONE"]; if(!isNull _truck) then { //private["_truck"]; _group addVehicle _truck; WBV_liveVehiclesArray = WBV_liveVehiclesArray + [_truck]; _truck setVariable ["SC_repairStatus",false,true]; _truck setVariable ["vehPos",_spawnLocation,true]; _truck setVariable ["vehClass",_truckClassToUse,true]; _WBV_truckSpawnLocation = [_spawnLocation,_radius,worldName]; _truck setVariable ["SC_truckSpawnLocation", _WBV_truckSpawnLocation,true]; _truck setFuel 1; _truck engineOn true; if(WBV_rcssTruckLocked) then { _truck lock 3; _truck setVehicleLock "LOCKED"; _truck setVariable ["ExileIsLocked", 1, true]; } else { _truck lock 0; _truck setVehicleLock "UNLOCKED"; _truck setVariable ["ExileIsLocked", 0, true]; }; _truck setVariable ["ExileIsPersistent", false]; _truck setSpeedMode "LIMITED"; _truck limitSpeed 60; _truck action ["LightOn", _truck]; _truck addEventHandler ["getin", "_this call SC_fnc_getIn;"]; _truck addEventHandler ["getout", "_this call SC_fnc_getOut;"]; _truck addMPEventHandler ["mpkilled", "_this call SC_fnc_truckDestroyed;"]; _truck addMPEventHandler ["mphit", "_this call SC_fnc_hitLand;"]; _Truck setVehicleVarName "SupplyTruck"; //diag_log format ["%1",_this]; //_Truck = _this select 0; _truckPos = position _truck; _mk = createMarker ["truckLocation",_truckPos]; _mk setMarkerPos _truckPos; Sleep 0.5; if(_side == "survivor") then { "truckLocation" setMarkerType "WBVExileConvoyGreenIcon"; "truckLocation" setMarkerText "Survivor Supply"; } else { "truckLocation" setMarkerType "WBVExileConvoyRedIcon"; "truckLocation" setMarkerText "Bandit Supply"; "truckLocation" setMarkerColor "ColorWhite"; "truckLocation" setMarkerSize [(1), (1)]; }; while {not isnull _truck do { "truckLocation" setmarkerpos getpos _truck; sleep 0.5; }; /* while {true} do { _pos = position _truck; _mk = vehicleVarName _truck; //_mk setMarkerPos _pos; //Sleep 0.5; //_posXY = position _x; //_marker = vehicleVarName _x; _mk setMarkerPos (getPosATL _truck); }; */ //deleteMarker vehicleVarName _truck; deleteMarker _mk; }; The Full .sqf Spoiler if (!isServer) exitWith {}; [] spawn { while {true} do { _logDetail = format['[WBV-RCSS:Supply Trucks] Started']; [_logDetail] call WBV_fnc_log; // set the default side for bandit AI _side = "bandit"; // more than _scaleAI players on the server and the max AI count drops per additional player _currentPlayerCount = count playableUnits; _maxAIcount = SC_maxAIcount; if(_currentPlayerCount > SC_scaleAI) then { _maxAIcount = _maxAIcount - (_currentPlayerCount - SC_scaleAI) ; }; // Don't spawn additional AI if the server fps is below _minFPS if(diag_fps < SC_minFPS) exitWith { _logDetail = format ["[WBV-RCSS:Supply Trucks]:: Held off spawning more AI as the server FPS is only %1",diag_fps]; [_logDetail] call WBV_fnc_log; }; _aiActive = { !isPlayer _x } count allunits; if((_aiActive > _maxAIcount) && !WBV_rcssTruckIgnoreCount) exitWith { _logDetail = format ["[WBV-RCSS:Supply Trucks]:: %1 active AI, so not spawning AI this time",_aiActive]; [_logDetail] call SC_fnc_log; }; WBV_liveVehicles = count(WBV_liveVehiclesArray); if (WBV_liveVehicles >= WBV_maxNumberofTruck) exitWith { _logDetail = format['[WBV-RCSS:Supply Trucks] End check %1 currently active (max %2) @ %3',WBV_liveVehicles,WBV_maxNumberofTruck,time]; [_logDetail] call SC_fnc_log; }; _trucksToSpawn = (WBV_maxNumberofTruck - WBV_liveVehicles); _middle = worldSize/2; _spawnCenter = [_middle,_middle,0]; _maxDistance = _middle; if(_trucksToSpawn > 0) then { if(WBV_rcssTruckSurvivors) then { // decide which side to spawn _sideToSpawn = random 100; if(_sideToSpawn <= SC_SurvivorsChance) then { _side = "survivor"; }; }; _useLaunchers = DMS_ai_use_launchers; for "_i" from 1 to _trucksToSpawn do { if (_trucksToSpawn > 0) then { private["_group"]; _locationArray = WBV_rcssTruckFixedPositions; // Select the spawn position _spawnLocation = [0,0,0]; _radius = 2000; if(WBV_rcssTruckUseFixedPos) then { { _vehLocation = _x getVariable "SC_truckSpawnLocation"; _locationArray = _locationArray - [_vehLocation]; }forEach WBV_liveVehiclesArray; if(count _locationArray > 0) then { _randomLocation = _locationArray call BIS_fnc_selectRandom; _spawnLocation = _randomLocation select 0; _radius = _randomLocation select 1; _locationArray = _locationArray - [_randomLocation]; } else { _spawnLocation = [ true, false ] call SC_fnc_findsafePos; _radius = 2000; }; } else { _spawnLocation = [ true, false ] call SC_fnc_findsafePos; _radius = 2000; }; diag_log format["[WBV-RCSS:Supply Trucks] found position %1",_spawnLocation]; _group = createGroup SC_BanditSide; if(_side == "survivor") then { deleteGroup _group; _group = createGroup SC_SurvivorSide; }; _group setVariable ["DMS_AllowFreezing",false]; _group setVariable ["DMS_LockLocality",false]; _group setVariable ["DMS_SpawnedGroup",true]; _group setVariable ["DMS_Group_Side", _side]; _truckClass = WBV_truckClassToUse call BIS_fnc_selectRandom; _truckClassToUse = _truckClass select 0; vehicleOkToSpawn = false; // Percentage chance to spawn a rare vehicle _rareChance = round (random 100); if(_rareChance >= 90) then { while{!vehicleOkToSpawn} do { if (_side == "survivor") then { _truckClass = WBV_SurvivorTruckClassToUseRare call BIS_fnc_selectRandom; _truckClassToUse = _truckClass select 0; _truckClassAllowedCount = _truckClass select 1; _truckCount = 0; { if(_truckClassToUse == typeOf _x) then { _truckCount = _truckCount + 1; }; }forEach WBV_liveVehiclesArray; if(_truckCount < _truckClassAllowedCount OR _truckClassAllowedCount == 0) then { vehicleOkToSpawn = true; }; } else { _truckClass = WBV_TruckClassToUseRare call BIS_fnc_selectRandom; _truckClassToUse = _truckClass select 0; _truckClassAllowedCount = _truckClass select 1; _truckCount = 0; { if(_truckClassToUse == typeOf _x) then { _truckCount = _truckCount + 1; }; }forEach WBV_liveVehiclesArray; if(_truckCount < _truckClassAllowedCount OR _truckClassAllowedCount == 0) then { vehicleOkToSpawn = true; }; }; }; } else { while{!vehicleOkToSpawn} do { if (_side == "survivor") then { _truckClass = WBV_SurvivorTruckClassToUse call BIS_fnc_selectRandom; _truckClassToUse = _truckClass select 0; _truckClassAllowedCount = _truckClass select 1; _truckCount = 0; { if(_truckClassToUse == typeOf _x) then { _truckCount = _truckCount + 1; }; }forEach WBV_liveVehiclesArray; if(_truckCount < _truckClassAllowedCount OR _truckClassAllowedCount == 0) then { vehicleOkToSpawn = true; }; } else { _truckClass = WBV_TruckClassToUse call BIS_fnc_selectRandom; _truckClassToUse = _truckClass select 0; _truckClassAllowedCount = _truckClass select 1; _truckCount = 0; { if(_truckClassToUse == typeOf _x) then { _truckCount = _truckCount + 1; }; }forEach WBV_liveVehiclesArray; if(_truckCount < _truckClassAllowedCount OR _truckClassAllowedCount == 0) then { vehicleOkToSpawn = true; }; }; }; }; _truck = createVehicle [_truckClassToUse, _spawnLocation, [], 0, "NONE"]; if(!isNull _truck) then { //private["_truck"]; _group addVehicle _truck; WBV_liveVehiclesArray = WBV_liveVehiclesArray + [_truck]; _truck setVariable ["SC_repairStatus",false,true]; _truck setVariable ["vehPos",_spawnLocation,true]; _truck setVariable ["vehClass",_truckClassToUse,true]; _WBV_truckSpawnLocation = [_spawnLocation,_radius,worldName]; _truck setVariable ["SC_truckSpawnLocation", _WBV_truckSpawnLocation,true]; _truck setFuel 1; _truck engineOn true; if(WBV_rcssTruckLocked) then { _truck lock 3; _truck setVehicleLock "LOCKED"; _truck setVariable ["ExileIsLocked", 1, true]; } else { _truck lock 0; _truck setVehicleLock "UNLOCKED"; _truck setVariable ["ExileIsLocked", 0, true]; }; _truck setVariable ["ExileIsPersistent", false]; _truck setSpeedMode "LIMITED"; _truck limitSpeed 60; _truck action ["LightOn", _truck]; _truck addEventHandler ["getin", "_this call SC_fnc_getIn;"]; _truck addEventHandler ["getout", "_this call SC_fnc_getOut;"]; _truck addMPEventHandler ["mpkilled", "_this call SC_fnc_truckDestroyed;"]; _truck addMPEventHandler ["mphit", "_this call SC_fnc_hitLand;"]; _Truck setVehicleVarName "SupplyTruck"; //diag_log format ["%1",_this]; //_Truck = _this select 0; _truckPos = position _truck; _mk = createMarker ["truckLocation",_truckPos]; _mk setMarkerPos _truckPos; Sleep 0.5; if(_side == "survivor") then { "truckLocation" setMarkerType "WBVExileConvoyGreenIcon"; "truckLocation" setMarkerText "Survivor Supply"; } else { "truckLocation" setMarkerType "WBVExileConvoyRedIcon"; "truckLocation" setMarkerText "Bandit Supply"; "truckLocation" setMarkerColor "ColorWhite"; "truckLocation" setMarkerSize [(1), (1)]; }; while {not isnull _truck do { "truckLocation" setmarkerpos getpos _truck; sleep 0.5; }; /* while {true} do { _pos = position _truck; _mk = vehicleVarName _truck; //_mk setMarkerPos _pos; //Sleep 0.5; //_posXY = position _x; //_marker = vehicleVarName _x; _mk setMarkerPos (getPosATL _truck); }; */ //deleteMarker vehicleVarName _truck; deleteMarker _mk; }; // Calculate the number of seats in the vehicle and fill the required amount _crewRequired = WBV_minimumCrewAmount; if(WBV_maximumCrewAmount > WBV_minimumCrewAmount) then { _crewRequired = ceil(random[WBV_minimumCrewAmount,WBV_maximumCrewAmount-WBV_minimumCrewAmount,WBV_maximumCrewAmount]); }; _amountOfCrew = 0; _unitPlaced = false; _truckRoles = (typeOf _truck) call bis_fnc_vehicleroles; { _unitPlaced = false; _truckRole = _x select 0; _truckSeat = _x select 1; if(_truckRole == "Driver") then { _loadOut = [_side] call SC_fnc_selectGear; _unit = [_group,_spawnLocation,"custom","random",_side,"Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; _amountOfCrew = _amountOfCrew + 1; _unit disableAI "FSM"; _unit disableAI "MOVE"; [_side,_unit] call SC_fnc_addMarker; _unit removeAllMPEventHandlers "mphit"; _unit removeAllMPEventHandlers "mpkilled"; _unit disableAI "TARGET"; _unit disableAI "AUTOTARGET"; _unit disableAI "AUTOCOMBAT"; _unit disableAI "COVER"; _unit disableAI "SUPPRESSION"; _unit assignAsDriver _truck; _unit moveInDriver _truck; _unit setVariable ["DMS_AssignedVeh",_truck]; _unit setVariable ["SC_drivenVehicle", _truck,true]; _unit addMPEventHandler ["mpkilled", "_this call SC_fnc_driverKilled;"]; _truck setVariable ["SC_assignedDriver", _unit,true]; }; if(_truckRole == "Turret" && _amountOfCrew < _crewRequired) then { _loadOut = [_side] call SC_fnc_selectGear; _unit = [_group,_spawnLocation,"custom","random",_side,"Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; _amountOfCrew = _amountOfCrew + 1; [_side,_unit] call SC_fnc_addMarker; _unit moveInTurret [_truck, _truckSeat]; _unit setVariable ["DMS_AssignedVeh",_truck]; _unit addMPEventHandler ["mpkilled", "_this call SC_fnc_unitMPKilled;"]; _unitPlaced = true; }; if(_truckRole == "CARGO" && _amountOfCrew < _crewRequired) then { _loadOut = [_side] call SC_fnc_selectGear; _unit = [_group,_spawnLocation,"custom","random",_side,"Vehicle",_loadOut] call DMS_fnc_SpawnAISoldier; _amountOfCrew = _amountOfCrew + 1; [_side,_unit] call SC_fnc_addMarker; _unit assignAsCargo _truck; _unit moveInCargo _truck; _unit setVariable ["DMS_AssignedVeh",_truck]; _unit addMPEventHandler ["mpkilled", "_this call SC_fnc_unitMPKilled;"]; _unitPlaced = true; }; if(SC_extendedLogging && _unitPlaced) then { _logDetail = format['[WBV-RCSS:Supply Trucks] %1 %2 added to vehicle %3',_side,_truckRole,_truck]; [_logDetail] call WBV_fnc_log; }; if(_amountOfCrew == _crewRequired) exitWith{}; } forEach _truckRoles; // Get the AI to shut the fuck up enableSentences false; enableRadio false; _logDetail = format['[WBV-RCSS:Supply Trucks] %3 vehicle %1 spawned @ %2',_truckClassToUse,_spawnLocation,_side]; [_logDetail] call WBV_fnc_log; sleep 2; { _unit = _x; _unit enableAI "FSM"; _unit enableAI "MOVE"; _unit enableAI "TARGET"; _unit enableAI "AUTOTARGET"; _unit enableAI "AUTOCOMBAT"; _unit allowCrewInImmobile false; reload _unit; _unitName = [_side] call SC_fnc_selectName; if(!isNil "_unitName") then { _unit setName _unitName; }; }forEach units _group; [_group,false] call DMS_fnc_FreezeToggle; [units _group] orderGetIn true; sleep 10; [_group, _spawnLocation, 2000] call bis_fnc_taskPatrol; _group setBehaviour "AWARE"; _group setCombatMode "RED"; sleep 0.2; clearMagazineCargoGlobal _truck; clearWeaponCargoGlobal _truck; clearItemCargoGlobal _truck; _truck addMagazineCargoGlobal ["HandGrenade", (random 2)]; _truck addItemCargoGlobal ["ItemGPS", (random 1)]; _truck addItemCargoGlobal ["Exile_Item_InstaDoc", (random 1)]; _truck addItemCargoGlobal ["Exile_Item_PlasticBottleFreshWater", 2 + (random 2)]; _truck addItemCargoGlobal ["Exile_Item_EMRE", 2 + (random 2)]; // Add weapons with ammo to the vehicle _possibleWeapons = [ "arifle_MXM_Black_F", "arifle_MXM_F", "arifle_MX_SW_Black_F", "arifle_MX_SW_F", "LMG_Mk200_F", "LMG_Zafir_F" ]; _amountOfWeapons = 1 + (random 3); for "_i" from 1 to _amountOfWeapons do { _weaponToAdd = _possibleWeapons call BIS_fnc_selectRandom; _truck addWeaponCargoGlobal [_weaponToAdd,1]; _magazinesToAdd = getArray (configFile >> "CfgWeapons" >> _weaponToAdd >> "magazines"); _truck addMagazineCargoGlobal [(_magazinesToAdd select 0),round random 3]; }; } else { _logDetail = format['[WBV-RCSS:Supply Trucks] vehicle %1 failed to spawn (check classname is correct)',_truckClassToUse]; [_logDetail] call WBV_fnc_log; }; }; }; WBV_liveVehicles = count(WBV_liveVehiclesArray); _logDetail = format['[WBV-RCSS:Supply Trucks] End check %1 currently active (max %2) @ %3',WBV_liveVehicles,WBV_maxNumberofTruck,time]; [_logDetail] call WBV_fnc_log; }; }; Share this post Link to post Share on other sites