Jump to content

DCS-SimpleSlotBlock - Multiplayer Slot Blocking Script


Recommended Posts

  • 1 month later...
  • Replies 110
  • Created
  • Last Reply

Top Posters In This Topic

Okay so I haven't tested this out yet, but as I understand the code you quoted, its only looking at the Base Captured flag, and if its the right value, will block any clients from joining any slot in the mission.

 

If I want to block a specific slot based on the Base Captured, I need to also grab the slotID and check if it should be blocked? Then I could set the SSB flag value at the same point that the client gets kicked?

 

 

 

@remus77

 

 

Here's the idea (required fields marked in red, do not remove any quotation marks):

 

local Callback_Table = {} [color=blue]-- A callback table is required for the script to work[/color]

function Callback_Table.onGameEvent(eventName, playerID, slotID)  [color=blue]-- This function will be called every time a server event happens[/color]
        
        if eventName == "change_slot" and slotID ~= nil and slotID ~= '' and playerID ~= nil then [color=blue]-- Check whether a player has changed slot, check whether it's a spectator slot, also, check for nil values[/color]
           
           if net.dostring_in('server', " return trigger.misc.getUserFlag(\"[color=Red]Flag name[/color]\"); ") ~= nil then 
              
              local CaptureFlag = net.dostring_in('server', " return trigger.misc.getUserFlag(\"[color=Red]Flag name[/color]\"); ") [color=blue]-- Makes the server return the value of a mission environment flag[/color]
           
              if CaptureFlag == "[color=Red]Flag value when base is captured[/color]" then [color=Blue]-- Checks whether the flag has the "base captured" value[/color]
              
                 local Player_List = net.get_player_list()
              
                 for PlayerIDIndex, playerId in pairs( Player_List ) do
                  
                     local Player_Info = net.get_player_info( playerId )
                     
                     if Player_Info.slot == slotID and playerID == playerId then
                     
                        net.force_player_slot(playerId, 0, '') [color=Blue]-- This forces the player attempting to enter the blocked slot back to spectators[/color]
                     
                        net.send_chat_to(Unit_Name.." DISABLED!", playerId)
                        net.send_chat_to("CHOOSE ANOTHER SLOT!", playerId)
                     end
                 end
              end
           end   
        end
end


DCS.setUserCallbacks(Callback_Table )

Btw, this dedicated server script must be placed in C:\Users\Your Username\Saved Games\DCS.openbeta\Scripts\Hooks

Link to comment
Share on other sites

@alt.sanity

 

Personally, I'd build a table including the names of all the slot units that should be blocked depending on base flag value.

 

For instance, imagine that we have 3 bases, each with 6 units (3 blue and 3 red) + its own flag (which changes value depending on the controlling coalition).

 

We can set up a table listing all the base slot units from the opposite coalition that should be blocked in each case, then set up the logic.

 

