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
-
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:
-
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
-
I don't know if setFog will work without the timing variable.
0 setFog fogLevel
Would it?
-
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
-
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..
-
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"
-
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?
-
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.
-
oh i fully understand nopw, thanks colonel!
-
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
-
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
-
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?
-
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
-
cool thanks a lot man.
-
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)
-
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.
-
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"
-
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.
-
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!!
-
hey thanks man.
-
The Link seems to be down... Can you send the mission with random objectives to this address Atslav@hotmail.com???
-
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.