Jump to content
ALPHIVE

How make box with stuff saved at each restart ?

Recommended Posts

Hi everybody !

 

Im searching how to make a box (named "box_alpha_1", that can be saved by the player, or automaticly, to avoid wipe when restart happens

Someone told me about InventoryOpen and InventoryClosed, but i dont know really what is this

 

Do you know a way ?


Thanks guys !

Share this post


Link to post
Share on other sites

My approach would be to use the ContainerClosed EH. This structure might give you a general idea:

// Init field of the box
if (isServer) then {
	this addEventHandler ["ContainerClosed", {
		params ["_container", "_unit"];
		// Get the container cargo (?)
		// _cargo = itemCargo _container; //???
		profilenamespace setvariable ["your_cargo_var",_cargo];
	}];
};

The code would be executed everytime the box was accessed and items potentially altered. Saving the contents periodically seems unneccessary as it only affects performance while the items shouldn't change without any player interaction.

Getting the cargo is another story though. I think I saw some code here on the forums but couldnt find it so far. Using profileNamespace is also not the perfect way as it clutters the users profileNamespace. It is the easiest option for persistency though.

  • Like 3

Share this post


Link to post
Share on other sites

I do something similar for the group of guys that I play with to emulate 'dwindling supplies' at the end of each mission. I use a trigger to report the contents of the crates containing our ammo and other supplies to the server.rpt right before the mission ends. I then can go through, pull those lines of code, and adjust the starting contents of the crates for the next mission. You could add the script to fire on a repeatable addAction or something similar. But it won't automatically update your crate, so it may not be the solution you are looking for.
 

_ammo1 = getMagazineCargo ammo1;
_ammo2 = getMagazineCargo ammo2;
_ammo3 = getMagazineCargo ammo3;
_ammo3_1 = getItemCargo ammo3;
_med1 = getItemCargo med1;
_med2 = getItemCargo med2;
_med3 = getItemCargo med3;
_med4 = getItemCargo med4;
_med5 = getItemCargo med5;
_food3 = getItemCargo food3;
_food2 = getItemCargo food2;
_food1 = getItemCargo food1;
_drink1 = getItemCargo drink1;
_drink2 = getItemCargo drink2;
_dumpAmmo = getMagazineCargo dump1;
_dumpItem = getItemCargo dump1;
copyToClipboard str _ammo1;
diag_log _ammo1;
copyToClipboard str _ammo2;
diag_log _ammo2;
copyToClipboard str _ammo3;
diag_log _ammo3;
copyToClipboard str _ammo3_1;
diag_log _ammo3_1;
copyToClipboard str _med1;
diag_log _med1;
copyToClipboard str _med2;
diag_log _med2;
copyToClipboard str _med3;
diag_log _med3;
copyToClipboard str _med4;
diag_log _med4;
copyToClipboard str _med5;
diag_log _med5;
copyToClipboard str _food1;
diag_log _food1;
copyToClipboard str _food2;
diag_log _food2;
copyToClipboard str _food3;
diag_log _food3;
copyToClipboard str _drink1;
diag_log _drink1;
copyToClipboard str _drink2;
diag_log _drink2;
copyToClipboard str _dumpAmmo;
diag_log _dumpAmmo;
copyToClipboard str _dumpItem;
diag_log _dumpItem;

 

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

×