Jump to content
onedigita

Lock uniforms and helmets so they cannot be removed

Recommended Posts

Been trying to figure out how I can prevent a player from removing there uniform and there helmet, so far my search has turned up nothing.

Share this post


Link to post
Share on other sites

By Iceman77:

Hmm. Try this.

init.sqf

if (!(isDedicated)) then {
waitUntil {!(isNull player)};
player addEventHandler ["inventoryOpened","_nul=execVM 'script.sqf'"];
};

script.sqf

waitUntil {!(isNull (findDisplay 602))};
while {!(isNull (findDisplay 602))} do {// Keep the "uniform slot" control on lockdown. Else there are loop holes. No pun intended.
ctrlEnable [6331, false]; 
};

Additional controls for later use

waitUntil {!(isNull (findDisplay 602))};
while {!(isNull (findDisplay 602))} do {
{
	ctrlEnable [_x, false];
} forEach [
	6331, // uniform
	6381, // vest
	6191, // backpack
	6240, // headgear
	610, // Primary Weapon
	620, // PW Muzzle
	621, // PW Optics
	622, // PW Flashlight
	611, // secondary weapon
	612, // hand Gun
	630, // HG Flashlight
	628, // HG Muzzle
	629 // HG Optics
];
};

---------- Post added at 13:04 ---------- Previous post was at 12:19 ----------

Could also use ctrl eventhandler(s) instead of the loop.

waitUntil {!(isNull (findDisplay 602))};
((findDisplay 602) displayCtrl 6331) ctrlAddEventHandler ["mouseButtonDown", "ctrlEnable [6331, false];"];
((findDisplay 602) displayCtrl 6331) ctrlAddEventHandler ["mouseHolding", "ctrlEnable [6331, false];"];

Share this post


Link to post
Share on other sites

lol i didnt get that the first time around it works for the uniform but not on helmet or vest. also i wonder would this prevent if this would also prevent the enemy from picking it up off a dead body?

also still allows you to put on other uniforms. but its a dam good start in the right direction tyvm

Edited by onedigita

Share this post


Link to post
Share on other sites

now this is kind if a secondary idea. but i also want to restrict my pilots to smgs, now would i have to than give them a smg upon starting the mission and just lock that one or can I allow to them choose from smgs?

Share this post


Link to post
Share on other sites
Take the text from script.sqf and write it again, and change the number to the appropriate one so helmet cannot be taken off.

Great script, player cannot to remove helmet and uniform, but anyway he can to exchange helmet or uniform with the dead body. How can that could be disabled?

Share this post


Link to post
Share on other sites
On 10.6.2018 at 8:57 PM, Cpt.Price21 said:

Could you tell nightvision id too ? İ mean number of slot nv goggles ?

The IDC is 6217

 

I have removed all unimportant information from the Inventory config so you only have the idcs for the slots:

