xcom Posted September 9, 2015 Share Posted September 9, 2015 Hey guys, I'm looking for a way to use the global net module that is explained in the DCS World\scripts\net\readme.txt file. I know Servman and SLMod are using it. Also I saw an issue with Servman, it is trying to get the following - if not players then local players = server.tblPlayersSrv end But I believe that the server.tblPlayersSrv is no longer available or that the command changed, as Players seems nil when servman is initiated. Anyway, if anyone can guide on how to get access to the server and net global modules it would be great for future events we are planning. Also if there is a list of functions/tables that are available it would be nice. Thanks! Xcom [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook Link to comment Share on other sites More sharing options...
ajax Posted September 9, 2015 Share Posted September 9, 2015 Servman and slmod both have access by hooking into the \scripts\net\main.lua file. You would have to do the same. You can't access the net environment using mission scripting. Use the table dump feature of Mist to get the net environment. You should be able to see the variables and functions. Unfortunately, I don't believe any public documentation exists. Link to comment Share on other sites More sharing options...
xcom Posted September 9, 2015 Author Share Posted September 9, 2015 Thanks Ajax. So my problem now is how to hook correctly and how to run commands through it later while the mission is running. I tried investigating their main . Lua, from what I saw they are loading their own files from within main.lua, now the question is if there's a way to make the net available in the mission scripting environment afterwards somehow? [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook Link to comment Share on other sites More sharing options...
Ciribob Posted September 9, 2015 Share Posted September 9, 2015 You should be able to access any lua function from your mission by commenting out the sanitizeModule functions in MissionScripting.lua It might be a completely separate environment though so you might need to load your functions again in the mission script. A good thing to have a look at would probably be DCS Witchcraft https://github.com/jboecker/dcs-witchcraft as that hooks in to the mission and uses the lua network functions --Initialization script for the Mission lua Environment (SSE) dofile('Scripts/ScriptingSystem.lua') --Sanitize Mission Scripting environment --Sanitize Mission Scripting environment --This makes unavailable some unsecure functions. --Mission downloaded from server to client may contain potentialy harmful lua code that may use these functions. --You can remove the code below and make availble these functions at your own risk. local function sanitizeModule(name) _G[name] = nil package.loaded[name] = nil end do sanitizeModule('os') sanitizeModule('io') sanitizeModule('lfs') require = nil loadlib = nil end Scripts: Complete Transport And Logistics Deployment - CTLD / CTLD Examples - Lots of example of how to use CTLD CSAR Script - Downed Pilot Rescue / Dedicated Server Script - Automatically launch DCS Multiplayer server at startup Range Scoring Script - Get scores and counts hits on targets for gunnery or bombs / SimpleSlotBlock - Multiplayer dynamic Slot Blocking Script Projects: DCS-SimpleRadio Standalone - DCS Radio Integration for All Aircraft - NO TeamSpeak Required! :) DCS-SimpleRadio Troubleshooting Post / DCS-SimpleRadio Free Support Channel on Discord Link to comment Share on other sites More sharing options...
xcom Posted September 10, 2015 Author Share Posted September 10, 2015 Thanks ciribob! I did try to load these modules or require them from the _G table, It might work after removing the sanitization on require or loadlib. Will give it a try! [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook Link to comment Share on other sites More sharing options...
ajax Posted September 10, 2015 Share Posted September 10, 2015 Good tip about dcs-witchcraft, Ciribob. I need to take a look at it. Thanks! Link to comment Share on other sites More sharing options...
xcom Posted September 13, 2015 Author Share Posted September 13, 2015 You should be able to access any lua function from your mission by commenting out the sanitizeModule functions in MissionScripting.lua It might be a completely separate environment though so you might need to load your functions again in the mission script. A good thing to have a look at would probably be DCS Witchcraft https://github.com/jboecker/dcs-witchcraft as that hooks in to the mission and uses the lua network functions --Initialization script for the Mission lua Environment (SSE) dofile('Scripts/ScriptingSystem.lua') --Sanitize Mission Scripting environment --Sanitize Mission Scripting environment --This makes unavailable some unsecure functions. --Mission downloaded from server to client may contain potentialy harmful lua code that may use these functions. --You can remove the code below and make availble these functions at your own risk. local function sanitizeModule(name) _G[name] = nil package.loaded[name] = nil end do sanitizeModule('os') sanitizeModule('io') sanitizeModule('lfs') require = nil loadlib = nil end Well, first, the Witchcraft does not get the net module. These is what I found when checking _G after working with the Witchcraft.lua: [ "log", "tostring", "gcinfo", "Unit", "mist", "os", "getfenv", "Spot", "debug", "assert", "tonumber", "coalition", "io", "env", "load", "module", "console", "Airbase", "witchcraft", "_G", "_FINAL_VERSION", "coroutine", "missionCommands", "country", "loadstring", "string", "xpcall", "package", "_VERSION", "AI", "witchcraft_log", "land", "table", "require", "setmetatable", "next", "trigger", "ipairs", "rawequal", "timer", "msg", "getmetatable", "Weapon", "witchcraft_start", "socket", "countryQty", "class", "Controller", "rawset", "Group", "print", "atmosphere", "unpack", "newproxy", "_ARCHITECTURE", "math", "pairs", "pcall", "world", "Object", "type", "radio", "SceneryObject", "select", "_ED_VERSION", "StaticObject", "rawget", "collectgarbage", "coord", "doZipFile", "setfenv", "lfs", "dofile", "error", "loadfile" ] It is probably required to load the module in someway, but I wasn't able to load it. This is basically the missing link, how to load the module into the scripting environment. I tried linking in to the main.lua, meaning to run Witchcraft from that file, but unsuccessfully. Any ideas anyone? [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook Link to comment Share on other sites More sharing options...
Grimes Posted September 13, 2015 Share Posted September 13, 2015 Use slmod to dump _G if you want to see whats in net. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
xcom Posted September 14, 2015 Author Share Posted September 14, 2015 Yes, question now is how to get the net module available from the scripting engine environment. [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook Link to comment Share on other sites More sharing options...
Ciribob Posted September 15, 2015 Share Posted September 15, 2015 (edited) Yes, question now is how to get the net module available from the scripting engine environment. I commented out all the sanitise code in MissionScripting.lua and I can now load the Lua Socket library into the mission scripting environment by using the attached udptest.lua in a DO SCRIPT as you would a normal mission script. Attached is a screenshot showing the UDP messages being received by a test program and I've attached my simple (and badly written :) ) lua code. Hope this helps!udptest.lua Edited September 15, 2015 by Ciribob Scripts: Complete Transport And Logistics Deployment - CTLD / CTLD Examples - Lots of example of how to use CTLD CSAR Script - Downed Pilot Rescue / Dedicated Server Script - Automatically launch DCS Multiplayer server at startup Range Scoring Script - Get scores and counts hits on targets for gunnery or bombs / SimpleSlotBlock - Multiplayer dynamic Slot Blocking Script Projects: DCS-SimpleRadio Standalone - DCS Radio Integration for All Aircraft - NO TeamSpeak Required! :) DCS-SimpleRadio Troubleshooting Post / DCS-SimpleRadio Free Support Channel on Discord Link to comment Share on other sites More sharing options...
xcom Posted September 15, 2015 Author Share Posted September 15, 2015 (edited) Awesome Ciribob, I'll take a look! EDIT - hmm, it does not include the net module, can you require the net module as well? such as - local net = require("net") ? this is the problem i have, even after commenting out the sanitization. Edited September 15, 2015 by xcom [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook Link to comment Share on other sites More sharing options...
Ciribob Posted September 15, 2015 Share Posted September 15, 2015 (edited) Awesome Ciribob, I'll take a look! EDIT - hmm, it does not include the net module, can you require the net module as well? such as - local net = require("net") ? this is the problem i have, even after commenting out the sanitization. Ah right sorry thats me being an idiot. I wasn't thinking and saw "net" and thought networking! I've had a look through the slmod code and main.lua, I think even if you include it, the lua environment for the mission is completely separate from the lua environment for the server and you won't be able to access the actual server lua state and variables. What you could do though is use the LUA socket library to communicate between the mission environment and server environment using UDP (or TCP!) I.e Start a UDP Listener on Port 7000 in the Mission Script Start a UDP listener on port 7001 in the Server Environment by hooking the functions on_net_Start() and on_net_stop() in Scripts/net/server.lua Use the JSON library to easily serialise and deserialise commands between the two environments and send commands using the socket library. You can then just write a simple API with the JSON messages for requesting or changing information. Edit: Just looking through SLMOD more, checkout the slmodmissionscription.lua file, it looks like thats what he's doing - Ignore most of the above as it looks like the environments aren't separate judging by the functions that SLMOD exposes. Edited September 15, 2015 by Ciribob New info Scripts: Complete Transport And Logistics Deployment - CTLD / CTLD Examples - Lots of example of how to use CTLD CSAR Script - Downed Pilot Rescue / Dedicated Server Script - Automatically launch DCS Multiplayer server at startup Range Scoring Script - Get scores and counts hits on targets for gunnery or bombs / SimpleSlotBlock - Multiplayer dynamic Slot Blocking Script Projects: DCS-SimpleRadio Standalone - DCS Radio Integration for All Aircraft - NO TeamSpeak Required! :) DCS-SimpleRadio Troubleshooting Post / DCS-SimpleRadio Free Support Channel on Discord Link to comment Share on other sites More sharing options...
xcom Posted September 15, 2015 Author Share Posted September 15, 2015 I understand what you are saying and how it should work, but I'm completly unfamiliar with the JSON library and how to create a udp/tcp listener into the server environment. But if there would be a simple framework/api that is created, it would mean a lot for mission scripting, the new available functions would open new and unexplored options. Btw in the scripts\net folder there is an api.lua file, not sure if it can be used. [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook Link to comment Share on other sites More sharing options...
Ciribob Posted September 15, 2015 Share Posted September 15, 2015 I understand what you are saying and how it should work, but I'm completly unfamiliar with the JSON library and how to create a udp/tcp listener into the server environment. But if there would be a simple framework/api that is created, it would mean a lot for mission scripting, the new available functions would open new and unexplored options. Btw in the scripts\net folder there is an api.lua file, not sure if it can be used. No worries! :) Have you looked at the mission script functions that SLMOD adds? What kind of functionality were you looking for? I might be able to mod SLMOD to add them if they're missing or make a new api if needed? I assume a good one would be to switch the mission based on a condition? Scripts: Complete Transport And Logistics Deployment - CTLD / CTLD Examples - Lots of example of how to use CTLD CSAR Script - Downed Pilot Rescue / Dedicated Server Script - Automatically launch DCS Multiplayer server at startup Range Scoring Script - Get scores and counts hits on targets for gunnery or bombs / SimpleSlotBlock - Multiplayer dynamic Slot Blocking Script Projects: DCS-SimpleRadio Standalone - DCS Radio Integration for All Aircraft - NO TeamSpeak Required! :) DCS-SimpleRadio Troubleshooting Post / DCS-SimpleRadio Free Support Channel on Discord Link to comment Share on other sites More sharing options...
xcom Posted September 15, 2015 Author Share Posted September 15, 2015 Yes, I had SLMOD installed on our server and we have decided to use a modded version of servman eventually. It is not because SLMOD isn't great, it's because servman was better on performance and working with large number of clients. Basically I wanted to use the net functions described in scripts\net\Readme.txt to create custom features such as to know when someone goes into a slot etc... Instead of working with the mission scripting environment which only let's you know stuff that is happening in the running mission. I'll have to go through the SLMOD functions again and see if any of those functions answer the requirement but basically allowing access from the scripting engine would be sufficient, afterwards we would need to map the new available and undocumented functions and tables of the server environment. [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook Link to comment Share on other sites More sharing options...
Coug4r Posted January 12, 2016 Share Posted January 12, 2016 Use slmod to dump _G if you want to see whats in net. How/where/when is this dumped? It's not a table from what i've tried with it. - If man were meant to fly he'd be filled with helium. Link to comment Share on other sites More sharing options...
Coug4r Posted January 13, 2016 Share Posted January 13, 2016 All i'm looking for is a net or server command/var that'll return the number of players. Servman used server.tblPlayersSrv i think but that doesn't return much anymore. Is there a server/net function for the # of players? - If man were meant to fly he'd be filled with helium. Link to comment Share on other sites More sharing options...
Coug4r Posted January 19, 2016 Share Posted January 19, 2016 BUMP?! - If man were meant to fly he'd be filled with helium. Link to comment Share on other sites More sharing options...
ajax Posted January 19, 2016 Share Posted January 19, 2016 There is a new gameGUI API that describes the new functions. Unfortunately, I don't remember where in the DCS file structure it is located. Link to comment Share on other sites More sharing options...
Pikey Posted January 19, 2016 Share Posted January 19, 2016 In the .\DCS World\API\ folder. ___________________________________________________________________________ SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING * Link to comment Share on other sites More sharing options...
stinkx Posted January 19, 2016 Share Posted January 19, 2016 Check out ...\DCS World OpenBeta\MissionEditor\GameGUI.lua Link to comment Share on other sites More sharing options...
Coug4r Posted January 20, 2016 Share Posted January 20, 2016 Interesting! Thank you! - If man were meant to fly he'd be filled with helium. Link to comment Share on other sites More sharing options...
Recommended Posts