Home   Help Search Login Register  

Author Topic: Splicing a variable together with format.. Then getting the value?  (Read 585 times)

0 Members and 1 Guest are viewing this topic.

Acecool

  • Guest
;? _this select 0 != _this select 1 : exit

_unit = _this select 0

? _unit == p1 : _unit_id = "p1"
? _unit == p2 : _unit_id = "p2"
? _unit == p3 : _unit_id = "p3"
? _unit == p4 : _unit_id = "p4"
? _unit == p5 : _unit_id = "p5"
? _unit == c1 : _unit_id = "c1"
? _unit == c2 : _unit_id = "c2"
? _unit == c3 : _unit_id = "c3"
? _unit == c4 : _unit_id = "c4"
? _unit == c5 : _unit_id = "c5"
? _unit == c6 : _unit_id = "c6"
? _unit == c7 : _unit_id = "c7"
? _unit == c8 : _unit_id = "c8"
? _unit == c9 : _unit_id = "c9"
? _unit == c10 : _unit_id = "c10"

_Money = format ["%1_Money", _unit_id]

hint format ["%1's Stats\n\nMoney: %2",name _unit,_Money]

Exit

---

Tried several ways, just returns "p1_Money" etc...

Any help is appreciated, thanks.

Offline ACF

  • Members
  • *
  • Llama?? Ain't that French for tanks?
Aren't you missing the Call command:

_Money = Call format ["%1_Money", _unit_id]

?

Offline RujiK

  • Members
  • *
  • KoKo Puh-Fizzles!
Im not exactly sure if this is your error, however this is an error.
_Money = format ["%1_Money", _unit_id] you have %1 strung together with _Money.
I would put in instead of what you have where you define the users i would put:
? _unit == p1 : _unit_id = "p1";_Cash = Moneyp1
Also you do not use call to format just to let you know, this will simply give you an error, call is for calling a .sqf file, not format.
« Last Edit: 04 Mar 2005, 20:22:15 by RujiK »
I like your approach, lets see your departure.
Download the New Flashlight Script!

Offline THobson

  • OFPEC Patron
  • Former Staff
  • ****
I believe the problem to be that the name command will return the name you have given the units in description.ext  If you have not given them a name you will not get anything - so producing the results you are getting.

Don't you have another thread on this problem?
http://www.ofpec.com/yabbse/index.php?board=6;action=display;threadid=22309
« Last Edit: 04 Mar 2005, 21:31:28 by THobson »

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Quote
call is for calling a .sqf file

Hmmm.....I think call can do more than just call sqf files.

Check the comref.


Planck
« Last Edit: 04 Mar 2005, 21:38:57 by Planck »
I know a little about a lot, and a lot about a little.

Acecool

  • Guest
That was for respawning etc etc...


Anyway, it works.. as it was...

Problem is with how I set the variables...

{call format ["%1_Money = 2500", _unit_id]}


To fix:

call format [{%1_Money = 2500}, _unit_id]
« Last Edit: 04 Mar 2005, 21:45:41 by Acecool »