Jump to content
  • 0

Different loadouts for admin or regular player


Psylicium

Question

I have a script that gives different default loadout based on whether you are a regular player or an admin. Or so it should... I had it working fine on a Nitrado server a few days back, but now when I try to implement it on a Vilayer server, it doesn't seem to work properly. It looks like this:

 

_playerUID = getPlayerUID player;
_admins = ["<MY_PLAYER_ID>","<MY_PLAYER_ID>"];
switch(true)do 
{ 
case (_playerUID in _admins): // Admins startgear
{
DefaultMagazines = ["Skin_Rocket_DZ","ItemSodaCoke","FoodSteakCooked","ItemAntibiotic","ItemMorphine","ItemPainkiller","20Rnd_556x45_Stanag","20Rnd_556x45_Stanag","20Rnd_556x45_Stanag","ItemBandage","ItemBandage","ItemBandage","17Rnd_9x19_glock17","17Rnd_9x19_glock17","17Rnd_9x19_glock17","17Rnd_9x19_glock17"];
DefaultWeapons = ["M4A1_HWS_GL","glock17_EP1","NVGoggles","Binocular","ItemCompass","ItemGPS","ItemToolbox","ItemCompass","ItemFlashlightRed","ItemEtool","ItemCrowbar","ItemKeyKit","ItemKnife","ItemMatchbox_DZE"];
DefaultBackpack = "DZ_LargeGunBag_EP1";
DefaultBackpackItems = ["DMR_DZ","20Rnd_762x51_DMR","20Rnd_762x51_DMR","20Rnd_762x51_DMR"];
}; 
default  // Standard startgear
    {
DefaultMagazines = ["ItemSodaCoke","ItemPainkiller","FoodCanBakedBeans","8Rnd_9x18_Makarov","ItemBandage","ItemBandage"];
DefaultWeapons = ["Makarov","ItemMap","ItemToolbox"];
DefaultBackpack = "DZ_Patrol_Pack_EP1";
DefaultBackpackItems = [""];
};
};

It seems to work for non-admins, because even though I am admin, I spawn with the items regular players should have. I also get the error "No entry 'bin\config.bin/CfgMagazines.'." whenever I spawn, and prior to that, I get the male/female selector every time. That's not right, is it? Like I said, it was working on Nitrado, but maybe I need to pay attention to something on Vilayer? And what does that CfgMagazine-thing mean? Am I trying to spawn something "wrong" to admins, and thus reverting to the regular loadout?

 

Also, I am aware that <MY_PLAYER_ID> is stated twice, and that's deliberate. According to the forum I found this, you need to specify at least 2 admins for it to work, and I have tried both 00000000000000000 and my player ID repeated, but the outcome is the same.

 

Can anyone spot the error, or recommend a better script than this?

 

Thank you ;)

 

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

 

I have a script that gives different default loadout based on whether you are a regular player or an admin. Or so it should... I had it working fine on a Nitrado server a few days back, but now when I try to implement it on a Vilayer server, it doesn't seem to work properly. It looks like this:

 

_playerUID = getPlayerUID player;
_admins = ["<MY_PLAYER_ID>","<MY_PLAYER_ID>"];
switch(true)do 
{ 
case (_playerUID in _admins): // Admins startgear
{
DefaultMagazines = ["Skin_Rocket_DZ","ItemSodaCoke","FoodSteakCooked","ItemAntibiotic","ItemMorphine","ItemPainkiller","20Rnd_556x45_Stanag","20Rnd_556x45_Stanag","20Rnd_556x45_Stanag","ItemBandage","ItemBandage","ItemBandage","17Rnd_9x19_glock17","17Rnd_9x19_glock17","17Rnd_9x19_glock17","17Rnd_9x19_glock17"];
DefaultWeapons = ["M4A1_HWS_GL","glock17_EP1","NVGoggles","Binocular","ItemCompass","ItemGPS","ItemToolbox","ItemCompass","ItemFlashlightRed","ItemEtool","ItemCrowbar","ItemKeyKit","ItemKnife","ItemMatchbox_DZE"];
DefaultBackpack = "DZ_LargeGunBag_EP1";
DefaultBackpackItems = ["DMR_DZ","20Rnd_762x51_DMR","20Rnd_762x51_DMR","20Rnd_762x51_DMR"];
}; 
default  // Standard startgear
    {
DefaultMagazines = ["ItemSodaCoke","ItemPainkiller","FoodCanBakedBeans","8Rnd_9x18_Makarov","ItemBandage","ItemBandage"];
DefaultWeapons = ["Makarov","ItemMap","ItemToolbox"];
DefaultBackpack = "DZ_Patrol_Pack_EP1";
DefaultBackpackItems = [""];
};
};

