God of Monkeys 14 Posted July 3, 2018 Hi, I want to add some variable on my custom item, the variable main purpose is log how many times this item use by any player.(multiplayer) So when this item used times is up to like 10 time, this item will disable and never can be use again. So if there is anyway can get the object in item, then I can setVariable on it and let anyone to take this item, and he will know the use limit. Can this possible? Thx Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted July 3, 2018 9 minutes ago, God of Monkeys said: Hi, I want to add some variable on my custom item, the variable main purpose is log how many times this item use by any player.(multiplayer) So when this item used times is up to like 10 time, this item will disable and never can be use again. So if there is anyway can get the object in item, then I can setVariable on it and let anyone to take this item, and he will know the use limit. Can this possible? Thx Could you give a less abstract example? Cheers 1 1 Share this post Link to post Share on other sites
Dedmen 2703 Posted July 3, 2018 17 minutes ago, God of Monkeys said: So if there is anyway can get the object in item, then I can setVariable on it No. Not possible. If you are making a mod you can just make a thousand different items with a unique ID and only create one item for each ID and track them that way. 1 Share this post Link to post Share on other sites
HazJ 1289 Posted July 3, 2018 Unless it virtual inventory UI and system. Share this post Link to post Share on other sites
xjoker_ 25 Posted July 3, 2018 2 hours ago, Dedmen said: No. Not possible. If you are making a mod you can just make a thousand different items with a unique ID and only create one item for each ID and track them that way. That's what TFAR do, isn't it ? How do you "track" these items to be sure not to create a dupplicate ? Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted July 3, 2018 2 hours ago, Dedmen said: No. Not possible. If you are making a mod you can just make a thousand different items with a unique ID and only create one item for each ID and track them that way. Well you can track an item, who had it, in what container did that unit put the item, etc. Things get odd when there's multiple items of same type in the same container, but other than that it's doable without an ID. Unless the thread starter elaborates further it's mostly assumptions at this point. Cheers Share this post Link to post Share on other sites
Dedmen 2703 Posted July 3, 2018 26 minutes ago, xjoker_ said: That's what TFAR do, isn't it ? How do you "track" these items to be sure not to create a dupplicate ? Yes. And the ID's are tracked on the server. The server just keeps a counter. And everytime someone requests a unique item the server increments the counter and returns the item with the ID according to the counter. Share this post Link to post Share on other sites
God of Monkeys 14 Posted July 5, 2018 On 2018/7/3 at 6:29 PM, Grumpy Old Man said: Could you give a less abstract example? Cheers On 2018/7/3 at 6:38 PM, Dedmen said: No. Not possible. If you are making a mod you can just make a thousand different items with a unique ID and only create one item for each ID and track them that way. Hi, sorry for my late reply. Fire, you can see this Github. I'm working with this author to implementation use times limit to simulate the power of AED. So if that AED use over the limit times, than I think we can remove the old AED and add a AED (consumed) into player inventory just like AT-4 (used). After I look your reply, I guess we can only get an unique name of the item on the ground.(the variable name is spawn by game engine) But when this item in the inventory or box container we can't get a same variable name to track this item, so we must spawn our own Id on server to track them? In first I think we can add some variable in config init event like this:("ADV_aceCPR_AED_UseLimit") class adv_aceCPR_AEDItem: Item_Base_F { scope = 2; scopeCurator = 2; displayName = "$STR_ADV_ACECPR_AED_DISPLAYNAME"; author = "[SeL] Belbo"; vehicleClass = "Items"; model = "\A3\Structures_F_EPA\Items\Medical\Defibrillator_F.p3d"; class TransportItems { MACRO_ADDITEM(adv_aceCPR_AED,1); }; class EventHandlers { init = "(_this select 0) setVariable ["ADV_aceCPR_AED_UseLimit",20]"; }; }; So we can simply use this variable to count the use times. But this idea is dead because we can't get that variable name. So if I use your example of TFAR, we just use the config init event to spawn a request for server to get a unique Id and let server track this item, is this right ? Thx Share this post Link to post Share on other sites
Dedmen 2703 Posted July 6, 2018 11 hours ago, God of Monkeys said: So if that AED use over the limit times, than I think we can remove the old AED and add a AED (consumed) into player inventory just like AT-4 (used). As you say AT-4. You could make the AED a pistol with "magazines" :D Or put it in the launcher slot so you have it on your back. 11 hours ago, God of Monkeys said: After I look your reply, I guess we can only get an unique name of the item on the ground No you can't. You can give the weaponHolder on the ground a name. But anyone can put any items in there or take them out and the name would still stay on the weaponHolder. A weaponHolder is kind of like a invisible box on the ground. 11 hours ago, God of Monkeys said: In first I think we can add some variable in config init event like this You cannot add Variables to Items. You could also just believe me if I say On 3.7.2018 at 12:38 PM, Dedmen said: No. Not possible. 11 hours ago, God of Monkeys said: So if I use your example of TFAR, we just use the config init event to spawn a request for server to get a unique Id and let server track this item, is this right ? Yes. You'd essentially make 1000 or more AED classes with a different classname for each one. Then you make sure that only one of each classname ever exists. And then you can just track it by it's classname. Other alternative would be to make the AED a magazine. Then you can just reduce the ammoCount on each use and if it reaches 0 you can't use it anymore. Share this post Link to post Share on other sites
HazJ 1289 Posted July 6, 2018 @Dedmen - I believe you. Share this post Link to post Share on other sites
Mr H. 402 Posted July 7, 2018 ACRE2 tracks its radios too but they only appear as the same item in the inventory, maybe they use a different method. Share this post Link to post Share on other sites
God of Monkeys 14 Posted July 9, 2018 On 2018/7/6 at 3:29 PM, Dedmen said: As you say AT-...... Roger that, thank your reply, I will try your way :) Share this post Link to post Share on other sites
computer 113 Posted July 9, 2018 Look at this mod: https://steamcommunity.com/sharedfiles/filedetails/?id=753946944 This mod solves the problem by using a magazine as an item(matchbox), every use of the item uses 1 bullet (via scripting). Hope this helps Share this post Link to post Share on other sites
Dedmen 2703 Posted July 9, 2018 On 7.7.2018 at 9:07 AM, Mr H. said: ACRE2 tracks its radios too but they only appear as the same item in the inventory, maybe they use a different method. Nope they do the same thing. TFAR items also appear as the same item. Well mostly. We also show the actual ID used in the displayName 39 minutes ago, computer said: Look at this mod: Yes! That's: On 6.7.2018 at 9:29 AM, Dedmen said: Other alternative would be to make the AED a magazine. Then you can just reduce the ammoCount on each use and if it reaches 0 you can't use it anymore. And in this case where you basically only want to track a decreasing number and nothing else. That is the most elegant approach. You don't even need to track each item. And the player also get's a nice "uses left" indicator. And I think it would probably also work with ACE magazine repacking :D So you can repack 2 half full AED batteries together to one full battery :D 2 Share this post Link to post Share on other sites