Home   Help Search Login Register  

Author Topic: Time different in multiplayer?  (Read 1187 times)

0 Members and 1 Guest are viewing this topic.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Time different in multiplayer?
« on: 09 Jun 2005, 01:08:03 »
I have a multiplayer mission that works fine in the editor.  

It starts with a heli on which I've implemented the "ultimatefire.sqs" script.
I tinkered with the values to get the heli to self destruct over a certain area range.

The problem is that after pbo'ing the mission and running it on my own computer the time it takes the heli to destruct is drastically less, so much so that is screws the beginning of the mission up.  I can re-tune the parameters to get what I want, but why should it make a difference when it is run on a non-dedicated server?  The values being passed into the script are identical, but the heli explodes 5-10 seconds sooner than it did in the mission editor...
« Last Edit: 09 Jun 2005, 10:34:45 by Mr.Peanut »
urp!

Offline Raptorsaurus

  • Editors Depot Staff
  • *****
Re:Time different in multiplayer?
« Reply #1 on: 09 Jun 2005, 02:02:51 »
I have noticed this same problem when switching from one computer to another (same mission on different computers will yeild different time).  I have also observed this with editor previewed missions versus "pbo"ed missions.

The solution is to not use the <wait> command in delay scripts.  Instead use the dedicated _time variable which yeilds the time in seconds the script has been running (it is local to the script), or <time> which yeilds the time in seconds that the mission has been running (global value).  The <_time> and <time> values are based on the computer's internal clock, and are therefore minimally affected by other scripts running, lag, and whether the mission is compiled as a pbo or not.  The <wait> or <~>, on the other hand, is effected by lag, multiple scripts running and "pbo"ed versus editor preview.

Here is how to use the <_time> in place of the <~>

Example script using the <wait>:

code line 1
code line 2
code line 3

~ 3            ; 3 second delay desired

code line 4
code line 5
exit

Example script using <_time>:

code line 1
code line 2
code line 3

_ref = _time
@ (_time - _ref) > 3     ; this will give a more precise 3 second delay.

code line 4
code line 5
exit

It adds more code to the script, but if you want delays to be more precise, it is the way to go.

I only use this method when timing is crucial, otherwise the ~ is more efficient.

Hope this helps.

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:Time different in multiplayer?
« Reply #2 on: 09 Jun 2005, 10:04:58 »
Thanks.. I will give it a try.

Ack. Didn't work.  Oh well. Will remove SetDamage command from script and use triggers to inflict damage instead.
« Last Edit: 09 Jun 2005, 10:34:21 by Mr.Peanut »
urp!

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Time different in multiplayer?
« Reply #3 on: 09 Jun 2005, 14:52:15 »
use the reserved variable time

eg

if (time >= XXX) then {if local server then{helo setdammage 1}}

if you run a 1 second looping script for 1800 loops, it will not have run its course at the same time as the command line as
time >= 1800

time is the length of time in seconds since your mission started and therefore is a much more accurate means of dictating when somewthing should happen

more importantly have the server control this and then possibly via a trigger tell the clients to do the same

setdammage isnt a local command so you dont need triggers
« Last Edit: 09 Jun 2005, 14:55:25 by Terox »
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re:Time different in multiplayer?
« Reply #4 on: 09 Jun 2005, 16:14:21 »
Yes I know.  But the "ultimatefire.sqs" script runs in a fast loop, so I'm better off just removing the SetDamage lines and then using a countdown trigger to inflict the damage necessary to fire the explosive end of the script, yet allow some randomness in where the heli crashes.

Thanks for all the help.


setdammage isnt a local command so you dont need triggers
« Last Edit: 09 Jun 2005, 16:14:39 by Mr.Peanut »
urp!