Jump to content
Odderino

Restrict Class to certain users?

Recommended Posts

I was wondering if there was a certain way to restrict certain classes to certain users on my server?

 

The server runs on a modified Invade and Annex base, so classes are currently setup like this:

 

 

class Item0
                {
                    position[]={15280.771,17.870386,17400.666};
                    azimut=-201.653;
                    special="NONE";
                    id=0;
                    side="WEST";
                    vehicle="SWOP_Clonetrooper";
                    player="PLAY CDG";
                    leader=1;
                    rank="LIEUTENANT";
                    skill=0.60000002;
                    text="s40";
                    init="(group this) setGroupId [""ALPHA""];";
                    description="Alpha Squad Leader";
                    syncId=0;
                    synchronizations[]={70};
                };

 

Vehicle is the name of an NPC, and spawns you with all the equipment the NPC wears. I think restricting the "vehicle" string to a certain User ID would be the best course of action.

 

Something like:

 

If player = SWOP_Clonetrooper

and

Player UID is not in list

then

display: You are not whitelisted for this slot

and then something with BIS_fnc_endMission

 

Obviously this is not how code works, and would appreciate any help!

Share this post


Link to post
Share on other sites

 

Spoiler

if (isDedicated) exitWith {};
waitUntil {player == player};
_whitelistedUID = 
[
	"3424324324324324",
	"3242343242342343",
	"4234234324324234"
];

_whitelistedSlots = ["AlphaSL", "BravoSL", "CharlieSL"];

_uid = getPlayerUID player;
_slot = vehiclevarname player;

if ((_slot in _whitelistedSlots)&& !(_uid in _whitelistedUID)) then {
   failMission "End1";
};

 

Not tested, should work.

 

Allows to modularity or whatever the fancy word for it is. You can add several different whitelists for pilots, squad leads, command etc. PM/Reply if you need more help. :)

  • Like 1

Share this post


Link to post
Share on other sites
On 7/27/2017 at 0:52 PM, Spatsiba said:

 

  Hide contents


if (isDedicated) exitWith {};
waitUntil {player == player};
_whitelistedUID = 
[
	"3424324324324324",
	"3242343242342343",
	"4234234324324234"
];

_whitelistedSlots = ["AlphaSL", "BravoSL", "CharlieSL"];

_uid = getPlayerUID player;
_slot = vehiclevarname player;

if ((_slot in _whitelistedSlots)&& !(_uid in _whitelistedUID)) then {
   failMission "End1";
};

 

Not tested, should work.

 

Allows to modularity or whatever the fancy word for it is. You can add several different whitelists for pilots, squad leads, command etc. PM/Reply if you need more help. :)

Doesn't work, still allows me to access whitelisted classes despite my ID not being in the whitelist.

 

I tried:

 

Changing the values in _whitelistedSlots

Putting the script in my init.sqf

Putting the script in my initServer.sqf

 

Share this post


Link to post
Share on other sites

Try the initPlayerLocal.sqf

  • Like 1

Share this post


Link to post
Share on other sites

Building upon what @Spatsiba mentioned:

 

initServer.sqf:

whitelistedUIDs = ["RANDOM NUMEBRS HERE"];


initPlayerServer.sqf:

params [
    ["_player", objNull, [objNull]],
    ["_jip", false, [false]]
];

_uid = getPlayerUID _player;
_slot = vehiclevarname player;

_whitelistedSlots = ["AlphaSL", "BravoSL", "CharlieSL"];

if ((_slot in _whitelistedSlots) && {!(_uid in whitelistedUIDs)}) then {
   ["End1"] remoteExec ["endMission", _player];
};

where "End1" is an ending defined in cfgDebriefing.

  • Like 2

Share this post


Link to post
Share on other sites

Tried everything above. I can still play as the squad leaders despite my own ID not being in the whilelisted UID parameter. 

Share this post


Link to post
Share on other sites
27 minutes ago, Odderino said:

Tried everything above. I can still play as the squad leaders despite my own ID not being in the whilelisted UID parameter. 

How are you testing it? I've tested it just now and it works.

 

Make sure that AlphaSL is the variable name of the unit, not its role description.

Edited by HallyG
  • Like 1

Share this post


Link to post
Share on other sites
3 hours ago, HallyG said:

variable name of the unit

Sorry to sound like an idiot, but where do I find this?

Share this post


Link to post
Share on other sites

Still allows me to play as the class, after doing everything above,

 

I even defined End1 in my description.ext:

 

class CfgDebriefing
{  
    class End1
    {
        title = "You all died!";
        subtitle = "";
        description = "Everyone is dead.";
        pictureBackground = "";
        picture = "KIA";
        pictureColor[] = {0.6,0.1,0.2,1};
    };
};

 

This was just a debug, it would be changed later, but it still does not end the mission.

Share this post


Link to post
Share on other sites

It might be a good idea to use the roleDescription command instead of the vehicleVarName. 

params [
    ["_player", objNull, [objNull]],
    ["_jip", false, [false]]
];

_uid = getPlayerUID _player;
_slot = roleDescription player;

_whitelistedSlots = ["Alpha Squad Leader", "Bravo Squad Leader", "Charlie Squad Leader"];

if ((_slot in _whitelistedSlots) && {!(_uid in whitelistedUIDs)}) then {
   ["End1"] remoteExec ["endMission", _player];
};

This command is MP only.

  • Like 2

Share this post


Link to post
Share on other sites

Nothing above works, is there a possibility something could be conflicting with it?

 

Do I have to tell the server to load initPlayerServer.sqf in another file? I didn't have that file before, so I just made one and put the code in there.

Share this post


Link to post
Share on other sites

@Odderino, how are you testing it? Since everything I have posted seems to work for me on my server.

Share this post


Link to post
Share on other sites
1 minute ago, HallyG said:

@Odderino, how are you testing it? Since everything I have posted seems to work for me on my server.

 

On my own server, hosted by Host Havoc.

Share this post


Link to post
Share on other sites

@Odderino, it's dedicated, hence why it isn't working since player returns a null object.

 

Change:

vehicleVarName player

to

vehicleVarName _player

 

(silly mistake on my part)

Share this post


Link to post
Share on other sites
9 minutes ago, HallyG said:

@Odderino, it's dedicated then so change:
 


vehiclevarname player

to


vehiclevarname _player

 

silly mistake on my part!

It works! Thank you for your patience.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×