Home   Help Search Login Register  

Author Topic: Random numbers in MP  (Read 1119 times)

0 Members and 1 Guest are viewing this topic.

evil

  • Guest
Random numbers in MP
« on: 03 Jul 2004, 06:20:57 »
Is it possible to use random numbers in MP?  I thought using this would work:

Code: [Select]
?!(local Server):goto "client"
_skip = random 12


#client
skiptime _skip

To skip a random amount of time.  However I can't get it to work right.  Any ideas?

I think it might be because the number isn't generated until after the clients execute it.  But the client I tested with had changing times, not the same.
« Last Edit: 03 Jul 2004, 06:25:09 by evil »

evil

  • Guest
Re:Random numbers in MP
« Reply #1 on: 03 Jul 2004, 07:14:26 »
Whoops, forgot about PublicVariable!  lol I knew I was forgetting something.  In case anyone else wants to see how it's done, here it is:

Code: [Select]
?!(local Server):goto "client"
skthmu = random 24; PublicVariable "skthmu"
#client
skiptime skthmu

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Random numbers in MP
« Reply #2 on: 03 Jul 2004, 10:05:21 »
INIT.SQS
Quote
[] exec "skiptime.sqs"



SERVER_SET.sqs
Quote
tx_Skip = (random 12)
tx_Newtime = true
{PublicVariable _x;}foreach["tx_Skip","tx_Newtime"]

and then you would need some form of monitoring script running on all machines or a trigger

SETIME.sqs
Quote
#START
~1
? (tx_Newtime): goto "SETIME"
goto "START"

#SETIME
tx_Newtime = false
skiptime tx_Skip

(either Exit or goto "START")

in your script above, the clients must know what the skiptime variable is,  what you could have done is put a 1 second delay before the skiptime command to give the server time to transmit the publicvariable to each client

in my system above, all machines run the setime.sqs, all you need to do yourself is script in when you want the server to set the time
Quote

If you were to use a trigger, which would probably be the better system, then you would set it up as follows

Condition:tx_Newtime
On activation: (tx_newtime = false) && (skiptime tx_Skip)

if you dont want to skiptime more than once, then dont set the trigger on repeating
« Last Edit: 03 Jul 2004, 10:09:17 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123