Kolmain 6 Posted June 26, 2015 I'm using locations to gather information around the player. However, when I build an array of positions (which works fine), and get the position of a location, I can't use it for a majority of scripts, as the location errors out. As a temp workaround, I've been grabbing the nearest building and moving on but I noticed sometimes it doesn't find one and the script goes outa-wack. Any ideas? [color="#FF8040"][color="#1874CD"]_bool[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]false[/color][color="#8B3E2F"][b];[/b][/color] [color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#8B3E2F"][b]([/b][/color][color="#7A7A7A"]"randomSideMissions"[/color] [color="#191970"][b]call[/b][/color] BIS_fnc_getParamValue[color="#8B3E2F"][b])[/b][/color] [color="#8B3E2F"][b]=[/b][/color][color="#8B3E2F"][b]=[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#1874CD"]_bool[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#000000"]true[/color][color="#8B3E2F"][b],[/b][/color] [color="#000000"]false[/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] BIS_fnc_selectRandom[color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color] [color="#191970"][b]else[/b][/color] [color="#8B3E2F"][b]{[/b][/color] [color="#1874CD"]_bool[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#000000"]true[/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#191970"][b]if[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#1874CD"]_bool[/color][color="#8B3E2F"][b])[/b][/color] [color="#191970"][b]then[/b][/color] [color="#8B3E2F"][b]{[/b][/color] csarLoc [color="#8B3E2F"][b]=[/b][/color] sideLocations [color="#191970"][b]call[/b][/color] BIS_fnc_selectRandom[color="#8B3E2F"][b];[/b][/color] [color="#000000"]_pos[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#191970"][b]locationPosition[/b][/color] csarLoc[color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_array[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#191970"][b]nearestObjects[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#000000"]_pos[/color][color="#8B3E2F"][b],[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"house"[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b],[/b][/color] [color="#FF0000"]500[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_obj[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#1874CD"]_array[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_img[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#191970"][b]getText[/b][/color][color="#8B3E2F"][b]([/b][/color][color="#191970"][b]configFile[/b][/color] [color="#8B3E2F"][b]>[/b][/color][color="#8B3E2F"][b]>[/b][/color] [color="#7A7A7A"]"CfgVehicles"[/color] [color="#8B3E2F"][b]>[/b][/color][color="#8B3E2F"][b]>[/b][/color] [color="#8B3E2F"][b]([/b][/color][color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"B_Heli_Light_01_F"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"B_Heli_Light_01_armed_F"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"B_Heli_Light_01_stripped_F"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"B_Heli_Attack_01_F"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"B_Heli_Transport_01_F"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"B_Heli_Transport_01_camo_F"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"B_Heli_Transport_03_unarmed_F"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"B_Heli_Transport_03_F"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"B_Heli_Transport_03_black_F"[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"B_Heli_Transport_03_unarmed_green_F"[/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] bis_fnc_selectRandom[color="#8B3E2F"][b])[/b][/color] [color="#8B3E2F"][b]>[/b][/color][color="#8B3E2F"][b]>[/b][/color] [color="#7A7A7A"]"picture"[/color][color="#8B3E2F"][b])[/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_ret[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#191970"][b]getPos[/b][/color] [color="#1874CD"]_obj[/color][color="#8B3E2F"][b]][/b][/color] [color="#191970"][b]call[/b][/color] EVO_fnc_nearestTownName[color="#8B3E2F"][b];[/b][/color] [color="#000000"]_name[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#1874CD"]_ret[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]0[/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_distance[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#1874CD"]_ret[/color] [color="#191970"][b]select[/b][/color] [color="#FF0000"]1[/color][color="#8B3E2F"][b];[/b][/color] [color="#1874CD"]_descrip[/color] [color="#8B3E2F"][b]=[/b][/color] [color="#191970"][b]format[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#7A7A7A"]"OPFOR taken out a friendly bird near %1. They're sending squads to find the crew, get them out of there!"[/color][color="#8B3E2F"][b],[/b][/color] [color="#000000"]_name[/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] availableSideMissions [color="#8B3E2F"][b]=[/b][/color] availableSideMissions [color="#8B3E2F"][b]+[/b][/color] [color="#8B3E2F"][b][[/b][/color] [color="#8B3E2F"][b][[/b][/color][color="#191970"][b]getPos[/b][/color] [color="#1874CD"]_obj[/color][color="#8B3E2F"][b],[/b][/color] EVO_fnc_sm_csar[color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]"CSAR Downed Helo Crew"[/color][color="#8B3E2F"][b],[/b][/color] [color="#1874CD"]_descrip[/color][color="#8B3E2F"][b],[/b][/color][color="#7A7A7A"]""[/color][color="#8B3E2F"][b],[/b][/color][color="#1874CD"]_img[/color][color="#8B3E2F"][b],[/b][/color][color="#FF0000"]1[/color][color="#8B3E2F"][b],[/b][/color][color="#8B3E2F"][b][[/b][/color][color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b]][/b][/color] [color="#8B3E2F"][b]][/b][/color][color="#8B3E2F"][b];[/b][/color] [color="#8B3E2F"][b]}[/b][/color][color="#8B3E2F"][b];[/b][/color][/color] Made with KK's SQF to BBCode Converter Share this post Link to post Share on other sites
das attorney 857 Posted June 26, 2015 With your check: _array = nearestObjects [_pos, ["house"], 500]; It may be that there are no near houses, so _array = []; Then if you try to select the first element, there is nothing to select. So do a: if not (_array isEqualTo []) then {_obj = _array select 0; // more code... Share this post Link to post Share on other sites
Kolmain 6 Posted June 26, 2015 With your check: _array = nearestObjects [_pos, ["house"], 500]; It may be that there are no near houses, so _array = []; Then if you try to select the first element, there is nothing to select. So do a: if not (_array isEqualTo []) then {_obj = _array select 0; // more code... I can do that but I want to just get the correct position of the location and go with that to avoid the building search all together, thats just because of the location issue. I think it's bellow the ground or something? Is there a conversion I can do? Share this post Link to post Share on other sites
das attorney 857 Posted June 26, 2015 Have you logged what _pos is and looked at it? Share this post Link to post Share on other sites
Kolmain 6 Posted June 26, 2015 Have you logged what _pos is and looked at it? I can't remember off the top of my head as I'm at the office but I think it only have two entries, [x,y], so I tried doing [x,y,0] and it didnt help. :/ Share this post Link to post Share on other sites
das attorney 857 Posted June 26, 2015 Okay well hope you get it sorted when you get home. I can't really help any more as I don't know what the error is or what sideLocations or csarLoc is (there could be a problem there as well with those variables - who knows) so it's all guesswork at the mo. Share this post Link to post Share on other sites
Kolmain 6 Posted June 26, 2015 Okay well hope you get it sorted when you get home. I can't really help any more as I don't know what the error is or what sideLocations or csarLoc is (there could be a problem there as well with those variables - who knows) so it's all guesswork at the mo. Everything is defined and working, the problem is, and I can replicate it, that I can reference the locations exact position in functions, spawnings, or anything else other than map markers. Thanks though! Share this post Link to post Share on other sites
haleks 8204 Posted June 26, 2015 I didn't even know about locationPosition! ^^ I've always used position _location and never had a problem with it. :) Share this post Link to post Share on other sites
Kolmain 6 Posted June 26, 2015 I didn't even know about locationPosition! ^^I've always used position _location and never had a problem with it. :) I started with position, but went to locationPosition to try and resolve this. Didn't help :( Share this post Link to post Share on other sites
haleks 8204 Posted June 26, 2015 Weird, maybe there's something wrong with the way you gather locations and pass them to "sideLocations"? What does that array look like? Share this post Link to post Share on other sites
Kolmain 6 Posted June 26, 2015 Project @ https://github.com/Kolmain/Evolution-A3/tree/dev _locs = nearestLocations [spawnBuilding, ["NameLocal"], 100000]; sideLocations = _locs; Share this post Link to post Share on other sites
haleks 8204 Posted June 26, 2015 (edited) Project @ https://github.com/Kolmain/Evolution-A3/tree/dev _locs = nearestLocations [spawnBuilding, ["NameLocal"], 100000]; sideLocations = _locs; "NameLocal" locations don't always have a name I think; and looking at the first post I presume you want to gather towns and villages as well. So maybe the error is coming from there (you said in the OP that you do have positions for your locations); could you try with the following? _locs = nearestLocations [spawnBuilding, ["NameVillage", "NameCity", "NameCityCapital"], call bis_fnc_mapSize]; If you really need "NameLocal" locations, consider filtering them with nearestLocationWithDubbing. Hope this helps. :) Edited June 26, 2015 by Pepe Hal Share this post Link to post Share on other sites
Kolmain 6 Posted June 26, 2015 "NameLocal" locations don't always have a name I think; and looking at the first post I presume you want to gather towns and villages as well.So maybe the error is coming from there (you said in the OP that you do have positions for your locations); could you try with the following? _locs = nearestLocations [spawnBuilding, ["NameVillage", "NameCity", "NameCityCapital"], call bis_fnc_mapSize]; If you really need "NameLocal" locations, consider filtering them with nearestLocationWithDubbing. Hope this helps. :) No, I actually want these to stay away from towns and villages. :) Thanks for the tip! Share this post Link to post Share on other sites
haleks 8204 Posted June 26, 2015 You're welcome! Another way to check if NameLocal locations have a name (if indeed the error is coming from that) would be to check the config entries for each locations - it might be a simpler solution than nearestLocationWithDubbing. Keep us updated! ;) Share this post Link to post Share on other sites