Jump to content
Sign in to follow this  
dr_eyeball

Prevent player picking up certain weapons

Recommended Posts

How would you prevent a player from picking up (or firing) a certain weapon (from off the ground, a truck, ammo crate, gear options, etc).

Eg: You only want specialty classes to use specialty weapons, like an AT Specialist class can only use AT weapons.

Assuming the same sort of rules would apply to the ammo.

Edit:

Resolved this using a trigger, even though it's a bit excessive to be constantly checking this:

Condition: "PipeBomb" in (magazines player)

Activation: player removeMagazine "PipeBomb"; hint "You are forbidden to carry Satchel Charges due to a lack of training.";

Share this post


Link to post
Share on other sites

And if I´d like to prevent an entire class, like any Rifle or any primary weapons (or even not allowing primary neither secondary, allowing just handgun which is what I intend to)  without having to write on each one of their "names"?

Share this post


Link to post
Share on other sites

Build an array of the units you want to check, then run the weapon removal on each unit in the array. It's a bit of a brute-force solution, and it won't likely run optimally on every system. You might also run into MP-compatibility issues.

Share this post


Link to post
Share on other sites

run script locally on from init.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

[] execVM "forbidden_weapons.sqf";

forbidden_weapons.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

forbidden_weps = ["PipeBomb"];

forbidden_mags = [];

for [{_i=0}, {_i < 1}, {_i=_i+1}] do

{

{

if (_x in forbidden_weps) then

{

player removeWeapon _x;

};

} foreach weapons player;

{

if (_x in forbidden_mags) then

{

player removeMagazine _x;

};

} foreach magazines player;

Sleep 0.4;

};

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
Sign in to follow this  

×