Something like this (required fields marked in red ... also, keep in mind that I haven't tested it) :


local Callback_Table = {}

local Block_List = { 
                    ["Value of Base_1_Flag when blue"] = { ["Red_unit_1"] = true , ["Red_unit_2"] = true, ["Red_unit_3"] = true } ,
                    ["Value of Base_2_Flag when blue"] = { ["Red_unit_1"] = true , ["Red_unit_2"] = true, ["Red_unit_3"] = true } ,
                    ["Value of Base_3_Flag when blue"] = { ["Red_unit_1"] = true , ["Red_unit_2"] = true, ["Red_unit_3"] = true } ,
                    
                    ["Value of Base_1_Flag when red"] = { ["Blue_unit_1"] = true , ["Blue_unit_2"] = true, ["Blue_unit_3"] = true } ,
                    ["Value of Base_2_Flag when red"] = { ["Blue_unit_1"] = true , ["Blue_unit_2"] = true, ["Blue_unit_3"] = true } ,
                    ["Value of Base_3_Flag when red"] = { ["Blue_unit_1"] = true , ["Blue_unit_2"] = true, ["Blue_unit_3"] = true } ,
                   }

function Callback_Table.onGameEvent(eventName, playerID, slotID)
        
  if eventName == "change_slot" and slotID ~= nil and slotID ~= '' and playerID ~= nil then    

    Slot_Unit_Name = DCS.getUnitProperty(slotID, DCS.UNIT_NAME) -- This returns the name of the unit in the selected slot

     local Base_1_Flag = tostring( net.dostring_in('server', " return trigger.misc.getUserFlag(\"Base 1 flag name\"); ") )
     local Base_2_Flag = tostring( net.dostring_in('server', " return trigger.misc.getUserFlag(\"Base 2 flag name\"); ") )
     local Base_3_Flag = tostring( net.dostring_in('server', " return trigger.misc.getUserFlag(\"Base 3 flag name\"); ") )              
  
     Block_Slot = false -- By default, the block marker is disabled           
     
     if Block_List[Base_1_Flag][Slot_Unit_Name] ~= nil or Block_List[Base_2_Flag][Slot_Unit_Name] ~= nil or Block_List[Base_3_Flag][Slot_Unit_Name] ~= nil then
        
        Block_Slot = true -- Whatever the base and flag values are, if the selected slot unit name is found in the relevant subtable, the block marker for that slot will be enabled
     end
     
     local Player_List = net.get_player_list()
                    
     for i, playerId in pairs( Player_List ) do
            
         local Player_Info = net.get_player_info( playerId )
         
         if Player_Info.slot == slotID and playerID == playerId and Block_Slot then
         
            net.force_player_slot(playerId, 0, '') -- This forces the player attempting to enter the blocked slot back to spectators
         
            net.send_chat_to(Slot_Unit_Name.." DISABLED!", playerId)
            net.send_chat_to("CHOOSE ANOTHER SLOT!", playerId)
         end
     end                 
  end
end           

DCS.setUserCallbacks(Callback_Table) 
 

Edited by Hardcard
Link to comment
Share on other sites

  • 2 weeks later...

Noob question here... if i set "ssb.enabledFlagValue = 2", does that mean a flag value of 0 or 1 will enable a slot?

 

I'd like to lock a slot based on an increase in flag values if they cross a certain threshold... without making a send trigger if possible.


Edited by Banzaiib
Link to comment
Share on other sites

  • 4 weeks later...
Anyone else having issues with this working since 2.5.6?

 

I've had an issue for a few months now where the script blocks fine at MP mission start, but once I unblock dynamically during the course of the mission, the newly unblocked planes need to be selected twice before it will allow me to spawn into them.

Link to comment
Share on other sites

  • 2 weeks later...
  • 4 months later...
@alt.sanity

 

Personally, I'd build a table including the names of all the slot units that should be blocked depending on base flag value.

 

For instance, imagine that we have 3 bases, each with 6 units (3 blue and 3 red) + its own flag (which changes value depending on the controlling coalition).

 

We can set up a table listing all the base slot units from the opposite coalition that should be blocked in each case, then set up the logic.

 

Something like this (required fields marked in red ... also, keep in mind that I haven't tested it) :

local Callback_Table = {}

local Block_List = { 
                    ["[color=Red]Value of Base_1_Flag when blue[/color]"] = { ["[color=red]Red_unit_1[/color]"] = true , ["[color=red]Red_unit_2[/color]"] = true, ["[color=red]Red_unit_3[/color]"] = true } ,
                    ["[color=red]Value of Base_2_Flag when blue[/color]"] = { ["[color=red]Red_unit_1[/color]"] = true , ["[color=red]Red_unit_2[/color]"] = true, ["[color=red]Red_unit_3[/color]"] = true } ,
                    ["[color=red]Value of Base_3_Flag when blue[/color]"] = { ["[color=red]Red_unit_1[/color]"] = true , ["[color=red]Red_unit_2[/color]"] = true, ["[color=red]Red_unit_3[/color]"] = true } ,
                    
                    ["[color=red]Value of Base_1_Flag when red[/color]"] = { ["[color=red]Blue_unit_1[/color]"] = true , ["[color=red]Blue_unit_2[/color]"] = true, ["[color=red]Blue_unit_3[/color]"] = true } ,
                    ["[color=red]Value of Base_2_Flag when red[/color]"] = { ["[color=red]Blue_unit_1[/color]"] = true , ["[color=red]Blue_unit_2[/color]"] = true, ["[color=red]Blue_unit_3[/color]"] = true } ,
                    ["[color=red]Value of Base_3_Flag when red[/color]"] = { ["[color=red]Blue_unit_1[/color]"] = true , ["[color=red]Blue_unit_2[/color]"] = true, ["[color=red]Blue_unit_3[/color]"] = true } ,
                  }

function Callback_Table.onGameEvent(eventName, playerID, slotID)
        
  if eventName == "change_slot" and slotID ~= nil and slotID ~= '' and playerID ~= nil then    

    local Slot_Unit_Name = DCS.getUnitProperty(slotID, DCS.UNIT_NAME) [color=Blue]-- This returns the name of the unit in the selected slot[/color]

     local Base_1_Flag = tostring( net.dostring_in('server', " return trigger.misc.getUserFlag(\"[color=Red]Base 1 flag name[/color]\"); ") )
     local Base_2_Flag = tostring( net.dostring_in('server', " return trigger.misc.getUserFlag(\"[color=red]Base 2 flag name[/color]\"); ") )
     local Base_3_Flag = tostring( net.dostring_in('server', " return trigger.misc.getUserFlag(\"[color=red]Base 3 flag name[/color]\"); ") )              
  
     Block_Slot = false [color=Blue]-- By default, the block marker is disabled[/color]           
     
     if Block_List[base_1_Flag][slot_Unit_Name] ~= nil or Block_List[base_2_Flag][slot_Unit_Name] ~= nil or Block_List[base_3_Flag][slot_Unit_Name] ~= nil then
        
        Block_Slot = true [color=blue]-- Whatever the base and flag value are, if the selected slot unit name is found in the relevant subtable, the block marker for that slot will be enabled[/color]
     end
     
     local Player_List = net.get_player_list()
                    
     for i, playerId in pairs( Player_List ) do
            
         local Player_Info = net.get_player_info( playerId )
         
         if Player_Info.slot == slotID and playerID == playerId and Block_Slot then
         
            net.force_player_slot(playerId, 0, '') [color=blue]-- This forces the player attempting to enter the blocked slot back to spectators[/color]
         
            net.send_chat_to(Unit_Name.." DISABLED!", playerId)
            net.send_chat_to("CHOOSE ANOTHER SLOT!", playerId)
         end
     end                 
  end
end           

DCS.setUserCallbacks(Callback_Table) 

 

 

 

 

Thank you for this Hardcard. I think I am having a bit of a blond moment, I'm not sure of these flag names:

 

 

local Base_1_Flag = tostring( net.dostring_in('server', " return trigger.misc.getUserFlag("Base 1 flag name"); ") )

local Base_2_Flag = tostring( net.dostring_in('server', " return trigger.misc.getUserFlag("Base 2 flag name"); ") )

local Base_3_Flag = tostring( net.dostring_in('server', " return trigger.misc.getUserFlag("Base 3 flag name"); ") )

 

 

 

I gave flag values to the first part 1,2, and 3

 

 

["Value of Base_1_Flag when blue"] = { ["Red_unit_1"] = true , ["Red_unit_2"] = true, ["Red_unit_3"] = true } ,

["Value of Base_2_Flag when blue"] = { ["Red_unit_1"] = true , ["Red_unit_2"] = true, ["Red_unit_3"] = true } ,

["Value of Base_3_Flag when blue"] = { ["Red_unit_1"] = true , ["Red_unit_2"] = true, ["Red_unit_3"] = true } ,

 

 

then 11,12 and 13 for

 

 

 

["Value of Base_1_Flag when red"] = { ["Blue_unit_1"] = true , ["Blue_unit_2"] = true, ["Blue_unit_3"] = true } ,

["Value of Base_2_Flag when red"] = { ["Blue_unit_1"] = true , ["Blue_unit_2"] = true, ["Blue_unit_3"] = true } ,

["Value of Base_3_Flag when red"] = { ["Blue_unit_1"] = true , ["Blue_unit_2"] = true, ["Blue_unit_3"] = true } ,

}

 

 

Thanks for the help

Midnight

Midnite Signature.jpg

552334314_MidniteSignature.jpg.7c1678ea5639bd6d044b092eb97c300e.jpg

Link to comment
Share on other sites

  • 2 months later...

Say you want to reserve an aircraft for a number of players only. The group's name is: Mi-8_Nalchik

Suppose I want to reserve it to Alpenwolf among other players. According to the example on the first post, this is how it should be done:

 

ssb.prefixes = {
-- "-=104th=-",
-- "-=VSAAF=-",
-- "ciribob", -- you could also add in an actual player name instead
"Mi-8_Nalchik Alpenwolf",
"Mi-8_Nalchik Alpenwolf1",
"Mi-8_Nalchik Alpenwolf2",
}

 

So this should reserve the slot for three players called Alpenwolf, Alpenwolf1 and Alpenwolf2. However, it doesn't.

I'm not using the latest script.

cold war 1947 - 1991.jpg

Cold War 1947 - 1991                                       Discord
Helicopters Tournaments
Combined Arms Tournaments

You can help me with keeping up the server via PayPal donations: hokumyounis@yahoo.com

Link to comment
Share on other sites

Say you want to reserve an aircraft for a number of players only. The group's name is: Mi-8_Nalchik

Suppose I want to reserve it to Alpenwolf among other players. According to the example on the first post, this is how it should be done:

 

ssb.prefixes = {
-- "-=104th=-",
-- "-=VSAAF=-",
-- "ciribob", -- you could also add in an actual player name instead
"Mi-8_Nalchik Alpenwolf",
"Mi-8_Nalchik Alpenwolf1",
"Mi-8_Nalchik Alpenwolf2",
}

 

So this should reserve the slot for three players called Alpenwolf, Alpenwolf1 and Alpenwolf2. However, it doesn't.

I'm not using the latest script.

That list is for prefixes, as in the start of the name

 

You would put Alpenwolf as the name in the list, and call the aircraft

 

Alpenwolf1 mi8 etc

 

If the start of the player name matches the prefix then it will let you in

 

 

Sent from my HD1903 using Tapatalk

 

 

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

  • 3 weeks later...

This seems really complicated for something so simple. Why doesnt the late activation of client spawns work?

 

coalition has airbase --> Active 10 client slots on that base --> Done. Whats the easiest way to go about this without having to dive so deep into scripting?

 

What If I already have 10 flags in use for other things?

Link to comment
Share on other sites

What would be the best way of implementing this on a larger scale meaning the way I would like to use it in my missions would be to physically place a bunch of units at each of the red airfields then have the slots become available once the airfield gets captured by blue. Would there be a way to do this without having to use tons and tons of triggers in each mission (as it happens i do have 2 trigger zones at each airbase for CTLD purposes but if there's a way to implement this on a larger scale without using those zones I'm all ears! Thanks Ciribob for yet another great script.

Link to comment
Share on other sites

  • 2 months later...

Hello everybody. I have a problem. I put the file in a folder "Hooks". But the script doesn't work. Doesn't work either in the editor or as a server host. The demo mission does not work either. Both helicopters are open.

 

My bad. Solved.


Edited by Hollander
Link to comment
Share on other sites

I had issues testing this but found out it was because I was launching through the mission editor (or as a single mission). As soon as I switched to multiplayer (exactly what it's designed for... duh) - it worked.

 

Hopefully this helps anyone else who's testing in future and struggles to locate why it's not working.

Link to comment
Share on other sites

  • 1 month later...

This probably has been asked, but does the host need SSB in the Scripts\Hooks folder once a mission is made, or is SBB integrated into the mission?

 

Thanks,

----------------

AKA_Clutter

 

Win 10 Pro, Intel i7 8700k @4.6 GHz, EVGA RTX 3080  FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, Oculus Rift S, HP Reverb G2, CH Fighterstick, Pro Throttle and Pro Rudder Pedals HOTAS, TM Warthog HOTAS, MFG Rudder Pedals, TrackIR 5 Pro w/Vector Expansion, PointCTRL.

Link to comment
Share on other sites

This probably has been asked, but does the host need SSB in the Scripts\Hooks folder once a mission is made, or is SBB integrated into the mission?
 
Thanks,
In bold on the first post :)

It has to be installed by the server in scripts/hooks

Sent from my HD1903 using Tapatalk

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

On 3/8/2021 at 11:00 PM, Ciribob said:

In bold on the first post 🙂


 

DUH on my part.  Thought I had seen that, but someone on DCS Discord said that it didn't have to be.

 

Another question for my edification (just getting started down the scripting/Lua/ME rabbit hole).  I know that some things like MOOSE are integrated into the MIZ files directly and the host doesn't need to install it (or that is my understanding).  

 

SSB isn't designed that way.  What are the considerations/advantages/problems avid by doing in this method.  As you can tell, I haven't a clue of what the difference is between Script and Scripts/folder, but assume you have good reason for this and I'm trying to learn.  

 

Thanks for the time, and THANKS for SSB.

 

****************************************************  EDIT ********************************************

 

Grimes answered my question on Discord.  The two folders Scripts and Scripts/HOOKS are operate on different environments.

 

Thanks all

 

********************************************************************************************


Edited by AKA_Clutter

----------------

AKA_Clutter

 

Win 10 Pro, Intel i7 8700k @4.6 GHz, EVGA RTX 3080  FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, Oculus Rift S, HP Reverb G2, CH Fighterstick, Pro Throttle and Pro Rudder Pedals HOTAS, TM Warthog HOTAS, MFG Rudder Pedals, TrackIR 5 Pro w/Vector Expansion, PointCTRL.

Link to comment
Share on other sites

DUH on my part.  Thought I had seen that, but someone on DCS Discord said that it didn't have to be.
 
Another question for my edification (just getting started down the scripting/Lua/ME rabbit hole).  I know that some things like MOOSE are integrated into the MIZ files directly and the host doesn't need to install it (or that is my understanding).  
 
SSB isn't designed that way.  What are the considerations/advantages/problems avid by doing in this method.  As you can tell, I haven't a clue of what the difference is between Script and Scripts/folder, but assume you have good reason for this and I'm trying to learn.  
 
Thanks for the time, and THANKS for SSB.
 
****************************************************  EDIT ********************************************
 
Grimes answered my question on Discord.  The two folders Scripts and Scripts/HOOKS are operate on different environments.
 
Thanks all
 
********************************************************************************************
Have a look in the dcs install directory for the api folder

Some docs there about the gamegui environment , which is used for things relating to multiplayer

Sent from my HD1903 using Tapatalk

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

I am not really very comfortable with programming and am very confused how to use the software. I just want to block a slot off for me and my buddy in my public server using our usernames as the Group name for the units. Can someone tell me what I need to enter into the triggers page to get this all set up? Any help would be much appreciated.

Link to comment
Share on other sites

I am not really very comfortable with programming and am very confused how to use the software. I just want to block a slot off for me and my buddy in my public server using our usernames as the Group name for the units. Can someone tell me what I need to enter into the triggers page to get this all set up? Any help would be much appreciated.
Read the first page and post, and watch the video. Should answer all the questions.

Sent from my HD1903 using Tapatalk

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

20 hours ago, Ciribob said:

Have a look in the dcs install directory for the api folder

Some docs there about the gamegui environment , which is used for things relating to multiplayer

Sent from my HD1903 using Tapatalk
 

Thanks!

----------------

AKA_Clutter

 

Win 10 Pro, Intel i7 8700k @4.6 GHz, EVGA RTX 3080  FTW, Ultra 64 GB G.Skill DDR4 3600 RAM, Acer 27" flat screen, Oculus Rift S, HP Reverb G2, CH Fighterstick, Pro Throttle and Pro Rudder Pedals HOTAS, TM Warthog HOTAS, MFG Rudder Pedals, TrackIR 5 Pro w/Vector Expansion, PointCTRL.

Link to comment
Share on other sites

Here is the error code I keep getting. I'm not sure what is wrong. I put the player names into the prefix list, but they don't get blocked.
2048548034_SSBErrorCode.PNG.c8048b63f6ddad9f470ec3162005d8f5.PNG
Screen_210315_143314.thumb.png.82b104a8dbd2bddde16ae13e05e1c93e.png
You need to edit the lua in the hooks folder as per the instructions

The only thing you do in the mission is set flags

Sent from my HD1903 using Tapatalk

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

  • 2 weeks later...
  • 1 month later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...