Jump to content
Sign in to follow this  
giallustio

Location and setvariable

Recommended Posts

Hi guys!

I need a little help with this script.

I'm trying to get a list of all "CityCenter" and then apply a variable to all of them.

This what i tried:

BTC_locations = nearestLocations [getPos player, ["CityCenter"], 99999];
{_x setVariable ["BTC_var", 0];hint format ["%1 - %2", _x, _x getVariable "BTC_var"];sleep 1;} foreach BTC_locations;
//returns = "location cityCenter at xxxx,yyyy - <null>";

Share this post


Link to post
Share on other sites

The only thing I can think of is that it's not one of the recognised variables that you can store a variable in although it does say you can store in loactions.

Perhaps this

BTC_locations = [["CityCenter"],[player,99999]] call BIS_fnc_locations;
{_x setVariable ["BTC_var", 0];
hint format ["%1 - %2",getpos _x, _x getVariable "BTC_var"];
sleep 1;
} foreach BTC_locations;

This will also give the city name.

BTC_locations = [["CityCenter"],[player,2000]] call BIS_fnc_locations;
{_x setVariable ["BTC_var", 0];
hint format ["%1 - %2", _x  getvariable "name", _x getVariable "BTC_var"];
sleep 1;
} foreach BTC_locations;}

Edited by F2k Sel

Share this post


Link to post
Share on other sites

You need to add the line below, to pause your script to allow time for the functions to load properly. This is in reference to F2k Sel's code. If you are trying to run it at mission start.

waituntil {!isnil "bis_fnc_init"};

Worked fine when I added this.

Hope this helps

Blake.

Edited by blakeace

Share this post


Link to post
Share on other sites
You need to add the line below, to pause your script to allow time for the functions to load properly. This is in reference to F2k Sel's code. If you are trying to rule it at mission start.

waituntil {!isnil "bis_fnc_init"};

Worked fine when I added this.

Hope this helps

Blake.

I don't get this post at all... :) ...I posted that i solved the problem...And i already know/use that line :)

Share this post


Link to post
Share on other sites

He is right about my code it should have that line included as it's calling a function.

I actually wrote it a trigger so it wasn't needed.

As for the wiki being wrong I wouldn't know I don't understand 90% of the stuff to do with variables.

Glad it works anyway.

Share this post


Link to post
Share on other sites

Giallustio's code is correct but set/getVariable is broken for locations

https://dev-heaven.net/issues/12096

F2k Sel's code with BIS_fnc_locations is working because that function creates a game logic for every location, i.e. BTC_locations is an array of objects and not locations

Share this post


Link to post
Share on other sites

Glad to know that i'm not stupid :D

@F2k Sel

Don't worry! I always use that line in the init.sqf ;)

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  

×