Jump to content

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


9.JG27 DavidRed

Recommended Posts

hey guys! just like the title says, i would like to know whether it would be possible to reserve aircraft for certain players in mp missions.so that only the one player can spawn in it.(maybe with dedecting the UCID?).and if another player tries to spawn in it, to give him a warning, and if he stays in it, to despawn it...

is this somehow possible with a script?

thx in advance

Link to comment
Share on other sites

Just noticed your thread here and since other groups like to reserve some slots for their friends/ members too, but don´t know how to, I post the script, we found working well enough here.

 

The script reserveunits_v1.lua (4.3 KB) reserves all in the table listed units for all in the table listed players, while the file reserveunits_individuell_v1.lua (4.3 KB) reserves the unit listed in line 1 of the unit table for the player listed in the playertable in line 1 and so on.

reserveunits_individuell_v1.lua

reserveunits_v1.lua

[sIGPIC][/sIGPIC]

 

Unsere Facebook-Seite

Link to comment
Share on other sites

  • 4 months later...
  • 1 year later...

anybody got either of the scripts working correctly currently?

 

for me, SNAFU's scripts dont do anything anymore, and Xcom's script is working only partially, meaning, that if i am the host of a mission, it will properly kick me from a plane thats reserved for someone else...but, clients get the warning message, but can stay in the aircraft...they are not getting kicked...BUT: although they are not getting kicked from their point of view, those planes seem to be pushed into a parallel universe, where they will not be able to see anybody else on the server, and all other players cannot see them. for other players, their aircraft remains on the ground in parking position, while in fact they took off and are flying...so this script now creates ghost planes pretty much...thats troublesome, as some players will not recognize the warning message, and dont know that they are sitting in a reserved plane...they fly happily around the server, without knowing why they cannot see anything...


Edited by 9./JG27 DavidRed
Link to comment
Share on other sites

So something like this is best handled on the server side of things via modification. You can check your install for a file in \DCS World\API\DCS_controlAPI.txt that has some useful documentation. Specifically you can use the callback onPLayerTryChangeSlot to intercept the players action of attempting to join a slot and check information about the player, like a UCID, and then allow or deny the player from joining the slot.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting 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

Nothing that I could whip up quickly with real code. Maybe when I get back to testing slmod I can give it a quick go.

 

Basically you'd need a table of accepted UCIDs for the players that can access reserved aircraft. You'd also need a set method of identifying reserved aircraft slots, perhaps part of the units name. "R_A10C_1_resv".

 

When a player tries to change slot you create your own little callback function for onPlayerTryChangeSlot(). Get information about the unit they tried to join. If it has the string "resv" in it then get the players UCID and check it against the table of accepted UCIDs. If it is on the list return true, if not return false.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting 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

Think I asked for it months and months ago for SLMOD and it was said it was out of scope. Also asked Ciribob for the code to just add slots blocking via a flag rather than as part of a script. Currently it's beyond non scripters which is a shame as I think slot blocking is an immensely useful part of making public missions. I'm not learning LUA just to do it when it would take someone 30 mins to rearrange the CSAR script to look for a flag instead of an in game function call.

 

Still, ages after 1.5 release, desperately needing a solution for this!

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

I remember those discussions. I haven't really touched slmod in a while because I was holding off on the 1.5/2.0 merge thinking it would have been in 2016. Also for a while there I didn't have access to a dedicated game server to properly test it with. I am planning on doing some slmod stuff soonish, but right at the moment Viggen missions are the priority.

 

I can't remember if it was discussed before, but what are the exact reasons you think slot blocking would be useful? I can think of two reasons but I'd like to know what others think on the matter and what is important to them.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting 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

I can't remember if it was discussed before, but what are the exact reasons you think slot blocking would be useful? I can think of two reasons but I'd like to know what others think on the matter and what is important to them.

 

Hi Grimes, from my perspective and experience I can provide some examples:

 

