From dadb9fd59f58b23f30f6943d52352df744a1e065 Mon Sep 17 00:00:00 2001 From: Ciaran Fisher Date: Sat, 12 Oct 2019 16:20:47 +0100 Subject: [PATCH 1/2] New Chat commands Fixed C101CC & EB Added Cipher only switch back to F16 Added two new features to the autoconnect file - SRS Chat commands to show frequencies and an automated message to all non connected users --- Scripts/DCS-SRS-AutoConnectGameGUI.lua | 157 ++++++++++++++++++++++++- Scripts/DCS-SimpleRadioStandalone.lua | 16 ++- 2 files changed, 167 insertions(+), 6 deletions(-) diff --git a/Scripts/DCS-SRS-AutoConnectGameGUI.lua b/Scripts/DCS-SRS-AutoConnectGameGUI.lua index e032bcfc8..9f1ace5eb 100644 --- a/Scripts/DCS-SRS-AutoConnectGameGUI.lua +++ b/Scripts/DCS-SRS-AutoConnectGameGUI.lua @@ -1,15 +1,38 @@ -- Version 1.6.3.0 --- ONLY COPY THIS FILE IS YOU ARE GOING TO HOST A SERVER! +-- ONLY COPY THIS WHOLE FILE IS YOU ARE GOING TO HOST A SERVER! -- The file must be in Saved Games\DCS\Scripts\Hooks or Saved Games\DCS.openalpha\Scripts\Hooks -- Make sure you enter the correct address into SERVER_SRS_HOST below. -- You can add an optional Port. e.g. "127.0.0.1:5002" +-- You can also enable SRS Chat commands to list frequencies and a message to all +-- non SRS connected users to encourage them to connect -- User options -- local SRSAuto = {} -SRSAuto.SERVER_SRS_HOST = "127.0.0.1" +SRSAuto.SERVER_SRS_HOST = "127.0.0.1:5002" SRSAuto.SERVER_SEND_AUTO_CONNECT = true -- set to false to disable auto connect or just remove this file +---- SRS CHAT COMMANDS ---- +SRSAuto.CHAT_COMMANDS_ENABLED = false -- if true type -freq, -freqs or -frequencies in ALL chat in multilayer to see the frequencies + +SRSAuto.SRS_FREQUENCIES = { + ["red"]= "ATC = 124, GCI = 126, Helicopters = 30FM", -- edit this to the red frequency list + ["blue"]= "ATC = 251, GCI = 264, Helicopters = 30FM", -- edit this to the blue frequency list + ["neutral"]= "" -- edit this to the spectator frequency list +} + + +---- SRS NUDGE MESSAGE ---- +SRSAuto.SRS_NUDGE_ENABLED = false -- set to true to enable the message below +SRSAuto.SRS_NUDGE_TIME = 600 -- SECONDS between messages to non connected SRS users +SRSAuto.SRS_MESSAGE_TIME = 30 -- SECONDS to show the message for +SRSAuto.SRS_NUDGE_PATH = "C:\\Program Files\\DCS-SimpleRadio-Standalone\\clients-list.json" -- path to SERVER JSON EXPORT - enable Auto Export List on the server +--- EDIT the message below to change what is said to users - DONT USE QUOTES - either single or double due to the injection into SRS it'll fail +--- Newlines must be escaped like so: \\\n with 3 backslashes +SRSAuto.SRS_NUDGE_MESSAGE = "****** DCS IS BETTER WITH COMMS - USE SRS ******\\\n\\\nMake sure to install DCS SimpleRadio Standalone - SRS - free and easy to install. \\\n\\\nSRS gives you VOIP Comms with other players through your aircrafts own radios. This will help you to be more effective, find enemies and wingmen, or call in support \\\n\\\n Google: DCS SimpleRadio Standalone \\\n\\\nGood comms and teamwork will help YOU and your team win! " + + -- DO NOT EDIT BELOW HERE -- + SRSAuto.unicast = true -- Utils -- @@ -20,6 +43,9 @@ SRSAuto.MESSAGE_PREFIX = "SRS Running @ " -- DO NOT MODIFY!!! package.path = package.path..";.\\LuaSocket\\?.lua;" package.cpath = package.cpath..";.\\LuaSocket\\?.dll;" +local JSON = loadfile("Scripts\\JSON.lua")() +SRSAuto.JSON = JSON + local socket = require("socket") SRSAuto.UDPSendSocket = socket.udp() @@ -56,5 +82,132 @@ SRSAuto.onPlayerChangeSlot = function(id) end end +SRSAuto.trimStr = function(_str) + return string.format("%s", _str:match("^%s*(.-)%s*$")) +end + +SRSAuto.onChatMessage = function(message, playerID) + local _msg = string.lower(SRSAuto.trimStr(message)) + + if _msg == "-freq" or _msg == "-frequencies" or _msg == "-freqs" then + + local _player = net.get_player_info(playerID) + + local _freq = "" + + if _player.coa == 0 then + _freq = SRSAuto.SRS_FREQUENCIES.neutral + elseif _player.coa == 1 then + _freq = SRSAuto.SRS_FREQUENCIES.red + else + _freq = SRSAuto.SRS_FREQUENCIES.blue + end + + local _chatMessage = string.format("*** SRS: %s ***",_freq) + net.send_chat_to(_chatMessage, _player.id) + return + end +end + +local _lastSent = 0 + +SRSAuto.onSimulationFrame = function() + + if SRSAuto.SRS_NUDGE_ENABLED then + + if not DCS.isServer() then + return + end + + local _now = os.time() + + -- send every 5 seconds + if _now > _lastSent + SRSAuto.SRS_NUDGE_TIME then + _lastSent = _now + + SRSAuto.srsNudge() + end + end +end + +SRSAuto.readFile = function (path) + local file = io.open(path, "rb") -- r read mode and b binary mode + if not file then return nil end + local content = file:read "*a" -- *a or *all reads the whole file + file:close() + return content +end + +SRSAuto.srsNudge = function() + + SRSAuto.log("SRS NUDGE Running") + + local _status, _result = pcall(function() + + local _playerByName = {} + for _,v in pairs(net.get_player_list()) do + + local _player = net.get_player_info(v) + if _player.id ~= 1 then + --filter server owner / user + if _player.side ~= 0 then + + _playerByName[_player.name] = _player + --SRSAuto.log("SRS NUDGE - Added ".._player.name) + + end + end + end + local fileContent = SRSAuto.readFile(SRSAuto.SRS_NUDGE_PATH); + + local srs = {} + srs = SRSAuto.JSON:decode(fileContent) + + if srs then + -- loop through SRS and remove players + for _,_srsPlayer in pairs(srs) do + _playerByName[_srsPlayer.Name] = nil + --SRSAuto.log("SRS NUDGE - Removed ".._srsPlayer.Name) + end + + -- loop through remaining and nudge + for _name,_player in pairs(_playerByName) do + + local _group = DCS.getUnitProperty(_player.slot, DCS.UNIT_GROUP_MISSION_ID) + + if _group then + + SRSAuto.log("SRS NUDGE - Messaging ".._player.name) + SRSAuto.sendMessage(SRSAuto.SRS_NUDGE_MESSAGE,SRSAuto.SRS_MESSAGE_TIME,_group) + + end + end + end + end) + + if not _status then + SRSAuto.log('ERROR: ' .. _result) + end + + + +end + +SRSAuto.sendMessage = function(msg, showTime, gid) + if gid then + local str = "trigger.action.outTextForGroup(" .. gid .. ",'" .. msg .. "'," .. showTime .. ",true); return true;" + local _status, _error = net.dostring_in('server', str) + if not _status and _error then + SRSAuto.log("Error! " .. _error) + end + else + local str = "trigger.action.outText('" .. msg .. "'," .. showTime .. ",true); return true;" + local _status, _error = net.dostring_in('server', str) + if not _status and _error then + SRSAuto.log("Error! " .. _error) + end + end +end + DCS.setUserCallbacks(SRSAuto) net.log("Loaded - DCS-SRS-AutoConnect1.6.3.0") diff --git a/Scripts/DCS-SimpleRadioStandalone.lua b/Scripts/DCS-SimpleRadioStandalone.lua index 41dbe452c..594e82920 100644 --- a/Scripts/DCS-SimpleRadioStandalone.lua +++ b/Scripts/DCS-SimpleRadioStandalone.lua @@ -1301,6 +1301,14 @@ function SR.exportRadioF16C(_data) end end + local _cipherOnly = SR.round(SR.getButtonPosition(443),1) < -0.5 --If HOT MIC CIPHER Switch, HOT MIC / OFF / CIPHER set to CIPHER, allow only cipher + if _cipherOnly and _data.radios[3].enc ~=true then + _data.radios[3].freq = 0 + end + if _cipherOnly and _data.radios[2].enc ~=true then + _data.radios[2].freq = 0 + end + _data.control = 0; -- SRS Hotas Controls return _data @@ -1746,7 +1754,7 @@ function SR.exportRadioC101EB(_data) local _selector = SR.getSelectorPosition(232, 0.25) if _selector ~= 0 then - _data.radios[2].freq = SR.getRadioFrequency(10) + _data.radios[2].freq = SR.getRadioFrequency(11) else _data.radios[2].freq = 1 end @@ -1760,7 +1768,7 @@ function SR.exportRadioC101EB(_data) _data.radios[3].modulation = 0 _data.radios[3].volume = SR.getRadioVolume(0, 412, { 0.0, 1.0 }, false) - _data.radios[3].freq = SR.getRadioFrequency(9) + _data.radios[3].freq = SR.getRadioFrequency(10) local _selector = SR.getSelectorPosition(404, 0.5) @@ -1789,7 +1797,7 @@ function SR.exportRadioC101CC(_data) _data.radios[1].volume = SR.getRadioVolume(0, 403, { 0.0, 1.0 }, false) _data.radios[2].name = "V/TVU-740" - _data.radios[2].freq = SR.getRadioFrequency(10) + _data.radios[2].freq = SR.getRadioFrequency(11) _data.radios[2].modulation = 0 _data.radios[2].volume = 1.0--SR.getRadioVolume(0, 234,{0.0,1.0},false) _data.radios[2].volMode = 1 @@ -1817,7 +1825,7 @@ function SR.exportRadioC101CC(_data) --local _vhfPower = SR.getSelectorPosition(413,1.0) -- --if _vhfPower == 1 then - _data.radios[3].freq = SR.getRadioFrequency(9) + _data.radios[3].freq = SR.getRadioFrequency(10) --else -- _data.radios[3].freq = 1 --end From 85fe251bddb404647d842390655d0f3fd20dfbef Mon Sep 17 00:00:00 2001 From: Ciaran Fisher Date: Sat, 12 Oct 2019 16:25:23 +0100 Subject: [PATCH 2/2] Release 1.6.4.0 --- DCS-SR-Client/Properties/AssemblyInfo.cs | 4 ++-- DCS-SR-Common/Network/UpdaterChecker.cs | 2 +- DCS-SimpleRadio Server/Properties/AssemblyInfo.cs | 4 ++-- Installer/Properties/AssemblyInfo.cs | 4 ++-- Scripts/DCS-SRS-AutoConnectGameGUI.lua | 4 ++-- Scripts/DCS-SRS-OverlayGameGUI.lua | 4 ++-- Scripts/DCS-SRSGameGUI.lua | 4 ++-- Scripts/DCS-SimpleRadioStandalone.lua | 4 ++-- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/DCS-SR-Client/Properties/AssemblyInfo.cs b/DCS-SR-Client/Properties/AssemblyInfo.cs index ea251889e..2b8b2d6c1 100644 --- a/DCS-SR-Client/Properties/AssemblyInfo.cs +++ b/DCS-SR-Client/Properties/AssemblyInfo.cs @@ -52,5 +52,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.3.0")] -[assembly: AssemblyFileVersion("1.6.3.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.4.0")] +[assembly: AssemblyFileVersion("1.6.4.0")] \ No newline at end of file diff --git a/DCS-SR-Common/Network/UpdaterChecker.cs b/DCS-SR-Common/Network/UpdaterChecker.cs index b1b61ab36..ec655210b 100644 --- a/DCS-SR-Common/Network/UpdaterChecker.cs +++ b/DCS-SR-Common/Network/UpdaterChecker.cs @@ -19,7 +19,7 @@ public class UpdaterChecker public static readonly string MINIMUM_PROTOCOL_VERSION = "1.6.0.0"; - public static readonly string VERSION = "1.6.3.0"; + public static readonly string VERSION = "1.6.4.0"; private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); diff --git a/DCS-SimpleRadio Server/Properties/AssemblyInfo.cs b/DCS-SimpleRadio Server/Properties/AssemblyInfo.cs index ddf7070de..76b73b006 100644 --- a/DCS-SimpleRadio Server/Properties/AssemblyInfo.cs +++ b/DCS-SimpleRadio Server/Properties/AssemblyInfo.cs @@ -52,5 +52,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.3.0")] -[assembly: AssemblyFileVersion("1.6.3.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.4.0")] +[assembly: AssemblyFileVersion("1.6.4.0")] \ No newline at end of file diff --git a/Installer/Properties/AssemblyInfo.cs b/Installer/Properties/AssemblyInfo.cs index d5df86018..0e6308ef4 100644 --- a/Installer/Properties/AssemblyInfo.cs +++ b/Installer/Properties/AssemblyInfo.cs @@ -52,5 +52,5 @@ // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.6.3.0")] -[assembly: AssemblyFileVersion("1.6.3.0")] \ No newline at end of file +[assembly: AssemblyVersion("1.6.4.0")] +[assembly: AssemblyFileVersion("1.6.4.0")] \ No newline at end of file diff --git a/Scripts/DCS-SRS-AutoConnectGameGUI.lua b/Scripts/DCS-SRS-AutoConnectGameGUI.lua index 9f1ace5eb..e23262be1 100644 --- a/Scripts/DCS-SRS-AutoConnectGameGUI.lua +++ b/Scripts/DCS-SRS-AutoConnectGameGUI.lua @@ -1,4 +1,4 @@ --- Version 1.6.3.0 +-- Version 1.6.4.0 -- ONLY COPY THIS WHOLE FILE IS YOU ARE GOING TO HOST A SERVER! -- The file must be in Saved Games\DCS\Scripts\Hooks or Saved Games\DCS.openalpha\Scripts\Hooks -- Make sure you enter the correct address into SERVER_SRS_HOST below. @@ -210,4 +210,4 @@ SRSAuto.sendMessage = function(msg, showTime, gid) end DCS.setUserCallbacks(SRSAuto) -net.log("Loaded - DCS-SRS-AutoConnect1.6.3.0") +net.log("Loaded - DCS-SRS-AutoConnect1.6.4.0") diff --git a/Scripts/DCS-SRS-OverlayGameGUI.lua b/Scripts/DCS-SRS-OverlayGameGUI.lua index dd48ae071..a45e6f69e 100644 --- a/Scripts/DCS-SRS-OverlayGameGUI.lua +++ b/Scripts/DCS-SRS-OverlayGameGUI.lua @@ -1,4 +1,4 @@ --- Version 1.6.3.0 +-- Version 1.6.4.0 -- Make sure you COPY this file to the same location as the Export.lua as well! -- Otherwise the Overlay will not work @@ -479,4 +479,4 @@ end DCS.setUserCallbacks(srsOverlay) -net.log("Loaded - DCS-SRS Overlay GameGUI - Ciribob - 1.6.3.0 ") \ No newline at end of file +net.log("Loaded - DCS-SRS Overlay GameGUI - Ciribob - 1.6.4.0 ") \ No newline at end of file diff --git a/Scripts/DCS-SRSGameGUI.lua b/Scripts/DCS-SRSGameGUI.lua index f82b24158..29adc7db7 100644 --- a/Scripts/DCS-SRSGameGUI.lua +++ b/Scripts/DCS-SRSGameGUI.lua @@ -1,4 +1,4 @@ --- Version 1.6.3.0 +-- Version 1.6.4.0 -- Make sure you COPY this file to the same location as the Export.lua as well! -- Otherwise the Radio Might not work @@ -127,4 +127,4 @@ end DCS.setUserCallbacks(SRS) -net.log("Loaded - DCS-SRS GameGUI - Ciribob -1.6.3.0") \ No newline at end of file +net.log("Loaded - DCS-SRS GameGUI - Ciribob -1.6.4.0") \ No newline at end of file diff --git a/Scripts/DCS-SimpleRadioStandalone.lua b/Scripts/DCS-SimpleRadioStandalone.lua index 594e82920..ab7410e04 100644 --- a/Scripts/DCS-SimpleRadioStandalone.lua +++ b/Scripts/DCS-SimpleRadioStandalone.lua @@ -1,4 +1,4 @@ --- Version 1.6.3.0 +-- Version 1.6.4.0 -- Special thanks to Cap. Zeen, Tarres and Splash for all the help -- with getting the radio information :) -- Add (without the --) To the END OF your Export.lua to enable Simple Radio Standalone : @@ -2221,4 +2221,4 @@ function SR.nearlyEqual(a, b, diff) return math.abs(a - b) < diff end -SR.log("Loaded SimpleRadio Standalone Export version:1.6.3.0") \ No newline at end of file +SR.log("Loaded SimpleRadio Standalone Export version:1.6.4.0") \ No newline at end of file