Jump to content

SWAPR - SWeet Automatic Player Replacement script


Hardcard

Recommended Posts

Hey @Hardcard, been putting together a multiplayer mission but I am having some issues with SWAPR. The static units spawn correctly, but do not despawn when a player fills the slot. Any ideas of what could be causing this? Works fine in singleplayer with "SP" selected. I have attached the mission file, the hook lua, and a screenshot of the incident. Thank you!

Screen_210603_162014.png

20210606_June_Campaign.miz SWAPR_1_4_Server_Hook.lua


Edited by Cyclops
Link to comment
Share on other sites

@Cyclops

 

Your server hook is using an incorrect suffix ( "_client" instead of "_Client" ), that's probably why it isn't working, remember that Lua is case sensitive. 

 

Also, I'd remove all the dashes from your client group / unit names in the mission, since they might cause problems, use underscores instead. 

 


Edited by Hardcard
Link to comment
Share on other sites

@Hardcard

 

Hey man! First, thanks for the super sweet mod! My buddies and I are trying to get this script to work but we are having an issue with the static/client planes disappearing after 3 minutes. Wondering if you or anyone else has encountered this problem. 

 

Thanks,

Spins

Link to comment
Share on other sites

@Spins321

Thanks.

Could you also attach the dcs.log that was running when you encountered the issue?

Also, if you were running the mission in MP, I'll need the server hook as well.

Additionally, if the mission is using mods, please remove any modded units/objects, so I'm not required to install them.
 


Edited by Hardcard
Link to comment
Share on other sites

@Spins321
Ok, we're talking about the replacements at Kobuleti, right?

 

I can confirm that AI replacements are removed after ~3 minutes, fortunately, this issue doesn't seem to affect static replacements.

 

Until I find the culprit, I recommend that you set Replacement_Type to "Static".

(Keep in mind that tomcat static models are bugged since the introduction of 2.7, this is a known DCS bug and has already been reported. It has nothing to do with SWAPR)

 

Also, I noticed that your SWAPR script is using several client suffixes that aren't present in the mission.

Your clients at Kobuleti only use "_client", so your SWAPR_Prefixes table should look like this: 

local SWAPR_Prefixes = { "_client" } 

 

 

Finally, a 10 second delay for the SWAPR script trigger might be a bit overkill 😉 

Link to comment
Share on other sites

On 6/4/2021 at 6:51 PM, Hardcard said:

@Cyclops

 

Your server hook is using an incorrect suffix ( "_client" instead of "_Client" ), that's probably why it isn't working, remember that Lua is case sensitive. 

 

Also, I'd remove all the dashes from your client group / unit names in the mission, since they might cause problems, use underscores instead. 

 

 

Forgot to respond to this, thank you @Hardcard this fixed it!

  • Like 1
Link to comment
Share on other sites

  • 2 weeks later...

Hello Hardcard.

First I would like to thank you for the work you put in this scripting.

 

I have installed the script on my dedicated server , but I ran into a small problem :

 

The SWAPR script starts normally and spawns all available aircraft as a static model.

I (or another player) joins the server and selects a aircraft.

The aircraft I (or any other player) spawn in spawns normally BUT the static aircraft does NOT despawn.

 

For ease of log reading :

First occurance : 2021-06-29 22:08:51.613

Second occurance : 2021-06-29 22:11:02.867

My testing : 2021-06-30 07:31:27.381

 

During testing I also noticed that sheltered clients are not replaced bij statics even though my lua settings should be correct for sheltered replacements

 

I have tried to check the logs but could not find any obvious errors.

SWAPR Report.zip


Edited by Erikson
Link to comment
Share on other sites

@Erikson

 

Thanks for including all the required files in the report 👍 

 

(Take note, guys, this is how you make a report 😁)

 


The SWAPR_1_4.lua inside your mission file is set to "SP", so if you run the script like that in a multiplayer environment, replacement removal won't work. 

 

The reason why I had to create separate "SP" and "MP" modes is because DCS events needed for the removal of replacements don't work in MP, only in SP. 

"MP" mode relies on server code (included in the server hook) for replacement removal instead.

 

I tested your mission with the game mode set to "MP" and it works fine, but keep in mind that I don't have access to a dedicated server, so this isn't 100% conclusive.

 

 

