From 3feafef999aa79e87bea368cb19511413f06478b Mon Sep 17 00:00:00 2001 From: janodesbois Date: Mon, 15 Jun 2015 00:06:20 +0200 Subject: [PATCH] minor correction in lag_adjust.nas (mp patch) --- Nasal/lag_adjust.nas | 31 ++++++++++++++----------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/Nasal/lag_adjust.nas b/Nasal/lag_adjust.nas index 2ba14999d..20fd60c11 100644 --- a/Nasal/lag_adjust.nas +++ b/Nasal/lag_adjust.nas @@ -1,12 +1,12 @@ var i = 0; -var net_raw = "false"; -var spectator = "false"; +var spectator = 0; var spectator_offset = 0.5; var range = 3.0; var offset = 0.0; -var apply_close = "false"; +var apply_close = 0; var master = 0; var close = 0; +var initialised = 0; var ls_spect = nil; var ls_spctoffset = nil; @@ -23,11 +23,11 @@ var ls_close = nil; var mpCheck = func() { var mpname = getprop("/ai/models/multiplayer["~i~"]/callsign"); if (mpname != nil) { - if (spectator) { + if ((spectator) and (master)) { setprop("/ai/models/multiplayer["~i~"]/controls/compensate-lag", 3); setprop("/ai/models/multiplayer["~i~"]/controls/player-lag", -spectator_offset); } else { - if (apply_close) { + if ((apply_close) and (master)) { var self = geo.aircraft_position(); var x = getprop("/ai/models/multiplayer["~i~"]/position/global-x"); var y = getprop("/ai/models/multiplayer["~i~"]/position/global-y"); @@ -55,21 +55,18 @@ var mpCheck = func() { } var mpInit = func() { - print("initialising the mp lag system"); - ls_spect = setlistener("/sim/multiplay/lag/spectator",func { spectator = getprop("/sim/multiplay/lag/spectator")}, 1); - ls_spctoffset = setlistener("/sim/multiplay/lag/spectator-offset",func { spectator_offset = getprop("/sim/multiplay/lag/spectator-offset")}, 1); - ls_range = setlistener("/sim/multiplay/lag/range",func { range = getprop("/sim/multiplay/lag/range")}, 1); - ls_offset = setlistener("/sim/multiplay/lag/offset",func { offset = getprop("/sim/multiplay/lag/offset")}, 1); - ls_close = setlistener("/sim/multiplay/lag/apply-close", func { apply_close = getprop("/sim/multiplay/lag/apply-close")}, 1); + if (!initialised) { + print("initialising the mp lag system"); + initialised = 1; + ls_spect = setlistener("/sim/multiplay/lag/spectator",func { spectator = getprop("/sim/multiplay/lag/spectator")}, 1); + ls_spctoffset = setlistener("/sim/multiplay/lag/spectator-offset",func { spectator_offset = getprop("/sim/multiplay/lag/spectator-offset")}, 1); + ls_range = setlistener("/sim/multiplay/lag/range",func { range = getprop("/sim/multiplay/lag/range")}, 1); + ls_offset = setlistener("/sim/multiplay/lag/offset",func { offset = getprop("/sim/multiplay/lag/offset")}, 1); + ls_close = setlistener("/sim/multiplay/lag/apply-close", func { apply_close = getprop("/sim/multiplay/lag/apply-close")}, 1); + } } var mpClean = func() { - removelistener(ls_spect); - removelistener(ls_spctoffset); - removelistener(ls_range); - removelistener(ls_offset); - removelistener(ls_close); - close = 1; master = 0; }