Jump to content
Daffy

Toggle Admin/Staff Loadout (Saves previous loadout to load when toggled off)

Recommended Posts

Author: Me (Josh L)

Difficulty: Easy

Description: On - Saves the players gear then gives them the staff loadout. Off - Loads the players old gear then gives it back to them.

 

 

  1. Download the file attached to this thread.
  2. Drop it into the "admin" folder - "core\admin".
  3. Open fn_keyHandler.sqf - "core\functions".
  4. Add the code below to the bottom below the "//U Key" case.
  5. Save the fn_keyHandler.sqf.
  6. Open functions.hpp in the main directory.
  7. Add class adminOnOffDuty {}; to "class Admin".
  8. Save functions.hpp.
  9. Open configuration.sqf in "core".
  10. Add "admin_onDuty = 0;" underneath "life_canpay_bail = true;".
  11. Save configuration.sqf
  12. Start the server, join the server and when you press Shift + 0 you will be set as On Duty.

    //Shift + 0 - On/Off Duty
    case 11: {
        if(_shift) then {
            [] spawn life_fnc_adminOnOffDuty;
        };
    };

 

Extras

 

 

fn_adminOnOffDuty.sqf

Edited by Daffy
Fixed script_macros.hpp error in script
  • Like 3

Share this post


Link to post
Share on other sites

Easier way to do this is how i did my prison clothes, i believe they work in the same fashion

old_gear = getUnitLoadout player;
removeUniform player;
removeHeadgear player;
removeVest player;
removeGoggles player;
removeBackpack player;
removeallWeapons player;
removeallAssignedItems player;
player setUnitLoadout old_gear;

 

Share this post


Link to post
Share on other sites

There will be easier ways to do what my script does but I wanted to learn things so I tried breaking everything down as you can see from how much code there is but it works perfectly as it is.

Thanks for the suggestion though, I will have a look at that later!

Share this post


Link to post
Share on other sites

when I go in game it doesn't do anything and the RTP log does not show an error ???
https://pastebin.com/Di9nwDuT

I have changed 
    //Shift + F1 - On/Off Duty
    case 59: {
        if(_shift) then {
            [] spawn life_fnc_adminOnOffDuty;
        };
    };
i have tried it with the Shift + 0 and its the same

Edited by Daniel Stewart

Share this post


Link to post
Share on other sites
18 hours ago, Daniel Stewart said:

is there a way I can make it so the VR suit is different depending on your admin level ??

i did like this there are probably some easier ways to do it but i did like this (i have not tested it yet)

if(FETCH_CONST(life_adminlevel) isEqualTo 1) then {
    _uniform = "U_B_Protagonist_VR";
};
if(FETCH_CONST(life_adminlevel) isEqualTo 2) then {
    _uniform = "U_I_Protagonist_VR";
};
if(FETCH_CONST(life_adminlevel) isEqualTo 3) then {
    _uniform = "U_C_Protagonist_VR";
};
if(FETCH_CONST(life_adminlevel) isEqualTo 4) then {
    _uniform = "U_O_Protagonist_VR";
};

 


    player forceAddUniform _uniform;

Edited by Hyper4u.'<3

Share this post


Link to post
Share on other sites
7 hours ago, Hyper4u.'<3 said:

i did like this there are probably some easier ways to do it but i did like this (i have not tested it yet)

if(FETCH_CONST(life_adminlevel) isEqualTo 1) then {
    _uniform = "U_B_Protagonist_VR";
};
if(FETCH_CONST(life_adminlevel) isEqualTo 2) then {
    _uniform = "U_I_Protagonist_VR";
};
if(FETCH_CONST(life_adminlevel) isEqualTo 3) then {
    _uniform = "U_C_Protagonist_VR";
};
if(FETCH_CONST(life_adminlevel) isEqualTo 4) then {
    _uniform = "U_O_Protagonist_VR";
};

 


    player forceAddUniform _uniform;

it does work it doesn't give me the suit

Edited by Daniel Stewart

Share this post


Link to post
Share on other sites