It seems to work for non-admins, because even though I am admin, I spawn with the items regular players should have. I also get the error "No entry 'bin\config.bin/CfgMagazines.'." whenever I spawn, and prior to that, I get the male/female selector every time. That's not right, is it? Like I said, it was working on Nitrado, but maybe I need to pay attention to something on Vilayer? And what does that CfgMagazine-thing mean? Am I trying to spawn something "wrong" to admins, and thus reverting to the regular loadout?

 

Also, I am aware that <MY_PLAYER_ID> is stated twice, and that's deliberate. According to the forum I found this, you need to specify at least 2 admins for it to work, and I have tried both 00000000000000000 and my player ID repeated, but the outcome is the same.

 

Can anyone spot the error, or recommend a better script than this?

 

Thank you ;)

 

 

Try this:

private "_playerUID";

waitUntil {_playerUID = getPlayerUID player; _playerUID != ""};
_adminUIDs = ["<MY_PLAYER_ID>","<MY_PLAYER_ID>"];

if (_playerUID in _adminUIDs) then {
	DefaultMagazines = ["Skin_Rocket_DZ","ItemSodaCoke","FoodSteakCooked","ItemAntibiotic","ItemMorphine","ItemPainkiller","20Rnd_556x45_Stanag","20Rnd_556x45_Stanag","20Rnd_556x45_Stanag","ItemBandage","ItemBandage","ItemBandage","17Rnd_9x19_glock17","17Rnd_9x19_glock17","17Rnd_9x19_glock17","17Rnd_9x19_glock17"];
	DefaultWeapons = ["M4A1_HWS_GL","glock17_EP1","NVGoggles","Binocular","ItemCompass","ItemGPS","ItemToolbox","ItemCompass","ItemFlashlightRed","ItemEtool","ItemCrowbar","ItemKeyKit","ItemKnife","ItemMatchbox_DZE"];
	DefaultBackpack = "DZ_LargeGunBag_EP1";
	DefaultBackpackItems = ["DMR_DZ","20Rnd_762x51_DMR","20Rnd_762x51_DMR","20Rnd_762x51_DMR"];
} else {
	DefaultMagazines = ["ItemSodaCoke","ItemPainkiller","FoodCanBakedBeans","8Rnd_9x18_Makarov","ItemBandage","ItemBandage"];
	DefaultWeapons = ["Makarov","ItemMap","ItemToolbox"];
	DefaultBackpack = "DZ_Patrol_Pack_EP1";
	DefaultBackpackItems = "";
};

Reasoning for some of my changes:

  • getPlayerUID doesn't always give you your UID at the start if the server is under load. It can take a few seconds, so we wait until we get the UID.
  • You were getting the config error because you were giving yourself "". If you don't want any backpack items it's simply DefaultBackpackItems = ""; instead of DefaultBackpackItems = [""];.
  • Shouldn't make a different but looks neater, if/else statement instead of case break.
  • Ignore variable name changes if you wish, just my OCD kicking in :D
Link to comment
Share on other sites

  • 0

 

Try this:

private "_playerUID";

waitUntil {_playerUID = getPlayerUID player; _playerUID != ""};
_adminUIDs = ["<MY_PLAYER_ID>","<MY_PLAYER_ID>"];

