Home   Help Search Login Register  

Author Topic: Runing Scripts  (Read 1472 times)

0 Members and 1 Guest are viewing this topic.

Offline Ghost644

  • Members
  • *
    • Ghostland
Runing Scripts
« on: 06 Jul 2006, 01:48:26 »
If i have a respawn script running to spawn enemy units over and over, or really any script running in multiplayer do i want to add the line:
Code: [Select]
?!(local server): exit
I understand that this line says to run the script on the server, but do i want to have that line in every script i use for mp coop missions? Will this then create a lot less lag? Thanks in advance.
Ghost

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Runing Scripts
« Reply #1 on: 07 Jul 2006, 15:34:03 »
In order for that code to work you must place a game logic on your map and name it server.  The problem in MP missions is that commands tend to operate locally. That is, if a command that operates on a unit (or group) is run on a machine that does not own the unit (or group), the command will not work.  This means that often you need to make sure certain commands are run on all machines, sometimes you want commands to only run on the server, and sometimes you want a command to only run on a certain player's machine. Game logics are local (i.e. owned) by the server, so that code line is a test to see if the machine is the server or not. If it is not the server the script does not run. This is especially important with createVehicle and createUnit commands which should be executed only on the server. Another common code line in MP scripting is ?!(local player):exit    - (or ?!(local _unit):exit, where _unit is a unit passed to the script)-  which makes sure a given script is only executed on a given player's machine.

Using the ?!(local server):exit will not reduce lag.  The only case for which it reduces network lag is improper use of the  createVehicle and createUnit commands. If run on each machine they create the unit separately on each machine and cause lag as this is communicated. For scripts that display messages or hints(e.g.hint, sideRadio, sideChat) or display effects  (e.g.switchMove/playMove, drop, camCreate) you do not want to use it.

A common pitfall in MP scripting, is that all AI units are local to the server, except AI units for which a player is leader. Those units are local to the player's (who is leader) machine.  Hope this helps. 
« Last Edit: 07 Jul 2006, 15:45:02 by Mr.Peanut »
urp!

Offline Ghost644

  • Members
  • *
    • Ghostland
Re: Runing Scripts
« Reply #2 on: 10 Jul 2006, 02:31:35 »
Ok ill have to keep that in mind when writing some scripts for MP. Thanks for the reply
Ghost