OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: tai mai shu on 25 Aug 2002, 11:52:19

Title: how do i randomize multi-player?
Post by: tai mai shu 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:
Title: Re:how do i randomize multi-player?
Post by: sussmori 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
Title: Re:how do i randomize multi-player?
Post by: Tactician on 25 Aug 2002, 16:47:47
I don't know if setFog will work without the timing variable.

0 setFog fogLevel

Would it?
Title: Re:how do i randomize multi-player?
Post by: tai mai shu 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
Title: Re:how do i randomize multi-player?
Post by: tai mai shu 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..
Title: Re:how do i randomize multi-player?
Post by: sussmori 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"
Title: Re:how do i randomize multi-player?
Post by: tai mai shu 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?
Title: Re:how do i randomize multi-player?
Post by: Solarix 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.

Title: Re:how do i randomize multi-player?
Post by: tai mai shu on 27 Aug 2002, 22:48:11
oh i fully understand nopw, thanks colonel!
Title: Re:how do i randomize multi-player?
Post by: Wiper 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
Title: Re:how do i randomize multi-player?
Post by: tai mai shu 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
Title: Re:how do i randomize multi-player?
Post by: tai mai shu 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?
Title: Re:how do i randomize multi-player?
Post by: Wiper 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
Title: Re:how do i randomize multi-player?
Post by: tai mai shu on 29 Aug 2002, 01:22:13
cool thanks a lot man.
Title: Re:how do i randomize multi-player?
Post by: Backoff 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)

Title: Re:how do i randomize multi-player?
Post by: icarus_uk on 29 Aug 2002, 21:15:00
When I do it, I just use booleans.

I set it false at the start of the script.  Then I set it true at the end of the servers section, with the clients waiting for the boolean to become true.
Title: Re:how do i randomize multi-player?
Post by: CapMorgan on 31 Aug 2002, 09:12:45
well, this can be late, but just in case.
This works under 146 and 175, i use it in almost all of my MP missions. (hope you don't mind spanish. tiempo = time, clima = overcast, niebla = fog)
This' ll make ramdom weather, fog and overcast.
I also have a script with random objetives for MP missions, just tell me if you need em. Hope this helps you out.
Don't fotget to put the "server" Logic.

?!(local Server): goto "cliente"
tiempo = random 23
clima = random 1
niebla = random 1
publicvariable "tiempo"
publicvariable "clima"
publicvariable "niebla"

#cliente
~5
skiptime tiempo
0 setovercast clima
0 setfog niebla
setViewDistance 1000

exit

PS: I use a fade of 6 sec. to make the changes "invisible"
Title: Re:how do i randomize multi-player?
Post by: tai mai shu on 31 Aug 2002, 23:31:29
hot damn capn morgan!!!!!  plz send me that stuff if ouve got it.  if you want, just e-mail me at taimaishu1103@hotmail.com

thanks man.
Title: Re:how do i randomize multi-player?
Post by: CapMorgan on 01 Sep 2002, 01:11:25
You can download this example mission
http://www.cazadoresdemonte.com.ar/misiones/misiones_MP/Cap_COOP_10_La%20mansion%20v1.0.Cain.zip

In there you have almost all my random scripts for MP missions. All working.
If you need any help just post here. I'm following the topic.
Salute!!
Title: Re:how do i randomize multi-player?
Post by: tai mai shu on 01 Sep 2002, 05:45:15
hey thanks man.
Title: Re:how do i randomize multi-player?
Post by: Atslav on 30 Jan 2005, 16:23:36
The Link seems to be down... Can you send the mission with random objectives to this address Atslav@hotmail.com???
Title: Re:how do i randomize multi-player?
Post by: Rocko Bonaparte on 30 Jan 2005, 19:13:03
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 ?

I have had similar trouble, yes.  I've been trying to randomly position units (in a special way) on the server.  I thought this would place the correctly on all machines--it doesn't.  I then tried to use public variables to transmit the new positions.  It was a real pain and failed in the end.  I'm still not very sure what it was I was doing wrong, but I developed a compromise that has been working well.