Home   Help Search Login Register  

Author Topic: how do i randomize multi-player?  (Read 4563 times)

0 Members and 1 Guest are viewing this topic.

tai mai shu

  • Guest
how do i randomize multi-player?
« on: 25 Aug 2002, 11:52:19 »
hell again,  was wondering, since the "random x" command randomly generates a # from 1-x, i want to use this to create random levels of fog in my coming CTF map, since the random number is gonna be different on each machine, how do i make it so only the server generates the fog value, and then transmits it to every client machine, and adjust fog accordingly???

is this possible? or am i just dreaming? do i have to use a global variables, and if so, please explain how.

i would extremely appreciate any response.  Im dying to figure this out, and i bet a lot of other people are also.  :-\  ???  :'(  :wave:

sussmori

  • Guest
Re:how do i randomize multi-player?
« Reply #1 on: 25 Aug 2002, 12:47:17 »
Create a gamelogic called "server". Then make this script:

setMPFog.sqs:
---------
fogLevel = -1

;this part runs only on server
?!(local server): goto "setfog"
fogLevel = random 1
publicVariable "fogLevel"

;this runs on all computers
#setFog
;wait for public variable to propagate
@(fogLevel != -1)
setFog fogLevel

Tactician

  • Guest
Re:how do i randomize multi-player?
« Reply #2 on: 25 Aug 2002, 16:47:47 »
I don't know if setFog will work without the timing variable.

0 setFog fogLevel

Would it?

tai mai shu

  • Guest
Re:how do i randomize multi-player?
« Reply #3 on: 25 Aug 2002, 23:25:29 »
Create a gamelogic called "server". Then make this script:

setMPFog.sqs:
---------
fogLevel = -1

;this part runs only on server
?!(local server): goto "setfog"
fogLevel = random 1
publicVariable "fogLevel"

;this runs on all computers
#setFog
;wait for public variable to propagate
@(fogLevel != -1)
setFog fogLevel

sussmori, your never cease to amaze me.  ;D

tai mai shu

  • Guest
Re:how do i randomize multi-player?
« Reply #4 on: 25 Aug 2002, 23:51:57 »
Create a gamelogic called "server". Then make this script:

setMPFog.sqs:
---------
fogLevel = -1

;this part runs only on server
?!(local server): goto "setfog"
fogLevel = random 1
publicVariable "fogLevel"

;this runs on all computers
#setFog
;wait for public variable to propagate
@(fogLevel != -1)
setFog fogLevel


sussmori, could you PLZ, pretty PLZ explain how this works?
im a total newb and dont understand how this works.... this is very important to me in mp, but i have no idea how to utilize it..

sussmori

  • Guest
Re:how do i randomize multi-player?
« Reply #5 on: 26 Aug 2002, 03:37:10 »
Basically the first part run only on the server and picks a random fog level. It then broadcasts this value to all computers using "publicVariable".

Then the second part runs on all computers, and only runs once the server has set the public variable fogLevel. It simply sets the fog level.

Just make file called init.sqs and put
[] exec "setMPFog.sqs"

tai mai shu

  • Guest
Re:how do i randomize multi-player?
« Reply #6 on: 26 Aug 2002, 05:23:20 »
yeah but what does ?!(local server) do? i mean, whats the signifigance of that? if "server" is not local, than it bypasses the random number, and thus you dnt get random fog?
« Last Edit: 26 Aug 2002, 05:25:24 by tai mai shu »

Solarix

  • Guest
Re:how do i randomize multi-player?
« Reply #7 on: 27 Aug 2002, 22:15:25 »
By what I see...

?!(local server):goto "setfog"

sends clients to the setfog label, where they are on hold until the server assigns the random number to the foglevel and makes it a publicvariable.  Once that is done, the foglevel is no longer -1, but is instead the random number, thus releasing the hold on the clients and assigning them to the same (random) foglevel as the server.

« Last Edit: 27 Aug 2002, 22:17:28 by Col Solarix »

tai mai shu

  • Guest
Re:how do i randomize multi-player?
« Reply #8 on: 27 Aug 2002, 22:48:11 »
oh i fully understand nopw, thanks colonel!

Offline Wiper

  • Members
  • *
Re:how do i randomize multi-player?
« Reply #9 on: 28 Aug 2002, 19:22:36 »
theoretically it should work  :-\

unfortunately it seems not to do so if the variable value on the client is already assigned (like fogLevel=-1).
looks like the publicvariable command sometimes(?) does NOT overwrite existing values on clients !

anyone else with such observations ?

thx
ww

tai mai shu

  • Guest
Re:how do i randomize multi-player?
« Reply #10 on: 28 Aug 2002, 20:15:09 »
damn.  i think this probly woulda worked b4 resistance.  but the new netcode probly rendered this obsolete.  :noo:

can anyone PLZ!!!! rewrite this??? it is pretty essential to my multiplayer mission.

peace
tai mai shu

tai mai shu

  • Guest
Re:how do i randomize multi-player?
« Reply #11 on: 28 Aug 2002, 20:19:32 »
hey guys, would this work???

Create a gamelogic called "server". Then make this script:

setMPFog.sqs:
---------

;this part runs only on server
?!(local server): goto "setfog"
fogLevel = random 1
publicVariable "fogLevel"

;this runs on all computers
#setFog
;wait for public variable to propagate
@(fogLevel != objnull)
setFog fogLevel

what i did was remove the first foglevel, thus there is no client side fog level.  it should be nothing (objnull)

it runs as normal, the server randomly selects a numer, and sets it as a public variable.  but will the @(foglevel != objnull)
actually be recognized as a valid command??

up until then, foglevel is a non existent number, so there fore it should be nothing.  thsu, it waits untill oglevel is not equal to nuthing, this occurs when the public variable is transmitted.  hmm, someone help?

Offline Wiper

  • Members
  • *
Re:how do i randomize multi-player?
« Reply #12 on: 29 Aug 2002, 00:27:59 »
this code should work if you need the fog variable only once:
;--------------------------------------------------------
? (local sever):FogLevel=random 1 ;publicvariable "FogLevel"
@FogLevel>0
...
..
.
;--------------------------------------------------------
(note that FogLevel is not defined before the broadcasting command. this is intended ! otherwise this code does not work for me...)

if u need the Fog value more than one time i.e. in a loop, u might need a bit more code to do the job :
;-----------------------------------------------------
#loop
_FogLevel=0
? (local server):FL=random 1 ;publicvariable "FL"
#wt
~0.1
_FogLevel=FL
? _FogLevel==0:goto "wt"
....
..
.
goto "loop"
;-----------------------------------------------------

does it help ?

ww

tai mai shu

  • Guest
Re:how do i randomize multi-player?
« Reply #13 on: 29 Aug 2002, 01:22:13 »
cool thanks a lot man.

Backoff

  • Guest
Re:how do i randomize multi-player?
« Reply #14 on: 29 Aug 2002, 20:07:41 »
You could also reinit the value to null when the script starts:

FogLevel = nil

then use sussmori's condition for the client part:

@(fogLevel != objnull)