Jump to content

OzDeaDMeaT

Members
  • Posts

    153
  • Joined

  • Last visited

Everything posted by OzDeaDMeaT

  1. Thnx to Shadowze and Wingthor from the Moose Discord for the help while I learn LUA. - Added an array of strings to blacklist against the save function - Added Debug to show / hide messages while testing (can be turned off and on) - Added Unit and Group count when saving file - Added Support for scripted units to be saved as well (can be turned off and on) - Bug - Cant delete file when no groups are being saved (thus resetting the persistence). Not sure if this is an issue with DCS or Moose at this point. --[[simple Group Saving by Pikey May 2019 (Updated by OzDeaDMeaT September 2020) Usage of this script should credit the following contributors: Pikey, Speed & Grimes for their work on Serialising tables, included below, FlightControl for MOOSE (Required) -------------------------------------------------------------------------------------- INTENDED USAGE DCS Server Admins looking to do long term multi session play that will need a server reboot in between and they wish to keep the Ground Unit positions true from one reload to the next. -------------------------------------------------------------------------------------- USAGE Ensure LFS and IO are not santitised in missionScripting.lua. This enables writing of files. If you don't know what this does, don't attempt to use this script. Requires versions of MOOSE.lua supporting "SET:ForEachGroupAlive()". Should be good for 6 months or more from date of writing. MIST not required, but should work OK with it regardless. Edit 'SaveScheduleUnits' below, (line 34) to the number of seconds between saves. Low impact. 10 seconds is a fast schedule. Place Ground Groups wherever you want on the map as normal. Run this script at Mission start The script will create a small file with the list of Groups and Units. At Mission Start it will check for a save file, if not there, create it fresh If the table is there, it loads it and Spawns everything that was saved. The table is updated throughout mission play The next time the mission is loaded it goes through all the Groups again and loads them from the save file. -------------------------------------------------------------------------------------- LIMITATIONS Only Ground Groups and Units are specified, play with the SET Filter at your own peril. Could be adjusted for just one Coalition or a FilterByName(). See line 107 and 168 for the SET. See https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Set.html##(SET_GROUP) Naval Groups not Saved. If Included, there may be issues with spawned objects and Client slots where Ships have slots for aircraft/helo. Possible if not a factor Statics are not included. See 'Simple Static Saving' for a solution Routes are not saved. Uncomment lines 148-153 if you wish to keep them, but they won't activate them on restart. It is impossible to query a group for it's current route, only for the original route it recieved from the Mission Editor. Therefore a DCS limitation. ]] ----------------------------------- --Configurable for user: SaveScheduleUnits=30 --how many seconds between each check of all the statics. local version = "1.2c" local SGS_DEBUG = false --Enable if you want verbose debug messages in your log (great for troubleshooting) local ALLOW_DROPIN_GROUPS = false --Enables drop in groups, i.e. groups that are loaded into the game from external scripts rather than Mission Editor added groups. local DELETE_FILE_ON_NO_GROUPS = false --This switch will delete the save file once there is no ground units to safe anymore allowing for automated persistent data reset. SaveFileName = "TestUnits.lua" --The File you want this script to use when writing out. t_SrchStringTable = {"IGNORE","sidemission", "AnotherString"} --This string will be forced lower case when searched as the GroupName searched is also forced to lowercase ----------------------------------- --Do not edit below here ----------------------------------- function IntegratedbasicSerialize(s) if s == nil then return "\"\"" else if ((type(s) == 'number') or (type(s) == 'boolean') or (type(s) == 'function') or (type(s) == 'table') or (type(s) == 'userdata') ) then return tostring(s) elseif type(s) == 'string' then return string.format('%q', s) end end end if SGS_DEBUG == true then env.info("Function: IntegratedbasicSerialize LOADED OK")end function IntegratedserializeWithCycles(name, value, saved) -- imported slmod.serializeWithCycles (Speed) local basicSerialize = function (o) if type(o) == "number" then return tostring(o) elseif type(o) == "boolean" then return tostring(o) else -- assume it is a string return IntegratedbasicSerialize(o) end end local t_str = {} saved = saved or {} -- initial value if ((type(value) == 'string') or (type(value) == 'number') or (type(value) == 'table') or (type(value) == 'boolean')) then table.insert(t_str, name .. " = ") if type(value) == "number" or type(value) == "string" or type(value) == "boolean" then table.insert(t_str, basicSerialize(value) .. "\n") else if saved[value] then -- value already saved? table.insert(t_str, saved[value] .. "\n") else saved[value] = name -- save name for next time table.insert(t_str, "{}\n") for k,v in pairs(value) do -- save its fields local fieldname = string.format("%s[%s]", name, basicSerialize(k)) table.insert(t_str, IntegratedserializeWithCycles(fieldname, v, saved)) end end end return table.concat(t_str) else return "" end end if SGS_DEBUG == true then env.info("Function: IntegratedserializeWithCycles LOADED OK")end function file_exists(name) --check if the file already exists for writing if lfs.attributes(name) then return true else return false end end if SGS_DEBUG == true then env.info("Function: file_exists LOADED OK")end function writemission(data, file)--Function for saving to file (commonly found) File = io.open(file, "w") File:write(data) File:close() end if SGS_DEBUG == true then env.info("Function: writemission LOADED OK")end function GroupStringSearch(t_SrchTbl, GroupName) --returns true if found BASE:F({t_SrchTbl,GroupName}) if type(t_SrchTbl) ~= "table" then env.info("Error: t_SrchTbl is not a table") return nil end if type(GroupName)~="string" then env.info("Error: GroupName is not a string") return nil end for index, str2check in ipairs(t_SrchTbl) do if type(str2check) == "string" then if string.find(string.lower(GroupName), string.lower(str2check)) ~= nil then return true end end end return false end if SGS_DEBUG == true then env.info("Function: GroupStringSearch LOADED OK")end function Generate_GroupSet() --Generates a set of Groups that have been filtered for Blacklisted group names local TempSET = SET_GROUP:New():FilterCategories("ground"):FilterActive(true):FilterOnce() --Creates a Moose Group Variable with all ground units local rtnSET = SET_GROUP:New() TempSET:ForEachGroup(function (MooseGroup) local GroupsName = MooseGroup:GetName() if SGS_DEBUG == true then env.info("Checking Group - " .. GroupsName)end if GroupStringSearch(t_SrchStringTable, GroupsName) == false then if SGS_DEBUG == true then env.info("Group Loaded - " .. GroupsName)end rtnSET:AddGroup(MooseGroup) end end) return rtnSET end if SGS_DEBUG == true then env.info("Function: Generate_GroupSet LOADED OK")end --SCRIPT START env.info("Loaded Simple Group Saving, by Pikey (2018), updated by OzDeaDMeaT (2020), version " .. version) if file_exists(SaveFileName) then --Script has been run before, so we need to load the save if SGS_DEBUG == true then env.info(SaveFileName .. " save file found. Loading now....")end AllGroups = Generate_GroupSet() AllGroups:ForEachGroup(function (grp) grp:Destroy() end) dofile(SaveFileName) tempTable={} Spawn={} --RUN THROUGH THE KEYS IN THE TABLE (GROUPS) for k,v in pairs (SaveUnits) do units={} --RUN THROUGH THE UNITS IN EACH GROUP for i= 1, #(SaveUnits[k]["units"]) do tempTable = { ["type"]=SaveUnits[k]["units"][i]["type"], ["transportable"]= {["randomTransportable"] = false,}, --["unitId"]=9000,used to generate ID's here but no longer doing that since DCS seems to handle it ["skill"]=SaveUnits[k]["units"][i]["skill"], ["y"]=SaveUnits[k]["units"][i]["y"] , ["x"]=SaveUnits[k]["units"][i]["x"] , ["name"]=SaveUnits[k]["units"][i]["name"], ["heading"]=SaveUnits[k]["units"][i]["heading"], ["playerCanDrive"]=true, --hardcoded but easily changed. } table.insert(units,tempTable) end --end unit for loop groupData = { ["visible"] = true, --["lateActivation"] = false, ["tasks"] = {}, -- end of ["tasks"] ["uncontrollable"] = false, ["task"] = "Ground Nothing", --["taskSelected"] = true, --["route"] = --{ --["spans"] = {}, --["points"]= {} -- },-- end of ["spans"] --["groupId"] = 9000 + _count, ["hidden"] = false, ["units"] = units, ["y"] = SaveUnits[k]["y"], ["x"] = SaveUnits[k]["x"], ["name"] = SaveUnits[k]["name"], --["start_time"] = 0, } coalition.addGroup(SaveUnits[k]["CountryID"], SaveUnits[k]["CategoryID"], groupData) groupData = {} end --end Group for loop else --Save File does not exist we start a fresh table, no spawns needed env.info("No File Found, Generating New file with name " .. SaveFileName) -- Added by OzDM SaveUnits={} AllGroups = Generate_GroupSet() end --THE SAVING SCHEDULE SCHEDULER:New( nil, function() env.info("SAVING - Ground Forces...") if ALLOW_DROPIN_GROUPS == true then AllGroups = Generate_GroupSet() end SavedUnitCount = 0 SavedGroupCount = 0 AllGroups:ForEachGroupAlive(function (grp) local DCSgroup = Group.getByName(grp:GetName() ) SavedGroupCount = SavedGroupCount + 1 local size = DCSgroup:getSize() SavedUnitCount = SavedUnitCount + size _unittable={} for i = 1, size do local tmpTable = { ["type"]=grp:GetUnit(i):GetTypeName(), ["transportable"]=true, ["unitID"]=grp:GetUnit(i):GetID(), ["skill"]="Average", ["y"]=grp:GetUnit(i):GetVec2().y, ["x"]=grp:GetUnit(i):GetVec2().x, ["name"]=grp:GetUnit(i):GetName(), ["playerCanDrive"]=true, ["heading"]=grp:GetUnit(i):GetHeading(), } table.insert(_unittable,tmpTable) --add units to a temporary table end SaveUnits[grp:GetName()] = { ["CountryID"]=grp:GetCountry(), ["SpawnCoalitionID"]=grp:GetCountry(), ["tasks"]={}, --grp:GetTaskMission(), --wrong gives the whole thing ["CategoryID"]=grp:GetCategory(), ["task"]="Ground Nothing", ["route"]={}, -- grp:GetTaskRoute(), ["groupId"]=grp:GetID(), --["SpawnCategoryID"]=grp:GetCategory(), ["units"]= _unittable, ["y"]=grp:GetVec2().y, ["x"]=grp:GetVec2().x, ["name"]=grp:GetName(), ["start_time"]=0, ["CoalitionID"]=grp:GetCoalition(), ["SpawnCountryID"]=grp:GetCoalition(), } end) if (SavedGroupCount > 0) then newMissionStr = IntegratedserializeWithCycles("SaveUnits",SaveUnits) --save the Table as a serialised type with key SaveUnits writemission(newMissionStr, SaveFileName)--write the file from the above to SaveUnits.lua env.info("SAVED - " .. SavedUnitCount .. " units in " .. SavedGroupCount .." groups have been successfully saved to ".. SaveFileName) else if (file_exists(SaveFileName) and DELETE_FILE_ON_NO_GROUPS == true) then env.info("DELETING - " .. SaveFileName) --io.remove (SaveFileName) seems to not work, not sure why. else env.info("SAVE EMPTY - " .. SaveFileName) end end --writemission(newMissionStr, "SaveUnits.lua")--write the file from the above to SaveUnits.lua SaveUnits={}--clear the table for a new write. --env.info("Data saved.") end, {}, 1, SaveScheduleUnits)
  2. Thanks for the Script Fargo. With a little help from the from AEF Zyfr and Wingthor from Moose I managed to get it working. I also added a section some variables at the start of the script to help people tweak it for various missions (i.e. the save file name && IgnoreString for groups) -- Simple Group Saving by Pikey May 2019 -- Usage of this script should credit the following contributors: --Pikey, --Speed & Grimes for their work on Serialising tables, included below, --FlightControl for MOOSE (Required) -- Modified by OzDeaDMeaT to add the ability to ignore specific groups defined by the mission maker. --INTENDED USAGE --DCS Server Admins looking to do long term multi session play that will need a server reboot in between and they wish to keep the Ground --Unit positions true from one reload to the next. --USAGE --Ensure LFS and IO are not santitised in missionScripting.lua. This enables writing of files. If you don't know what this does, don't attempt to use this script. --Requires versions of MOOSE.lua supporting "SET:ForEachGroupAlive()". Should be good for 6 months or more from date of writing. --MIST not required, but should work OK with it regardless. --Edit 'SaveScheduleUnits' below, (line 34) to the number of seconds between saves. Low impact. 10 seconds is a fast schedule. --Place Ground Groups wherever you want on the map as normal. --Run this script at Mission start --The script will create a small file with the list of Groups and Units. --At Mission Start it will check for a save file, if not there, create it fresh --If the table is there, it loads it and Spawns everything that was saved. --The table is updated throughout mission play --The next time the mission is loaded it goes through all the Groups again and loads them from the save file. --LIMITATIONS --Only Ground Groups and Units are specified, play with the SET Filter at your own peril. Could be adjusted for just one Coalition or a FilterByName(). --See line 107 and 168 for the SET. --See https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Set.html##(SET_GROUP) --Naval Groups not Saved. If Included, there may be issues with spawned objects and Client slots where Ships have slots for aircraft/helo. Possible if not a factor --Statics are not included. See 'Simple Static Saving' for a solution --Routes are not saved. Uncomment lines 148-153 if you wish to keep them, but they won't activate them on restart. It is impossible to query a group for it's current --route, only for the original route it recieved from the Mission Editor. Therefore a DCS limitation. ----------------------------------- --Configurable for user: SaveScheduleUnits=30 --how many seconds between each check of all the statics. ----------------------------------- --Do not edit below here ----------------------------------- local version = "1.1a" SaveFileName = "TestUnits.lua" --The File you want this script to use when writing out. SrchString = "IGNORE" --This string will be forced lower case when searched as the GroupName searched is also forced to lowercase function IntegratedbasicSerialize(s) if s == nil then return "\"\"" else if ((type(s) == 'number') or (type(s) == 'boolean') or (type(s) == 'function') or (type(s) == 'table') or (type(s) == 'userdata') ) then return tostring(s) elseif type(s) == 'string' then return string.format('%q', s) end end end function IntegratedserializeWithCycles(name, value, saved) -- imported slmod.serializeWithCycles (Speed) local basicSerialize = function (o) if type(o) == "number" then return tostring(o) elseif type(o) == "boolean" then return tostring(o) else -- assume it is a string return IntegratedbasicSerialize(o) end end local t_str = {} saved = saved or {} -- initial value if ((type(value) == 'string') or (type(value) == 'number') or (type(value) == 'table') or (type(value) == 'boolean')) then table.insert(t_str, name .. " = ") if type(value) == "number" or type(value) == "string" or type(value) == "boolean" then table.insert(t_str, basicSerialize(value) .. "\n") else if saved[value] then -- value already saved? table.insert(t_str, saved[value] .. "\n") else saved[value] = name -- save name for next time table.insert(t_str, "{}\n") for k,v in pairs(value) do -- save its fields local fieldname = string.format("%s[%s]", name, basicSerialize(k)) table.insert(t_str, IntegratedserializeWithCycles(fieldname, v, saved)) end end end return table.concat(t_str) else return "" end end function file_exists(name) --check if the file already exists for writing if lfs.attributes(name) then return true else return false end end function writemission(data, file)--Function for saving to file (commonly found) File = io.open(file, "w") File:write(data) File:close() end --SCRIPT START env.info("Loaded Simple Group Saving, by Pikey, 2018, version " .. version) if file_exists(SaveFileName) then --Script has been run before, so we need to load the save env.info("Existing database, loading from File.") AllGroups = SET_GROUP:New() --Create Moose Group Variable local TempSET = SET_GROUP:New():FilterCategories("ground"):FilterActive(true):FilterOnce() --Creates a Moose Group Variable with all ground units TempSET:ForEachGroup(function (MooseGroup) local GroupsName = MooseGroup:GetName() env.info("Checking Group - " .. GroupsName) if string.find(string.lower(GroupsName), string.lower(SrchString)) == nil then env.info("Group Loaded - " .. GroupsName) AllGroups:AddGroup(MooseGroup) end end) --AllGroups = SET_GROUP:New():FilterCategories("ground"):FilterActive(true):FilterStart() AllGroups:ForEachGroup(function (grp) grp:Destroy() end) dofile(SaveFileName) tempTable={} Spawn={} --RUN THROUGH THE KEYS IN THE TABLE (GROUPS) for k,v in pairs (SaveUnits) do units={} --RUN THROUGH THE UNITS IN EACH GROUP for i= 1, #(SaveUnits[k]["units"]) do tempTable = { ["type"]=SaveUnits[k]["units"][i]["type"], ["transportable"]= {["randomTransportable"] = false,}, --["unitId"]=9000,used to generate ID's here but no longer doing that since DCS seems to handle it ["skill"]=SaveUnits[k]["units"][i]["skill"], ["y"]=SaveUnits[k]["units"][i]["y"] , ["x"]=SaveUnits[k]["units"][i]["x"] , ["name"]=SaveUnits[k]["units"][i]["name"], ["heading"]=SaveUnits[k]["units"][i]["heading"], ["playerCanDrive"]=true, --hardcoded but easily changed. } table.insert(units,tempTable) end --end unit for loop groupData = { ["visible"] = true, --["lateActivation"] = false, ["tasks"] = {}, -- end of ["tasks"] ["uncontrollable"] = false, ["task"] = "Ground Nothing", --["taskSelected"] = true, --["route"] = --{ --["spans"] = {}, --["points"]= {} -- },-- end of ["spans"] --["groupId"] = 9000 + _count, ["hidden"] = false, ["units"] = units, ["y"] = SaveUnits[k]["y"], ["x"] = SaveUnits[k]["x"], ["name"] = SaveUnits[k]["name"], --["start_time"] = 0, } coalition.addGroup(SaveUnits[k]["CountryID"], SaveUnits[k]["CategoryID"], groupData) groupData = {} end --end Group for loop else --Save File does not exist we start a fresh table, no spawns needed -- Added by OzDM SaveUnits={} AllGroups = SET_GROUP:New() --Create Moose Group Variable local TempSET = SET_GROUP:New():FilterCategories("ground"):FilterActive(true):FilterOnce() --Creates a Moose Group Variable with all ground units TempSET:ForEachGroup(function (SpecificGroup) local GrpName = SpecificGroup:GetName() if string.find(string.lower(GrpName), string.lower(SrchString)) == nil then env.info("Group Saved - " .. GrpName) AllGroups:AddGroup(SpecificGroup) end end) -- ORIGINAL -- SaveUnits={} -- AllGroups = SET_GROUP:New():FilterCategories("ground"):FilterActive(true):FilterStart() end --THE SAVING SCHEDULE SCHEDULER:New( nil, function() AllGroups:ForEachGroupAlive(function (grp) local DCSgroup = Group.getByName(grp:GetName() ) local size = DCSgroup:getSize() _unittable={} for i = 1, size do local tmpTable = { ["type"]=grp:GetUnit(i):GetTypeName(), ["transportable"]=true, ["unitID"]=grp:GetUnit(i):GetID(), ["skill"]="Average", ["y"]=grp:GetUnit(i):GetVec2().y, ["x"]=grp:GetUnit(i):GetVec2().x, ["name"]=grp:GetUnit(i):GetName(), ["playerCanDrive"]=true, ["heading"]=grp:GetUnit(i):GetHeading(), } table.insert(_unittable,tmpTable) --add units to a temporary table end SaveUnits[grp:GetName()] = { ["CountryID"]=grp:GetCountry(), ["SpawnCoalitionID"]=grp:GetCountry(), ["tasks"]={}, --grp:GetTaskMission(), --wrong gives the whole thing ["CategoryID"]=grp:GetCategory(), ["task"]="Ground Nothing", ["route"]={}, -- grp:GetTaskRoute(), ["groupId"]=grp:GetID(), --["SpawnCategoryID"]=grp:GetCategory(), ["units"]= _unittable, ["y"]=grp:GetVec2().y, ["x"]=grp:GetVec2().x, ["name"]=grp:GetName(), ["start_time"]=0, ["CoalitionID"]=grp:GetCoalition(), ["SpawnCountryID"]=grp:GetCoalition(), } end) newMissionStr = IntegratedserializeWithCycles("SaveUnits",SaveUnits) --save the Table as a serialised type with key SaveUnits writemission(newMissionStr, SaveFileName)--write the file from the above to SaveUnits.lua --writemission(newMissionStr, "SaveUnits.lua")--write the file from the above to SaveUnits.lua SaveUnits={}--clear the table for a new write. --env.info("Data saved.") end, {}, 1, SaveScheduleUnits)
  3. Release v1.172f - Added VNC Remote Connection Support (note your VNC Server must use TCP connections for !access to detect connection correctly) - Added VNC Server EXE Path check for Check-DDC2-PS function - Modified Node-Red workflow to now support VNC Server connections ##Note## A number of Server admins have requested the link between AutoStart and delay 1s has been removed and can be added when you implement the new version.
  4. OK, I have racked my brain, asked Moose folk and generally given up on such a simple addition to make this script a little more useful (at least for me) Issue: I want to have the script ignore ALL ground vehicle groups with the word 'IGNORE' or 'ignore' or 'Ignore' or any variance of the word ignore in the group name, but save all the other ground units. The script is currently only writing the line below now. SaveUnits = {} Any help would be appreciated as I am completely stuck. Here is the code I have attempted to put in but had no success with. It was originally saving the ignore groups and on reload the ignore groups had no waypoints. Now after i modified line 181 it only saves the following line. -- Simple Group Saving by Pikey May 2019 -- Usage of this script should credit the following contributors: --Pikey, --Speed & Grimes for their work on Serialising tables, included below, --FlightControl for MOOSE (Required) -- Modified by OzDeaDMeaT to add the IGNORE --INTENDED USAGE --DCS Server Admins looking to do long term multi session play that will need a server reboot in between and they wish to keep the Ground --Unit positions true from one reload to the next. --USAGE --Ensure LFS and IO are not santitised in missionScripting.lua. This enables writing of files. If you don't know what this does, don't attempt to use this script. --Requires versions of MOOSE.lua supporting "SET:ForEachGroupAlive()". Should be good for 6 months or more from date of writing. --MIST not required, but should work OK with it regardless. --Edit 'SaveScheduleUnits' below, (line 34) to the number of seconds between saves. Low impact. 10 seconds is a fast schedule. --Place Ground Groups wherever you want on the map as normal. --Run this script at Mission start --The script will create a small file with the list of Groups and Units. --At Mission Start it will check for a save file, if not there, create it fresh --If the table is there, it loads it and Spawns everything that was saved. --The table is updated throughout mission play --The next time the mission is loaded it goes through all the Groups again and loads them from the save file. --LIMITATIONS --Only Ground Groups and Units are specified, play with the SET Filter at your own peril. Could be adjusted for just one Coalition or a FilterByName(). --See line 107 and 168 for the SET. --See https://flightcontrol-master.github.io/MOOSE_DOCS_DEVELOP/Documentation/Core.Set.html##(SET_GROUP) --Naval Groups not Saved. If Included, there may be issues with spawned objects and Client slots where Ships have slots for aircraft/helo. Possible if not a factor --Statics are not included. See 'Simple Static Saving' for a solution --Routes are not saved. Uncomment lines 148-153 if you wish to keep them, but they won't activate them on restart. It is impossible to query a group for it's current --route, only for the original route it recieved from the Mission Editor. Therefore a DCS limitation. ----------------------------------- --Configurable for user: SaveScheduleUnits=30 --how many seconds between each check of all the statics. ----------------------------------- --Do not edit below here ----------------------------------- local version = "1.0" function IntegratedbasicSerialize(s) if s == nil then return "\"\"" else if ((type(s) == 'number') or (type(s) == 'boolean') or (type(s) == 'function') or (type(s) == 'table') or (type(s) == 'userdata') ) then return tostring(s) elseif type(s) == 'string' then return string.format('%q', s) end end end -- imported slmod.serializeWithCycles (Speed) function IntegratedserializeWithCycles(name, value, saved) local basicSerialize = function (o) if type(o) == "number" then return tostring(o) elseif type(o) == "boolean" then return tostring(o) else -- assume it is a string return IntegratedbasicSerialize(o) end end local t_str = {} saved = saved or {} -- initial value if ((type(value) == 'string') or (type(value) == 'number') or (type(value) == 'table') or (type(value) == 'boolean')) then table.insert(t_str, name .. " = ") if type(value) == "number" or type(value) == "string" or type(value) == "boolean" then table.insert(t_str, basicSerialize(value) .. "\n") else if saved[value] then -- value already saved? table.insert(t_str, saved[value] .. "\n") else saved[value] = name -- save name for next time table.insert(t_str, "{}\n") for k,v in pairs(value) do -- save its fields local fieldname = string.format("%s[%s]", name, basicSerialize(k)) table.insert(t_str, IntegratedserializeWithCycles(fieldname, v, saved)) end end end return table.concat(t_str) else return "" end end function file_exists(name) --check if the file already exists for writing if lfs.attributes(name) then return true else return false end end function writemission(data, file)--Function for saving to file (commonly found) File = io.open(file, "w") File:write(data) File:close() end --SCRIPT START env.info("Loaded Simple Group Saving, by Pikey, 2018, version " .. version) if file_exists("TestUnits.lua") then --Script has been run before, so we need to load the save env.info("Existing database, loading from File.") AllGroups = SET_GROUP:New() --Create Moose Group Variable local TempSET = SET_GROUP:New():FilterCategories("ground"):FilterActive(true):FilterOnce() --Creates a Moose Group Variable with all ground units TempSET:ForEachGroup(function (MooseGroup) local GroupsName = MooseGroup:GetName() if string.find(GroupsName, "IGNORE*") == nil then env.info("Group Loaded - " .. GroupsName) AllGroups:Add(MooseGroup) end end) --AllGroups = SET_GROUP:New():FilterCategories("ground"):FilterActive(true):FilterStart() AllGroups:ForEachGroup(function (grp) grp:Destroy() end) dofile("TestUnits.lua") tempTable={} Spawn={} --RUN THROUGH THE KEYS IN THE TABLE (GROUPS) for k,v in pairs (SaveUnits) do units={} --RUN THROUGH THE UNITS IN EACH GROUP for i= 1, #(SaveUnits[k]["units"]) do tempTable = { ["type"]=SaveUnits[k]["units"][i]["type"], ["transportable"]= {["randomTransportable"] = false,}, --["unitId"]=9000,used to generate ID's here but no longer doing that since DCS seems to handle it ["skill"]=SaveUnits[k]["units"][i]["skill"], ["y"]=SaveUnits[k]["units"][i]["y"] , ["x"]=SaveUnits[k]["units"][i]["x"] , ["name"]=SaveUnits[k]["units"][i]["name"], ["heading"]=SaveUnits[k]["units"][i]["heading"], ["playerCanDrive"]=true, --hardcoded but easily changed. } table.insert(units,tempTable) end --end unit for loop groupData = { ["visible"] = true, --["lateActivation"] = false, ["tasks"] = {}, -- end of ["tasks"] ["uncontrollable"] = false, ["task"] = "Ground Nothing", --["taskSelected"] = true, --["route"] = --{ --["spans"] = {}, --["points"]= {} -- },-- end of ["spans"] --["groupId"] = 9000 + _count, ["hidden"] = false, ["units"] = units, ["y"] = SaveUnits[k]["y"], ["x"] = SaveUnits[k]["x"], ["name"] = SaveUnits[k]["name"], --["start_time"] = 0, } coalition.addGroup(SaveUnits[k]["CountryID"], SaveUnits[k]["CategoryID"], groupData) groupData = {} end --end Group for loop else --Save File does not exist we start a fresh table, no spawns needed -- Added by OzDM SaveUnits={} AllGroups = SET_GROUP:New() --Create Moose Group Variable local TempSET = SET_GROUP:New():FilterCategories("ground"):FilterActive(true):FilterOnce() --Creates a Moose Group Variable with all ground units TempSET:ForEachGroup(function (SpecificGroup) local GrpName = SpecificGroup:GetName() if string.find(GrpName, "IGNORE*") == nil then env.info("Group Saved - " .. GrpName) AllGroups:Add(SpecificGroup) end end) -- ORIGINAL -- SaveUnits={} -- AllGroups = SET_GROUP:New():FilterCategories("ground"):FilterActive(true):FilterStart() end --THE SAVING SCHEDULE SCHEDULER:New( nil, function() AllGroups:ForEachGroupAlive(function (grp) local DCSgroup = Group.getByName(grp:GetName() ) local size = DCSgroup:getSize() _unittable={} for i = 1, size do local tmpTable = { ["type"]=grp:GetUnit(i):GetTypeName(), ["transportable"]=true, ["unitID"]=grp:GetUnit(i):GetID(), ["skill"]="Average", ["y"]=grp:GetUnit(i):GetVec2().y, ["x"]=grp:GetUnit(i):GetVec2().x, ["name"]=grp:GetUnit(i):GetName(), ["playerCanDrive"]=true, ["heading"]=grp:GetUnit(i):GetHeading(), } table.insert(_unittable,tmpTable) --add units to a temporary table end SaveUnits[grp:GetName()] = { ["CountryID"]=grp:GetCountry(), ["SpawnCoalitionID"]=grp:GetCountry(), ["tasks"]={}, --grp:GetTaskMission(), --wrong gives the whole thing ["CategoryID"]=grp:GetCategory(), ["task"]="Ground Nothing", ["route"]={}, -- grp:GetTaskRoute(), ["groupId"]=grp:GetID(), --["SpawnCategoryID"]=grp:GetCategory(), ["units"]= _unittable, ["y"]=grp:GetVec2().y, ["x"]=grp:GetVec2().x, ["name"]=grp:GetName(), ["start_time"]=0, ["CoalitionID"]=grp:GetCoalition(), ["SpawnCountryID"]=grp:GetCoalition(), } end) newMissionStr = IntegratedserializeWithCycles("SaveUnits",SaveUnits) --save the Table as a serialised type with key SaveUnits writemission(newMissionStr, "TestUnits.lua")--write the file from the above to SaveUnits.lua --writemission(newMissionStr, "SaveUnits.lua")--write the file from the above to SaveUnits.lua SaveUnits={}--clear the table for a new write. --env.info("Data saved.") end, {}, 1, SaveScheduleUnits) (FYI I am not a LUA person, just trying to get this most basic of basic feature additions added to this script)
  5. ok, worked it out. Apparently if you have an IPv6 address for the DCS Server, IPv4 will not allow the connection for TACView. So, if you have IPv6 setup for your DCS Server you must connect using the IPv6 IP. (if you are on the same LAN as your Server)
  6. I can connect to the Server Realtime Telemetry fine from the localhost, I can't connect to it outside of the system. That is both with the windows firewall enabled and disabled.
  7. Are you running the server as administrator? Do you have stuff like SLMOD installed or any other mods?
  8. Is that happening when you load a specific mission or when you start the server application itself. What does the dcs.log say?
  9. ahhh, Thnx Grimes, I am sure that is exactly what it is. I will give it a go tonight.
  10. This method of server config is ancient mate. you dont need a graphics card to run a dedicated server. If you have no hardware contention you wont see any performance degradation between a dedicated server and a VM. I run my servers with ESXi 6.7, Dual vCPU and 10GB RAM and 200GB of HDD space. That is with about 600 units on the mission with no lag or server issues.
  11. OK, it turns out SLMOD was ****ing me up. I have since removed SLMOD while i try and work out how this thing is supposed to work. I can't seem to get the vehicles to load correctly on startup. it seems to generate a new file and overwrite then old one with a full list of units again.
  12. My MissionScripting.lua file is uncommenting out the following lines every time the server starts. sanitizeModule('io') sanitizeModule('lfs') I want the lines to look like this --sanitizeModule('io') --sanitizeModule('lfs') But every time i start my server it alters the files back to uncommented. Is there a way to stop this from happening cause its ****ing annoying?
  13. Hey Pikey, Firstly great script. I am attempting to load the externally from the .miz file. It all loads and creates the file ok. I am doing the same for Moose first also. Rather than starting the Moose script on Mission Start (it crashes my server for some reason) I am running the external include.lua that is running Moose etc. I got an external include script that is injected into the mission itself. local missionScriptsDir = [[C:\DCS_SCRIPTS\OzDM_Syria_Persistence_Test\]] dofile(missionScriptsDir ..[[include.lua]]) The include looks like this: local mooseDir = [[C:\DCS_SCRIPTS\MOOSE\]] dofile(mooseDir ..[[Moose.lua]]) ---------------------------------------------------------------------------MOOSE local missionScriptsDir = [[C:\DCS_SCRIPTS\OzDM_Syria_Persistence_Test\]] dofile(missionScriptsDir ..[[sGS.lua]]) The file is generated correctly, its on reload that I am getting an error saying the file exists. 2020-09-02 16:24:44.424 INFO SCRIPTING: *** MOOSE INCLUDE END *** 2020-09-02 16:24:44.424 INFO SCRIPTING: Loaded Simple Group Saving, by Pikey, 2018, version 1.0 2020-09-02 16:24:44.424 ERROR SCRIPTING: Mission script error: [string "C:\DCS_SCRIPTS\OzDM_Syria_Persistence_Test\SGS.lua"]:90: attempt to index global 'lfs' (a nil value) stack traceback: [C]: ? [string "C:\DCS_SCRIPTS\OzDM_Syria_Persistence_Test\SGS.lua"]:90: in function 'file_exists' [string "C:\DCS_SCRIPTS\OzDM_Syria_Persistence_Test\SGS.lua"]:105: in main chunk [C]: in function 'dofile' [string "C:\DCS_SCRIPTS\OzDM_Syria_Persistence_Test\include.lua"]:5: in main chunk [C]: in function 'dofile' [string "C:\Users\C0RNER~1\AppData\Local\Temp\DCS.openbeta_server\/~mis00006B1D.lua"]:2: in main chunk I have changed two lines in your script. Firstly I have it so the units list is saved every 10 minutes. SaveScheduleUnits=600 --how many seconds between each check of all the statics. Secondly I changed it so the File it saves out to is of a similar name to the mission file itself. writemission(newMissionStr, "OzDM_Syria_Persistence_Test.lua")--write the file from the above to SaveUnits.lua The server is running SLMOD and i keep commenting out the likes but each time the server starts it uncomments these two lines. sanitizeModule('io') sanitizeModule('lfs') I believe this is the problem but ****ed if i know how to stop DCS from modifying the lines at server start.
  14. My Server keeps uncommenting out these likes each time the server starts. Is there a way to stop this from happening? --sanitizeModule('io') --sanitizeModule('lfs')
  15. Fantastic news Fizzxit. Was there anything I missed or could have described better in the Instructional Video Series?
  16. Call your ISP, you might fall under a carrier grade NAT. It is where your ISP has a firewall of sorts between you and the internet. Check out this website to see what ports you have open. https://www.ipfingerprints.com/portscan.php I would also recommend getting a friend who understands networking to go over your setup. Hopefully it's just a misconfigured setting somewhere.
  17. I am conducting a standard installation of Tacview on my Dedicated Server. It does not appear to be generating the options.lua data or moving the Mods or Scripts folders into the DCS profile either. Is this a known issue? Also, is there a location like a discord or something that people can discuss these kinds of issues?
  18. Thanks mate, I eventually found that the UCID is referenced if you enable SLMOD statistics.
  19. Yep, next set of videos are due as soon as my replacement UPS comes in. The majority of my server infrastructure is offline until it arrives.
  20. Hi ViFF, Will it work if our root server setup is multiple instances of DCS each running on a distinct windows user? The update capability requires console access (until DCS introduces a silent installer). That would be the only limiting factor for with regards running this against multiple users, but with this system you wouldn't need to have multiple users anymore. DDC2 would need root access and the ability to control the processes and you would need a seperate powershell script per instance pointing to the individual config and exe locations. A bit of code would need to change in the powershell script to pick the specific processes to stop for that instance of DCS. You can have multiple instances of DDC2 running at the same time.(different flows). Is there any conflict with the webgui on dcs website? can they be used in parallel? No conflict, works perfectly well. Do you have the ability to add the option to remotely kill and restart the dcs.exe for each instance running on a specific user? Specific user not sure, killing other user processes is usually ok if you are the admin and they are a standard user. I am not sure with regards admin to admin process manipulation. The system could technically work against a system running multiple instances of DCS but it doesn't currently have that capability. (multiple instances shouldn't be a problem if i can distinguish between them, are the different installation paths?) Great questions. My turn, how do most people run multiple instances of DCS on a server? Single EXE with different process window names? Separate install locations?
  21. Yeah, happy to work on some localisation stuff. I will need to work out how to do that in Node-Red but yeah, love the idea.
×
×
  • Create New...