OFPEC Forum

Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting Multiplayer => Topic started by: Dmitri on 17 Dec 2007, 13:47:42

Title: Random and publicVariable
Post by: Dmitri on 17 Dec 2007, 13:47:42
I've got a clientside script that requires a random value every few seconds from the server.

The server is successfully generating a random value in a loop and broadcasting it via a publicVariable.

My problem is that the clientside script only fetches the value once from the publicVariable, the variable does
not change clientside after mission start.

Do I need to exit and restart the clientside script repeatedly (instead of looping it) to "reload" the variable?
Title: Re: Random and publicVariable
Post by: Loyalguard on 17 Dec 2007, 15:07:50
I assume that the client side script using the value of the public variable directly in the loop?  Is that correct?

If so, this might be a long shot but what about a line at or near the beginning of your loop that assigns the public variable to a local variable and thereby theoretically "reloading" it everytime the loops begins again.  So, as an example, if the public variable was called "publicValue" then at the beginning of the loop have a line this:

Loop Code:
Code: [Select]
_localValue = publicValue;
///Insert remainder of loop code here.

If that doesn't work, maybe another way of interupting the loop to get the new value as opposed to exiting and re-ececuting the script.  Good luck!
Title: Re: Random and publicVariable
Post by: Mr.Peanut on 19 Dec 2007, 20:49:57
Use one variable to transmit and receive and another to store it. Have the client wait until the variable is received, store it, and reset to nil. Let's say server is PV'ing txValue. Then run the following on the client.
Code: [Select]
while {TRUE} do {
   waitUntil not isnil txValue;
   myValue = txValue;
   txValue = nil;
};