class RscDisplayInventory
{
	class controls
	{
		class SlotPrimary: GroundTab
		{
			idc=610;
		};
		class SlotPrimaryMuzzle: SlotPrimary
		{
			idc=620;
		};
		class SlotPrimaryUnderBarrel: SlotPrimary
		{
			idc=641;
		};
		class SlotPrimaryFlashlight: SlotPrimary
		{
			idc=622;
		};
		class SlotPrimaryOptics: SlotPrimary
		{
			idc=621;
		};
		class SlotPrimaryMagazineGL: SlotPrimary
		{
			idc=644;
		};
		class SlotPrimaryMagazine: SlotPrimary
		{
			idc=623;
		};
		class SlotSecondary: SlotPrimary
		{
		};
		class SlotSecondaryMuzzle: SlotPrimary
		{
			idc=624;
		};
		class SlotSecondaryUnderBarrel: SlotPrimary
		{
			idc=642;
		};
		class SlotSecondaryFlashlight: SlotPrimary
		{
			idc=626;
		};
		class SlotSecondaryOptics: SlotPrimary
		{
			idc=625;
		};
		class SlotSecondaryMagazine: SlotPrimary
		{
			idc=627;
		};
		class SlotHandgun: SlotPrimary
		{
			idc=612;
		};
		class SlotHandgunMuzzle: SlotPrimary
		{
			idc=628;
		};
		class SlotHandgunUnderBarrel: SlotPrimary
		{
			idc=643;
		};
		class SlotHandgunFlashlight: SlotPrimary
		{
			idc=630;
		};
		class SlotHandgunOptics: SlotPrimary
		{
			idc=629;
		};
		class SlotHandgunMagazine: SlotPrimary
		{
			idc=631;
		};
		class SlotHeadgear: SlotPrimary
		{
			idc=6240;
		};
		class SlotGoggles: SlotPrimary
		{
			idc=6216;
		};
		class SlotHMD: SlotPrimary
		{
			idc=6217;
		};
		class SlotBinoculars: SlotPrimary
		{
			idc=6238;
		};
		class SlotMap: SlotPrimary
		{
			idc=6211;
		};
		class SlotGPS: SlotPrimary
		{
			idc=6215;
		};
		class SlotCompass: SlotPrimary
		{
			idc=6212;
		};
		class SlotRadio: SlotPrimary
		{
			idc=6214;
		};
		class SlotWatch: SlotPrimary
		{
			idc=6213;
		};
		class UniformTab: GroundTab
		{
			idc=6332;
		};
		class UniformSlot: SlotPrimary
		{
			idc=6331;
		};
		class VestSlot: SlotPrimary
		{
			idc=6381;
		};
		class BackpackSlot: SlotPrimary
		{
			idc=6191;
		};
	};
};

 

Share this post


Link to post
Share on other sites

7erra , Thank you so much you helped. But there is one more problem, When someone trying to take uniform from body he can take it how can i solute it ? İt blocks only drop unit elements but don't block to swap..

Share this post


Link to post
Share on other sites
14 hours ago, Cpt.Price21 said:

When someone trying to take uniform from body he can take it how can i solute it ?

Hm though question. I'd try something like this:

this addEventHandler ["InventoryClosed", {
	params ["_unit", "_container"];
	_defaultUniform = "U_I_G_Story_Protagonist_F";
	_curUniform = uniform _unit;
	if (_curUniform != _defaultUniform) then {
		_itemsUnit = uniformItems _unit;
		_unit forceAddUniform _defaultUniform;
		{_unit addItemToUniform _x} forEach _itemsUnit;
	};
}];

Run this from the init line of the unit. atm I can't find a solution do delete the dropped uniform and restoring the uniform of the container as there is no command to remove one specific item. Change the _defaultUniform to what the player should wear.

Share this post


Link to post
Share on other sites

 

this spawn {
    _unif = uniform _this;
    _inv = uniformItems _this;
    waitUntil {sleep0.3; (uniform _this isEqualTo _unif)};
    removeUniform _this;
    _this forceAddUniform _unif;
    {_this addItemToUniform _x} forEach _inv
  };

 

Share this post


Link to post
Share on other sites
5 hours ago, pierremgi said:

 


this spawn {
    _unif = uniform _this;
    _inv = uniformItems _this;
    waitUntil {sleep0.3; (uniform _this isEqualTo _unif)};
    removeUniform _this;
    _this forceAddUniform _unif;
    {_this addItemToUniform _x} forEach _inv
  };

 

Shouldn't this be a loop? Otherwise it's a one way use. And I think the waitUntil statement is missing a ! since it will return true on the first run.

Share this post


Link to post
Share on other sites
4 hours ago, 7erra said:

Shouldn't this be a loop? Otherwise it's a one way use. And I think the waitUntil statement is missing a ! since it will return true on the first run.

yep! my bad. I have more time to write something more convenient:


 

