Jump to content
Sign in to follow this  
kyfohatl

Can SetVariable/getVariable be used on default game locations?

Recommended Posts

Ok so I created this simple experimental script that I will use later on to tell which faction owns a certain location:

//create some custom locations on UTES island
_location1 = createLocation ["NameVillage", (getMarkerPos "cp1"), 20, 20];
_location2 = createLocation ["NameVillage", (getMarkerPos "cp2"), 20, 20];
_location3 = createLocation ["NameVillage", (getMarkerPos "cp3"), 20, 20];
_location4 = createLocation ["NameVillage", (getMarkerPos "cp4"), 20, 20];
_location5 = createLocation ["NameVillage", (getMarkerPos "cp5"), 20, 20];
_location6 = createLocation ["AirPort", (getMarkerPos "Airport"), 20, 20];

//put all capturable locations in the array _locationList
_locationList = nearestLocations [[5,5,5], ["NameVillage", "AirPort"], 25000];

//set controlling faction as USMC for now, will play around with that later
_n = 0;
while {_n < (count _locationList)} do {
(_locationList select _n) setVariable ["controlingFac", "USMC"];
_n = _n + 1;
sleep 0.2;
};

//just a simple test to tell me if it worked
_myStr = "";
_n = 0;
while {_n < (count _locationList)} do {
_myStr = _myStr + ((_locationList select _n) getVariable "controlingFac") + ",";
_n = _n + 1;
sleep 0.2;
};

hint format ["%1", _myStr];

Except it didn't work... so after some testing I tried the following script:

//create some custom locations on UTES island
_location1 = createLocation ["NameVillage", (getMarkerPos "cp1"), 20, 20];
_location2 = createLocation ["NameVillage", (getMarkerPos "cp2"), 20, 20];
_location3 = createLocation ["NameVillage", (getMarkerPos "cp3"), 20, 20];
_location4 = createLocation ["NameVillage", (getMarkerPos "cp4"), 20, 20];
_location5 = createLocation ["NameVillage", (getMarkerPos "cp5"), 20, 20];
_location6 = createLocation ["AirPort", (getMarkerPos "Airport"), 20, 20];

//NOTICE THAT IN THIS CASE DEFAULT GAME LOCATIONS (i.e. Kamenyy and Strelka) HAVE BEEN EXCLUDED
_locationList = [];
_locationList = _locationList + [_location1] + [_location2] + [_location3] + [_location4] + [_location5] + [_location6];

//set controlling faction as USMC for now, will play around with that later
_n = 0;
while {_n < (count _locationList)} do {
(_locationList select _n) setVariable ["controlingFac", "USMC"];
_n = _n + 1;
sleep 0.2;
};

//just a simple test to tell me if it worked
_myStr = "";
_n = 0;
while {_n < (count _locationList)} do {
_myStr = _myStr + ((_locationList select _n) getVariable "controlingFac") + ",";
_n = _n + 1;
sleep 0.2;
};

hint format ["%1", _myStr];

It worked this time. Based on this I assume that I cannot use setVariable/getVariable on default locations (in this case villages of Kamenyy and Strelka)? I can only use it on custom locations that I created (using createLocation) in the script?

It'd be nice if someone pointed out what I'm doing wrong/ or a way to work around that.

(Btw I did do some research under "setVariable" but I did not find anything relevant)

Share this post


Link to post
Share on other sites

It's strange how it works for one not the other, The really odd thing is if you place hint str (_location1 getVariable "controlingFac"); at the end of the script it has the data ie "UMSC"

if you place a hint in the final while you can see the string being built but it won't show outside the while.

hint str _myStr;

Share this post


Link to post
Share on other sites

Damn is there a way to work around this? All factions in the mission run this one script and it needs to tell them which locations they own and which locations are owned by other factions. Maybe I just have to use the vars_Array method:

vars_Array = [["Kamenyy", "CDF"], ["Strelka", "USMC"], etc.]; ---> first element will specify the location, second element tells which faction owns it.

Except the problem with this is that I don't know how to retrieve the name of a default in-game location. The "name" command doesn't seem to work with locations. Any better ideas?

Share this post


Link to post
Share on other sites

Place a game logic on the location and give it the name of the village? :)

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  

×