Jump to content
Sign in to follow this  
Guest

Get Assigned Items of a Weapon in a Container

Recommended Posts

Guest

Hi,

If i do that:

1 - Get a weapon that have a optic assigned item

2 - Remove the optic assigned item from the weapon

3 - Add the weapon, without the optic item, into a container (a vehicle or a box, etc)

Question: There is a way to know, using scripts, that this weapon inside the container don't have the optic item?

Thankyou in advance!

Share this post


Link to post
Share on other sites

Firstly, wrong section.

Secondly, to add a weapon to a crate with attachments already added you need to create (or use) a new class that already has those attachments attached. I suppose you could check to see if the base-class weapon is in the crate and/or if the optic'ed weapon is in there, though I'd be unsure of the correct scripting command to use.

Share this post


Link to post
Share on other sites
Guest

Sorry for the wrong section, and thakyou for the replyes.

I'm saving the container data in mySql.

If the original weapon class have optics and i remove the optics and put the weapon inside the container.. and save it to the database, the classname saved on db is the one with optics.

So this make a way to duplicate optics after server restart.

Share this post


Link to post
Share on other sites
Guest

Thankyou pedeathtrian. I understand now how it works.

Share this post


Link to post
Share on other sites
Guest

Sorry for the small monologue.

 

Any help on this new question is apreciated:

 

Ok, now i can save the BOX weapons info to the DB like that:

[
	"arifle_MX_ACO_pointer_F",
	"muzzle_snds_H",
	"acc_pointer_IR",
	"optic_Aco",
	[
		"30Rnd_65x39_caseless_mag",
		30
	],
	"bipod_01_F_blk"
]
Q: When the server starts i push this info from the BD... ok. But how to add this array as a weapon in the BOX?

 

The only way i see is to make an analisys of the array to discovery the weapon classnames that have all those items then add this class name to the BOX... what is a ubber work.

Share this post


Link to post
Share on other sites

Q: When the server starts i push this info from the BD... ok. But how to add this array as a weapon in the BOX?

First (actually better do this on writing to DB), you will need to get a base class of a rifle using BIS_fnc_baseWeapon. This will free you from checking whether attachments are correspondant to weapon class.

Second, unfortunately Arma still does not have commands to put weapons with attachments to containers, so you will need to use workarounds, e.g. "DropWeapon" action. More details in this post.

Share this post


Link to post
Share on other sites

http://www.armaholic...ge.php?id=24467


 

