Jump to content

DCS-SimpleSlotBlock - Multiplayer Slot Blocking Script


Recommended Posts

  • 1 month later...

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 post
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 = { 
                    ["[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) 


Edited by Hardcard
Link to post
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 post
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 post
Share on other sites
  • 2 weeks later...

I've heard issues with people not being able to lock down the back seat of the f14, has this been resolved?

-System Specs are:

 

CPU: i9-9900K @ 4.9Ghz

M/B: Asus TUF z390 Gaming Plus

RAM: 32GB

Video Card: EVGA RTX 2080 Ti XC Hybrid Gaming (11G-P4-2384)

VR: Oculus Rift S

Controls: Warthog Stick & Throttle, TPR pedals, Streamdeck XL

Link to post
Share on other sites
  • 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 post
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.

[sIGPIC][/sIGPIC]

Cold War 1947 - 1991

Helicopters Tournaments

Combined Arms Tournaments

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

Link to post
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 post
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 post
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 post
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 post
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 post
Share on other sites

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...