Home   Help Search Login Register  

Author Topic: Reserved Slots for Members  (Read 1491 times)

0 Members and 1 Guest are viewing this topic.

Offline Krup

  • Members
  • *
Reserved Slots for Members
« on: 27 May 2008, 13:15:56 »
Hello, a long time ago I remeber a unit that had its own set of playable units that were locked to the public.  I don't rember exactly how it was done but I think it worked off a password.  My unit plays nothing but COOP and we're always happy to have public  joining us but I'd like to be able to lock off our squad units so that we won't have random people jumping in and mucking up the fireteams.  Would also be nice to use in the Evo/Warfare style maps so that we  have our own reserved slots and don't need to kick anyone in order to make room for a late joining member.  As I said a password would be nice or if it could even be baised off squad.xml or player names. 

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Reserved Slots for Members
« Reply #1 on: 30 May 2008, 23:35:11 »
I don't think it is possible to actually kick a player. The best you can do is lock them up so they can't do anything and might as well quit (if they are real smacktards, they could just sit there holding the slot, even if they can't do anything with it).

You could check based on password, but it would be best to store that info in a server-side addon rather than the individual mission, since a determined player could just depbo the mission he downloaded and find the password out. This also means it is easier to change the password for accessing your slots in any mission, without having to change all missions. If you aren't that bothered though (deterrent, not prevention) then you could stick it in the mission.

Create a server-side addon .pbo simply containing a config file:
Code: (config.cpp) [Select]
CLAN_SLOT_PASSWORD = "fish";

In the mission, wait until the player object has synced (waitUntil { not (isNull player) } ), then if the player object is one of the protected slots, create a dialog with a text entry (make sure that if they press "escape" to close the window, you open it again for them ;P). When the correct password (_password = getText (configFile >> "CLAN_SLOT_PASSWORD"));is given, the window would close permanently. Without the password, the player would stare at the dialog without being able to do anything at all.

You could also check on names or just for clan tags, though this would be extremely easy to circumvent if the player was trying to...

e.g. call this with:
["[RGG]", [soldier1, soldier2]] execVM "CheckClanTagPostfix.sqf";
Code: (CheckClanTagPostfix.sqf) [Select]
if (isServer) exitWith {};

private ["_tag", "_name", "_inClan"];
_tag = _this select 0;
_restricted = _this select 1;

_tag = toArray _tag;

// Wait until player object syncs.
waitUntil { not (isNull player) };

// If the player isn't a restricted soldier, everything is fine.
if (not (player in _restricted)) exitWith {};
_name = toArray (name player);

_inClan = true;

// Check the ends of each string for equivalency.
for "_offset" from 1 to (count _tag) do
{
   if ((_name select ((count _name) - _offset)) != (_tag select ((count _tag) - _offset))) exitWith
   {
     _inClan = false;
   };
};

if (not _inClan) then
{
  // Open a non-closable dialog (well, keep opening it again if the player closes it)
  // telling the player to bog off and get into another slot.
};

This is all off the top of my head, but should get you started...
« Last Edit: 30 May 2008, 23:42:04 by Spooner »
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)