Jump to content

REQUEST-is it possible to reserve planes for certain players?


9.JG27 DavidRed

Recommended Posts

David contacted me about the script that wasn't working and I told him it's no longer supported as the main function in it - destroy clients, does not really work for a long time now.

 

I saw some of the comments here, yes we use slot restrictions in Blue Flag, we do it the way Grimes mentioned. We saw new servers starting to use it as well, glad the idea is being picked up! :D

 

So I created a GameGUI script for restricting slots:

 

specific options -

coalition restriction - player ucid is restricted to the first coalition he selects until the mission is restarted - might require a DCS server restart :)

fixed name - unit name = player name.

 

tests are ran on the selected slot -

unit name - prefix or complete name.

group name - prefix or complete name.

 

compared with -

user - prefix or name.

 

 

Installation:

Take the file and put it in the servers - C:\Users\<computer name>\Saved Games\DCS\Scripts\

File has to end with GameGUI.lua (case sensitive), notice any mission will have this on from that point and you will have to rename or remove the file, afterwards to restart DCS so the restrictions are off.

 

It was a quick scribble and not tested too much, so if anyone finds an issue let me know and I'll have a go at fixing it, notice it is a good platform to start any restrictions you might think of.

Enjoy!

 

-- INTRODUCTION:
-- this script will check users who change slots in order to restrict specific units or groups.
--
-- CONFIGURATION INFO:
-- fixedName - set to true if you simply want to test the user nickname vs the unit name.
-- restrictCoa - set to true if you want to restrict the first coalition selection by each player (restricted by ucid)
--
-- user-
-- prefix - will check if the nickname of the user starts with the matching string in squad_prefix.
-- members - will check if the nickname of the user is in the table of members.
-- using both useMembers & usePrefix will test first the prefix and if not applicable will check in the squad_members list.
-- there must be atleast one configuration set here to be tested against.
-- 
-- unit & group:
-- prefix - enter the unit name or group name prefix to be checked against the reserved members or prefix.
-- names - enter the unit names or group names to be checked against the reserved members or prefix.
-- there must be atleast one configuration set here to be tested against.
-- 
-- 

net.log("Reserve Slots Script - Running")
local reserve = {}
local restrictCoa = {}

------------------edit here only------------------
reserve.config =
{
   ['fixedName'] = true,
   ['restrictCoa'] = true,
   ['user'] = 
   {
       ['prefix']     =         '9./JG27',                 --put in the user prefix to test, empty - disabled.
       ['members'] =                             
       {
           [1] =             'Xcom',        --put in the specific members you want to test, empty - disabled.
           [2] =             '9./JG27 DavidRed',    
       },
   },
   
   ['unit'] = 
   {
       ['prefix']     =         '1',                 --put in the unit prefix to test, empty - disabled.
       ['names'] =                             
       {
           [1] =             'Xcom',    --put in the specific unit names you want to test, empty - disabled.
           [2] =             '9./JG27 bf-109 #002',    
       },
   },
   
   ['group'] = 
   {
       ['prefix']     =         '2',                 --put in the unit prefix to test, empty - disabled.
       ['names'] =                             
       {
           [1] =             '9./JG27 bf-109',        --put in the specific group names you want to test, empty - disabled.
           [2] =             '9./JG27 FW-190',
       },
   },
}
------------------edit here only------------------

