_Jack Posted August 23, 2017 Report Share Posted August 23, 2017 Hey guys, here is a simple script I made that allows players to scan for ore veins. I no longer run arma 2 servers so I decided to release some of the scripts I used! Hope you find it useful! :) //Range that it will scan for veins ScanRange = 1500; //Get number of each vein within defined range VeinsCountIron = count ((position player) nearObjects ["Iron_Vein_DZE",ScanRange]); VeinsCountSilver = count ((position player) nearObjects ["Silver_Vein_DZE",ScanRange]); VeinsCountGold = count ((position player) nearObjects ["Gold_Vein_DZE",ScanRange]); //Get total veins VeinsCountTotal = VeinsCountGold+VeinsCountSilver+VeinsCountIron; //Display results to player systemChat format["[IG]Within %1M there are %2 ore veins: %3 Iron, %4 Silver and %5 Gold.",ScanRange,VeinsCountTotal,VeinsCountIron,VeinsCountSilver,VeinsCountGold]; format["[IG]Within %1M there are %2 ore veins: %3 Iron, %4 Silver and %5 Gold.",ScanRange,VeinsCountTotal,VeinsCountIron,VeinsCountSilver,VeinsCountGold] call dayz_rollingMessages; Hooty, Schalldampfer, Zoranth and 1 other 4 Link to comment Share on other sites More sharing options...
Zoranth Posted August 23, 2017 Report Share Posted August 23, 2017 Thank you for this. Would you happen to have an idea on how to add a General direction such as N,NE,E,SE,S,SW,W,NW or if not then a direction in Degrees Relative? Such as 1 Silver Vein 140, 1 Iron Vein 224 I am pretty sure it would need to use the following but I really do not know how to implement it. _dir = [player, object] call BIS_fnc_relativeDirTo; juandayz 1 Link to comment Share on other sites More sharing options...
_Jack Posted August 23, 2017 Author Report Share Posted August 23, 2017 Could try something similar to this; _dir = [player, VeinsCountIron] call BIS_fnc_relativeDirTo systemchat format ["There is %1 Iron vein at %2 on compass",VeinsCountIron,_dir]; Might have to play around with foreach. Could cause lag if there are a lot of gems nearby though. Link to comment Share on other sites More sharing options...
Zoranth Posted August 23, 2017 Report Share Posted August 23, 2017 Thank you Jack, I will mess around with that and see if I can get it to work Link to comment Share on other sites More sharing options...
Ford Posted August 23, 2017 Report Share Posted August 23, 2017 Thank you for the script. Also, its more clearly to use: - getPosATL instead of position player (getPos), that slower in 1.67 times. - local variables instead of global. My variant: //Range that it will scan for veins _scanRange = 1500; //Get number of each vein within defined range _pos = getPosATL player; _ironVeins = count (_pos nearObjects ["Iron_Vein_DZE",_scanRange]); _silverVeins = count (_pos nearObjects ["Silver_Vein_DZE",_scanRange]); _goldVeins = count (_pos nearObjects ["Gold_Vein_DZE",_scanRange]); //Get total veins _total = _ironVeins + _silverVeins + _goldVeins; //Display results to player systemChat format["Within %1m there are %2 ore veins: %3 Iron, %4 Silver and %5 Gold.", _scanRange,_total,_ironVeins,_silverVeins,_goldVeins]; If you are using "Deploy Anything" script, its so simple to add script handler on right click on, e.g. map. DZE_CLICK_ACTIONS = DZE_CLICK_ACTIONS + ["ItemMap","Find Ore Veins","execVM 'scripts\findOreVeins.sqf';","true"]; Schalldampfer and Zoranth 2 Link to comment Share on other sites More sharing options...
Zoranth Posted August 23, 2017 Report Share Posted August 23, 2017 Thank you Ford for the variation. I will give it a try. I have already added this to my clickactions off of the Compass Also, what is your take on providing a direction to an ore vein type from player position? Any Ideas? Link to comment Share on other sites More sharing options...
SKS.Goliath Posted August 23, 2017 Report Share Posted August 23, 2017 nice this work Link to comment Share on other sites More sharing options...
Ford Posted August 23, 2017 Report Share Posted August 23, 2017 On 23.08.2017 at 0:57 PM, Zoranth said: Thank you Ford for the variation. I will give it a try. I have already added this to my clickactions off of the Compass Also, what is your take on providing a direction to an ore vein type from player position? Any Ideas? I modified the script a bit. Now it shows nearest iron, silver and gold ore vines, distance to it and direction too. E.g. Code: Spoiler private ["_ironVeins","_silverVeins","_goldVeins"]; /** Config. */ _scanRange = 1500; // Scanning range. _showAllVeines = true; // Show how many each ore vines are in range. E.g. Within 1500m there are 3 Ore Veins: 2 Iron, 0 Silver and 1 Gold. _showNearestIronOreVine = true; // Show nearest iron ore vine with distance and direction. _showNearestSilverOreVine = true; // Show nearest silver ore vine with distance and direction. _showNearestGoldOreVine = true; // Show nearest gold ore vine with distance and direction. _findObj = { private ["_class","_pos","_range","_objectsArray","_nearest"]; _class = _this select 0; _pos = _this select 1; _range = _this select 2; _objectsArray = []; _nearest = ""; { _objectsArray set [count _objectsArray, _x]; if (_forEachIndex == 0) then { _nearest = _x; }; } forEach nearestObjects [_pos, [_class], _scanRange]; [_objectsArray, count _objectsArray, _nearest] }; _revealNearest = { private ["_name","_nearest"]; _name = _this select 0; _nearest = _this select 1; _degree = round (abs ([player, _nearest] call BIS_fnc_relativeDirTo)); _distance = floor (player distance _nearest); _direction = call { if ((_degree >= 0 && _degree < 45) || _degree == 360) exitWith { 'North' }; if (_degree >= 45 && _degree < 90) exitWith { 'NorthEast' }; if (_degree >= 90 && _degree < 135) exitWith { 'East' }; if (_degree >= 135 && _degree < 180) exitWith { 'SouthEast' }; if (_degree >= 180 && _degree < 225) exitWith { 'South' }; if (_degree >= 225 && _degree < 270) exitWith { 'SouthWest' }; if (_degree >= 270 && _degree < 315) exitWith { 'West' }; if (_degree >= 315 && _degree < 360) exitWith { 'NorthWest' }; "unknown" }; systemChat format["Nearest %1 Ore Vein in %2m on the %3.", _name, _distance, _direction]; }; _pos = getPosATL player; _ironVeins = ["Iron_Vein_DZE", _pos, _scanRange] call _findObj; _silverVeins = ["Silver_Vein_DZE", _pos, _scanRange] call _findObj; _goldVeins = ["Gold_Vein_DZE", _pos, _scanRange] call _findObj; _ironCount = _ironVeins select 1; _silverCount = _silverVeins select 1; _goldCount = _goldVeins select 1; if (_showAllVeines) then { _total = _ironCount + _silverCount + _goldCount; if (_total > 0) then { systemChat format["Within %1m there are %2 Ore Veins: %3 Iron, %4 Silver and %5 Gold.", _scanRange, _total, _ironCount, _silverCount, _goldCount]; } else { systemChat format["Within %1m there are no Ore Vines.", _scanRange]; }; }; if (_showNearestIronOreVine && _ironCount > 0) then { ["Iron", (_ironVeins select 2)] call _revealNearest; }; if (_showNearestSilverOreVine && _silverCount > 0) then { ["Silver", (_silverVeins select 2)] call _revealNearest; }; if (_showNearestGoldOreVine && _goldCount > 0) then { ["Gold", (_goldVeins select 2)] call _revealNearest; }; Schalldampfer, WLF and Zoranth 3 Link to comment Share on other sites More sharing options...
Zoranth Posted August 23, 2017 Report Share Posted August 23, 2017 Thank You, This is what I was looking for. I will test it and let you know how it goes. Kind of makes it a possible treasure hunt for our players Link to comment Share on other sites More sharing options...
Zoranth Posted August 23, 2017 Report Share Posted August 23, 2017 @Ford I just tried this and it is showing the direction to the ore vein based on the direction you are facing. For example: If I am facing true north and the _nearest ore vein is to the east, it will display the ore vein is to the east. However, if I am facing east and the _nearest is to the east, it will display that the ore vein is to the north. In other words, it is displaying the relative direction based on the direction I am facing instead of true north. Link to comment Share on other sites More sharing options...
Ford Posted August 24, 2017 Report Share Posted August 24, 2017 @Zoranth Yeah, you are right. I just edited script and used other function to get real direction to object. Code: Spoiler /** Config. */ _scanRange = 1500; // Scanning range. _showAllVeines = true; // Show how many each ore vines are in range. E.g. Within 1500m there are 3 Ore Veins: 2 Iron, 0 Silver and 1 Gold. _showNearestIronOreVine = true; // Show nearest iron ore vine with distance and direction. _showNearestSilverOreVine = true; // Show nearest silver ore vine with distance and direction. _showNearestGoldOreVine = true; // Show nearest gold ore vine with distance and direction. _findObj = { private ["_class","_pos","_range","_objects","_objCount","_nearest"]; _class = _this select 0; _pos = _this select 1; _range = _this select 2; _nearest = objNull; _objects = nearestObjects [_pos, [_class], _scanRange]; _objCount = count _objects; if (_objCount > 0) then { _nearest = _objects select 0; }; [_objCount, _nearest] }; _revealNearest = { private ["_name","_nearest"]; _name = _this select 0; _nearest = _this select 1; _degree = round ([player, _nearest] call BIS_fnc_dirTo); if (_degree < 0 ) then { _degree = 360 + _degree }; _distance = floor (player distance _nearest); _direction = call { if ((_degree >= 0 && _degree < 45) || _degree == 360) exitWith { 'North' }; if (_degree >= 45 && _degree < 90) exitWith { 'NorthEast' }; if (_degree >= 90 && _degree < 135) exitWith { 'East' }; if (_degree >= 135 && _degree < 180) exitWith { 'SouthEast' }; if (_degree >= 180 && _degree < 225) exitWith { 'South' }; if (_degree >= 225 && _degree < 270) exitWith { 'SouthWest' }; if (_degree >= 270 && _degree < 315) exitWith { 'West' }; if (_degree >= 315 && _degree < 360) exitWith { 'NorthWest' }; "unknown" }; systemChat format["Nearest %1 Ore Vein in %2m on the %3.", _name, _distance, _direction]; }; _pos = getPosATL player; _ironVeins = ["Iron_Vein_DZE", _pos, _scanRange] call _findObj; _silverVeins = ["Silver_Vein_DZE", _pos, _scanRange] call _findObj; _goldVeins = ["Gold_Vein_DZE", _pos, _scanRange] call _findObj; _ironCount = _ironVeins select 0; _silverCount = _silverVeins select 0; _goldCount = _goldVeins select 0; if (_showAllVeines) then { _total = _ironCount + _silverCount + _goldCount; if (_total > 0) then { systemChat format["Within %1m there are %2 Ore Veins: %3 Iron, %4 Silver and %5 Gold.", _scanRange, _total, _ironCount, _silverCount, _goldCount]; } else { systemChat format["Within %1m there are no Ore Vines.", _scanRange]; }; }; if (_showNearestIronOreVine && _ironCount > 0) then { ["Iron", (_ironVeins select 1)] call _revealNearest; }; if (_showNearestSilverOreVine && _silverCount > 0) then { ["Silver", (_silverVeins select 1)] call _revealNearest; }; if (_showNearestGoldOreVine && _goldCount > 0) then { ["Gold", (_goldVeins select 1)] call _revealNearest; }; Zoranth 1 Link to comment Share on other sites More sharing options...
Zoranth Posted August 24, 2017 Report Share Posted August 24, 2017 @Ford@jack Thank You, This works Great. and again, Thank You @jack for the original work For anyone that wants to use actual Compass Directions in Degree's instead of Points of the Compass (otherwise known as a Compass Rose) you can change the following: Spoiler _degree = round ([player, _nearest] call BIS_fnc_dirTo); if (_degree < 0 ) then { _degree = 360 + _degree }; _distance = floor (player distance _nearest); // Remove or Comment out everything from this line _direction = call { if ((_degree >= 0 && _degree < 45) || _degree == 360) exitWith { 'North' }; if (_degree >= 45 && _degree < 90) exitWith { 'NorthEast' }; if (_degree >= 90 && _degree < 135) exitWith { 'East' }; if (_degree >= 135 && _degree < 180) exitWith { 'SouthEast' }; if (_degree >= 180 && _degree < 225) exitWith { 'South' }; if (_degree >= 225 && _degree < 270) exitWith { 'SouthWest' }; if (_degree >= 270 && _degree < 315) exitWith { 'West' }; if (_degree >= 315 && _degree < 360) exitWith { 'NorthWest' }; "unknown" }; // To this line // Change this line: systemChat format["Nearest %1 Ore Vein in %2m on the %3.", _name, _distance, _direction]; // To this: systemChat format["Nearest %1 Ore Vein in %2m on heading %3.", _name, _distance, _degree]; If you want to change the output from being displayed in System Chat to Rolling Messages that are in the middle of your screen. Do the following: Spoiler Change the following line" systemChat format["Nearest %1 Ore Vein in %2m on the %3.", _name, _distance, _direction]; // To this: format["Nearest %1 Ore Vein in %2m on the %3.", _name, _distance, _direction]; call dayz_rollingMessages; You could even have two separate files. One that is activated off of the Map that gives the Points of the Compass (General Direction such as NW, W, SE) to the ore vein. Then have the second file that is activated off of the GPS that gives the actual relative direction from you to the ore vein. Link to comment Share on other sites More sharing options...
_Jack Posted August 25, 2017 Author Report Share Posted August 25, 2017 No problem @Zoranth :)))) Link to comment Share on other sites More sharing options...
Hooty Posted August 26, 2017 Report Share Posted August 26, 2017 GG @_Jack I know we never saw eye to eye but glad too hear you turned over a leaf Link to comment Share on other sites More sharing options...
Reaper5150 Posted December 11, 2019 Report Share Posted December 11, 2019 How would one go about only allowing certain players with a set amount of humanity to only be able to use this? Say players with 5000 and -5000? Thanks, Link to comment Share on other sites More sharing options...
GodZilla Posted December 16, 2019 Report Share Posted December 16, 2019 In your Click Actions replace this: ["ItemMap","Find Ore Veins","execVM 'scripts\findOreVeins.sqf';","true"] with this: ["ItemMap","Find Ore Veins","execVM 'scripts\findOreVeins.sqf';","(player getVariable['humanity',0] < -5000 || player getVariable['humanity',0] > 5000)"] Reaper5150 1 Link to comment Share on other sites More sharing options...
Reaper5150 Posted December 19, 2019 Report Share Posted December 19, 2019 Okay! thank you :) Link to comment Share on other sites More sharing options...
Reaper5150 Posted December 20, 2019 Report Share Posted December 20, 2019 Unfortunately it does not work! It will not execute script. Link to comment Share on other sites More sharing options...
GodZilla Posted December 20, 2019 Report Share Posted December 20, 2019 just change in your clickactions: "true" with this: "(player getVariable['humanity',0] < -5000 || player getVariable['humanity',0] > 5000)" Link to comment Share on other sites More sharing options...
dayz noob Posted January 14, 2020 Report Share Posted January 14, 2020 is it possible to do this with player id ? rather then humanity? Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now