Forum Jump :

Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 59
In-game name: Kobayashi Maru

 
#183696 Posted at 2015-11-02 21:05        
     
TamedFury, Wak gave you code to write in init.sqf or any script which runs at start. As _unit and _leader are local variables, you can't split the lines, spreading in multiple scopes (sqf, trigger or else).
Local variables need to stay in a local script, in order to refer to the same thing or return a consistent value.
You can place all the lines in a trigger but, as remembered every week on this forum, you need to execVM an sqf or wrap code in a scheduled event like this 0 = [] spawn {all code you want here}; in on act field of the trigger.

local or global? Each time you can script in local (here is the case) script in local. You can the use _unit in different scripts, for different contexts, avoiding overwriting.
Use global variables each time you want to declare something for all the scripts fired on your PC. That's true for all "name" you write in object editor. Example CAR1 in a Hunter edited object is a variable which refer to this object (even if dead) for all the game.
Furthermore, if you script for MP, have a look at publicVariable. This command, not simple to manage, allows you to share a variable on every PCs (It's not always the case for global ones! JIP issue).

This post was edited by Pierre MGI (2015-11-02 21:13, ago)

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS





Tags: Group, Scripting, Talk