0 = this spawn {
  while {alive _this} do {
    _this setVariable ["invUnifPlyr",uniformItems _this];
    sleep 2;
    };
};
0 = this spawn {
  _unif = uniform _this;
  while {alive _this} do {
     waitUntil {sleep 0.3; !(uniform _this isEqualTo _unif)};
     removeUniform _this;
     _inv = _this getVariable ["invUnifPlyr",uniformItems _this];
     _this forceAddUniform _unif;
     {_this addItemToUniform _x} forEach _inv;
  };
};

 

  • Like 2

Share this post


Link to post
Share on other sites
On 7/24/2018 at 9:23 AM, pierremgi said:

yep! my bad. I have more time to write something more convenient:


 


0 = this spawn {
  while {alive _this} do {
    _this setVariable ["invUnifPlyr",uniformItems _this];
    sleep 2;
    };
};
0 = this spawn {
  _unif = uniform _this;
  while {alive _this} do {
     waitUntil {sleep 0.3; !(uniform _this isEqualTo _unif)};
     removeUniform _this;
     _inv = _this getVariable ["invUnifPlyr",uniformItems _this];
     _this forceAddUniform _unif;
     {_this addItemToUniform _x} forEach _inv;
  };
};

 

Is there a way to do this while using custom textured uniforms using setObjectTextureGlobal?

Share this post


Link to post
Share on other sites

you probably need to texture the "new" uniform after forcing it. So setting object texture  like you did somewhere:

_this forceAddUniform _unif;

_this setObjectTextureGlobal [0, <your texture here>];

 

See also the 2nd example here.

 

Share this post


Link to post
Share on other sites

Firstly apologies for resurrecting an old thread but after searching around for a while this is the only thing that comes close to what I want to achieve.

In my SP mission I want the player to wear the same uniform loadout (uniform, headgear, vest and backpack) from beginning to end so I need the ability to remove the option to switch or take clothing/equipment from dead bodies.

 

Spoiler
On 7/24/2018 at 5:23 PM, pierremgi said:

 



0 = this spawn {
  while {alive _this} do {
    _this setVariable ["invUnifPlyr",uniformItems _this];
    sleep 2;
    };
};
0 = this spawn {
  _unif = uniform _this;
  while {alive _this} do {
     waitUntil {sleep 0.3; !(uniform _this isEqualTo _unif)};
     removeUniform _this;
     _inv = _this getVariable ["invUnifPlyr",uniformItems _this];
     _this forceAddUniform _unif;
     {_this addItemToUniform _x} forEach _inv;
  };
};

 

 

This code still seems to work but it has a few drawbacks, when the player tries to switch uniforms it generates a copy of the players original uniform on the ground, this uniform still contains the items the player was originally carrying, so my question would be...

Is it possible to amend the code so these duplicated inventory items are removed from the groundholder uniform.

My mission is survival based so I don't want the player to have access to these "freebies".    

 

  • Like 1

Share this post


Link to post
Share on other sites

Still looking for a bit of help with this code...

Spoiler

0 = this spawn {
  while {alive _this} do {
    _this setVariable ["invUnifPlyr",uniformItems _this];
    sleep 2;
    };
};
0 = this spawn {
  _unif = uniform _this;
  while {alive _this} do {
     waitUntil {sleep 0.3; !(uniform _this isEqualTo _unif)};
     removeUniform _this;
     _inv = _this getVariable ["invUnifPlyr",uniformItems _this];
     _this forceAddUniform _unif;
     {_this addItemToUniform _x} forEach _inv;
  };
};

 

It's perfect for my needs and I've managed to work around my issues stated in the previous post but as the code stands when a player tries to change uniform it creates a duplicate of the players original uniform on the ground (suitpack), so is there any code that could be added to script provided by pierremgi to delete this discarded ground uniform as soon as it's duplicated?

It also doesn't help that the discarded uniform has no texture but I believe this to be a CUP issue with the PMC uniform itself.

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

×