OFPEC Forum

Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: KeyCat on 17 Dec 2002, 17:13:38

Title: Client hosting vs dedicated server
Post by: KeyCat on 17 Dec 2002, 17:13:38
Wonder if there are any scripting differences when running a mission on a client hosting vs the mission on a dedicated server?

For example does the trick with the "? !(local Server) : exit" work the same in both cases? Are there any other general  things that a script newbie should know of regarding writing MP scripts for OFP?

/Christer (a.k.a KeyCat)

Title: Re:Client hosting vs dedicated server
Post by: Ranger on 17 Dec 2002, 19:18:43
Definitely, there are some differences.  Some code works in SP only and not in MP, and some works in both.  Get In/Load and Get Out/Unload waypionts (and vehicle usage in general) work better for the host than for the clients.  When you have a dedicated server, then everyone is a client, some code won't work at all for anyone.

The only way to know reliably if code will work in both cases is to test it.  Save your mission as a multiplayer mission, and test both with a client host and a dedicated server.  I find many bugs in my missions when I test like this, bugs that otherwise didn't exist in the editor's preview mode.
Title: Re:Client hosting vs dedicated server
Post by: KeyCat on 19 Dec 2002, 01:03:44
Thanks for your reply Ranger! This may be old news but I did some test today while hosting and i looks like the "? !(local Server) : exit" check works on both a client hosting and a dedicated server.

Here what I did... I placed a Game Logic named "Server" and had a radio trigger run the following code...

Code: [Select]
? !(local Server) : goto "Client"
hint "DEBUG: I'm a server"
exit
#Client
hint "DEBUG: I'm a client"
exit

When some of us clicked on the radio trigger it corretly indicated me as a server and my friend as a client.

Hope BIS will continue to improve the script support for MP. Read Snypir's post and understood that it requires several and special tricks to get things to work in MP...

If anyone else have any generic MP tips for a newbie I'm still listening  ;)

/Christer (a.k.a KeyCat)

PS: This forum is great but extremeley slow, anyone else experince this?

Title: Re:Client hosting vs dedicated server
Post by: Tactician on 19 Dec 2002, 11:55:34
Most things are fine when executed by everyone, but there are a few things that should be handled by just the server, like scoring and AI behaviour.

Say you've got a trigger that starts an AI ambush when a player walks into it.  Your trigger would be triggered once by West present, with the condition:

local Server AND this

And activation:

ambushergroup move getPos ((list triggername) select 0)

The trigger will never be activated by a client, and I assume that since the first condition is false that clients won't even bother checking the trigger, sort of an optimization.

Note the when a trigger is only activated on the server, any hint/titleText effects it produces will only be on the server.  If you added hint text to the trigger's activation, only the host would see it.  There are ways around this, read my tutorial about it.

Putting ?!(local Server) at the beginning of a script isn't the only way to make something server-side.  (local Server) returns boolean true or false, so you can put it anywhere as a condition or as part of an "if" structure.
Title: Re:Client hosting vs dedicated server
Post by: KeyCat on 21 Dec 2002, 15:43:08
Thanks T! Will look up your tutorial (if I not already have it)...

/Christer (a.k.a KeyCat)