Jump to content
Sign in to follow this  
iceman77

Weapon deletion

Recommended Posts

I need a function that immediately deletes any item, weapon or magazine that a player may set onto the ground. I don't even know where to begin! So close to conquest beta :p

Share this post


Link to post
Share on other sites

Good question.

I've got a couple of ideas but need to check something with you.

Is it specifically loose items on the ground that need to be deleted?

For example if a player puts an M16 onto a dead player or in an ammobox, then it stays in the game, but if he/she drops it on the ground, then it gets deleted?

I'm thinking of a looped script that checks for weaponHolders, clears out any weapons and mags, then deletes them.

private ["_loose_stuff_array","_unit"];
_loose_stuff_array = [];
_unit = player;
while { 2 > 1} do
{
_loose_stuff_array = nearestObjects [_unit, ["weaponholder"], 10];
if (count _loose_stuff_array > 0) then
{
	{
		clearMagazineCargoGlobal _x;
		clearWeaponCargoGlobal _x;
		deleteVehicle _x;
	} forEach _loose_stuff_array;
};
sleep 2;
};

Not sure if that's what you're looking for, but it should be safe with backpacks, dead bodies, crates etc

NOTE: Untested! Let em know how you get on.

EDIT: Noticed you could remove the loop and just call it to check for weaponHolders around the player, however, there's no kind of eventhandler for inventory/gear change, so unless you've got some way of firing this pre-arranged, you may need to put a loop in to check for players dropping stuff. Be interested to see how this goes for you. I'm going down the shop to get some beers now so any scripting I suggest later on may be bad!

Edited by Das Attorney

Share this post


Link to post
Share on other sites

Thanks Das. I'll check this out :). Bodies will sink & get deleted almost instantly. So checking bodies isn't needed. Unless ofcourse it's not a bother to impliment. Also, now that you mention it, placing a weapon into a crate or vehicle would be another way to exploit :(.

---------- Post added at 14:27 ---------- Previous post was at 14:22 ----------

Or I may be going about this the wrong way. Maybe if I explain further, a better solution can be realized. In example, in the conquest dialog, you're unable to select a launcher if you possess a weapon that's in an array. Which works fine, until 2 deviants go about exploiting; Laying launchers onto the ground for one another etc.

Share this post


Link to post
Share on other sites

while {true} do
{
_objs = nearestObjects [getPos player, ["weaponholder", "LandVehicle", "Air", "Ship", "Tank"], 10];
_men = nearestObjects [getPos player, ["Man"], 10];
{
	clearWeaponCargoGlobal _x;
	clearMagazineCargoGlobal _x;
} forEach _objs;
{
	removeAllWeapons _x;
} forEach _men;

sleep 0.2;
};

Share this post


Link to post
Share on other sites

Thanks Horner! I'll check this one out too. Much appreciated guys.

Share this post


Link to post
Share on other sites
Or I may be going about this the wrong way. Maybe if I explain further, a better solution can be realized. In example, in the conquest dialog, you're unable to select a launcher if you possess a weapon that's in an array. Which works fine, until 2 deviants go about exploiting; Laying launchers onto the ground for one another etc.

Ah yes if that's the situation, I would approach it differently. Rather than deleting loose weapons and wepaons from Backpacks and crates, maybe the better thing to do is focus on the players themselves.

You could have a looped script that checks the player every 15 seconds or so (so there's not many cpu cycles involved) and inspects their weapons. If they have a primaryWeapon in a pre-defined array, it checks if they have a secondaryWeapon from another array. If the script finds it, it deletes it. Like this:

private ["_priWeap","_secWeap","_unit","_arr_priWeaps","_arr_bannedWeaps"];

_unit = player;

_arr_priWeaps = ["DMR","m107","M24","M24_des_EP1"];

_arr_bannedWeaps = ["SMAW","MAAWS"];

while {2 > 1} do
{
_priWeap = primaryWeapon _unit;
_secWeap = secondaryWeapon _unit;

if (_priWeap in _arr_priWeaps) then
{
	if (_secWeap in _arr_bannedWeaps) then
	{
		_unit removeWeapon _secWeap;
	};
};
sleep 15; // arbitrary number - see how it plays out
};

EDIT: Untested. Just sub in the weapons you want to be banned etc.

Edited by Das Attorney

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  

×