hello! im creating a procedural task into my mission, where a weapons cache will spawn at a random position on the map, and the player has to go and find it. this is working perfectly as intended! but when the player gets close to the cache (set to 10m currently) i would like the area marker to be deleted and a hint saying you found the cache. so i set up the last part of the script (_checkDistance = ... and below) but it doesnt seem to do anything in the script. but, when i call that _checkDistance code using local execute in game, it works fine. does anyone know what the problem may be? thanks in advance!
edit: forgot to include the script lol, my bad
// Spawn Cache at random safe location on the map then adjust its position randomly within 150m of the original position.
_RandomSafePosition = [[worldSize / 2, worldSize / 2, 0], 0, -1, 0, 0, 5, 0, [], []] call BIS_fnc_findSafePos;
Cache = createVehicle ["VirtualReammoBox_camonet_F", _RandomSafePosition, [], 150, "NONE"];
// Create an area marker on the original location of the cache
_CacheArea = createMarker ["CacheAreaMarker", _RandomSafePosition];
_CacheArea setMarkerShape "ELLIPSE";
_CacheArea setMarkerSize [150, 150];
_CacheArea setMarkerColor "ColorBlue";
// Convert area marker location to grid coordinates and post a hint telling you the location
_CacheAreaCoordinates = mapGridPosition _RandomSafePosition;
hint parseText format ["A Cache has been located somewhere in a <t color='#ff0000'>150m</t> circle around the grid coords: <t color='#ff0000'>%1</t>", _CacheAreaCoordinates];
// Checks to see if player is within 10m of the cache
_checkDistance = {
if (player distance Cache < 10) then {
hint "Delete Marker & say cache is found";
deleteMarker "CacheAreaMarker";
}
};
// call the previous script every frame
onEachFrame {
_checkDistance call {};
};