OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Oakstar on 10 Oct 2003, 12:27:36
-
I've made a Init.sqs that creates random:
Startposition, objective, time of day and weather. Then moves
all players, enemys etc to the correct positions.
A random mission generator.
It works perfect when I play alone, but in multiplayer,
all clients gets different random start, objective, markers etc
Even the weather and time of day is different!
I have tried the ?(Local server) command to not randomise values on the clients,
but they don't get any info at all now, and are not moved to their startpos.
I also tried to execute the script using a initfield of a soldier(Not named init.sqs then).
-
You should take care about following aspects here:
- init.sqs is executed by server and clients
- only boolean and numeric variables, group/object-names can be transferred by publicVariable
- if you use publicVariable, to transmit anything from anywhere
to anywhere else, you should add a time-delay, before using
the transmitted data.
- ?(local Server) requires an only serverside available object
on the map (like a gamelogic), called: Server
- setMarkerPos does only happen where it's been executed
(just in case you do setmarkerpos some markers only on
serverside)
Now the logical order how your init.sqs should look like
<<init.sqs>>
global stuff here
wait_server = false
?!(local Server): goto "wait_client"
create your random values here
....
let's say: blabla1 = random 75
blabla2 = random 80
blabla3 = blabla1 / blabla2 * 3.141592763 - 9
....
"publicVariable {_x}" forEach [blabla1,blabla2,blabla3]
~1
wait_server = true
~0.1
publicVariable "wait_server"
#wait_client
@wait_server
use your random values here and
it should be equal to everyone
let's say: sheep1 setpos [blabla1,blabla2]
sheep2 setdammage blabla3
etc.
that should do it
hope this helps a bit
~S~ CD
-
Thanks, it was very helpful.
-
do you have a demo of this i could look at please as it sounds intresting