Home   Help Search Login Register  

Author Topic: Dedicated server  (Read 2621 times)

0 Members and 4 Guests are viewing this topic.

pazuzu

  • Guest
Dedicated server
« on: 17 Nov 2005, 22:27:52 »
I've been looking for info on how dedicated servers work. Like how to broadcast commands to all machines or how to have all machines run a script. I've found some good info here and at the BIS forum but I have a couple specific questions to ask here.

Would this command work on a dedi server?:

("(_x distance ro) < 2" count units grp1 > 0)

I was reading about variables too when using on dedi servers...

If I create a variable like cut=true(after putting cut=false in the init.sqs) and put the command "publicVariable "cut" along with it will this variable be recognized on all machines?

And will a script be run on all machines if its called in a trigger?

Thanks.




Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re:Dedicated server
« Reply #1 on: 17 Nov 2005, 23:31:06 »
as far as I know, nothing of what you have mentioned will work diffrently on a dedicated server. If you want to broadcast something to all machines, you publicvariable it, to run a script on all machines, you execute it on all machines, and as long as that command works, it should work on a dedicated too.

And yes, a script will be run on all machines if it's executed from a trigger. I have experienced that one computer haven't noticed that a trigger have been activated, and therefor the command in that trigger didn't run on that computer, but that got nothing to do with dedicated servers...afaik :P

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Dedicated server
« Reply #2 on: 18 Nov 2005, 16:14:58 »
Most global variables can be transmitted over the network with the exception of
1) Strings
2) Arrays

however, even for the above variable types, there is a work around and that is COC Network services

Certain commands are local, which means that if you run that code on machine A and the actual unit is local on Machine B, then the unit wont be effected by that command

certain commands are global, which means no matter which machine you run it on, the unit/object will be affected by that command


Example of a global command
SETPOS

Example of a local command
SETDIR


Problems can arise when you issue a global command on every machine
eg if you have all machines run a script from say a trigger with a setpos command in thst script, the affected unit will be setpossed numerous times, this can obviously be problematic

So to avoid this from happening, we can use switches, as in the example below

?(Local _unitname): _unitname setpos (getmarkerpos "Safezone")

If you want specific code run on a server, then you can create a gamelogic, call it "server" and then use the following piece of code

?(Local Server): _unitname setpos (getmarkerpos "Safezone")

Reason: Gamelogics created in the mission editor are local to the server only, so by referring to the name of the gamelogic as in the above example, we can be assured that the code it runs will only be run once and run on the server only

« Last Edit: 18 Nov 2005, 16:24:06 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re:Dedicated server
« Reply #3 on: 18 Nov 2005, 17:56:48 »
I have experienced that one computer haven't noticed that a trigger have been activated, and therefor the command in that trigger didn't run on that computer, but that got nothing to do with dedicated servers...afaik :P

That behaviour is explained by Kegetys:

Triggers, scripts and addAction in multiplayer

I have participated for example in multiplayer missions where objectives have been completed for some but not for all players. That problem is also very likely caused by lag. Kegetys' explanation is a sensible one because otherwise it would be hard to explain why the triggers are not in sync. A certain tutorial in the Editors Depot says:

Quote
snYpir's MP editing rule 4: Triggers and waypoints are automatically synchronised by the server, and rule 1, 2 and 3 do not apply when commands are used in the 'on activation' or 'init' field of editor-placed objects.

Saying that triggers are automatically synced by the server can't be the case because we have seen it not to work like that. Under heavy lag, the server should then still send the synchronization messages to clients and clients should receive those messages at some point and make corrections. Because we have seen that desync can continue for a long time (for the rest of the mission) and no corrections are made, the server is obviously not doing anything for the desync problem.

pazuzu

  • Guest
Re:Dedicated server
« Reply #4 on: 19 Nov 2005, 21:12:17 »
Thanks for the replies. Very interesting stuff...

I'm using:

deletevehicle (for enemy in the area when cutscene starts)

unassignVehicle

setpos getmarkerpos (for snowboards to teleport to players position)

