English Solved Automatic Seizure of Items in the Evidence Locker

  • Auteur de la discussion Auteur de la discussion JohnC48
  • Date de début Date de début

JohnC48

User
9/5/21
8
0
100
Maxence Maxence Hello, I spoke it to you on Discord.

First of all, thank you for Creating this script, it is very well done and looks great!

I was wondering If You Could Possibly modify it for us.

The modifications I was looking to have are the Following:

- I would like to have 1 locker placed onto the map known as the "Evidence Locker". I would like all items (physical and virtual) that are seized by the police to automatically be put into this locker. I would also like to be this locker robbable by Civilians.

I have purchased the script.

If this can be done that Would Be Amazing - I am more than willing to toss you some more cash if Necessary!

My Discord: JohnC48#4211
 
Solution
Hello ! I tried to do something, can you try it and tell me if it works ?

In your fn_seizeClient.sqf, replace :
Code:
{
    if (!(_x in _exempt)) then {
        player removeWeapon _x;
    };
} forEach weapons player;

{
    if (!(_x in _exempt)) then {
        player removeItemFromUniform _x;
    };
} forEach uniformItems player;

{
    if (!(_x in _exempt)) then {
        player removeItemFromVest _x;
    };
} forEach vestItems player;

{
    if (!(_x in _exempt)) then {
        player removeItemFromBackpack _x;
    };
} forEach backpackItems player;

{
    if (!(_x in _exempt)) then {
            player removeMagazine _x;
    };
} forEach magazines player;

