Texeiro 15 Posted June 17, 2019 Hi, Im trying to make a script to refiil an ammo box only with explosives, until a max number. Also, I want to made that when I take some explosives out of the box, the box refill again. What I did: _magazines = count (magazineCargo crate); for [{_magazines=1},{_magazines<=10},{_magazines=_magazines+1}] do { crate addMagazineCargo ["SatchelCharge_Remote_Mag", 1]; sleep 1; hint format ["Total explosives %1",_magazines + 1]; sleep 0.5; _magazines = _magazines + 1; }; That code fill the box, but when I take a cargo out, it doesn´t refill. Could anyone help me? Share this post Link to post Share on other sites
Mr H. 402 Posted June 17, 2019 I wrote one that refills the crate, here: https://github.com/MisterHLunaticwraith/MRHMilsimTools/blob/master/Addons/MRHFunctions/functions/MRHUtilities/fn_RefillBox.sqf you just have to add the explosives before calling the function. **Advertising minute: of course feel free to use the function and modify it as you please, but should you wish to use the whole mod it adds an attribute to containers that allows mission makers to make them infinite ** Advertising minute ends here 😉 1 Share this post Link to post Share on other sites
Texeiro 15 Posted June 17, 2019 thanks Mr. H! I ll check your script, but I want a limited cargo in box, not unlimited. I ll explain my whole intention: I want to set an IED factory with this logic: Bombmaker sits in area factory. Bombmaker is alive Bombmaker has material (i.e. C4 in the ammobox) Bombmaker build an IED each 30 minutes and puts it in ammo box. If a player takes 1/2/3 IED´s, and above conditions are still on-------> bombmaker will buil 1/2/3 IED´s in the next 3 minutes. Share this post Link to post Share on other sites
Mr H. 402 Posted June 17, 2019 Okay my bad I read too quickly however you can still use : _box addEventHandler ["ContainerOpened" to check the contents of the box whenever it's opened. 2 Share this post Link to post Share on other sites
Texeiro 15 Posted June 21, 2019 Quote Tried a couple new approarchs,, didn t work.... This: _crateCont = getItemCargo crate; _ammo = _crateCont select 1; hint format [" satchels %1", _crateCont select 1 ]; while {_ammo <= 10} do { crate addMagazineCargo ["SatchelCharge_Remote_Mag", 1]; sleep 2; ----------------------------------------------------------------------------- adn this: magazinesqw = count (magazineCargo crate); while {magazinesqw <= 10} do { crate addMagazineCargo ["SatchelCharge_Remote_Mag", 1]; sleep 1; hint format ["Total explosives %1",magazinesqw + 1]; sleep 0.5; magazinesqw = magazinesqw + 1; }; with magazomesqw = 0 in init.sqf REfreshing what I m trying to do: Bombmaker sits in area factory. Bombmaker is alive Bombmaker has material (i.e. C4 in the ammobox) Bombmaker build an IED each 30 minutes and puts it in ammo box. If a player takes 1/2/3 IED´s, and above conditions are still on-------> bombmaker will buil 1/2/3 IED´s in the next 3 minutes Of course, if player take explosives from ammo box, loop would work again... I tried also defining a varible as _explosive = SatchelCarge_Remote_Mag, but for some reason it wasn´t "readable". Please, If someone could give me a hand at this... Share this post Link to post Share on other sites
Dedmen 2691 Posted June 21, 2019 7 hours ago, Texeiro said: while {_ammo <= 10} do { crate addMagazineCargo ["SatchelCharge_Remote_Mag", 1]; Your _ammo variable is never updated. It will always keep the same value, so either you are adding infinite magazines or none. Also you maybe should use addMagazineCargoGlobal. 7 hours ago, Texeiro said: with magazomesqw = 0 in init.sqf 🤔 7 hours ago, Texeiro said: magazinesqw 7 hours ago, Texeiro said: magazomesqw You got a typo there 7 hours ago, Texeiro said: I tried also defining a varible as _explosive = SatchelCarge_Remote_Mag, but for some reason it wasn´t "readable". You tried to read a variable called "SatchelCarge_Remote_Mag" which most likely is not defined. 1 Share this post Link to post Share on other sites
Texeiro 15 Posted June 21, 2019 3 hours ago, Dedmen said: 11 hours ago, Texeiro said: while {_ammo <= 10} do { crate addMagazineCargo ["SatchelCharge_Remote_Mag", 1]; Your _ammo variable is never updated. It will always keep the same value, so either you are adding infinite magazines or none. I thought I had defined _ammmo in the previous line Yes you re rigth, It must be used AddmagazineCargoGlobal. The typos, are typos in here, in the sqf are ok. 3 hours ago, Dedmen said: 11 hours ago, Texeiro said: I tried also defining a varible as _explosive = SatchelCarge_Remote_Mag, but for some reason it wasn´t "readable". You tried to read a variable called "SatchelCarge_Remote_Mag" which most likely is not defined. mmmm....Again I m making an error defining a variable...I thougth that _explosive = SatchelCarge_Remote_Mag was ok. Please, could you tell me whats the right way to do it? And thank you Dedmen, vey much for your answer and your patience. Share this post Link to post Share on other sites
Dedmen 2691 Posted June 21, 2019 5 hours ago, Texeiro said: I thought I had defined _ammmo in the previous line You did, but you never change it's value after that. 5 hours ago, Texeiro said: The typos, are typos in here, in the sqf are ok. Please only post the EXACT code you are using, if you don't then all attempts to troubleshoot are useless. 5 hours ago, Texeiro said: Please, could you tell me whats the right way to do it? I have no idea what you are trying to do there. 1 Share this post Link to post Share on other sites