Jump to content
Sign in to follow this  
1para{god-father}

CBA_fnc_getNearestBuilding confused

Recommended Posts

OK i have alot of marker zones on my map and have selected a random one, now I need to place a VIP in one of those zones but need it in a house

So i thought i would use CBA_fnc_getNearestBuilding I get the following returnedf to use:- [e78f200# 48009: house_k_1_ep1.p3d,6]

But now I am stuck how can I now use that to move my VIP into in? I know this example has 6 positions, so how could I random is the position as well?

VIP is called vip1

Or is there a easier way , thought i would use CBA as it is installed

Thanks

Share this post


Link to post
Share on other sites

I'd assume something like

_obj = _pos call CBA_fnc_getNearestBuilding;
_house = _obj select 0;
_housepos = floor (random (_obj select 1));
vip1 setPos (_house buildingPos _housepos);

Share this post


Link to post
Share on other sites
I'd assume something like

_obj = _pos call CBA_fnc_getNearestBuilding;
_house = _obj select 0;
_housepos = floor (random (_obj select 1));
vip1 setPos (_house buildingPos _housepos);

Ahhh FAB works :)

And I understand why, I was using select 1 to put him in the building forgot to start at select 0 !

Thanks

-----------------------------------------------

Any idea why this will not work ?

Working fine if I set _obj

_grp = createGroup RESISTANCE; 
_pilot = _grp createUnit ["GUE_Soldier_Pilot", _RandomTownPosition, [], 10, "FORM"];
_randomlocation= (mymissionmarkers) call BIS_fnc_selectRandom;
_obj = [5250,4750,0] call CBA_fnc_getNearestBuilding;
_house = _obj select 0;
_housepos = floor (random (_obj select 1));
_pilot setPos (_house buildingPos _housepos);

Not working but it is using the same thing only a randon location now

mymissionmarkers has the following : - ["[4150,11750,0]","[4150,11850,0]","[4250,11850,0]","[4250,11750,0]","[4150,11450,0]","[3950,11350,0]"]

_randomlocation = mymissionmarkers call BIS_fnc_selectRandom; // returns [2050,250,0] in .rpt

_grp = createGroup RESISTANCE; 
_pilot = _grp createUnit ["GUE_Soldier_Pilot", _RandomTownPosition, [], 10, "FORM"];
_obj = _randomlocation call CBA_fnc_getNearestBuilding;
_house = _obj select 0;
_housepos = floor (random (_obj select 1));
_pilot setPos (_house buildingPos _housepos);

.rpt

Error in expression <ivate ["_building", "_i"];

_building = nearestBuilding _this;

_i = 0;

while {s>

Error position: <nearestBuilding _this;

_i = 0;

while {s>

Error nearestbuilding: Type String, expected Array,Object

Edited by psvialli
Another Question !

Share this post


Link to post
Share on other sites

Your mymissionmarkers is an array of strings, which is why you're getting the Type String, expected Array error in the createUnit call.

 mymissionmarkers has the following : - [[4150,11750,0],[4150,11850,0],[4250,11850,0],[4250,11750,0],[4150,11450,0],[3950,11350,0]];

That should work, not sure what those " were doing in there. :)

Share this post


Link to post
Share on other sites
Your mymissionmarkers is an array of strings, which is why you're getting the Type String, expected Array error in the createUnit call.

 mymissionmarkers has the following : - [[4150,11750,0],[4150,11850,0],[4250,11850,0],[4250,11750,0],[4150,11450,0],[3950,11350,0]];

That should work, not sure what those " were doing in there. :)

Thanks but mymissionmarkers is generated as below, so am i going wrong there then if so what would i need to do to get rid of thoes extra "" ?

_houses = [markerpos _marker,700, 2, true] call findHouses;

{
_pos = _x call getGridPos;
_mkr = str _pos;
if (getMarkerPos _mkr select 0 == 0) then {
	_mkr = createMarkerLocal[_mkr, _pos]; 
	_mkr setMarkerShapeLocal "RECTANGLE"; 
	_mkr setMarkerTypeLocal "SOLID";		
	_mkr setMarkerSizeLocal [50,50]; 
	_mkr setMarkerAlphaLocal 0.9; 
	_mkr setMarkerColorLocal mymarkercolour; 
	[color="#FF0000"]mymissionmarkers set [count mymissionmarkers,_mkr];[/color]
};

} forEach _houses;

Edited by psvialli

Share this post


Link to post
Share on other sites

You could just replace _mkr with _pos in the red area there to keep track of the positions you're using.

Share this post


Link to post
Share on other sites

Like this if you want to store the marker positions in the array...

mymissionmarkers set [count mymissionmarkers,getmarkerpos _mkr];

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×