if (uniform player in _uniform) then {removeUniform player;};
if (vest...
Hello ! I tried to do something, can you try it and tell me if it works ?

In your fn_seizeClient.sqf, replace :
Code:
{
    if (!(_x in _exempt)) then {
        player removeWeapon _x;
    };
} forEach weapons player;

{
    if (!(_x in _exempt)) then {
        player removeItemFromUniform _x;
    };
} forEach uniformItems player;

{
    if (!(_x in _exempt)) then {
        player removeItemFromVest _x;
    };
} forEach vestItems player;

{
    if (!(_x in _exempt)) then {
        player removeItemFromBackpack _x;
    };
} forEach backpackItems player;

{
    if (!(_x in _exempt)) then {
            player removeMagazine _x;
    };
} forEach magazines player;

if (uniform player in _uniform) then {removeUniform player;};
if (vest player in _vest) then {removeVest player;};
if (headgear player in _headgear) then {removeHeadgear player;};
by these lines :
Code:
_position = [1000,1000,0];
_className = "Land_OfficeCabinet_02_F";
_itemsToStore = [];

{
    if (!(_x in _exempt)) then {
        player removeWeapon _x;
        _itemsToStore pushBack [1,_x];
    };
} forEach weapons player;

{
    if (!(_x in _exempt)) then {
        player removeMagazine _x;
        _itemsToStore pushBack [4,_x];
    };
} forEach magazines player;

{
    if (!(_x in _exempt)) then {
        player removeItemFromUniform _x;
        _itemsToStore pushBack [3,_x];
    };
} forEach uniformItems player;

{
    if (!(_x in _exempt)) then {
        player removeItemFromVest _x;
        _itemsToStore pushBack [3,_x];
    };
} forEach vestItems player;

{
    if (!(_x in _exempt)) then {
        player removeItemFromBackpack _x;
        _itemsToStore pushBack [3,_x];
    };
} forEach backpackItems player;

if (uniform player in _uniform) then {_itemsToStore pushBack [2,(uniform player)]; removeUniform player;};
if (vest player in _vest) then {_itemsToStore pushBack [2,(vest player)]; removeVest player;};
if (headgear player in _headgear) then {_itemsToStore pushBack [2,(headgear player)]; removeHeadgear player;};

_locker = nearestObject [_position,_className];

diag_log "[Lockers] Waiting for not in use";
waitUntil { !(_locker getVariable ["locker_in_use",false]) };
diag_log "[Lockers] Adding items";

{
    _type = _x select 0;
    _item = _x select 1;

    _lockerData = _locker getVariable ["locker_inv",[[],0,0,-1]];
    _lockerInv = _lockerData select 0;

    _itemWeight = ([_type,_item,1] call max_lockers_fnc_lockerItemWeight);
    if (((_lockerData select 1) + _itemWeight) > (_lockerData select 2)) then {
        hint (["STR_LOCKER_FULL","Max_Settings_Lockers","Lockers_Localization"] call theprogrammer_core_fnc_localize);
    } else {
        switch (_type) do {
            case 0: {
                _index = [_item,_lockerInv] call max_lockers_fnc_findIndexArray;

                if (_index isEqualTo -1) then {
                    _lockerInv pushBack [_type,_item,1];
                } else {
                    _val = (_lockerInv select _index) select 2;
                    _lockerInv set [_index,[_type,_item,(_val + 1)]];
                };
            };

            case 1: {
                _index = [_item,_lockerInv] call max_lockers_fnc_findIndexArray;

                if (_index isEqualTo -1) then {
                    _lockerInv pushBack [_type,_item,1];
                } else {
                    _val = (_lockerInv select _index) select 2;
                    _lockerInv set [_index,[_type,_item,(_val + 1)]];
                };
            };

            case 2: {
                _index = [_item,_lockerInv] call max_lockers_fnc_findIndexArray;

                if (_index isEqualTo -1) then {
                    _lockerInv pushBack [_type,_item,1];
                } else {
                    _val = (_lockerInv select _index) select 2;
                    _lockerInv set [_index,[_type,_item,(_val + 1)]];
                };
            };

            case 3: {
                _index = [_item,_lockerInv] call max_lockers_fnc_findIndexArray;

                if (_index isEqualTo -1) then {
                    _lockerInv pushBack [_type,_item,1];
                } else {
                    _val = (_lockerInv select _index) select 2;
                    _lockerInv set [_index,[_type,_item,(_val + 1)]];
                };
            };

            case 4: {
                _dataArray = _item splitString ",";
                _item = (_dataArray select 0);
                _ammo = parseNumber (_dataArray select 1);

                _array = [];
                {
                    _array pushBack [(_x select 1),(_x select 2),(_x select 3)];
                } forEach _lockerInv;
                _index = [_item,_array,_ammo] call max_lockers_fnc_findIndexArray;

                if (_index isEqualTo -1) then {
                    _lockerInv pushBack [_type,_item,1,_ammo];
                } else {
                    _val = (_lockerInv select _index) select 2;
                    _lockerInv set [_index,[_type,_item,(_val + 1),_ammo]];
                };
            };
        };
    };

    _locker setVariable ["locker_inv",[_lockerInv,((_lockerData select 1) + _itemWeight),(_lockerData select 2),(_lockerData select 3)],true];
} forEach _itemsToStore;

In your fn_searchClient.sqf, replace :
Code:
{
    _var = configName(_x);
    _val = ITEM_VALUE(_var);
    if (_val > 0) then {
        _inv pushBack [_var,_val];
        [false,_var,_val] call life_fnc_handleInv;
    };
} forEach ("getNumber(_x >> 'illegal') isEqualTo 1" configClasses (missionConfigFile >> "VirtualItems"));

if (!life_use_atm) then  {
    CASH = 0;
    _robber = true;
};

[player,_inv,_robber] remoteExec ["life_fnc_copSearch",_cop];
by these lines :
Code:
_itemsToStore = [];

{
    _var = configName(_x);
    _val = ITEM_VALUE(_var);
    if (_val > 0) then {
        _inv pushBack [_var,_val];
        [false,_var,_val] call life_fnc_handleInv;
        _itemsToStore pushBack _x;
    };
} forEach ("getNumber(_x >> 'illegal') isEqualTo 1" configClasses (missionConfigFile >> "VirtualItems"));

if (!life_use_atm) then  {
    CASH = 0;
    _robber = true;
};

[player,_inv,_robber] remoteExec ["life_fnc_copSearch",_cop];

_position = [1000,1000,0];
_className = "Land_OfficeCabinet_02_F";

_locker = nearestObject [_position,_className];
waitUntil { !(_locker getVariable ["locker_in_use",false]) };

{
    _type = 0;
    _item = _x;

    _lockerData = _locker getVariable ["locker_inv",[[],0,0,-1]];
    _lockerInv = _lockerData select 0;

    _itemWeight = ([_type,_item,1] call max_lockers_fnc_lockerItemWeight);
    if (((_lockerData select 1) + _itemWeight) > (_lockerData select 2)) then {
        hint (["STR_LOCKER_FULL","Max_Settings_Lockers","Lockers_Localization"] call theprogrammer_core_fnc_localize);
    } else {
        _index = [_item,_lockerInv] call max_lockers_fnc_findIndexArray;

        if (_index isEqualTo -1) then {
            _lockerInv pushBack [_type,_item,1];
        } else {
            _val = (_lockerInv select _index) select 2;
            _lockerInv set [_index,[_type,_item,(_val + 1)]];
        };
    };

    _locker setVariable ["locker_inv",[_lockerInv,((_lockerData select 1) + _itemWeight),(_lockerData select 2),(_lockerData select 3)],true];
} forEach _itemsToStore;

Replace the 2 first lines with the informations of the locker :
Code:
_position = [1000,1000,0];
_className = "Land_OfficeCabinet_02_F";
 
Dernière édition:
Solution
I just tested this and this is what I found:

  • When searching players the virtual items do not seize into the locker (I think this would be a separate script though)
  • Ammo seems to go into the stuff category and looks like this: https://gyazo.com/48ecc566f5fcfad8bef04030aba43185
  • Whatever illegal items are inside of your clothes dupe inside of the locker (If I put any item inside my clothing and if those items get seized by a cop, they will duplicate inside of the locker).

But other than that it works well.

We also have a script that allows cops to seize illegal items on the ground - would it be possible to add that also?

Here is that script:

Code:
/*
    BLAH
    BLAH
*/
_clear = nearestObjects [player,["weaponholder"],3];
_clear = _clear + nearestObjects [player,["GroundWeaponHolder"],3];
_clear = _clear + nearestObjects [player,["WeaponHolderSimulated"],3];
_destroyed = 0;
for "_i" from 0 to count _clear - 1
do
{
    _destroyed = _destroyed + 1;
    deleteVehicle (_clear select _i);
};

titleText[format["Seized %1 ground objects in the vicinity.", _destroyed],"PLAIN"];
 
Dernière édition par un modérateur:
When searching players the virtual items do not seize into the locker
I updated my reply with the modifications in the fn_searchClient.sqf

Ammo seems to go into the stuff category
All the ammos are going to this category ? Can you send me the classname of a vanilla ammo that doesn't go into the right category ?
Where was the ammo in your inventory ? Backback, clothes, weapon, other ?

they will duplicate inside of the locker
There will be 2 item instead of 1 in the locker ?

We also have a script that allows cops to seize illegal items on the ground
Replace your script by this one :
Code:
/*
    BLAH
    BLAH
*/
_clear = nearestObjects [player,["weaponholder"],3];
_clear = _clear + nearestObjects [player,["GroundWeaponHolder"],3];
_clear = _clear + nearestObjects [player,["WeaponHolderSimulated"],3];
_destroyed = 0;
_itemsToStore = [];

for "_i" from 0 to count _clear - 1
do
{
    _destroyed = _destroyed + 1;
    _itemsToStore pushBack (typeOf (_clear select _i));
    deleteVehicle (_clear select _i);
};

titleText[format["Seized %1 ground objects in the vicinity.", _destroyed],"PLAIN"];

{
    _var = configName(_x);
    _val = ITEM_VALUE(_var);
    if (_val > 0) then {
        _inv pushBack [_var,_val];
        [false,_var,_val] call life_fnc_handleInv;
    };
} forEach ("getNumber(_x >> 'illegal') isEqualTo 1" configClasses (missionConfigFile >> "VirtualItems"));

_position = [1000,1000,0];
_className = "Land_OfficeCabinet_02_F";

_locker = nearestObject [_position,_className];
waitUntil { !(_locker getVariable ["locker_in_use",false]) };

{
    _type = 1;
    _item = _x;

    _lockerData = _locker getVariable ["locker_inv",[[],0,0,-1]];
    _lockerInv = _lockerData select 0;

    _itemWeight = ([_type,_item,1] call max_lockers_fnc_lockerItemWeight);
    if (((_lockerData select 1) + _itemWeight) > (_lockerData select 2)) then {
        hint (["STR_LOCKER_FULL","Max_Settings_Lockers","Lockers_Localization"] call theprogrammer_core_fnc_localize);
    } else {
        _index = [_item,_lockerInv] call max_lockers_fnc_findIndexArray;

        if (_index isEqualTo -1) then {
            _lockerInv pushBack [_type,_item,1];
        } else {
            _val = (_lockerInv select _index) select 2;
            _lockerInv set [_index,[_type,_item,(_val + 1)]];
        };
    };

    _locker setVariable ["locker_inv",[_lockerInv,((_lockerData select 1) + _itemWeight),(_lockerData select 2),(_lockerData select 3)],true];
} forEach _itemsToStore;
 
Dernière édition:
I updated my reply with the modifications in the fn_searchClient.sqf


All the ammos are going to this category ? Can you send me the classname of a vanilla ammo that doesn't go into the right category ?
Where was the ammo in your inventory ? Backback, clothes, weapon, other ?


There will be 2 item instead of 1 in the locker ?


Replace your script by this one :
Code:
/*
    BLAH
    BLAH
*/
_clear = nearestObjects [player,["weaponholder"],3];
_clear = _clear + nearestObjects [player,["GroundWeaponHolder"],3];
_clear = _clear + nearestObjects [player,["WeaponHolderSimulated"],3];
_destroyed = 0;
_itemsToStore = [];

for "_i" from 0 to count _clear - 1
do
{
    _destroyed = _destroyed + 1;
    _itemsToStore pushBack (_clear select _i);
    deleteVehicle (_clear select _i);
};

titleText[format["Seized %1 ground objects in the vicinity.", _destroyed],"PLAIN"];

{
    _var = configName(_x);
    _val = ITEM_VALUE(_var);
    if (_val > 0) then {
        _inv pushBack [_var,_val];
        [false,_var,_val] call life_fnc_handleInv;
       
    };
} forEach ("getNumber(_x >> 'illegal') isEqualTo 1" configClasses (missionConfigFile >> "VirtualItems"));

_position = [1000,1000,0];
_className = "Land_OfficeCabinet_02_F";

_locker = nearestObject [_position,_className];
waitUntil { !(_locker getVariable ["locker_in_use",false]) };

{
    _type = 1;
    _item = _x;

    _lockerData = _locker getVariable ["locker_inv",[[],0,0,-1]];
    _lockerInv = _lockerData select 0;

    _itemWeight = ([_type,_item,1] call max_lockers_fnc_lockerItemWeight);
    if (((_lockerData select 1) + _itemWeight) > (_lockerData select 2)) then {
        hint (["STR_LOCKER_FULL","Max_Settings_Lockers","Lockers_Localization"] call theprogrammer_core_fnc_localize);
    } else {
        _index = [_item,_lockerInv] call max_lockers_fnc_findIndexArray;

        if (_index isEqualTo -1) then {
            _lockerInv pushBack [_type,_item,1];
        } else {
            _val = (_lockerInv select _index) select 2;
            _lockerInv set [_index,[_type,_item,(_val + 1)]];
        };
    };

    _locker setVariable ["locker_inv",[_lockerInv,((_lockerData select 1) + _itemWeight),(_lockerData select 2),(_lockerData select 3)],true];
} forEach _itemsToStore;
Thank you very much for all the help so far, you are the best.

- Yes, all of the ammo is going into the Stuff category and not the Ammo category, which is not too big of a deal. Seems like it might just be with modded ammo.

- Yes illegal items inside of clothing will be duped when seized.
 
Can you send me the mod of the ammo and the classname of the ammo that doesn't work ?

--

I don't really understand how items can be duplicated as they are removed from inventory, and then added to the locker.
Can you make a short video to see the problem and try to reproduce it on my side ?
 
Can you send me the mod of the ammo and the classname of the ammo that doesn't work ?

--

I don't really understand how items can be duplicated as they are removed from inventory, and then added to the locker.
Can you make a short video to see the problem and try to reproduce it on my side ?
There is a bunch of modded ammo, like a lot.

A new error we are getting now is that it says "Size of locker not big enough, can't hold many items.".

How do you increase the weight capacity of the locker?
 
Can you give me just 1 example that doesn't work (classname + mod download link) ?

You can edit the sizes of the lockers here :
Voir la pièce jointe 1962
I will increase all of those sizes and test it out. Thank you.

An example classname of modded ammo we have is "SMA_30Rnd_762x35_SS" which is for the gun "SMA_HK416afg" in this mod:

We also use this mod for weapons:

I have a google doc of every gun and ammo classname we use on our server for both of those mods if you would like to see that.
 
Okay, so I tested on my side, it looks like ammo are considered as magazines (right) but also as vest items.
So I changed the code in the fn_seizeClient.sqf of my reply #3 to remove all the magazines for the player first, and then check the vest items (which are only items, and not magazines as they were removed).

Can you update the code and tell me if that solved the problem ?
 
Okay, so I tested on my side, it looks like ammo are considered as magazines (right) but also as vest items.
So I changed the code in the fn_seizeClient.sqf of my reply#3to remove all the magazines for the player first, and then check the vest items (which are only items, and not magazines as they were removed).

Can you update the code and tell me if that solved the problem ?
Updated it, however I am having an issue with the locker size. It does not put any items into it and it says it does not have enough space.

I edited the size like you said above.

Any other way to make it have infinite space?

This is the message and script error I get https://gyazo.com/b11fc0f1d8ac7d64693ec2c7d5644b31
 
To remove the locker size limit, you can remove the check of the size in your @The_Programmer/addons/lockers/client/fn_lockerStoreItem.sqf by deleting this line :
Code:
if (((_lockerData select 1) + _itemWeight) > (_lockerData select 2)) exitWith {hint (["STR_LOCKER_FULL","Max_Settings_Lockers","Lockers_Localization"] call theprogrammer_core_fnc_localize);};

And also remove the information about the current size of the items in the locker, in your mission folder/The-Programmer/Lockers/dialogs/locker.hpp delete this control :
Code:
class LockerWeight : Life_RscStructuredText
{
   idc = 5004;
   text = "";
   x = 0.613541666666666 * safezoneW + safezoneX;
   y = 0.266470009832841 * safezoneH + safezoneY;
   w = 0.106770833333333 * safezoneW;
   h = 0.0403146509341204 * safezoneH;
};

About the error, when do you have this message ?
 
To remove the locker size limit, you can remove the check of the size in your @The_Programmer/addons/lockers/client/fn_lockerStoreItem.sqf by deleting this line :
Code:
if (((_lockerData select 1) + _itemWeight) > (_lockerData select 2)) exitWith {hint (["STR_LOCKER_FULL","Max_Settings_Lockers","Lockers_Localization"] call theprogrammer_core_fnc_localize);};

And also remove the information about the current size of the items in the locker, in your mission folder/The-Programmer/Lockers/dialogs/locker.hpp delete this control :
Code:
class LockerWeight : Life_RscStructuredText
{
   idc = 5004;
   text = "";
   x = 0.613541666666666 * safezoneW + safezoneX;
   y = 0.266470009832841 * safezoneH + safezoneY;
   w = 0.106770833333333 * safezoneW;
   h = 0.0403146509341204 * safezoneH;
};

About the error, when do you have this message ?
I will do these changes now and test it out.

The error occurred when we seized illegal items off the ground. But it occurs when we try to seize any gear or weapons.