in this link . you can see this old (very old ) mod , which add to the MX and Kaybar 7.62 ! ... what's the problem ?! simple ! .. This mod does not work well , because as expected the sound of the gun , the old sound !! the first ov vanilla first sound ( I think) rifle mx ... this is the prblm ! when using this mod , see the weapon to shoot, but no sound !! ..im seriously desperate , because im looking for a mod that has the ability to get out of shell casings from the rifle MX !!!!!! , And this is the only , ONLY mod to allow this .. any ideas : ' (?? (sorry for bad english ) ... please !! T_T

Share this post


Link to post
Share on other sites
Guest

pedeathtrian,

Thanks a lot. This is a very creative solution!

I'm just unsure if this method can be used to pull 350+ Containers from a data base that can have many many weapons.

Share this post


Link to post
Share on other sites

I'm just unsure if this method can be used to pull 350+ Containers from a data base that can have many many weapons.

Yeah, this could be a pain even if proper scripting commands existed... You should definitely vote for their adding when feedback tracker is back (link posted by chronicsilence in the same thread from my previous post).

Share this post


Link to post
Share on other sites
Guest

I have a solution.

Bellow is just an example:

What i'm saving on the database:

[
	[
		"arifle_MX_ACO_pointer_F",
		"muzzle_snds_H",
		"acc_pointer_IR",
		"optic_Aco",
		[
			"30Rnd_65x39_caseless_mag",
			30
		],
		"bipod_01_F_blk"
	],
	"magazine720",
	"magazine720",
	"magazine554",
	"magazine554",
	"magazine554",
	"ItemMap",
	"CustomItemBread",
	"ITemBinocular"
]

What i will save to the database:

The code received by the database saver will still be:

[
	[
		"arifle_MX_ACO_pointer_F",
		"muzzle_snds_H",
		"acc_pointer_IR",
		"optic_Aco",
		[
			"30Rnd_65x39_caseless_mag",
			30
		],
		"bipod_01_F_blk"
	],
	"magazine720",
	"magazine720",
	"magazine554",
	"magazine554",
	"magazine554",
	"ItemMap",
	"CustomItemBread",
	"ITemBinocular"
]

But aditional code will convert it to:

[
	"arifle_MX_F", //FOUND WITH BIS_fnc_baseWeapon
	"muzzle_snds_H",
	"acc_pointer_IR",
	"optic_Aco",
	"30Rnd_65x39_caseless_mag",
	"bipod_01_F_blk"
	"magazine720",
	"magazine720",
	"magazine554",
	"magazine554",
	"magazine554",
	"ItemMap",
	"CustomItemBread",
	"ITemBinocular"
]

Good solution, don't?

Share this post


Link to post
Share on other sites
Guest

Sorry, for the double post, but its new thing.

 

BIS_fnc_baseWeapon is returning the weapon with bipod... Base weapons comes with bipod?

 

Thankyou again!

Share this post


Link to post
Share on other sites
Guest

Here my solution to the case:

//========================================
//========================================
//SAVING A BOX WITH ITEMS ON THE DATA BASE
//========================================
//========================================

//=========
//FUNCTIONS
//=========

BRPVP_addCargo = {
	params ["_cargo","_class"];
	_nameArr = _cargo select 0;
	_qttArr = _cargo select 1;
	_idx = _nameArr find _class;
	if (_idx >= 0) then {
		_qttArr set [_idx,(_qttArr select _idx) + 1];
		_cargo set [1,_qttArr];
	} else {
		_nameArr = _nameArr + [_class];
		_qttArr = _qttArr + [1];
		_cargo = [_nameArr,_qttArr];
	};
	_cargo
};

//=======================================
//GET MAGS BACKPACKS AND ITEMS IN THE BOX
//=======================================

_mags = getMagazineCargo _myBox; //_myBox is the container
_bpack = getBackpackCargo _myBox; //_myBox is the container
_items = getItemCargo _myBox; //_myBox is the container

//================================================
//GET WEAPONS, DISMANTLE THE WEAPON ITEMS AND MAGS
//AND PUT THEN IN THE _items AND _mags VARIABLES
//================================================

_weaps = [[],[]];
_weaponsItemsCargo = weaponsItemsCargo _myBox; //_myBox is the container
{
	_weap = _x;
	{
		if (_forEachIndex == 0) then {
			_weaps = [_weaps,_x call BIS_fnc_baseWeapon] call BRPVP_addCargo;
		} else {
			if (typeName _x == "ARRAY") then {
				if (count _x > 0) then {
					_mags = [_mags,_x select 0] call BRPVP_addCargo;
				};
			};
			if (typeName _x == "STRING") then {
				if (_x != "") then {
					_items = [_items,_x] call BRPVP_addCargo;
				};
			};
		};
	} forEach _weap;
} forEach _weaponsItemsCargo;

//=======================================
//CREATE THE BOX STATE ARRAY THAT WILL BE
//SEND TO SERVER TO SAVE ON DATA BASE
//=======================================

_boxState = [_weaps,_mags,_bpack,_items];

//===============================
//SEND BOX STATE TO SERVER, TO BE
//SAVED ON SERVER SIDE
//===============================

BRPVP_saveBoxOnBd = _boxState;
publicVariableServer "BRPVP_saveBoxOnBd";

On server side:

"BRPVP_saveBoxOnBd" addPublicVariableEventHandler {
	_boxState = _this select 1;
	//SAVE ON DATA BASE USING YOUR CHOOSEN SAVE METHOD (i use Arma 2 Net with MySQL plugin).
};

Cons:

- Half used magazines back to full state.

- Bipod can be not removed from the weapon, because the BI function BIS_fnc_baseWeapon can return the weapon with bipod (not the mostly base weapon). Leading to bipod duplication.

 

Solution for Cons:

A natural function that get the array generated by weaponsItemsCargo and put the weapons in that array inside the container. Something like addWeaponsItemsCargo.

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  

×