Snake323CO Posted September 5, 2015 Share Posted September 5, 2015 Hi: I was wondering if the multiplayer respawn function stopped working. I had it working about a year or so ago, but as of today, it's no longer working. I have two triggers set up...the first one fires off at mission start to load Mist3.3. The second one fires when a group dies. I have 1 F-15 group called 'F-15 Group01'. When it dies it should fire off the lua script I have for respawning. The contents are below: if not Group.getByName('F-15 Group01') then mist.respawnGroup('F-15 Group01', true) end This used to work....any ides why it doesn't any longer? And yes, I am testing this in multiplayer. Thanks for any help. -Snake Link to comment Share on other sites More sharing options...
Grimes Posted September 5, 2015 Share Posted September 5, 2015 The mist function still works, the problem lies with Group.getByName() always returning a group, even if its dead. A simple function will work around the issue and still work once the bug gets fixed. local function groupIsDead(groupName) -- a certain bug hasn't been fixed, so I have to use this instead. if (Group.getByName(groupName) and Group.getByName(groupName):isExist() == false) or (Group.getByName(groupName) and #Group.getByName(groupName):getUnits() < 1) or not Group.getByName(groupName) then return true end return false end if groupIsDead('F-15 Group01') == true then mist.respawnGroup('F-15 Group01', true) end 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...
Snake323CO Posted September 5, 2015 Author Share Posted September 5, 2015 Grimes...thanks for the help. I used that code you gave me as is, and it didn't work. I noticed that the first 'IF' param repeats itself, where as the 2nd param has a # before Group.getByName, so I added it to the first param. I tested it and still no go. I then replaced all the (groupName) with ('F-15 Group01'), and still no go. What am I missing??? I am running this in multiplayer, and there is only 1 aircraft (F-15 Group01). The 1st trigger are loading Mist3.3 at Mission Start, and the 2nd trigger is set up as: TYPE: Once, CONDITIONS:Group Dead (F-15 Group01), ACTIONS: Do Script File Link to comment Share on other sites More sharing options...
Grimes Posted September 5, 2015 Share Posted September 5, 2015 Try an updated version of mist, it is up to 3.7. You can find it in my signature. I noticed that the first 'IF' param repeats itself, where as the 2nd param has a # before Group.getByName, so I added it to the first param. It is by design. When # is used in front of a table that is indexed numerically it returns the size of the table. So this: Group.getByName(groupName) and #Group.getByName(groupName):getUnits() < 1 is the same as "if the group is returned and the size of the group is less than 1, then the group is dead." 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...
Snake323CO Posted September 7, 2015 Author Share Posted September 7, 2015 Hey Grimes: Sorry for being such a PITA. However I'm still having a respawn issue. I have determined that the original trigger, which had a condition of Group Dead, is not working. The Action would never run. I changed the Condition to Unit Dead, and now the Action is running. Now when I crash my aircraft into the water, I get the beginning of the 'water splash' cut scene, and then the sim freezes. A dialogue window pops up stating: Mission Script Error [string "C:\users\JD\AppData\Local\Temp\DCS\/~mis00004622"]:1:<name> or '...' expected near "F-15 Group01" I get this error when I replace all occurrences of (groupName) with ('F-15 Group01') Any ideas? And again...Thanks for all the help!!! Link to comment Share on other sites More sharing options...
Grimes Posted September 7, 2015 Share Posted September 7, 2015 Uh, I never said to modify the function itself. And I miss-read your first reply and didn't realize you had edited the function. So try this. Create a trigger Mission Start> Time Less than 10> Do Script. Copy the following code into that do script box and don't change anything. function groupIsDead(groupName) if (Group.getByName(groupName) and Group.getByName(groupName):isExist() == false) or (Group.getByName(groupName) and #Group.getByName(groupName):getUnits() < 1) or not Group.getByName(groupName) then return true end return false end Remove any other use of that above code from your mission. Now, anywhere that you had if not Group.getByName('F-15 Group01') then replace that line with if groupIsDead('F-15 Group01') == true then And change the name accordingly. DON'T edit that first box. It is a function where groupName is anything that gets passed to the function. 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...
Snake323CO Posted September 8, 2015 Author Share Posted September 8, 2015 Hey Grimes: Sorry for the misunderstanding. Being an 'old' VB coder, I'm used to getting code snippets that are generic in nature, and then having to tweak them for my specific situation. I'm not used to getting code that's ready to go out the gate. VERY NICE!!!! I saw groupName, and instictively shoved in the 'group name'. Sorry about that!!! OK....I added the code, as is, per your instructions, but I'm still getting a script error. What appears to be happening is, MIST isn't loading. Here's the scenerio; 1st trigger: TYPE: Mission Start, CONDITIONS: Time More Than 1, ACTIONS: Do Script File - mistv3_7_51.lua 2nd trigger: TYPE: Mission Start, CONDITIONS: Time Less Than 10, ACTIONS: Do Script - function groupIsDead (as is) 3rd trigger: TYPE: Once, CONDITIONS: Unit Dead, ACTIONS: Do Script - if groupIsDead('F-15 Group01') == true then mist.respawnGroup('F-15 Group01', true) end I fly this, crash the aircraft, and get the following script error. [string "C:\users\jd\AppData\Loacal\Temp\DCS\/~mis00001A4A"]:1: attempt to call global 'groupIsDead' (a nil value) stack traceback: [C]:in function 'grouIsDead' [string "C:\users\jd\AppData\Loacal\Temp\DCS\/~mis00001A4A"]:1: in mainchunk So then, for sh*ts and giggles, I removed the 1st trigger, which loads MIST, and flew it again. Low and behold, I get the same error. It's acting like MIST isn't loading, and causing the script error. Link to comment Share on other sites More sharing options...
Grimes Posted September 8, 2015 Share Posted September 8, 2015 Mission start occurs exactly when you unpause the mission, the time that it occurs at is exactly 0, therefore mist won't load with that setup. Change the condition to be like the 2nd trigger condition. But groupIsDead is not a mist function, its completely separate and it isn't loading. You could just switch it back to what I originally suggested by declaring the function each time it checks if the group is dead. It is a little less efficient but its not like its some massive block of code, so there won't be an impact. 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...
Snake323CO Posted September 8, 2015 Author Share Posted September 8, 2015 (edited) Got it pal. THANKS so much for ALL the help!!!!!!!!!!!!!!!!! YOU DA MAN!!!! Off topic, but is there a way to get the HUD only view, with ONLY the HUD?? Without the map and VSD? Edited September 9, 2015 by Snake323CO Link to comment Share on other sites More sharing options...
shagrat Posted November 14, 2016 Share Posted November 14, 2016 Hello Grimes I need some help with this script snippet. :helpsmilie: I tried to move your example to a separate file and integrate it with an EventHandler that works pretty well with the S_EVENT_HIT, already. The implementation of the snippet described in this thread in the ME window with a single GroupName works as well. Now when I add the second event condition (S_EVENT_DEAD) to my script and try to iterate through a list of Groups, it wont respawn the group anymore. I suspect the For loop or the table to be the culprit, but I can't figure out what I'm doing wrong, here. I've attached the complete script, as it isn't very complex. Any help is highly appreciated. function groupIsDead(groupName) if (Group.getByName(groupName) and Group.getByName(groupName):isExist() == false) or (Group.getByName(groupName) and #Group.getByName(groupName):getUnits() < 1) or not Group.getByName(groupName) then return true end return false end CollHandler = {} function CollHandler:onEvent(event) local tgt = event.target local init = event.initiator if event.id == world.event.S_EVENT_HIT then if tgt then if tgt:getCountry()==16 and init:getCoalition()==2 then --Georgia trigger.action.outText("Don't shoot at civilians!", 10, true) end end elseif event.id == world.event.S_EVENT_DEAD then --if a unit dies, check if the group is still alive local t = {'CIV_Traffic1', 'CIV_Traffic2', 'CIV_Traffic3', 'CIV_Traffic4'} --Civilian vehicles (one per group) to monitor for k, v in pairs(t) do -- iterate through the groups in table t if groupIsDead(k) == true then mist.respawnGroup(k, true) end end end end world.addEventHandler(CollHandler) Shagrat - Flying Sims since 1984 - Win 10 | i5 10600K@4.1GHz | 64GB | GeForce RTX 3090 - Asus VG34VQL1B | TrackIR5 | Simshaker & Jetseat | VPForce Rhino Base & VIRPIL T50 CM2 Stick on 200mm curved extension | VIRPIL T50 CM2 Throttle | VPC Rotor TCS Plus/Apache64 Grip | MFG Crosswind Rudder Pedals | WW Top Gun MIP | a hand made AHCP | 2x Elgato StreamDeck (Buttons galore) Link to comment Share on other sites More sharing options...
Whisper Posted November 14, 2016 Share Posted November 14, 2016 No doc ag hand, but is there both target and initiator for a dead event? Whisper of old OFP & C6 forums, now Kalbuth. Specs : i7 6700K / MSI 1070 / 32G RAM / SSD / Rift S / Virpil MongooseT50 / Virpil T50 CM2 Throttle / MFG Crosswind. All but Viggen, Yak52 & F16 Link to comment Share on other sites More sharing options...
shagrat Posted November 14, 2016 Share Posted November 14, 2016 No, but that is for the S_EVENT_HIT to check for blue on blue. The S_EVENT_DEAD doesn't use initiator or target for anything. I simply monitor the event, so if any unit is dead, the for-loop checks all group names in the table "t" if they are still alive. If not, it should respawn the unit with its task (mist.respawnGroup(_the name from the table_, true). Shagrat - Flying Sims since 1984 - Win 10 | i5 10600K@4.1GHz | 64GB | GeForce RTX 3090 - Asus VG34VQL1B | TrackIR5 | Simshaker & Jetseat | VPForce Rhino Base & VIRPIL T50 CM2 Stick on 200mm curved extension | VIRPIL T50 CM2 Throttle | VPC Rotor TCS Plus/Apache64 Grip | MFG Crosswind Rudder Pedals | WW Top Gun MIP | a hand made AHCP | 2x Elgato StreamDeck (Buttons galore) Link to comment Share on other sites More sharing options...
Whisper Posted November 14, 2016 Share Posted November 14, 2016 No, but that is for the S_EVENT_HIT to check for blue on blue. The S_EVENT_DEAD doesn't use initiator or target for anything. I simply monitor the event, so if any unit is dead, the for-loop checks all group names in the table "t" if they are still alive. If not, it should respawn the unit with its task (mist.respawnGroup(_the name from the table_, true). That's the point. I'm not sure the S_EVENT_DEAD even has a "initiator" value. So you're perhaps setting init to an unexisting value. I'd suggest to move local tgt = event.target local init = event.initiatorinto the specific S_EVENT_HIT part : function groupIsDead(groupName) if (Group.getByName(groupName) and Group.getByName(groupName):isExist() == false) or (Group.getByName(groupName) and #Group.getByName(groupName):getUnits() < 1) or not Group.getByName(groupName) then return true end return false end CollHandler = {} function CollHandler:onEvent(event) if event.id == world.event.S_EVENT_HIT then local tgt = event.target local init = event.initiator if tgt then if tgt:getCountry()==16 and init:getCoalition()==2 then --Georgia trigger.action.outText("Don't shoot at civilians!", 10, true) end end elseif event.id == world.event.S_EVENT_DEAD then --if a unit dies, check if the group is still alive local t = {'CIV_Traffic1', 'CIV_Traffic2', 'CIV_Traffic3', 'CIV_Traffic4'} --Civilian vehicles (one per group) to monitor for k, v in pairs(t) do -- iterate through the groups in table t if groupIsDead(k) == true then mist.respawnGroup(k, true) end end end end world.addEventHandler(CollHandler) Whisper of old OFP & C6 forums, now Kalbuth. Specs : i7 6700K / MSI 1070 / 32G RAM / SSD / Rift S / Virpil MongooseT50 / Virpil T50 CM2 Throttle / MFG Crosswind. All but Viggen, Yak52 & F16 Link to comment Share on other sites More sharing options...
shagrat Posted November 14, 2016 Share Posted November 14, 2016 Hmm, good point, if it has to handle an invalid value there, it might never get to the S_EVENT_DEAD part. I'll try and report back... Shagrat - Flying Sims since 1984 - Win 10 | i5 10600K@4.1GHz | 64GB | GeForce RTX 3090 - Asus VG34VQL1B | TrackIR5 | Simshaker & Jetseat | VPForce Rhino Base & VIRPIL T50 CM2 Stick on 200mm curved extension | VIRPIL T50 CM2 Throttle | VPC Rotor TCS Plus/Apache64 Grip | MFG Crosswind Rudder Pedals | WW Top Gun MIP | a hand made AHCP | 2x Elgato StreamDeck (Buttons galore) Link to comment Share on other sites More sharing options...
Recommended Posts