1. In "persistant world" type of missions where airfield capturing is part of the objectives. Slot blocking for airfields that become captured and fall under the control of the opposite side, and removing of slot blocking when airfields are re-captured. I believe this is the method being used in Blue Flag.

 

2. In "dynamic spawning" type missions where the slots become available based on a dynamically created frag list based on certain events occuring. For example: the slots of a SEAD flight are unblocked when a recon function discovers a SAM in the AO. There was an example of how to create this type of dynamic frag list using MOOSE.

 

3. As mentioned previously on this post (what I understand as to the reason): slots blocked for a particular squad or VIPs on popular servers that normally are very full. This to ensure that there will always be slots available to clients that the server owner considers them VIPs, for example people who contribute money to support the cost of the server hosting vs guests who just come to fly.

 

S!


Edited by ViFF

IAF.ViFF

 

http://www.preflight.us

Israel's Combat Flight Sim Community Website

Link to comment
Share on other sites

I can't remember if it was discussed before, but what are the exact reasons you think slot blocking would be useful? I can think of two reasons but I'd like to know what others think on the matter and what is important to them

 

From my perspective, running a server, I'd like to prevent people from swapping sides to have a look at the opposite side and then targeting them. I'd also like to reserve certain squadrons for registered players and leave others open to public players. Or, restrict public players to one side or another perhaps.

 

The other pressing reason for slot blocking would be to restrict who has access to the Tactical Command slots. One person can wreak havoc on a mission in a server when I'm not around but it is very useful to keep for those who can use it responsibly.

Link to comment
Share on other sites

Sniped really by ViFF, these are the points I'd want. It's essentially a workaround for "creating dynamic slots". You create them first, and open them up instead. CSAR has it's own use-case which is disabling slots for pilot rescue, which is nice. Less about reserving slots, but it might be nice to block or enable Ground commander slots based on some criteria, same with Game master.

 

We can create both red and blue slots at an airfield, sadly we can use both without restriction.

 

You can also begin to improvise restrictions based on other misison conditions....fuel, arrival of the engineers.

 

My mind runs wild to be honest.

Hi Grimes, from my perspective and experience I can provide some examples:

 

1. In "persistant world" type of missions where airfield capturing is part of the objectives. Slot blocking for airfields that become captured and fall under the control of the opposite side, and removing of slot blocking when airfields are re-captured. I believe this is the method being used in Blue Flag.

 

2. In "dynamic spawning" type missions where the slots become available based on a dynamically created frag list based on certain events occuring. For example: the slots of a SEAD flight are unblocked when a recon function discovers a SAM in the AO. There was an example of how to create this type of dynamic frag list using MOOSE.

 

3. As mentioned previously on this post (what I understand as to the reason): slots blocked for a particular squad or VIPs on popular servers that normally are very full. This to ensure that there will always be slots available to clients that the server owner considers them VIPs, for example people who contribute money to support the cost of the server hosting vs guests who just come to fly.

 

S!

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

This also, side swapping on public as per BF implementation which locks you into one or the other with a chat feature.

 

There's also the extension of "reserved slots" in more gentle fashions, like providing access to slots with a special skin/tail numbers, which is more the conventional reason.

 

So

1. Create artificial progress on a map (capturing airfields)

2. Enforcing side balancing

3. Mission design elements (Something must happen for the plane to become useable via flag, can be tactical like arriving fuel truck/convoy)

4. Enforce time to start for timely mission objectives

5. Enforce reservations for squadrons that feel they need

6. Passwording slots that are vulnerable like Game master/tactical commander

7. Provide direct access to a specific plane/loadout/skin/tailnumber only

8. Prevent or handle gracefully, side swapping (can be limited as opposed to merely prevented)

9. Interface with the server to provide server response based on a chat comand, eg input your side, then limits to red, or in other ways, restrict to CAP/CAS/helicopter based on previous scoring or lives

