Jump to content
  • 0

Loot populated "Storage" EG Sheds per reboot?


Cannon

Question

Hey all,

So I'm customising our map and I want a few of the AI bases to have storages sheds etc that fill with loot once per restart.

 

I can write the script to spawn the loot or do a random check to spawn in a selection of loot in various quantities but I have no idea how to apply this to say, a Wood_shed or such like once per restart??

 

Anyone got any clever Ideas or am I missing something obvious?

 

(I'm very new to all this and I've only been looking into scripting for a week now and have learnt a LOT from constantly breaking my new server trying to apply other peoples scripts and have even managed to butcher a few to customize them or straight up fix them so now I want to try something more ambitious but google is failing me and I have no idea what the next step should be..)

Link to comment
Share on other sites

4 answers to this question

Recommended Posts

  • 0

Just a rough idea from memory (i'm sure it works like filling a ammo crate).

Might work, might not. But it's close either way :P

 

Create your spawn script (best to run it server side, in your modules or custom folder):

_vehicle = createVehicle ["VEHICLE_ID_HERE","WORLDSPACE_HERE",[], 0, "CAN_COLLIDE"];
[_vehicle] execVM "\z\addons\dayz_server\modules\loot.sqf";
_vehicle setVariable ["permaLoot",true]; // This stops the Vehicle being deleted

Then create your loot script:

_vehicle = _this select 0;

_vehicle addWeaponCargoGlobal ["ItemMatchbox_DZE", 16];

_vehicle addMagazineCargoGlobal ["ItemSodaCoke",(random 40)];
_vehicle addMagazineCargoGlobal ["ItemSodaPepsi",(random 30)];
_vehicle addMagazineCargoGlobal ["ItemSodaMdew",(random 30)];
_vehicle addMagazineCargoGlobal ["ItemSodaR4z0r",(random 3)];
_vehicle addMagazineCargoGlobal ["ItemSodaRbull",(random 3)];
_vehicle addMagazineCargoGlobal ["ItemSodaOrangeSherbet",(random 3)];

_vehicle addMagazineCargoGlobal ["FoodCanBakedBeans",(random 5)];
_vehicle addMagazineCargoGlobal ["FoodCanFrankBeans",(random 30)];
_vehicle addMagazineCargoGlobal ["FoodCanPasta",(random 30)];
_vehicle addMagazineCargoGlobal ["FoodCanSardines",(random 30)];
_vehicle addMagazineCargoGlobal ["FoodMRE",(random 30)];
_vehicle addMagazineCargoGlobal ["FoodPistachio",(random 30)];
_vehicle addMagazineCargoGlobal ["FoodNutmix",(random 30)];

_vehicle addMagazineCargoGlobal ["ItemHeatPack",(random 30)];
_vehicle addMagazineCargoGlobal ["ItemBandage", (random 30)];
_vehicle addMagazineCargoGlobal ["ItemMorphine", (random 30)];
_vehicle addMagazineCargoGlobal ["ItemEpinephrine", (random 30)];
_vehicle addMagazineCargoGlobal ["ItemPainkiller", (random 30)];
_vehicle addMagazineCargoGlobal ["ItemSodaCoke", (random 30)];
_vehicle addMagazineCargoGlobal ["FoodCanBakedBeans", (random 30)];
_vehicle addMagazineCargoGlobal ["ItemAntibiotic", (random 30)];
_vehicle addMagazineCargoGlobal ["ItemBloodbag", (random 30)];

_vehicle addBackpackCargoGlobal ['DZ_LargeGunBag_EP1',1];

If that works, share your script ;)

Link to comment
Share on other sites

  • 0

Ahh! So instead of trying to populate a building that I've already created in the map editor I'll have it spawn in each server restart? that seems like quite an elegent solltion thank you :)

 

I assume as this doesn't save to the Database (dynamic spawn) there is no worry about ending up with 100 stacked sheds :)

 

I'll give it a try tonight and let you know how I get on thank you!

Link to comment
Share on other sites

  • 0

Yes, spawn them in at server start up using seperate scripts.  Makes it easier to change later on.  You might want to remove them for example, this way you can without having to edit the custom map editions sqf (I use this method so I can add a random event variable, will the shed be there this restart? who knows, they'll have to find out) .. You won't get 100 stacked sheds, unless you actually spawn 100 stacked sheds :P

 

Make sure to run the scripts with 

 

if (isServer) then { 

 

So that it only runs once and only runs on the server :D

You know how to call files from the server pbo , right ? (i.e server side)

 

good luck.

Link to comment
Share on other sites

  • 0

Ya I put everythingI can in the PBO and call it in init.sqf with z\etc\etc to keep the mission file down as much as I can.

I'll probably have the scripts for the actual loot generation kept in the unpacked folders just so I don't have to unpack-repack the PBO everytime I want to edit the loot tables :)

 

Thanks ;)

 

Can I ask though why the "CargoGlobal", not familiar with this  term and I was just going to "AddItem" etc ;)
I was expecting to have to do a random x then say if y, spawn but in your example it looks like I only need to say Random x and then I assume that's just the % chance of it spawning?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...