--test functions
reserve.testUnitPrefix = function(id, _playerName, _unitName)
   if reserve.config.unit.prefix and reserve.config.unit.prefix ~= '' and string.sub(_unitName,1,string.len(#reserve.config.unit.prefix)) == reserve.config.unit.prefix then
       if string.sub(_playerName,1,string.len(#reserve.config.user.prefix)) == reserve.config.user.prefix then
           net.log("Reserve Slots Script (unit prefix - user prefix) - ".. _playerName .." entered unit name - ".._unitName)
           return true
       end
       
       for i,name in ipairs(reserve.config.user.members) do
           if name == _playerName then
               net.log("Reserve Slots Script (unit prefix - user member) - ".. _playerName .." entered unit name - ".._unitName)
               return true
           end
       end

       --kick out of the slot
       local _chatMessage = string.format("=== %s, THIS SLOT IS RESERVED, PLEASE USE A DIFFERENT SLOT.  ***",_playerName)
       net.send_chat_to(_chatMessage, id)
       net.force_player_slot(id, 0, '')
       net.log("Reserve Slots Script (unit prefix) - ".. _playerName .." kicked from unit name - ".._unitName)
       return true
   end
end

reserve.testUnitNames = function(id, _playerName, _unitName)
   for i,uName in ipairs(reserve.config.unit.names) do
       if uName == _unitName then
           if string.sub(_playerName,1,string.len(#reserve.config.user.prefix)) == reserve.config.user.prefix then
               net.log("Reserve Slots Script (unit names - user prefix) - ".. _playerName .." entered unit name - ".._unitName)
               return true
           end
           
           for i,name in ipairs(reserve.config.user.members) do
               if name == _playerName then
                   net.log("Reserve Slots Script (unit names - user member) - ".. _playerName .." entered unit name - ".._unitName)
                   return true
               end
           end
           
           --kick out of the slot
           local _chatMessage = string.format("=== %s, THIS SLOT IS RESERVED, PLEASE USE A DIFFERENT SLOT.  ***",_playerName)
           net.send_chat_to(_chatMessage, id)
           net.force_player_slot(id, 0, '')
           net.log("Reserve Slots Script (unit names) - ".. _playerName .." kicked from unit name - ".._unitName)
           return true
       
       end
   end
end

reserve.testGroupPrefix = function(id, _playerName, _groupName)
   if reserve.config.group.prefix and reserve.config.group.prefix ~= '' and string.sub(_groupName,1,string.len(#reserve.config.group.prefix)) == reserve.config.group.prefix then
       if string.sub(_playerName,1,string.len(#reserve.config.user.prefix)) == reserve.config.user.prefix then
           net.log("Reserve Slots Script (group prefix - user prefix) - ".. _playerName .." entered group name - ".._groupName)
           return true
       end
       
       for i,name in ipairs(reserve.config.user.members) do
           if name == _playerName then
               net.log("Reserve Slots Script (group prefix - user member) - ".. _playerName .." entered group name - ".._groupName)
               return true
           end
       end
       
       --kick out of the slot
       local _chatMessage = string.format("=== %s, THIS SLOT IS RESERVED, PLEASE USE A DIFFERENT SLOT.  ***",_playerName)
       net.send_chat_to(_chatMessage, id)
       net.force_player_slot(id, 0, '')
       net.log("Reserve Slots Script (group prefix) - ".. _playerName .." kicked from group name - ".._groupName)
       return true

   end
end

reserve.testGroupNames = function(id, _playerName, _groupName)
   for i,gName in ipairs(reserve.config.group.names) do
       if gName == _groupName then
           if string.sub(_playerName,1,string.len(#reserve.config.group.prefix)) == reserve.config.group.prefix then
               net.log("Reserve Slots Script (group names - group prefix) - ".. _playerName .." entered group name - ".._groupName)
               return true
           end
           
           for i,name in ipairs(reserve.config.group.members) do
               if name == _playerName then
                   net.log("Reserve Slots Script (group names - group member) - ".. _playerName .." entered group name - ".._groupName)
                   return true
               end
           end
           
           --kick out of the slot
           local _chatMessage = string.format("=== %s, THIS SLOT IS RESERVED, PLEASE USE A DIFFERENT SLOT.  ***",_playerName)
           net.send_chat_to(_chatMessage, id)
           net.force_player_slot(id, 0, '')
           net.log("Reserve Slots Script (group names) - ".. _playerName .." kicked from group name - ".._groupName)
           return true
           
       end
   end
end

reserve.testCoa = function(id, _playerName, _playerUCID, _playerCoa)
   if restrictCoa then
       if restrictCoa[_playerUCID] then
           if restrictCoa[_playerUCID] == _playerCoa then
               return false
           else
               --kick out of the slot
               local _chatMessage = string.format("=== %s, THIS SLOT IS IN THE WRONG COALITION, PLEASE SELECT THE COALITION YOU INITIALLY SELECTED.  ***",_playerName)
               net.send_chat_to(_chatMessage, id)
               net.force_player_slot(id, 0, '')
               net.log("Reserve Slots Script - ".. _playerName .." kicked due to wrong coalition")
               return true
           end
       else
           restrictCoa[_playerUCID] = _playerCoa
           return false
       end
   end
end

reserve.testFixedName = function(id, _playerName, _unitName)
   if reserve.config.unit and reserve.config.unit.names then
       for i, name in ipairs(reserve.config.unit.names) do
           if name == _unitName then
               if _unitName == _playerName then
                   net.log("Reserve Slots Script - ".. _playerName .." entered unit name - ".._unitName)
                   return true
               else
                   --kick out of the slot
                   local _chatMessage = string.format("=== %s, THIS SLOT IS RESERVED, PLEASE USE A DIFFERENT SLOT.  ***",_playerName)
                   net.send_chat_to(_chatMessage, id)
                   net.force_player_slot(id, 0, '')
                   net.log("Reserve Slots Script - ".. _playerName .." kicked from unit name - ".._unitName)
                   return true
               end
           end
       end
   else
       net.log("Reserve Slots Script - Missing unit names for comparison")
   end
end

--change slot check
reserve.onPlayerChangeSlot = function(id)
   local _playerName = net.get_player_info(id, "name" )
   local _playerSlotID = net.get_player_info(id,'slot')
   local _playerUCID = net.get_player_info(id, "ucid" )
   local _playerCoa = net.get_player_info(id, "side" )
   local _unitName = DCS.getUnitProperty(_playerSlotID, DCS.UNIT_NAME)
   local _groupName = DCS.getUnitProperty(_playerSlotID, DCS.UNIT_GROUPNAME)

   if  (_playerSide ~=0 and  _playerSlotID ~='' and _playerSlotID ~= nil)  then
       if _playerName ~= nil then
           local result
           
           --restrictCoa test
           if reserve.config.restrictCoa == true then
               local result = reserve.testCoa(id, _playerName, _playerUCID, _playerCoa)
               if result then
                   return
               end
           end
           
           --fixedName test:
           if reserve.config.fixedName == true then
               local result = reserve.testFixedName(id, _playerName, _unitName)
               if result then
                   return
               end
           end
           
           --check unit prefix
           result = reserve.testUnitPrefix(id, _playerName, _unitName)
           if result then
               return
           end
           
           --check unit names
           result = reserve.testUnitNames(id, _playerName, _unitName)
           if result then
               return
           end
           
           --check group prefix
           result = reserve.testGroupPrefix(id, _playerName, _groupName)
           if result then
               return
           end
           
           --check group names
           result = reserve.testGroupNames(id, _playerName, _groupName)
           if result then
               return
           end
       end
   end
end

DCS.setUserCallbacks(reserve)
net.log("Reserve Slots Script - reserve callbacks loaded")

 

will need to test this, but thank you so much my old friend!rep inbound!:thumbup:

Link to comment
Share on other sites

In Storm of War (using Cliffs of Dover), we allowed units to request and be based at specific airfield dispersals and had a fully integrated aircraft allocation system which gave you what A/C serial number or Werknummer you were flying. Only members of those squadrons could spawn at their base, and aircraft were only available until their stock ran out. Is this possible with the DCS system?

 

Tenuously related question - Is it possible to restrict the slot screen to only show aircraft available to your "side". It seems somewhat odd that you can immediately see where the opposition is based and what aircraft they have available.

Link to comment
Share on other sites

In Storm of War (using Cliffs of Dover), we allowed units to request and be based at specific airfield dispersals and had a fully integrated aircraft allocation system which gave you what A/C serial number or Werknummer you were flying. Only members of those squadrons could spawn at their base, and aircraft were only available until their stock ran out. Is this possible with the DCS system?

 

Yes, using scripted conditions like the one posted above by xcom, essentially using those conditions to "kick / not kick back to spectator" clients when they click those slots.

 

 

Tenuously related question - Is it possible to restrict the slot screen to only show aircraft available to your "side". It seems somewhat odd that you can immediately see where the opposition is based and what aircraft they have available.

 

Unfortunately no method AFAIK. You have full visibility what slots are being used/held by the opposing side, and any further information available depending what the mission author has written in the text fields of the slot, group name, etc.

 

Cheers


Edited by ViFF

IAF.ViFF

 

http://www.preflight.us

Israel's Combat Flight Sim Community Website

Link to comment
Share on other sites

  • 1 month later...
  • Recently Browsing   0 members

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