10. Alternative to the CSAR already provided and the same funcitonality - eg lock slot you burned up

11. Limit actual plane use by numbers...eg have 12 slots, kill them all and nothing left to enter as they are all destroyed.

 

 

Gotta stop now, but thats a fairly decent list.

From my perspective, running a server, I'd like to prevent people from swapping sides to have a look at the opposite side and then targeting them. I'd also like to reserve certain squadrons for registered players and leave others open to public players. Or, restrict public players to one side or another perhaps.

 

The other pressing reason for slot blocking would be to restrict who has access to the Tactical Command slots. One person can wreak havoc on a mission in a server when I'm not around but it is very useful to keep for those who can use it responsibly.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

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")

ReserveSquadGameGUI.lua

  • Like 1
Link to comment
Share on other sites

Just gonna itemize each one with my own thoughts in terms of difficulty, my opinion on it, etc.

1. Create artificial progress on a map (capturing airfields)

Possibly straight forward. Could be done automatically via cross-checking which coalition owns the airbase, if it isn't your side don't allow spawn. Could also be enabled/disabled via commands.

2. Enforcing side balancing

I get the desire for it but it isn't something I think is really needed. Mostly because something like that could get tricky fast, especially if it is in a mission with the first suggestion as part of it. What I mean is it requires a script that defines balance which is what would get complicated fairly quickly. For instance one side is kicking ass and taking bases, suppose for a moment that the balancer wants people to join the losing team, what happens if that team "runs out" of available slots due to lack of airbases and the balancer stops people from joining the team that has slots. You'd get a player in the server that can't actually play. There are other issues. It could be done via broad categorizations of aircraft such as "fighter, strike, helicopter" but I think most would agree that not all aircraft are equal. By the simple rules the teams could be 10x Mig-15 vs 10x F-15C and it would be considered balanced. Plus players will more likely have to deal with possible restrictions preventing them from getting on the same team as their friends in a game whose servers generally have a small turn-over rate of players. It'd cause problems if your team is way above the balancer threshold and you decide you wanted to switch aircraft types but stay on your team.

 

3. Mission design elements (Something must happen for the plane to become useable via flag, can be tactical like arriving fuel truck/convoy)

Kind of the same as number 1 but on a per aircraft basis. Same difficulty as a trigger enable/disable of certain airfields.

4. Enforce time to start for timely mission objectives

Same as 3. It makes more sense to me for the mission builder to define when slots would become (un)/available.

5. Enforce reservations for squadrons that feel they need

Understandable and relatively easy if setup as part of the mission. Sorta like my above suggestion. It looks for a keyword in the unit name and if present crosschecks the UCID of the player from a list. Only way it would be more complicated is if you wanted to reserve specific slots for specific players.

6. Passwording slots that are vulnerable like Game master/tactical commander

Understandable. It is kinda similar to 5. Could do it similar to how slmod handles admin functionality in that it is basically white-listed for certain players.

7. Provide direct access to a specific plane/loadout/skin/tailnumber only

Again similar to 5.

8. Prevent or handle gracefully, side swapping (can be limited as opposed to merely prevented)

It is a little complicated due to defining the rules of of it. Like I routinely accidentally choose a slot because I'm scrolling through the list and I hit my PTT button for teamspeak and DCS recognizes it as a mouse click. I'm more in favor of limiting it than preventing, but its just one of those things I don't think is super important. People can team-switch for a number of reasons... balance, to fly a specific aircraft, to fly with friends, or to cheat. How do you quantify what a person might be doing? That is where things get complicated :)

9. Interface with the server to provide server response based on a chat comand, eg input your side, then limits to red, or in other ways, restrict to CAP/CAS/helicopter based on previous scoring or lives

That is in the auto-balance territory with interaction via the admin to unilaterally decide what the balance should be.

10. Alternative to the CSAR already provided and the same funcitonality - eg lock slot you burned ups