#include "..\..\script_macros.hpp"
/*
    File: fn_adminOnOffDuty.sqf
    Author: Josh L
    
    Description:
    Saves the players gear then gives them the staff loadout.
    Loads the players old gear then gives it back to them.
*/
_suit = [
    "U_O_Protagonist_VR",
    "U_B_Protagonist_VR",
    "U_I_Protagonist_VR"
];
_random = selectRandom _suit; 
if(FETCH_CONST(life_adminlevel) < 2) exitWith {closeDialog 0; hint "You do not have acccess to this";};
if(admin_onDuty == 1) then {
    admin_onDuty = 0;
    player setVariable["onDuty",0,true];
    
    systemChat "Loading previous gear...";

    removeUniform player;
    removeVest player;
    removeBackpack player;
    removeHeadgear player;
    removeGoggles player;

    player forceAddUniform life_oldUniform;
    _count = (count life_oldUniformItems) - 1; 
    for "_x" from 0 to _count do { 
        _item = life_oldUniformItems select _x;
        player addItemToUniform _item;
    };
    player addVest life_oldVest;
    _count = (count life_oldVestItems) - 1; 
    for "_x" from 0 to _count do { 
        _item = life_oldVestItems select _x;
        player addItemToVest _item;
    };
    player addBackpack life_oldBackpack;
    _count = (count life_oldBackpackItems) - 1; 
    for "_x" from 0 to _count do {
        _item = life_oldBackpackItems select _x;
        player addItemToBackpack _item;
    };
    player addHeadgear life_oldHeadgear;
    player addGoggles life_oldGoggles;
    [] call life_fnc_playerSkins;

    player addWeapon life_oldPWeapon;
    player addWeapon life_oldSWeapon;
    player addMagazine life_oldPWeaponMag;
    player addMagazine life_oldSWeaponMag;
    {
        player addPrimaryWeaponItem _x;
    } forEach life_oldPWeaponItems;
    {
        player addHandgunItem _x;
    } forEach life_oldSWeaponItems;
    
    player allowDamage true;
    
    systemChat "Loaded previous gear!";
    hint "You are now off duty!";
} else {
    admin_onDuty = 1;
    player setVariable["onDuty",1,true];
    
    systemChat "Saving previous gear...";

    life_oldUniformItems = uniformItems player;
    life_oldVestItems = vestItems player;
    life_oldBackpackItems = backpackItems player;

    life_oldPWeapon = primaryWeapon player;
    life_oldSWeapon = handgunWeapon player;
    life_oldPWeaponMag = (getarray (configFile >> "CFGWeapons" >> life_oldPWeapon >> "magazines") select 0);
    life_oldSWeaponMag = (getarray (configFile >> "CFGWeapons" >> life_oldSWeapon >> "magazines") select 0);
    life_oldPWeaponItems = primaryWeaponItems player;
    life_oldSWeaponItems = handgunItems player;

    life_oldUniform = uniform player;
    life_oldVest = vest player;
    life_oldBackpack = backpack player;
    life_oldHeadgear = headgear player;
    life_oldGoggles = goggles player;

    removeUniform player;
    removeVest player;
    removeBackpack player;
    removeHeadgear player;
    removeGoggles player;
    removeAllWeapons player;

    player forceAddUniform _random;
    player addGoggles "G_Bandanna_aviator";
    player addHeadgear "H_CrewHelmetHeli_B";
    player addVest "V_PlateCarrier1_blk";
    player addBackpack "B_ViperLightHarness_blk_F";

    player addItem "ItemMap";
    player assignItem "ItemMap";
    player addItem "ItemCompass";
    player assignItem "ItemCompass";
    player addItem "ItemWatch";
    player assignItem "ItemWatch";
    player addItem "ItemGPS";
    player assignItem "ItemGPS";
    
    player allowDamage false;
    [] call life_fnc_playerSkins;

    systemChat "Saving previous gear!";
    hint "You are now on duty!";
};

@Deadlesszombie where do i put it then ??

Edited by Daniel Stewart

Share this post


Link to post
Share on other sites
7 hours ago, Daniel Stewart said:

#include "..\..\script_macros.hpp"
/*
    File: fn_adminOnOffDuty.sqf
    Author: Josh L
    
    Description:
    Saves the players gear then gives them the staff loadout.
    Loads the players old gear then gives it back to them.
*/
_suit = [
    "U_O_Protagonist_VR",
    "U_B_Protagonist_VR",
    "U_I_Protagonist_VR"
];
_random = selectRandom _suit; 
if(FETCH_CONST(life_adminlevel) < 2) exitWith {closeDialog 0; hint "You do not have acccess to this";};
if(admin_onDuty == 1) then {
    admin_onDuty = 0;
    player setVariable["onDuty",0,true];
    
    systemChat "Loading previous gear...";

    removeUniform player;
    removeVest player;
    removeBackpack player;
    removeHeadgear player;
    removeGoggles player;

    player forceAddUniform life_oldUniform;
    _count = (count life_oldUniformItems) - 1; 
    for "_x" from 0 to _count do { 
        _item = life_oldUniformItems select _x;
        player addItemToUniform _item;
    };
    player addVest life_oldVest;
    _count = (count life_oldVestItems) - 1; 
    for "_x" from 0 to _count do { 
        _item = life_oldVestItems select _x;
        player addItemToVest _item;
    };
    player addBackpack life_oldBackpack;
    _count = (count life_oldBackpackItems) - 1; 
    for "_x" from 0 to _count do {
        _item = life_oldBackpackItems select _x;
        player addItemToBackpack _item;
    };
    player addHeadgear life_oldHeadgear;
    player addGoggles life_oldGoggles;
    [] call life_fnc_playerSkins;

    player addWeapon life_oldPWeapon;
    player addWeapon life_oldSWeapon;
    player addMagazine life_oldPWeaponMag;
    player addMagazine life_oldSWeaponMag;
    {
        player addPrimaryWeaponItem _x;
    } forEach life_oldPWeaponItems;
    {
        player addHandgunItem _x;
    } forEach life_oldSWeaponItems;
    
    player allowDamage true;
    
    systemChat "Loaded previous gear!";
    hint "You are now off duty!";
} else {
    admin_onDuty = 1;
    player setVariable["onDuty",1,true];
    
    systemChat "Saving previous gear...";

    life_oldUniformItems = uniformItems player;
    life_oldVestItems = vestItems player;
    life_oldBackpackItems = backpackItems player;

    life_oldPWeapon = primaryWeapon player;
    life_oldSWeapon = handgunWeapon player;
    life_oldPWeaponMag = (getarray (configFile >> "CFGWeapons" >> life_oldPWeapon >> "magazines") select 0);
    life_oldSWeaponMag = (getarray (configFile >> "CFGWeapons" >> life_oldSWeapon >> "magazines") select 0);
    life_oldPWeaponItems = primaryWeaponItems player;
    life_oldSWeaponItems = handgunItems player;

    life_oldUniform = uniform player;
    life_oldVest = vest player;
    life_oldBackpack = backpack player;
    life_oldHeadgear = headgear player;
    life_oldGoggles = goggles player;

    removeUniform player;
    removeVest player;
    removeBackpack player;
    removeHeadgear player;
    removeGoggles player;
    removeAllWeapons player;

    player forceAddUniform _random;
    player addGoggles "G_Bandanna_aviator";
    player addHeadgear "H_CrewHelmetHeli_B";
    player addVest "V_PlateCarrier1_blk";
    player addBackpack "B_ViperLightHarness_blk_F";

    player addItem "ItemMap";
    player assignItem "ItemMap";
    player addItem "ItemCompass";
    player assignItem "ItemCompass";
    player addItem "ItemWatch";
    player assignItem "ItemWatch";
    player addItem "ItemGPS";
    player assignItem "ItemGPS";
    
    player allowDamage false;
    [] call life_fnc_playerSkins;

    systemChat "Saving previous gear!";
    hint "You are now on duty!";
};

@Deadlesszombie where do i put it then ??

You remove the random uniform generator and where it forces adds the random uniform

Share this post


Link to post
Share on other sites

