Pikey Posted January 15, 2016 Posted January 15, 2016 Hi guys, I was gonna PM a few of you but better to just fire it out there. Ciribob got me thinking when he said about checking the new API from ED, then today the patch notes came up with an edit to the DCS_ControlAPI.txt regarding the net.X functions. Now to the problem, there used to be a way of slot blocking in MP by just destroying the unit. But this didn't work after 1.5. This broke two things I loved: Blue Flag and Ciribobs CSAR script. I can't script LUA, can anyone that can see if we can fix these scripts by testing slot blocking using say this: net.force_player_slot(playerID, sideID, slotID) -> boolean Forces a player to occupy a set slot. Slot '' means no slot (moves player to spectators) SideID: 0 - spectators, 1 - red, 2 - blue rather than the older _unit:destroy() which no longer works? Ta ___________________________________________________________________________ SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *
Grimes Posted January 16, 2016 Posted January 16, 2016 To answer the title of the thread, no it does not but it possibly could. Object.destroy is bugged for clients, and Ciribob has reported it to the relevant dev. These API functions are only available as a server side mod. For instance slmod uses several of them to get information on the mission and server admin purposes. So you'd need a local mission script to be able to communicate with the server side mod to run these functions. 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
Ciribob Posted January 16, 2016 Posted January 16, 2016 Okay, cleared my old incorrect posts. This now works!!! I added the script below in file I created in C:/Users/<USERNAME>/Saved Games/DCS/Scripts/debugGameGUI.lua The trick is, the documentation is incorrect... the dostring_in needs to be executed in the server enviroment, not the mission environment. :thumbup: local debugTest = {} net.log("testing net") debugTest.onPlayerTrySendChat = function(playerID, msg, all) net.log("chat: 1 "..msg) local _status,_error = net.dostring_in('server', " trigger.action.setUserFlag(1,5); return 5; ") if (not _status) and _error then net.log("status 1: ".._error) elseif _status then net.log("status 1: ".._status) end _status,_error = net.dostring_in('server', " return trigger.misc.getUserFlag(1); ") if not _status and _error then net.log("status 2: ".._error) elseif _status then net.log("status 2: ".._status) end net.log("done chat 2") return msg end DCS.setUserCallbacks(debugTest) net.log("callbacks loaded") Start a server after setting up the script file and then type a chat message. In the DCS logs you'll see that the flag now has the correct value, showing interaction between the server environment and mission environment. With this, its then possible in theory to do slot blocking and dynamic enabling and disabling of slots which i'll have a look at next. Very happy! :D 1 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
xcom Posted January 16, 2016 Posted January 16, 2016 Oh gawd, great Ciribob! This will possibly let us more forward again with Blue Flag! Ciribob, I gotta say, from the whole time I'm here, you have shown up only recently, but the time you have been here has helped us scripting guys and mission designers tremendously. Appriciate all your hard work, your scripts, assistance and commitment! Thank you. [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook
Ciribob Posted January 16, 2016 Posted January 16, 2016 Oh gawd, great Ciribob! This will possibly let us more forward again with Blue Flag! Ciribob, I gotta say, from the whole time I'm here, you have shown up only recently, but the time you have been here has helped us scripting guys and mission designers tremendously. Appriciate all your hard work, your scripts, assistance and commitment! Thank you. No worries :) Was about to send you a PM actually, should hopefully have a proof of concept running tonight that you can just fill in a few bits of code in and it should work for Blue Flag... but we'll see! 1 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
xcom Posted January 16, 2016 Posted January 16, 2016 Great stuff! I'll start checking out what you did in that previous snippet meanwhile. [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook
Pikey Posted January 16, 2016 Author Posted January 16, 2016 Ah, I feel like a scripting dating agency, everything I wanted to accomplish in the thread actually happened, with the people I wanted it to :) Let's hope you can make a baby wsith this API and get slot management nailed. ___________________________________________________________________________ SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *
xcom Posted January 16, 2016 Posted January 16, 2016 two more and you got a room in heaven. I'd change nickname from Mule to Cupid ;) [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook
Ciribob Posted January 16, 2016 Posted January 16, 2016 (edited) LOL Pikey :D Got something working... Put slotBlockGameGUI.lua in C:Users<YOUR USERNAME>Saved GamesDCSScripts or C:Users<YOUR USERNAME>Saved GamesDCS.openalphaScripts if its Nevada. In the mission script, flags will now control which aircraft is currently disabled or enabled, but you will have to host a mission to test. When a slot is disabled and a user tries to join, a chat message will be shown telling them that the slot is disabled which only they can see. This isn't the best solution as you have to find out all the unit ids (listed in the mission file as well), but my better method didnt work.... :( The flag number is the same as the unit id of the unit in a certain slot. For example: trigger.action.setUserFlag(1,1); would disable the slot of the unit with an ID of 1 trigger.action.setUserFlag(1,0); would enable it again I've also attached an example mission with an F10 radio command . You can use that to disable a slot. Demo video as well: EDIT: Forgot to add, if you dont switch slots but the aircraft is disabled while you're flying. You'll be kicked out of it for any of these events - but this can easily be modified :) : --"friendly_fire" --"kill" --"self_kill" --"change_slot" --"crash" --"eject", --"takeoff" --"landing --"pilot_death" Xcom, for Blue Flag I assumed you'd limit to pilot_death, crash and eject which'll stop you respawning in the now disabled aircraftdebug.mizslotBlockGameGUI.lua Edited January 16, 2016 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
xcom Posted January 16, 2016 Posted January 16, 2016 Hey Ciribob, thanks. I've been also working on creating something, basically what I need now is to get a table that is handled in the mission scripting environment to be working on the server environment and to update each time a player changes slot (so we know if to throw him out of the slot). So, I did this - local BFslots = {} local _PAKInfo = {} net.log("testing net") BFslots.onPlayerChangeSlot = function(id) net.log("Player Changed ID - "..id) _PAKInfo,_error = net.dostring_in('server', "return PAKInfo; ") if (not _PAKInfo) and _error then net.log("error: ".._error) elseif _PAKInfo then net.log("PAKInfo retrieved to _PAKInfo") end --[[local abtest = '' for pakNum,pakT in ipairs(_PAKInfo) do if type(pakT)=="table" then for ABName,ABTable in pairs(pakT) do abtest = abtest..','..ABName end end end--]] net.log(_PAKInfo) --net.force_player_slot(id, 0, '') end DCS.setUserCallbacks(BFslots) net.log("callbacks loaded") PAKInfo is the table I would like to import from the scripting engine environment. It does seem to work with the log showing - 00281.606 INFO LuaNET: Player Changed ID - 2 00281.606 INFO LuaNET: PAKInfo retrieved to _PAKInfo 00281.606 INFO LuaNET: The 3rd log was supposed to show the _PAKInfo table, but it shows an empty string. Any idea if return PAKInfo; would actually return the table? is there another way you can think of that might import the table? Thanks! [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook
Ciribob Posted January 16, 2016 Posted January 16, 2016 (edited) PAKInfo is the table I would like to import from the scripting engine environment. It does seem to work with the log showing - 00281.606 INFO LuaNET: Player Changed ID - 2 00281.606 INFO LuaNET: PAKInfo retrieved to _PAKInfo 00281.606 INFO LuaNET: The 3rd log was supposed to show the _PAKInfo table, but it shows an empty string. Any idea if return PAKInfo; would actually return the table? is there another way you can think of that might import the table? Thanks! Thats exactly what I spend an hour or so trying to do... :( As far as I can tell you can't actually access any mission editor variables, only standard mission editor functions like flags. This is the version I wrote with something similar to your code but you'll see that any global variables you reference in the code that gets executed in the "server" environment will be nil so it doesnt work. This is the code I had in the mission and "ssb" should have been accessible to the other script. ssb = {} function ssb.chatMessage(_playerName,_message) trigger.action.outText(_message.." ".._playerName , 3,false) return _message end function ssb.shouldAllowSlot(_playerName,_unitId) env.info("shouldAllow: ".._playerName.." ".._unitId) return {allow=true, message=""} end slotBlockGameGUI_scriptversion.lua Edited January 16, 2016 by Ciribob added more text 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
stinkx Posted January 19, 2016 Posted January 19, 2016 i wonder if dofile works within the API environment. that way you can store lives of pilots in a file as a table in the scripting environment and then call it from the API environment.
xcom Posted January 19, 2016 Posted January 19, 2016 (edited) That's what we already do for Blue Flag. Edited May 7, 2016 by xcom 1 [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook
stinkx Posted January 19, 2016 Posted January 19, 2016 thanks for the fast reply. it seems that im a few days behind you guys :) btw check your pm xcom
xcom Posted January 19, 2016 Posted January 19, 2016 replied, I think the first reply was only sent to Ciribob by mistake. [sIGPIC][/sIGPIC] BuddySpike Website | Live Map & Statistics BuddySpike Twitch Channel Buddyspike Discord Buddyspike Facebook
Pikey Posted January 19, 2016 Author Posted January 19, 2016 Hi Xcom, so for stupid people like me, can I just check, in order to use the new API functions, where is the crossover exactly? I know Ciribob says you can share flags because they are global, can we refer to global variables made in the BlahgameGUI.lua? Can mission editor run script refer to functions in the blaggamegui.lua? All I think I know is that we cannot call the functions of the API directly in missions scripts. Assuming this is the gamegui.lua file here, so you could load your pakinfo table (list of owned airports etc?) into this file for referencing...is that the missing link? I've an amateur programming head at best so excuse me missing the eureka moment exactly, I'm looking to see if there are other ways we can exploit the API and the methods we need to do that with (with smarter folk than me!). Mike ___________________________________________________________________________ SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *
Coug4r Posted March 29, 2016 Posted March 29, 2016 Some more functions and events would be nice for the gamegui.lua, my mission could really use a base captured event and some method to get the coalition of an airbase so i would be able to save the captured state of an airbase. Crashes occur, it's pretty frustrating for players when the mission completely resets to it's initial state. - If man were meant to fly he'd be filled with helium.
Tyrannik Posted June 29, 2016 Posted June 29, 2016 Would anyone be able to release a simple version of the slot blocking script used in Blue Flag? It would be exceptionally useful for anyone in the community needing a similar script. I tried using Ciribob's solution using the unitIDs but I have no idea how to say, get the unit IDs of at a certain airfield. I tried to manually look for the UnitIDs in the mission file the .miz, but sadly the units are not given the same names as you assign them in the editor. I myself am not well versed in lua currently so I'm having a lot of trouble finding a solution. Any help would be appreciated, thanks in advance!
Pikey Posted September 2, 2016 Author Posted September 2, 2016 So... does it died? Has what died? The API? nope. ___________________________________________________________________________ SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *
Recommended Posts