Home   Help Search Login Register  

Author Topic: PublicVariable with an Array - (1.09)  (Read 1454 times)

0 Members and 1 Guest are viewing this topic.

Offline Lor

  • Members
  • *
PublicVariable with an Array - (1.09)
« on: 19 Jan 2008, 14:32:11 »
Hi all, it's me again!

I'm having a bit of an issue with passing an Array around in multiplayer using publicVariable. Basically, I need to transfer an array from unit A to unit B when unit B performs an action.

At the moment, I'm using the following code:

Code: [Select]
_unitA = (here I grab the unit that I want to obtain the array from);
_randomID = floor(random 30000);


call compile format["getArray_%1 = [""blah""];", _randomID];

call compile format["_unitA setVehicleInit ""getArray_%1 = +globalArrayA; publicVariable 'getArray_%1';"";", _randomID];
processInitCommands;

call compile format["waitUntil {((getArray_%1 select 0) != ""blah"")};", _randomID];

After this code is executed, getArray_(random number) should be equal to globalArrayA, which is local to unit A.

Just for information, the format of globalArrayA is ["", "", FALSE, FALSE, FALSE, []] - so it's two strings, three bools, and a nested array.

Interestingly, I'm using the exact same code to transfer an integer elsewhere in the script, and it works perfectly - it's just this array thing that I can't figure out. SOMETHING gets passed, because the waitUntil stops looping, but it's not the array from unit A.

I hope I've explained this well enough, if you need any more info please ask! Many thanks.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: PublicVariable with an Array - (1.09)
« Reply #1 on: 19 Jan 2008, 15:00:32 »
I dont see anything wrong there, while I have tested array publications with 1.09, only "weird" thing might be that the name of the variable published is between ' instead of ".

After the last while you might hint all the getArray_ content to see what's there.

Offline Lor

  • Members
  • *
Re: PublicVariable with an Array - (1.09)
« Reply #2 on: 19 Jan 2008, 15:47:55 »
Hrm, I'll try it with the variable name between "" instead of '.

I have a sideChat thing that tells me the value of the array.

What happens is unit A and unit B both have woundArray, which starts off as ["", "", FALSE, FALSE, FALSE, []].

Then, unit A gets wounded, so the woundArray on unit A's machine changes to ["bullet wound", "", FALSE, FALSE, FALSE, []].

Unit B wants to check what wound unit A has, so I use the previously posted code to transfer unit A's woundArray to the variable getArray_(random number), then public variable it.

What happens is getArray_(random number) returns as ["", "", FALSE, FALSE, FALSE, []] -- even after unit A was wounded.

Any ideas? I've been trying to work out this particular problem for literally two weeks.


Unit A array
["bullet wound", "leg", FALSE, FALSE, FALSE, []]