TheMeq

Single Script Reserved Slots

21 posts in this topic

Hello, wanted to release my reserved slots script :) 

Go to your mp_missions/exile.<map>/ and create a new file called reservedslots.sqf. Paste in the following code: 

// Reserved Slots Script by TheMeq

private ["_reserved_uids", "_uid","_playercount","_servernoreserve","_server_reservedslots","_server_maxplayers","_testplayer"];

// Max Players
_server_maxplayers = 70;

// Reserved Slots
_server_reservedslots = 10;

// Reserved Player UID's
_reserved_uids = [
		"UID1","UID2","UID3"
		];

		waitUntil {!isNull player};
		waitUntil {(vehicle player) == player};
		waitUntil {(getPlayerUID player) != ""};
		
		_playercount = count playableUnits;
		_uid = getPlayerUID player;
		_servernoreserve = _server_maxplayers - _server_reservedslots;
		{
			_testplayer = getPlayerUID _x;
			if(_testplayer in _reserved_uids) then
				{
					_servernoreserve = _servernoreserve + 1;
					if (_servernoreserve > _server_maxplayers) then
						{
							_servernoreserve = _server_maxplayers;
						};
				};
		} forEach allPlayers;
		
		if ((_playercount > _servernoreserve)&& !(_uid in _reserved_uids)) then 
			{
				titleText ["", "BLACK OUT"];
				disableUserInput true;
				hint "You are in a reserved slot! You will be kicked to the lobby in 10 seconds!";
				sleep 5;
				hint "You are in a reserved slot! You will be kicked to the lobby in 5 seconds!";
				sleep 5;
				titleText ["", "BLACK IN"];
				disableUserInput false;
				failMission "end1";
			};  

Change _server_maxplayers to your server capacity including reserved slots.
Change _server_reservedslots to your number of reserved slots.
Change _reserved_uids to an array of what players have reserved slots. 

Add the following line to init.sqf

[] execVM "addons\reservedslot.sqf";

And your good to go!

This was adapted and improved from another script.

Edited by TheMeq
updated script
8 people like this

Share this post


Link to post
Share on other sites
Advertisement

Updated OP Code. This doesn't need the while loop and may cause server performance issue's if you leave it in.

Share this post


Link to post
Share on other sites

Thanks for your efforts! However it doesn't seem to work for me, no errors but people join in the reserved slots.

Share this post


Link to post
Share on other sites

Os Not an issue with the players uid to be on the pbo that anyone can download? Any chance to make it only server side like running from a preinit.sqf

Share this post


Link to post
Share on other sites
6 hours ago, TMHackSaW said:

Os Not an issue with the players uid to be on the pbo that anyone can download? Any chance to make it only server side like running from a preinit.sqf

That's easy to do. 

 

Replace all 

_reserved_uids 

with 

reserved_uids 

 

Open preinit.sqf and add this add the bottom:

reserved_uids = ["0"];publicVariable "reserved_uids";

 

2 people like this

Share this post


Link to post
Share on other sites

Changed the code slightly as my private variables where not private'd correctly :)

Share this post


Link to post
Share on other sites
_server_reserveslots = 10;

should be

_server_reservedslots = 10;
1 person likes this

Share this post


Link to post
Share on other sites
Advertisement

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.