Jump to content
Sign in to follow this  
shiner

Variable Variables

Recommended Posts

Howdy, thank you in advance for the help.

I think I might have seen this done before, but can't find it in all my searching.

For each player I have named : W01, W02, W03

I want to have a "wallet" variable that stores the cash they have are earning during the mission : W01_wallet as the variable store player W01's cash.

What I want to do in my function is have a loop that takes the player name "W01" which is passed into the script and performs the other passed arguments.

I've tried to use format and call's but to no avail. Any ideas or do I have to resort to an ugly amount of duplication.

For example

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

// ["W01","Add",100] execVM "wallet.sqf"

Format["%1_wallet", (_this select 0)] = Format["%1_wallet", (_this select 0)] + 100;

Share this post


Link to post
Share on other sites

Is this for a multiplayer mission?

You may want to take into account that the variables are local, aswell as actions and menu's and whatnot. Unless it is imperative that one player can see how much money another player has than you could just go with a much easier route of setting one variable, Playermoney, and rewarding the players as you see fit, and if you want to 'spend' any money, using say an action menu or dialogue, it would only deduct the amount from one player due to it being local.

Otherwise you're on the right track but I would use something such as: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">call format ["%1_wallet = %1_wallet + 100",_this select 0]

Share this post


Link to post
Share on other sites
Is this for a multiplayer mission?

...

WOW. I just have to say I disobeyed your sig smile_o.gif and clicked. That RTS video is incredible.

As to your answers yes, it is a MP mission and your assumption is pretty accurate that I am using addActions for the "purchasing". My intent is to add some RTS elements to the game, through an economics model that rewards teamwork and mission success with $$ that can be used to by better equipment.

I'm still way out of my league on locality, but I will play around with using a single non public variable.

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  

×