Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
mach1muscle351

Weapon Restriction

Recommended Posts

I need to lock weapons to specific players. So that medics cant carry Heavy Anti-Materiel rifles ect. How do I make weapons "not allowed due to class restriction" for the entirety of the mission. There was a similar question to this out there and the solution was connecting players to crates individually. However, since this will be a MP mission I want the weapon to be limited even if lets say marksman class or sniper class dies with a heavy anti-materiel rifle. The medic gets a message."unable to handle weapon due to class limitation" or something like this.

Share this post


Link to post
Share on other sites

In your init.sqf:

hint "Stop being silly.";

Applies equally to both the PilotSniperMedicJavelinGuy and mission designer who wants to programmaticly limit weapons. :) The amount of work to lock down boxes and bodies and enemy bodies and vehicles that might have such weapons is not worth your noble goal. Players will always break this kind of thing and the stress involved in fighting isn't worth it. If Little Bobby wants to run around as a medic with his AS-50 and be completely ineffective at both combat and healing, why stop him?

Share this post


Link to post
Share on other sites
_layer = 85125;
_block = false;

_restrictedClasses = ["USMC_Soldier_Medic"];
_restrictedWeapons = ["M24", "M107"];

while {true} do
{
if (({player isKindOf _x} count _restrictedClasses > 0) &&
	{{player hasWeapon _x} count _restrictedWeapons > 0}) then
{
	if (!_block) then
	{
		_layer cutText ["You cannot use this weapon. Please drop it.", "BLACK OUT"];
		_block = true;
	};
}
else
{
	if (_block) then
	{
		_layer cutText ["", "PLAIN"];
		_block = false;
	};
};
sleep 1;
};

Share this post


Link to post
Share on other sites

Lol at Kylania that code didnt work for some reason :P seriously though bobby happens to be a friend of mine yes hes young and a little stupid but in order for him to have fun he needs a few guidelines. I say lets have bobby play with us instead of like rambo and maybe he will have fun as well as us :)

Deadfast I will try that first thing tom morning. Thanks!

Share this post


Link to post
Share on other sites

I did the thing with the local boxes. And furthermore I made it so, that when a player dies, he respawns with the same gear and the stuff on his corpse gets deleted. So of course there are possibilities that a medic gets his hands on a machine gun (dead enemy, dead player who left server before respawn) but that's not unrealistic. If a medic is at war and his weapon is damaged or empty, he would grab whatever he could get his hands on to defend himself (I guess) ;)

Share this post


Link to post
Share on other sites

Deadfast, script works great I was wondering if you could help me fluff it up a bit. Is it possible so that the player can carry the weapon lets say on his back but not able to use it? Also, noob question but where do I add other classes and other restrictions for that class

Share this post


Link to post
Share on other sites

I tried to put two separate scripts in the init.sqf to see if it works but it only restricts the medic class the _restricted weapons

Heres what I tried

_layer = 85125; 
_block = false; 

_restrictedClasses = ["US_Soldier_Medic_EP1"]; 
_restrictedWeapons = ["M24", "M107", "M40A3", "M24_des_EP1", "m107_TWS_EP1", "ACE_M110", "M110_NVG_EP1", "M110_TWS_EP1", "ACE_M110_SD", "PMC_AS50_scoped", "BAF_AS50_scoped", 
"PMC_AS50_TWS", "BAF_AS50_TWS", "ACE_AS50", "DMR", "ACE_TAC50", "ACE_TAC50_SD"]; 

while {true} do 
{ 
   if (({player isKindOf _x} count _restrictedClasses > 0) && 
       {{player hasWeapon _x} count _restrictedWeapons > 0}) then 
   { 
       if (!_block) then 
       { 
           _layer cutText ["You cannot use this weapon. Please drop it.", "BLACK OUT"]; 
           _block = true; 
       }; 
   } 
   else 
   { 
       if (_block) then 
       { 
           _layer cutText ["", "PLAIN"]; 
           _block = false; 
       }; 
   }; 
   sleep 1; 
};  

_layer = 85125; 
_block = false; 

_restrictedClasses = ["US_Soldier_Marksman_EP1"]; 
_restrictedWeapons = ["M24", "M107", "M40A3", "M24_des_EP1", "m107_TWS_EP1", "ACE_M110", "M110_NVG_EP1", "M110_TWS_EP1", "ACE_M110_SD", "PMC_AS50_scoped", "BAF_AS50_scoped", 
"PMC_AS50_TWS", "BAF_AS50_TWS", "ACE_AS50", "DMR", "ACE_TAC50", "ACE_TAC50_SD"]; 

while {true} do 
{ 
   if (({player isKindOf _x} count _restrictedClasses > 0) && 
       {{player hasWeapon _x} count _restrictedWeapons > 0}) then 
   { 
       if (!_block) then 
       { 
           _layer cutText ["You cannot use this weapon. Please drop it.", "BLACK OUT"]; 
           _block = true; 
       }; 
   } 
   else 
   { 
       if (_block) then 
       { 
           _layer cutText ["", "PLAIN"]; 
           _block = false; 
       }; 
   }; 
   sleep 1; 
};  

It doesnt work for the marksman unless he is in the first script. Is there a way to add multiple classes to this maybe a more efficient way?

Share this post


Link to post
Share on other sites
Sign in to follow this  

×