Jump to content

Kanelbolle

Members
  • Posts

    386
  • Joined

  • Last visited

Everything posted by Kanelbolle

  1. Open the Miz file as a zip file. Change the mission file. Remove the mods in the first part of the file under requiredModules.
  2. Can this topic be moved to the "Scripting Tips, Tricks & Issues" please thx
  3. For anyone who needs a side select script! Scraped this together from examples on the Forum and a lot of testing. Enjoy! --- Install in <DCS profile path>\Scripts\Hooks\ -- ONLY WORKS IN MULTIPLAYER! YOU CAN NOT TEST THIS IN THE SINGLEPLAYER! -- USES LFS and IO to save and load files! net.log("-- HOOK: Side Select v100 loading...") sideCall = {} sidesel = {} -- The line below gets your DCS profile path: <DCS profile path>\Scripts\ sidesel.loadDir = lfs.writedir() .. [[Scripts\]] sidesel.saveFilename = "sideselect_save.lua" -- Settings: sidesel.verboslog = false -- Define the sides and corresponding slot names local sides = { ["blue"] = "blue", ["red"] = "red", } sidesel.sideplayerTbl = {} sidesel.adminTbl = {} -- Uncomment and add UCID of Admins that can run Admin commands in chat! --sidesel.adminTbl["admin players ucid"] = "admin" --sidesel.adminTbl["admin players ucid"] = "admin" --sidesel.adminTbl["admin players ucid"] = "admin" --sidesel.adminTbl["admin players ucid"] = "admin" -- Function to handle chat messages function onChatMessage(message, from) local ucid = net.get_player_info(from, 'ucid') local _playername = net.get_player_info(from, 'name') local playerId = net.get_player_info(from, 'id') local playerside = nil -- Check if the message is a side selection local side = sides[string.lower(message)] if (sidesel.sideplayerTbl[ucid] ~= nil) then elseif (sidesel.sideplayerTbl[ucid] == nil) then if side then sidesel.sideplayerTbl[ucid] = { ["side"]= side, ["nicename"]= _playername, } net.log(" ---------------- " .. _playername .. " - Selected SIDE : " .. side) local msg = string.format(" You are now on the %s Side!", side) net.send_chat_to(msg, playerId) -- Save Table to file! sidesel.save() end else --some error net.log(" ---------------- ERROR: some error MSG") end -- of if(sidesel.sideplayerTbl[ucid] == nil) then -- Admin Commands if (sidesel.adminTbl[ucid] ~= nil) then if (string.lower(message) == "-reloadsides") then net.log("-- HOOK: Is Admin player! - reloadsides - Name: " .. _playername .. " - UCID: " .. ucid) local lpath = sidesel.loadDir .. sidesel.saveFilename if file_exists(lpath) then assert(loadfile(lpath))() if (loadsideplayerTbl) then sidesel.sideplayerTbl = loadsideplayerTbl end end net.log("-- HOOK: Reloaded save file!") end -- of if (string.lower(message) == "-reloadsides") then if (string.lower(message) == "-purgesides") then net.log("-- HOOK: Is Admin player! - purgesides - Name: " .. _playername .. " - UCID: " .. ucid) sidesel.sideplayerTbl = {} net.log("-- HOOK: Pureged Side Table file!") end -- of if (string.lower(message) == "-reloadsides") then if (string.lower(message) == "-printtable") then net.log("-- HOOK: Is Admin player! - print table - Name: " .. _playername .. " - UCID: " .. ucid) net.log("-- HOOK: : -printtable Running: ") for key,value in pairs(sidesel.sideplayerTbl) do if (sidesel.verboslog == true) then net.log("-- HOOK: : Key: " .. key) --net.log("-- HOOK: : Value: " .. value) -- Table cant print end for skey,svalue in pairs(sidesel.sideplayerTbl[key]) do if (sidesel.verboslog == true) then net.log("-- HOOK: : sKey: " .. skey) net.log("-- HOOK: : sValue: " .. svalue) end end end net.log("-- HOOK: -printtable End!") end -- of if (string.lower(message) == "-reloadsides") then end end -- of if (playerside == nil) or (adminplayer ~= nil) then function sideCall.onPlayerConnect(playerId) local ucid = net.get_player_info(playerId, 'ucid') local playerName = net.get_player_info(playerId, 'name') net.log("---------------- Player: " .. playerName .. " - Connected: " .. ucid) end function sideCall.onPlayerTryChangeSlot(playerId, side, slotId) local playerName = net.get_player_info(playerId, 'name') net.log(" ---------------- Player Changed Slot: " .. playerName) local ucid = net.get_player_info(playerId, 'ucid') local sidename = "" if (side == 1) then sidename = "red" elseif (side == 2) then sidename = "blue" else sidename = "spectator" end if (sidesel.sideplayerTbl[ucid] == nil) then -- New player with no side selected net.log(" ---------------- " .. playerName .. " - No SIDE Selected!") local message = string.format(" Player: %s - Please select a side by Typing red or blue in chat!", playerName) net.send_chat_to(message, playerId) return false elseif (sidesel.sideplayerTbl[ucid] ~= nil) then if (sidesel.sideplayerTbl[ucid].side == sidename) then net.log(" ---------------- " .. playerName .. " - Correct side : " .. sidename .. " - Has Side: " .. sidesel.sideplayerTbl[ucid].side) elseif (sidename == "spectator") then net.log(" ---------------- " .. playerName .. " - Spectator side : " .. sidename) elseif (sidesel.sideplayerTbl[ucid].side ~= sidename) then local message = string.format("You are not allowed to join that side: %s - Please select a slot on the other side!", playerName) net.send_chat_to(message, playerId) net.log(" ---------------- " .. playerName .. " - Wrong side : " .. sidename .. " - Has Side: ".. sidesel.sideplayerTbl[ucid].side) return false end -- of if (sidesel.sideplayerTbl[ucid].side == sidename) then else --some error net.log(" ---------------- ERROR: Something went wrong with finding the player in sidesel.sideplayerTbl") end -- of if(sidesel.sideplayerTbl[ucid] == nil) then end function sidesel.save() net.log('-- HOOK: : sideselect - Running sidesel.save()') wFile = io.open(sidesel.loadDir .. sidesel.saveFilename, 'w') wFile:write('loadsideplayerTbl = {}' .. '\n') for key,value in pairs(sidesel.sideplayerTbl) do if (sidesel.verboslog == true) then net.log("-- HOOK: : Key: " .. key) end wFile:write('loadsideplayerTbl["' .. key .. '"] = {\n') for skey,svalue in pairs(sidesel.sideplayerTbl[key]) do if (sidesel.verboslog == true) then net.log("-- HOOK: : sKey: " .. skey) net.log("-- HOOK: : sValue: " .. svalue) end wFile:write('["' .. skey .. '"]= "' .. svalue .. '",\n') end wFile:write('}\n') end -- of for key,value in pairs(sidesel.sideplayerTbl) do wFile:write('net.log("-- HOOK:sideselect - Save file has been loaded")' .. '\n') wFile:close() wFile = nil end function sidesel.load() -- local loadpath = sidesel.loadDir .. sidesel.saveFilename -- net.log('-- HOOK: Loading save file : ' .. loadpath) -- assert(loadfile(loadpath))() local loadpath = sidesel.loadDir .. sidesel.saveFilename if file_exists(loadpath) then assert(loadfile(loadpath))() if (loadsideplayerTbl) then sidesel.sideplayerTbl = loadsideplayerTbl net.log("-- HOOK: Loaded save file Table : loadsideplayerTbl") end net.log("-- HOOK: Loaded save file : " .. loadpath) end if (sidesel.verboslog == true) then for key,value in pairs(sidesel.sideplayerTbl) do net.log("-- HOOK: : Key: " .. key) for skey,svalue in pairs(sidesel.sideplayerTbl[key]) do net.log("-- HOOK: : sKey: " .. skey) net.log("-- HOOK: : sValue: " .. svalue) end end end -- of if (sidesel.verboslog == true) then end function file_exists(name) local f=io.open(name,"r") if f~=nil then io.close(f) return true else return false end end sideCall.onMissionLoadEnd = function() net.log('-- HOOK: onMissionLoadEnd()') if (loadsideplayerTbl ~= nil) then if (sidesel.verboslog == true) then net.log('loadsideplayerTbl is NOT nil') end if (sidesel.verboslog == true) then for key,value in pairs(loadsideplayerTbl) do net.log("-- HOOK: Loaded Key: " .. key) net.log("-- HOOK: Loaded Value: " .. value) end end else if (sidesel.verboslog == true) then net.log('loadsideplayerTbl is nil') end end end -- Add the chat message handler function to the server event loop DCS.setUserCallbacks({ onChatMessage = onChatMessage, }) DCS.setUserCallbacks(sideCall) -- Load Save file sidesel.load() net.log("-- HOOK: Side Select script loaded!")
  4. Placing the script in the script folder does not load the script file in to your mission. You can load it in to the mission with a trigger named "DO SCRIPT FILE" : PS: If you change the script after loading it, you need to load it again. see here how to load it :
  5. Try running the function trigger.action.explosion(table vec3 , number power ) on each location of units you want to destroy. If the units are placed in the Mission Editor and not spawned by script you can use the same Trigger action in the Editor called "EXPLODE UNIT" Might need to use "S_EVENT_UNIT_LOST" to get the AI units that are killed. Also can't see any use for the following, since it does not have any group. function testDestroy() Group.destroy(Group.getByName(currentGroup)) trigger.action.outTextForCoalition(coalition.side.BLUE, "Destroying Current Group: " .. currentGroup, 20) end timer.scheduleFunction(testDestroy, {}, timer.getTime() + 35)
  6. First this question is off topic JTACAutolase is not a valid command in vanilla DCS. If you are using the CTLD script it should be "ctld.JTACAutoLase" Function from CTLD: function ctld.JTACAutoLase(_jtacGroupName, _laserCode, _smoke, _lock, _colour, _radio) If you are using "DCS-JTACAutoLaze" script, then you have a typing error. Lua is Case sensetive. Should be: JTACAutoLase('JTAC1', 1688, false,"all") If that does not work, then you have not loaded the script correctly.
  7. Edit: This seam to have been fixed in the last OB patch: - MP Events. Base captured events each time a player joins the server - fixed. Hi! awesome script! Makes blocking slots a lot easier! Just wanted to let you know there is an issue with players getting kicked out of the slot if you use "Neutral Airfields" in the ME and add slots to them and you have cfxSSBClient.allowNeutralFields = false If players are spawning in a captured airbase that was Neutral but not anymore. Example Blue now. The players will get kicked out of the slot every time a player joins the Multiplayer Server. DCS in ED's wisdom resets all Airfields that are set to Neutral in ME back to Neutral for 1 second and back to the captured side every time a client joins. (Join in progress update) The Capture event is responsible for this. In my capture the base script i circumvented this problem by saving the state of every airbase to FLAGS. And if it changed the script checks the flag if it is the right side. The Capture event in the script only updated the flag if it changed to Red or blue. So the slots would not be blocked in case of a player joining the server. Now cfxSSBClient.allowNeutralFields = true will fix this, but if you want Neutral Airfields that you can not spawn on in the game, this is not possible in the current version unless you code something that closes the airfield with "cfxSSBClient.closeAirfieldNamed" when it is Neutral. Hope this helps Have a good one!
  8. Creating a mission with a save script is different from a regular mission. Example you can sett all the units you have to "Late Activation" and use the "- FLAG or LUA variable for tracking if the mission is loaded in a persistent state." See the example missions included, there are units in the trigger list that only activate if the mission is started without a save. (Flag "spgginitalstart" is true)
  9. See "Step 3 - How to SPAWN units in your mission" Page 7 in the readme. (should be step 4, but misspelled)
  10. Don't delete the save file, delete the content of the file or run "spgg.clearSavefile()" in the mission. The timer to save is every 60 min. If you want to force a save you can run "spgg.save()" in the mission. It is explained in "Step 4 - Saving groups" on page 8 in the readme.
  11. Hi, there are errors in your log file: 2023-03-26 16:00:27.178 ERROR SCRIPTING (Main): Mission script error: [string "C:\Users\tarko\AppData\Local\Temp\DCS.openbeta_server\/~mis00007258.lua"]:20: attempt to index global 'lfs' (a nil value) stack traceback: [C]: ? [string "C:\Users\tarko\AppData\Local\Temp\DCS.openbeta_server\/~mis00007258.lua"]:20: in main chunk The error code is is shown in the Troubleshooting section of the readme: Troubleshooting Check Dcs.log file under path: %userprofile%\Saved Games\DCS.openbeta\Logs\ 1. Error messages: [string "local _sDrive= lfs.writedir() .. [[Scripts\SPGG\]]..."]:1: attempt to index global 'lfs' (a nil value) Cause: LUA’s “LFS” and/or “IO” module is sanitized in DCS. Solution: See “Step 1 - Removing LFS and IO sanitation” You have not successfully completed "Step 1 - Removing LFS and IO sanitation" in the readme file. The scripting environment can not access files on your system. Thereby it can not load the files.
  12. Can you include the log file from a mission start where it fails? Or see if you can find any of the errors on page 12 of the readme?
  13. Hi again, you seam to be missing my point. The function "lfs.writedir()" is getting your profile path to DCS already. As long as you are starting your sever with the same profile path as you installed the script, it is already pointing to the correct location. It does not matter if you have "DCS.OpenBeta" or "DCS.openbeta_server" in your profile path. Example 1: If you change the last part of this script to "SPGG2\" like this : local _sDrive= lfs.writedir() .. [[Scripts\SPGG2\]] assert(loadfile(_sDrive .. "SPGG.lua"))() The script will try and find the script files in your case here in the path: "C:\Users\tarko\Saved Games\DCS.openbeta_server\Scripts\SPGG2\" Example 2: If you remove "lfs.writedir()" from the script like this: local _sDrive= [[C:\Users\tarko\Saved Games\DCS.openbeta_server\Scripts\SPGG2\]] assert(loadfile(_sDrive .. "SPGG.lua"))() It will also point to the same place: "C:\Users\tarko\Saved Games\DCS.openbeta_server\Scripts\SPGG2\" Hope this helps. If you need any more help let me know.
  14. Hi again, not sure what you mean by my tone, since i am typing and not on a voice chat with you. The reason i always mention to read the readme is because 95% of people contacting me have not done so and are struggling with the same pathing. The install instructions under "Step 2 - Where to install SPGG" say the following "Please change SPGG.lua if you install SPGG to a different location!" The key word here is "if". As far as i can tell you did not change the install location. It will default to "C:\Users\tarko\Saved Games\DCS.openbeta_server\Scripts\SPGG\" as i previously mentioned. On page 12 you also have "Troubleshooting" section that explains errors you get in the log file if you have the wrong pathing. SPGG.lua also explains the pathing at the start of the file (line 8 to 21) If you have installed the script under "C:\Users\tarko\Saved Games\DCS.openbeta_server\Scripts\SPGG\" then your SPGG.lua should have the default path as already stated in my last post: spgg.defaultDrive = lfs.writedir() .. [[Scripts\SPGG\]]
  15. Hi, yes the script is still maintained. Please read the "Readme SPGG v020.pdf". It is clearly stated under the section "Step 3 - How to Load SPGG in to your mission" how to load the script. The path in SPGG.lua should be as it is by default. (Do not change it if you don't know what you are doing) To load the script from your mission use this in a "DO SCRIPT": local _sDrive= lfs.writedir() .. [[Scripts\SPGG\]] assert(loadfile(_sDrive .. "SPGG.lua"))() The above code is the same as your path (also explained in the readme) : "C:\Users\tarko\Saved Games\DCS.openbeta_server\Scripts\SPGG\SPGG.lua" The code you have put in SPGG.lua: spgg.defaultDrive = lfs.writedir() .. [[C:\Users\tarko\Saved Games\DCS.openbeta_server\Scripts\SPGG]] amounts to this : "C:\Users\tarko\Saved Games\DCS.openbeta_server\C:\Users\tarko\Saved Games\DCS.openbeta_server\Scripts\SPGG\SPGG.lua" lfs.writedir() is a function that gets the path to your: "C:\Users\tarko\Saved Games\DCS.openbeta_server\"
  16. The last DCS patch introduced a bug that static objects can't be read properly. All server that use static objects in scripts are effected. Example if you try save a FOB from CTLD with SPGG it will not save. Hopefully ED will fix this in a hotfix soon. Se bug report her:
  17. Yea, it seams to go faster the higher the throttle is set. Driving me MAD!
  18. 1. The script saves the position of units. If it moves and a save is conducted, it will spawn where it moved. 2. Look at the features list at the first page. It does not save routs or tasks. You have to script a new move order if you load the units. (Reuse group and unit names comes in handy here.) Please read the readme and look at the example mission before creating a mission. Designing a mission with a save script is different from a regular mission!
  19. Yes, a empty file is correct. Or you can run the function provided in the script with a "DO SCRIPT" trigger action: spgg.clearSaveFile() It empty's the save file from the game. You can use it for testing or if you have a condition that will reset the mission if it is completed (before a restart). I have not seen this behavior on my server. Hard to say what this is caused by whiteout info on what happened. Most likely it is caused by your mission design or the save settings used. (Example you do not exclude deactivated groups in the save prosess)
  20. There will be a script error if you delete the file, I recommend deleting the content in the file, not the file it self.
  21. Yes. With the functions getlife mist.getUnitsInZones trigger.action.setUserFlag You can find them all by searching here: https://wiki.hoggitworld.com/view/Hoggit_DCS_World_Wiki
  22. Update v020: Added FLAG (spgginitalstart) and global script variable (spgg.initalstart) to detect if mission has loaded a save file. *1 (See last trigger in Example .miz files) Added detection if MIST is used to avoid "spgg.useMIST = true" forcing the use of MIST if not loaded. Updated example mission files! Refurbished the readme file! Now contains troubleshooting section (95% of errors users get). Changed back to the old folder name. "SPGG" for easy understanding of the folder to use. (Added examples how the folder path work in SPGG.lua) *1: Can be used by mission makes to avoid spawning units that should only spawn at initial mission start and not just after a restart of the server/mission. If upgrading from a previous version with a save file in use and populated, please add "spgg.initalstart = false" to your save file (SPGG_savefile.lua)
  23. Hi, The file is not found or able to access the file: can't open 'E:\Dropbox\Saved Games\DCS_Laptop\Scripts\SPGG_v019\SPGG_Save_v019.lua' Check that the path is correct and DCS can access the file. Windows folder permission might block it or Lua LFS & IO is sanitized. (See the SPGG readme)
  24. Yea, i missed that. I always use 60 min, so i did not catch that. (Must of broken when i changed that parameter a few releases back) Thx for pointing it out
  25. Update v019 - Hotfix1: Fixed schedule function for saving not reading the parameter "spgg.Savetime" in SPGG.lua
×
×
  • Create New...