Jump to content
Sign in to follow this  
cookies2432

Delete object without ID

Recommended Posts

So, it's late and my brain isn't working properly sadly. I was wondering if anyone knows how to delete an object without it having a variable name? It calls a function so i tried "deleteVehicle (_this select 0);" but arma 3 gave me hell for that so i haven't consider trying it again. I appriciate all the help I can get, and for anyone who's curious, it's food items, something of a project i'm working on, this is just a part of it :)

Share this post


Link to post
Share on other sites

How is the object accessed in the first place? Is it passed as an argument to a file? function? You need some way to access the object you're trying to delete otherwise you'd be deleting thin air.

Share this post


Link to post
Share on other sites
fnc_pickup =
{
hint "fired";
_item = _this select 0;
_plr = _this select 1;
_itemClass = typeOf (_item select 0);
_indexNum = itemArray find _itemClass;
_plrInv = profileNamespace getVariable "VirtualInventory";
_amount = _plrInv select _indexNum;
_plrInv set [_indexNum, _amount +1];
profileNamespace setVariable ["VirtualInventory",_plrInv];
_plrInv = profileNamespace getVariable "VirtualInventory";
hint format ["%1",_item];

deleteVehicle (_this select 0);

};

This is the code i'm using, the object calls it via an addAction put on the object however, in the future it wont be an addAction in its init line

Share this post


Link to post
Share on other sites

so _item is an array according to this?

_itemClass = typeOf (_item select 0);

you cannot delete array with deleteVehicle

Share this post


Link to post
Share on other sites

_item is the whole id name sort of of the item (a rice box for example) and _itemClass is the pure classname itself (land_rice_somethinghereidk.p3d)

 

And ah okay, how would i go on about deleting the object?

Share this post


Link to post
Share on other sites

Wait, can't you simply do a

 

{  delteVehicle _x } forEach arrayname;

 

?

Share this post


Link to post
Share on other sites

Thank you! It works, however it gives me a weird error (even tho it works) deleteVehicle type number, expected object?

Share this post


Link to post
Share on other sites

What about forEach units arrayname; ? (not tested, just guessing right now)

Share this post


Link to post
Share on other sites

It's okay, i solved it with 

_itemTake = _item select 0;


_itemTake = deleteVehicle _itemTake;

:)

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  

×