Home   Help Search Login Register  

Author Topic: Random numbers , etc, in MP  (Read 2186 times)

0 Members and 2 Guests are viewing this topic.

Offline UH60MG

  • Members
  • *
Random numbers , etc, in MP
« on: 07 Apr 2009, 14:05:01 »
Hello,

I want to generate 1 random number for all the machines in a multiplayer COOP game, then I want to spawn the enemies using CreateUnit. How do I do this so I dont get multiple copies?

I am using .sqs scripts.
« Last Edit: 07 Apr 2009, 14:30:18 by UH60MG »

Offline i0n0s

  • Former Staff
  • ****
Re: Random numbers , etc, in MP
« Reply #1 on: 07 Apr 2009, 14:58:57 »
Code: [Select]
//Init
Random_array = [];
for "_i" from 0 to MAXNUMBER do {
Random_array = Random_array + [_i];
};

//Get random number:
_random = Random_array select floor random (count Random_array);
Random_array = Random_array - [_random];
I'm using SQF.

Offline Deadfast

  • Members
  • *
Re: Random numbers , etc, in MP
« Reply #2 on: 07 Apr 2009, 16:10:00 »
CreateUnit is global BTW so no need to execute it on every client.

Offline UH60MG

  • Members
  • *
Re: Random numbers , etc, in MP
« Reply #3 on: 08 Apr 2009, 23:42:06 »
CreateUnit is global BTW so no need to execute it on every client.

That is helpful. Is there a list anywhere of which commands are global?

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Random numbers , etc, in MP
« Reply #4 on: 09 Apr 2009, 09:40:10 »
Check the "Links" section of this site. The list is not complete yet but it's a good start.
try { return true; } finally { return false; }