OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: Acecool on 04 Mar 2005, 19:53:36

Title: Splicing a variable together with format.. Then getting the value?
Post by: Acecool on 04 Mar 2005, 19:53:36
;? _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.
Title: Re:Splicing a variable together with format.. Then getting the value?
Post by: ACF on 04 Mar 2005, 20:13:37
Aren't you missing the Call command:

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

?
Title: Re:Splicing a variable together with format.. Then getting the value?
Post by: RujiK on 04 Mar 2005, 20:18:42
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.
Title: Re:Splicing a variable together with format.. Then getting the value?
Post by: THobson on 04 Mar 2005, 21:16:16
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 (http://www.ofpec.com/yabbse/index.php?board=6;action=display;threadid=22309)
Title: Re:Splicing a variable together with format.. Then getting the value?
Post by: Planck on 04 Mar 2005, 21:38:26
Quote
call is for calling a .sqf file

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

Check the comref.


Planck
Title: Re:Splicing a variable together with format.. Then getting the value?
Post by: Acecool on 04 Mar 2005, 21:42:28
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]