As for sheltered clients being replaced by AI instead of statics, this is intended, since statics used to spawn on top of shelters instead of in them when I created the script.

I think that ED recently fixed this particular issue, so I might modify SWAPR to allow static spawning in sheltered spots again, we'll see. 

 

 

As for AI replacements being removed from the map after ~3 minutes, it might be a relatively new DCS cleanup routine that didn't exist before. 

I might end up ditching AI replacements and using statics exclusively... but it's risky, since there's a good chance statics will get bugged again in the future. 😭 

Link to comment
Share on other sites

Hi Hardcard.

Thanks for the help.

 

I didn't know the actual swapr script would get encoded into the mission file.

I thought it would just refer to the script (location) so I left the script in SP mode on my play machine thinking it would work on the server in the same way.

 

I have now updated my play machine to a MP setting so I can edit missions for the server.

 

Thanks again.

Link to comment
Share on other sites

5 hours ago, Erikson said:

I didn't know the actual swapr script would get encoded into the mission file.

 

When you load a file in Mission Editor, DCS makes a copy of it, which is saved in the miz file.

You need to reload the file every time you make changes to it, otherwise these changes won't apply. 

 

There's also the possibility of loading scripts dynamically, which allows you to modify script files without having to reload them every time. 

 

Here, Pikey made a nice tutorial about it: 

 

Link to comment
Share on other sites

  • 3 weeks later...

Is this updated for Marianas?

 1A100.png?format=1500w  

Virtual CVW-8 - The mission of Virtual Carrier Air Wing EIGHT is to provide its members with an organization committed to presenting an authentic representation of U.S. Navy Carrier Air Wing operations in training and combat environments based on the real world experience of its real fighter pilots, air intercept controllers, airbosses, and many others.

 

Link to comment
Share on other sites

Hi, I just updated my swapr script to 1.4 and now I'm having a problem. I'm getting replacement units displayed for both coalitions no matter which coalition owns the airfield, so it seems the capture logic isn't working.

 

Attached a simple mission (in SP mode), with sawpr units for red and blue. A ground blue unit is inside airfield capture zone so airfield is Blue, but I'm getting swapr units for red and blue displayed anyways. The same thing is happening in more complex missions since I updated to 1.4.

 

 

SWAPR_1_4_Server_Hook.lua SWAPR_v1_4.lua swapr_test(SWAPR_1_4).miz dcs.log


Edited by pacastro
Link to comment
Share on other sites

@pacastro

 

Capture logic was only implemented in an experimental 1.3 version, 1.4 doesn't support it. 

 

The reason being that DCS automatically removes airbase replacements and prevents them from spawning upon capture (at least sometimes). 
It was a mess, so I removed the related code. 


Edited by Hardcard
Link to comment
Share on other sites

Hey Hardcard, 

 

First, great job with this product!  Really brings the airfield alive!

I do have a quick question for you, have you noticed or had any reports of glitches with using SWAPR with objects spawned using the "Takeoff From Ground" option, where the objects are spawned in a (as they should), but are hovering about a foot or so above the ground?

 

Just wanted to know if it is already a known issue (... and if it's being worked on...) before I go through the work of stripping my mission of addons and uploading it here...

 

Once again... thanks again for this awesome script!

 

-Jimi

Link to comment
Share on other sites

On 8/1/2021 at 1:36 PM, Jimi08 said:

objects spawned using the "Takeoff From Ground" option, where the objects are spawned in a (as they should), but are hovering about a foot or so above the ground?

 

Just wanted to know if it is already a known issue (... and if it's being worked on...) before I go through the work of stripping my mission of addons and uploading it here...

 

Sounds like a new issue, but, tbh, I don't think I can do anything about it, script wise. 

 

DCS spawning has been screwed for a long time and looks like they're finding new ways of screwing it with every new build 🤣

Link to comment
Share on other sites

13 hours ago, Hardcard said:

 

Sounds like a new issue, but, tbh, I don't think I can do anything about it, script wise. 

 

DCS spawning has been screwed for a long time and looks like they're finding new ways of screwing it with every new build 🤣

Figured as much, but I figured I'd ask anyways.  Thanks.

Link to comment
Share on other sites

  • Recently Browsing   1 member

×
×
  • Create New...