Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
Sign in to follow this  
Hath Kull

Storing player's equipment in a crate

Recommended Posts

Hi,

my problem seems to never have been asked by anyone.

I want to strip the player of every piece of equipment and put it all in a nearby ammobox or something (so he can pick it up again later). Has anyone an idea?

[i built a shooting range with randomly appearing targets and all the stuff. Now I want the player to lose all of his equipment first. Then he should get a training weapon of his choice. Nothing big, except for the equipment moving from the player to the storage device.]

Hath Kull

Fight for the light, die for the light and once it may shine upon thee.

Share this post


Link to post
Share on other sites

Try this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

private ["_w","_m","_unit","_crate"]

_unit = _this select 0

_crate = _this select 1

_w = weapons _unit

_m = magazines _unit

{_crate addweaponcargo [_x,1]} foreach _w

{_crate addmagazinecargo [_x,1]} foreach _m

removeallweapons _unit

exit

save this in your mission folder as something (e.g. "putequipment.sqs")

then whenever you want to run it:

[<unitname>,<cratename>] exec "putequipment.sqs"

Share this post


Link to post
Share on other sites

AN ARRAY! Of course!

Thanks man. Sometime I'll help you out...

Hath Kull

Share this post


Link to post
Share on other sites

Hey Mr. Crashdome,

I was a little too enthusiastic before. For some reason the script doesn't work. The player has no weapons anymore, but they don't get stored in the crate. Apparently (according to the ComRef) the "weapons" and "magazines" commands are designed for vehicles only - so that's probably the crucial point.

To sum up, it does not work. I'd appreciate any other ideas.

Hath Kull

Share this post


Link to post
Share on other sites

Hmm.. it should work.

"weapons" and "magazines" do work on any unit.

I assume you are trying in SP or in Preview mode?

let me do a quick test....

Yup.. worked fine for me.

Double Check the following:

<ul>[*] script is exactly as above (use copy/paste)

[*]you have named both the unit AND the ammo crate

[*]you call the script with both the unit's AND the ammocrate's name (e.g. [player,crate1] exec "putequipment.sqs")

notes:

<ul>[*]you can use this on vehicles with cargo holds

[*]this script will NOT work in MP because only the unit that called the script will see what is in the crate.

Share this post


Link to post
Share on other sites

Don't know what I did wrong the first time. I just tried again in a blank mission. Now it works perfectly good. Exactly what I was searching for.

Thanx,

Hath Kull

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  

×