action ["eject", vehicle

moveincargo

removeweapon

and skiptime commands in the script.

Do I need to add ?(Local Server): before the setpos commands so the command will only run from server? I'm a little confused how this works...

The script I have is supposed to start a cutscene which is just a blackout that happens when the first obj is done and when it blacksin it's supposed to be the next morning and the players find themselves in a truck with a weapons crate nearby and some snowboards that can be used to get to the next obj (Mission is on Nogojev and first obj is on the highest peak).

Here's the script:

~5
0 fadesound 0
enableradio false
TitleCut ["","BLACK OUT",5]
deletevehicle t1
deletevehicle t2
deletevehicle t3
deletevehicle t4
deletevehicle t5
deletevehicle t6
deletevehicle t7
deletevehicle t8
deletevehicle t9
deletevehicle t10
deletevehicle t11
deletevehicle t12

~5
TitleText ["The radio tower is destroyed....\nSo we'll just lay low for the night.","Plain"]
skiptime 10
~0
unassignVehicle p1
unassignVehicle p2
unassignVehicle p3
unassignVehicle p4
unassignVehicle p5
unassignVehicle p6
unassignVehicle p7
unassignVehicle p8
unassignVehicle p9
unassignVehicle p10
unassignVehicle p11
unassignVehicle p12

truck1 setpos getmarkerpos "e1"

b1 setpos getmarkerpos "s1"
b2 setpos getmarkerpos "s2"
b3 setpos getmarkerpos "s3"
b4 setpos getmarkerpos "s4"
b5 setpos getmarkerpos "s5"
b6 setpos getmarkerpos "s6"
b7 setpos getmarkerpos "s7"
b8 setpos getmarkerpos "s8"
b9 setpos getmarkerpos "s9"
b10 setpos getmarkerpos "s10"
b11 setpos getmarkerpos "s11"
b12 setpos getmarkerpos "s12"

crate_1 setpos getmarkerpos "c1"

~.05
p1 action ["eject", vehicle p1]
p2 action ["eject", vehicle p2]
p3 action ["eject", vehicle p3]
p4 action ["eject", vehicle p4]
p5 action ["eject", vehicle p5]
p6 action ["eject", vehicle p6]
p7 action ["eject", vehicle p7]
p8 action ["eject", vehicle p8]
p9 action ["eject", vehicle p9]
p10 action ["eject", vehicle p10]
p11 action ["eject", vehicle p11]
p12 action ["eject", vehicle p12]

? alive p1 : p1 moveincargo truck1
? alive p2 : p2 moveincargo truck1
? alive p3 : p3 moveincargo truck1
? alive p4 : p4 moveincargo truck1
? alive p5 : p5 moveincargo truck1
? alive p6 : p6 moveincargo truck1
? alive p7 : p7 moveincargo truck1
? alive p8 : p8 moveincargo truck1
? alive p9 : p9 moveincargo truck1
? alive p10 : p10 moveincargo truck1
? alive p11 : p11 moveincargo truck1
? alive p12 : p12 moveincargo truck1

p1 removeweapon "NVGoggles"
p2 removeweapon "NVGoggles"
p3 removeweapon "NVGoggles"
p4 removeweapon "NVGoggles"
p5 removeweapon "NVGoggles"
p6 removeweapon "NVGoggles"
p7 removeweapon "NVGoggles"
p8 removeweapon "NVGoggles"
p9 removeweapon "NVGoggles"
p10 removeweapon "NVGoggles"
p11 removeweapon "NVGoggles"
p12 removeweapon "NVGoggles"

~12
TitleCut ["Ok, Wake up you lazy bastards...","BLACK IN",15]

[[ge5,ge6,ge9,ge10,ge11,ge12],[ge3,ge4,ge7,ge8],[ge3],grp1,0,0.30] exec "ai\grouplink2.sqs"

truck1 setfuel 1

off1 action ["eject", vehicle off1]
unassignVehicle off1

0 fadesound 5
enableradio true
~10
0 fademusic 5
exit

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Dedicated server
« Reply #5 on: 20 Nov 2005, 19:20:48 »
reduce all the continous listing of equal commands to

_UnitArray = [P1,P2,P3,P4,P5,P6,P7,P8,P9,P10,P11,P12]

{deletevehicle _x}foreach [t1,t2,t3,t4,t5,t6,t7,t8,t9,t10,t11,t12]
{unnasignvehicle _x}foreach [_UnitArray

{_x action ["eject", vehicle _x]}foreach _UnitArray


{if(alive _x)then{_x moveincargo truck1; _x removeweapon "NVGoggles"}}foreach _UnitArray


setpos is a global command, so if you run the command on more than 1 client/server machine the command will be issued and carried out for each machine it is run on
Therefore it is best to run it only on the server

using
?(local server):
not forgetting to create a gamelogic named server somewhere in the mission
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

pazuzu

  • Guest
Re:Dedicated server
« Reply #6 on: 20 Nov 2005, 22:30:19 »
That looks much more sensible.

Although, you said above:

Quote
Most global variables can be transmitted over the network with the exception of
1) Strings
2) Arrays

But here your saying to use arrays? I must be misunderstanding you.

But I'll give it a try.

Where do I put the ?(local server): line

Like this?:  ?(local server): b1 setpos getmarkerpos "s1"

Just have it before each setpos line?

Edit: hmm I keep getting an error for these arrays...something about _UnitArray
  • Missing error


something like that...

Thanks for the help.
« Last Edit: 20 Nov 2005, 23:51:26 by pazuzu »

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Dedicated server
« Reply #7 on: 21 Nov 2005, 23:32:31 »
tx_a = [1,2,3,4]; Publicvariable "tx_a"

wont work, because you cannot publicvariable an array, eg transmit it to other clients

whereas

tx_a = 1; Publicvariable "tx_a"

can be publicvariabled
meaning, transmit this variable value across to all other machines

in my post above there isnt any publicvariabling carried out

___________________________________________________________

also

in the above example, the arrays are local

eg _unitarray, which means it is only a useable variable within the script that creates it, once the script exits, the variable dies

If you need to use a variable in more than 1 script, then it needs to be a global variable, eg held in permanent memory on the client for use in any script that requires it

example of local variable
_a
local variables always start with an underscore

example of global variable
tx_a


there was an error in the above post

{unnasignvehicle _x}foreach [_UnitArray

should be

{unnasignvehicle _x}foreach _UnitArray

___________________________________________________________

?(local server):
?!(local server):
?(Local player):

can be used as in your example above, at the start of the command line

eg
?(Local server): Hint "This is the server"
or if you want part of the script to be read by everyone but want the server to read all the script then you could use

?!(local server): exit

at the point where you want the script to be terminated by clients only

or  

?(local player): goto "SKIP"
server code ran here
#SKIP
client server code ran here
« Last Edit: 21 Nov 2005, 23:43:13 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123