OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: popS on 25 Jan 2005, 17:32:27

Title: Public variables
Post by: popS on 25 Jan 2005, 17:32:27
Im having trouble getting access to public variable in a script.
The variable is declared in a different script.
In script A:
Code: [Select]
WestFlag = WestFlag + [_flag]
PublicVariable "WestFlag"

In script B:
Code: [Select]
?!(Flag1 in WestFlag) : JumpOnLeftLegScreemingImALuckyPotatoe^^^^^^^^^^^^
This part look like its not working. It looks like the array "WestFlag" is empty.

"WestFlag" should be an array of objects, since "_flag" should be a flag. "Flag1" should also be a flag.

Maybe I shouldnt use public variables at all?
Title: Re:Public variables
Post by: TheCaptn on 25 Jan 2005, 17:44:11
JumpOnLeftLegScreemingImALuckyPotatoe

Oh if only...  ;D
Title: Re:Public variables
Post by: Mr.Peanut on 25 Jan 2005, 18:08:11
In your init.sqs before any reference to WestFlag try adding the following line :

Code: [Select]
WestFlag = []
to initialise the array.  Then you can add elements to it.  You only need to use PublicVariable when you want to update the WestFlag array on all clients and the server.  
Title: Re:Public variables
Post by: popS on 25 Jan 2005, 18:26:08
Thats it, Thx a mill.