OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Acecool on 04 Aug 2008, 19:37:57
-
Is it possible to do something like
foreach array as _variable
{
? (this select 0 == Player) && (this select 0 distance < 100 from workzone) : {_variable}_money+=civ_paycheck
};
-
* Use forEach , which puts the iterated value into the special variable, _x (you can use this on one line in SQS, which is line-based, but you can spread it on multiple lines in SQF).
* You can't use ?: inside {} or in an SQF script, so you have to use if/then/else.
* You also don't have += defined in the parser, and have to do that manually.
* I have no idea what you are trying to achieve with "{_variable}_money", but I'd guess you want to use dynamic code to generate the variable-name.
* I assume you mean to use _this, rather than this.
{
if (((_this select 0) == Player) && (((_this select 0) distance workzone) < 100)) then
{
call format ["%1_money = %1_money + civ_paycheck", _x];
};
} forEach array;
I'd worry about learning the simple end of scripting syntax before worrying too much about forEach and dynamic code generation.