Home   Help Search Login Register  

Author Topic: Random and publicVariable  (Read 1418 times)

0 Members and 1 Guest are viewing this topic.

Offline Dmitri

  • Members
  • *
Random and publicVariable
« 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?
« Last Edit: 17 Dec 2007, 13:49:49 by Dmitri »

Offline Loyalguard

  • Former Staff
  • ****
Re: Random and publicVariable
« Reply #1 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!

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Random and publicVariable
« Reply #2 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;
};
urp!