Jump to content
Sign in to follow this  
SicSemperTyrannis

Verification of item/magazine/weapon added?

Recommended Posts

I'm trying to make a pretty basic item shop for my mode, but when items, weapons, mags etc don't fit into your inventory the function fails.

That's fine, totally, but is there some way to actually check if the item was added after the call?

It seems there's no result codes for addItemCargo/addBackpack/addVest/addWeaponCargo/addMagazineCargo/addWeapon/addMagazine/addItem/addUniform

I'm wondering if there's some way to confirm the item was added to their inventory or an ammo box, or not (in the case of not having enough space to carry it)

Share this post


Link to post
Share on other sites

It doesn't throw any exceptions when it fails to add a magazine, weapon or item. It just sort of does nothing.

Maybe I'll submit a ticket asking for a return code, but if there's any way to accomplish this before then it'd be super helpful.

I saw the:

loadAbs

loadBackpack

loadUniform

loadVest

functions in the ARMA3 docs, but there's no "max" function for any of those things, nor do I know how to retrieve the mass of a given object.

If I had those things I'd be able to calculate mass before/after and tell if they went over and make it fail, but I don't.

Share this post


Link to post
Share on other sites

ACE did this.

I guess you could save all magazines or weapons into an array, add them, count the new magazines or weapons and see if there's a difference.

Share this post


Link to post
Share on other sites

Well, I put in an issue to the bug tracker anyway.

https://dev-heaven.net/issues/71348

It should solve my problems and many others, I'm sure other people would also enjoy these functions. I hope they respond.

Until then I might just hash their inventory before and after. I'm using an extension on the server-side I made which includes MD5/CRC functionality so I could just check if something has changed until they reply.

---------- Post added at 18:03 ---------- Previous post was at 16:28 ----------

This might be useful:

Rather than checking the array before/after to see if something was added, try this:

https://community.bistudio.com/wiki/load

Basically,

_loadBefore = load _unit;
_unit addWeapon "M_RPG32_F";
sleep 1;
_loadAfter = load _unit;

if(_loadAfter > _loadBefore) then {
// We made it brah
} else {
// nope
};

I'm not completely sure if it also counts the "load" of currently equipped items, but I'd hope so. If not, you could just stick it in their backpack/vest/uniform and check the specific load with loadBackpack/loadUniform/loadVest.

Share this post


Link to post
Share on other sites

Update: This seems to work

_data = _this select 3;
_data = _data select 0;
_name = _data select 0;
_disp = _data select 1;
_type = _data select 2;
_moni = _data select 3;

if((currentWeapon player) == _name) exitWith {
titleText["You already own one of these.", "PLAIN DOWN"];
};

_previousLoad = load player;

call compile format['player %1 "%2";', _type, _name]; //type = addWeapon, addMagazine, addItem, etc

_newLoad = load player;

if(_previousLoad == _newLoad) exitWith {
titleText["You don't have enough inventory space to buy this item.", "PLAIN DOWN"];
};

titleText["You bought the item!", "PLAIN DOWN"];

It can be buggy though. If the previous load matches the new load (if an item "weighs" the same as the one discarded) it can give you a false-positive.

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  

×