You will quickly run out of slots. :music_whistling:

Again it is similar to the specific slot locking, just with different rules to define it. It would be easy enough for a mission script to interact with a server side script rather than having the server side script handle it all automatically.

 

11. Limit actual plane use by numbers...eg have 12 slots, kill them all and nothing left to enter as they are all destroyed.

Try using the warehouse system? Literally does the same thing. But if slot blocking on a per aircraft basis was done, then so could this. But again I think it should be a mission side script interacting with the server side one to define the actual behavior.

 

 

How this all relates to slmod...

 

Ok so I've been kinda on the fence with expanding slmod for a while now. It all comes down to slmod was built at a time when a lot of scripting functionality simply wasn't part of the core game and that certain features were simply locked out from MP. Specifically for the longest time only the host could do stuff like use the F10 radio menu. Slmod was eventually morphed into server administration functionality while keeping all that original stuff. Pretty much all of the slmod scripting functions are available in the scripting engine. So there is a lot of redundant code in slmod that is only there for the sake of backward compatibility. On one hand I'd like to start fresh with an admin mod that interacts with the scripting engine for stuff that it can't do today. On the other I can just keep adding to slmod.

 

I don't know if you can tell, but if something can be done via mission scripting, then I think that is exactly where it should be done. At least as far as a publicly released script can go. Its pretty obvious that some servers are using server side mods to obfuscate and protect the code they've written to handle mission scripting on the server side. That is another subject for another time though. What I am trying to say is that for a generalized server administration mod/tool I don't see a whole lot of value in building in a bunch of functionality that can be 90% handled by the scripting engine. I'd rather have the mod do that last 10% and give the mission builders a choice for how to best use it.

The right man in the wrong place makes all the difference in the world.

Current Projects:  Grayflag ServerScripting 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

Well, yeah, I would expect this to be handled by GameGUI.lua as per XCOM's upstairs, I don't disagree, this is an extension to something outwith core SLMOD and doesn't entirely fit with it's scope.

 

The use cases listed you seem to refer to GameGUI and the API as the solution, if this is correct, that's understood. Still looking for a framework to do that, despite XCOM's naming solution right above. I'd simply like to interface with the FLAG system so I can be the dumbass non scripter that can simply use ME to create a flag using the inbuilt conditions which has all the "Aerodrome is BLUE" conditions to then lock out the slots that belong to it. No need to make SLMOD grow arms and legs.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

Hi XCOM,

 

Sorry to ask when you already gave.... You know me... :)

 

Is it possible to add a function on a reserved FLAG number to limit a slot? In this way we can just use the ME conditions to create flags in game which would cover some of the use cases.

 

Idea is simply, use the ME in game to create a flag based on a condition. can be capturing an aerodrome, farp, unit destroyed, unit group in zone, whatever, there is a bunch of stuff. Then make a flag a number. If that number is X the GameGui then can restrict or open slot number XYZ.

 

Does this make sense? I don't write LUA so I'm not sure if I have this as too simple in my head and haven't thought through at the code level.

 

cheers, Mike

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")

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

Will exchange for a Swedish Coastal defence gun mod? :) just found out this requirement for my Viggen missions should be fairly simple. Have to find a way to make it in 2 days and still complete my Viggen campaign for launch. I'm full until Friday, then after Friday im stoked!

 

This can wait post Viggen etc, not likely to use it until we've all deciphered the plane comfortably. And wife computer died so my dedicated squadron hardware is now being abused by having World of Warcraft installed on it and being unavailable with no near term remedy.

I think it's possible, need to look into it.

I take NIS & $s ;)

 

Let me see if it's possible and what it requires, free time unfortunately has grown to be very valuable recently.

___________________________________________________________________________

SIMPLE SCENERY SAVING * SIMPLE GROUP SAVING * SIMPLE STATIC SAVING *

Link to comment
Share on other sites

  • Recently Browsing   0 members

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