Home   Help Search Login Register  

Author Topic: Public variables  (Read 1291 times)

0 Members and 1 Guest are viewing this topic.

popS

  • Guest
Public variables
« 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?

TheCaptn

  • Guest
Re:Public variables
« Reply #1 on: 25 Jan 2005, 17:44:11 »
JumpOnLeftLegScreemingImALuckyPotatoe

Oh if only...  ;D

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:Public variables
« Reply #2 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.  
« Last Edit: 25 Jan 2005, 18:09:51 by Mr.Peanut »
urp!

popS

  • Guest
Re:Public variables
« Reply #3 on: 25 Jan 2005, 18:26:08 »
Thats it, Thx a mill.