#include "..\..\script_macros.hpp"
/*
    File: fn_adminOnOffDuty.sqf
    Author: Josh L
    
    Description:
    Saves the players gear then gives them the staff loadout.
    Loads the players old gear then gives it back to them.
*/
_suit = [
    "U_O_Protagonist_VR",
    "U_B_Protagonist_VR",
    "U_I_Protagonist_VR"
];
if(FETCH_CONST(life_adminlevel) < 2) exitWith {closeDialog 0; hint "You do not have acccess to this";};
if(admin_onDuty == 1) then {
    admin_onDuty = 0;
    player setVariable["onDuty",0,true];

    

    systemChat "Loading previous gear...";

    removeUniform player;
    removeVest player;
    removeBackpack player;
    removeHeadgear player;
    removeGoggles player;

    player forceAddUniform life_oldUniform;
    _count = (count life_oldUniformItems) - 1; 
    for "_x" from 0 to _count do { 
        _item = life_oldUniformItems select _x;
        player addItemToUniform _item;
    };
    player addVest life_oldVest;
    _count = (count life_oldVestItems) - 1; 
    for "_x" from 0 to _count do { 
        _item = life_oldVestItems select _x;
        player addItemToVest _item;
    };
    player addBackpack life_oldBackpack;
    _count = (count life_oldBackpackItems) - 1; 
    for "_x" from 0 to _count do {
        _item = life_oldBackpackItems select _x;
        player addItemToBackpack _item;
    };
    player addHeadgear life_oldHeadgear;
    player addGoggles life_oldGoggles;
    [] call life_fnc_playerSkins;

    player addWeapon life_oldPWeapon;
    player addWeapon life_oldSWeapon;
    player addMagazine life_oldPWeaponMag;
    player addMagazine life_oldSWeaponMag;
    {
        player addPrimaryWeaponItem _x;
    } forEach life_oldPWeaponItems;
    {
        player addHandgunItem _x;
    } forEach life_oldSWeaponItems;
    
    player allowDamage true;
    
    systemChat "Loaded previous gear!";
    hint "You are now off duty!";
} else {
    admin_onDuty = 1;
    player setVariable["onDuty",1,true];
    
    systemChat "Saving previous gear...";

    life_oldUniformItems = uniformItems player;
    life_oldVestItems = vestItems player;
    life_oldBackpackItems = backpackItems player;

    life_oldPWeapon = primaryWeapon player;
    life_oldSWeapon = handgunWeapon player;
    life_oldPWeaponMag = (getarray (configFile >> "CFGWeapons" >> life_oldPWeapon >> "magazines") select 0);
    life_oldSWeaponMag = (getarray (configFile >> "CFGWeapons" >> life_oldSWeapon >> "magazines") select 0);
    life_oldPWeaponItems = primaryWeaponItems player;
    life_oldSWeaponItems = handgunItems player;

    life_oldUniform = uniform player;
    life_oldVest = vest player;
    life_oldBackpack = backpack player;
    life_oldHeadgear = headgear player;
    life_oldGoggles = goggles player;

    removeUniform player;
    removeVest player;
    removeBackpack player;
    removeHeadgear player;
    removeGoggles player;
    removeAllWeapons player;

if(FETCH_CONST(life_adminlevel) isEqualTo 1) then {
    _uniform = "U_O_Protagonist_VR";
};
if(FETCH_CONST(life_adminlevel) isEqualTo 2) then {
    _uniform = "U_O_Protagonist_VR";
};
if(FETCH_CONST(life_adminlevel) isEqualTo 3) then {
    _uniform = "U_C_Protagonist_VR";
};
if(FETCH_CONST(life_adminlevel) isEqualTo 4) then {
    _uniform = "U_I_Protagonist_VR";
};
if(FETCH_CONST(life_adminlevel) isEqualTo 5) then {
    _uniform = "U_B_Protagonist_VR";
};

    player forceAddUniform _uniform;
    player addGoggles "G_Bandanna_aviator";
    player addHeadgear "H_CrewHelmetHeli_B";
    player addVest "V_PlateCarrier1_blk";
    player addBackpack "B_ViperLightHarness_blk_F";

    player addItem "ItemMap";
    player assignItem "ItemMap";
    player addItem "ItemCompass";
    player assignItem "ItemCompass";
    player addItem "ItemWatch";
    player assignItem "ItemWatch";
    player addItem "ItemGPS";
    player assignItem "ItemGPS";
    
    player allowDamage false;
    [] call life_fnc_playerSkins;

    systemChat "Saving previous gear!";
    hint "You are now on duty!";
};

@Deadlesszombie there is no error but doesn't give me a VR-suit 

Edited by Daniel Stewart

Share this post


Link to post
Share on other sites
On 17/12/2017 at 4:19 PM, AnonOp said:

add in your configuration.sqf

admin_onDuty = 0;

 

Sorry guys, forgot to add this xD

Thanks @AnonOp

Edited by Daffy

Share this post


Link to post
Share on other sites
On 20/12/2017 at 2:54 PM, Daffy said:

Sorry guys, forgot to add this xD

Thanks @AnonOp

Np dude just make sure you update the tut

Share this post


Link to post
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

×