if (_playerUID in _adminUIDs) then {
	DefaultMagazines = ["Skin_Rocket_DZ","ItemSodaCoke","FoodSteakCooked","ItemAntibiotic","ItemMorphine","ItemPainkiller","20Rnd_556x45_Stanag","20Rnd_556x45_Stanag","20Rnd_556x45_Stanag","ItemBandage","ItemBandage","ItemBandage","17Rnd_9x19_glock17","17Rnd_9x19_glock17","17Rnd_9x19_glock17","17Rnd_9x19_glock17"];
	DefaultWeapons = ["M4A1_HWS_GL","glock17_EP1","NVGoggles","Binocular","ItemCompass","ItemGPS","ItemToolbox","ItemCompass","ItemFlashlightRed","ItemEtool","ItemCrowbar","ItemKeyKit","ItemKnife","ItemMatchbox_DZE"];
	DefaultBackpack = "DZ_LargeGunBag_EP1";
	DefaultBackpackItems = ["DMR_DZ","20Rnd_762x51_DMR","20Rnd_762x51_DMR","20Rnd_762x51_DMR"];
} else {
	DefaultMagazines = ["ItemSodaCoke","ItemPainkiller","FoodCanBakedBeans","8Rnd_9x18_Makarov","ItemBandage","ItemBandage"];
	DefaultWeapons = ["Makarov","ItemMap","ItemToolbox"];
	DefaultBackpack = "DZ_Patrol_Pack_EP1";
	DefaultBackpackItems = "";
};

Reasoning for some of my changes:

  • getPlayerUID doesn't always give you your UID at the start if the server is under load. It can take a few seconds, so we wait until we get the UID.
  • You were getting the config error because you were giving yourself "". If you don't want any backpack items it's simply DefaultBackpackItems = ""; instead of DefaultBackpackItems = [""];.
  • Shouldn't make a different but looks neater, if/else statement instead of case break.
  • Ignore variable name changes if you wish, just my OCD kicking in :D

 

 

Thank you for your suggestion, Mikeeeyy :) I have apparently messed up my database all of a sudden, but I will try your code as soon as it is fixed. And yes, you are right - when there are only 2 choices, if/else looks cleaner, and I totally agree with you on the OCD. I want my code to look good too, haha. I'll let you know if it works :)

Link to comment
Share on other sites

  • 0

I love mine and work like a charm.

 

Add in init.sqf

//Custom Loadouts

[] ExecVM "custom\loadout.sqf";

 

and in you custom folder create a file and name it loadout.sqf and paste that. You don,t need to add anything in the back pack, repeat the admin loadout for other players you want with a specific things.

 

 

//Default Loadout
DefaultMagazines = ["ItemPainkiller","ItemBandage","ItemTinBar","ItemMorphine","ItemBloodbag","ItemTroutCooked","ItemSodaPepsi","30Rnd_556x45_Stanag","30Rnd_556x45_Stanag"];
DefaultWeapons = ["M16A4_ACG","ItemMap","ItemToolbox","ItemHatchet_DZE","ItemRadio"];
DefaultBackpack = "DZ_ALICE_Pack_EP1";
DefaultBackpackWeapon = "";
 
        //Admin Loadout
if ((getPlayerUID player) in ["PLAYER ID HERE]) then {   //Admins: NAME
DefaultMagazines = ["30Rnd_9x19_UZI_SD","30Rnd_9x19_UZI_SD","30Rnd_9x19_UZI_SD","20Rnd_762x51_DMR","20Rnd_762x51_DMR","20Rnd_762x51_DMR","20Rnd_762x51_DMR","ItemBandage","ItemBandage","ItemBandage","ItemMorphine","ItemBloodbag","ItemPainkiller","ItemSodaPepsi","FoodMRE"];
DefaultWeapons = ["UZI_SD_EP1","DMR","Binocular_Vector","NVGoggles","ItemMap","ItemCrowbar","ItemRadio","ItemKnife","ItemMatchbox_DZE","ItemHatchet_DZE","ItemGPS","ItemEtool","Itemtoolbox"];
  DefaultBackpack = "DZ_Backpack_EP1";
DefaultBackpackWeapon = "";
};
Link to comment
Share on other sites

  • 0

Mikeeeyy, I tried yours, but it got stuck at "waiting for server to start authentication" for several minutes, and nothing really happened. I didn't check the logs, but tried Petite's suggestion instead, and that works like a charm. But thanks for helping me, both of you :) Server is almost ready to go online now .... ooooooooooooh :D

Link to comment
Share on other sites

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
  • Discord

×
×
  • Create New...