Koni 1 Posted May 24, 2011 Can this be detected when a unit or player opens up the menu screen of a ammo box to look inside it ? Thanks Share this post Link to post Share on other sites
Koni 1 Posted May 26, 2011 The only way I can think of to create this kind of condition is to place a unique nice weapon that will tempt the player to pick it up, then use the player has weaponName to know they have been in that ammo box. Is there not a better way ? Share this post Link to post Share on other sites
sxp2high 16 Posted May 26, 2011 Place a box somewhere on the map with your contents. Name it RealBox. Place a cargo container or similar and put this into it's init line: this addAction ["Gear","Gear.sqf"]; Gear.sqf: _Player = _this select 1; _Player action ["Gear", RealBox]; hint "Viewing the box..."; Cargo container because i don't know how to remove the original "gear" action from boxes. So when you use this on a crate it would have 2 Gear actions. :( Share this post Link to post Share on other sites
Tankbuster 1533 Posted May 26, 2011 Isn't that going to add a spurious action menu - yours plus the box one? I'd add an eventhandler to the unit, maybe animstatechanged and check when the unit goes into the reload anim. Then run a script and check his nearest objects, if there's an ammobox within 2 meters, it's probably safe to assume he's in the ammobox. Share this post Link to post Share on other sites
2nd ranger 275 Posted May 26, 2011 Cargo container because i don't know how to remove the original "gear" action from boxes. So when you use this on a crate it would have 2 Gear actions. :( In that case he could just use the Ammo Crate objects in Objects (Military) for the 'fake' crate. They are just objects with no gear capability. Share this post Link to post Share on other sites
sxp2high 16 Posted May 26, 2011 (edited) Yea thats why i suggested a cargo container or so. Would be perfect if theres a way to remove the original Gear action. :) But youre right, animchanged is maybe better... @2nd Ranger Sounds good! :) Edit2: I've just discovered that "somewhere on the map" isn't working. The real box needs to be < 2 meters away from the player for access. So you have to put this into the RealBox's init line too: this attachTo [FakeBox,[0,0,-1.9]]; hideObject this; Edited May 26, 2011 by sxp2high Share this post Link to post Share on other sites
Koni 1 Posted May 26, 2011 Ok, RealBox is the Ammo box I want to detect when someone goes into it, so I placed the RealBox called RealBox, then placed a Cargo Container and called it FakeBox. In the FakeBox init line I put this addAction ["Gear","Gear.sqf"]; then made the gear.sqf. In the RealBox init line I put this attachTo [FakeBox,[0,0,-1.9]]; hideObject this; but that just hides both boxes for me. I've swapped around and put the init lines info in the others init line if you know what I mean, and that then gives me the RealBox still on the surface, but with 2 gear options, one activates the script the second dosent. Share this post Link to post Share on other sites
f2k sel 145 Posted May 26, 2011 (edited) I had a problem of where to place the box so it opens correctly, using large items made the problem worse. in the end it's quite simple. Place the real box on the map and use hideobjet this in the init and name it realbox place the fakebox and in the init put this addAction ["Gear","Gear.sqf"]; and name it fakebox then save the code as Gear.sqf //this addaction ["Gear","Gear.sqf",[], 6, true, true, "", "(_this distance (_target))<2"]; _Player = _this select 1; realbox setpos position _player ; _Player action ["Gear", RealBox]; hint "Viewing the box..."; All it does is at the time of trying to open the fake box it moves the invisible box to the player so placing it within 2meters. Edited August 4, 2011 by F2k Sel Share this post Link to post Share on other sites
kylania 546 Posted May 26, 2011 You can check animation states, this is how Evolution originally did the 'save gear' thing. Share this post Link to post Share on other sites
Koni 1 Posted May 28, 2011 I had a problem of where to place the box so it opens correctly, using large items made the problem worse.in the end it's quite simple. Place the real box on the map and use hideobjet this in the init and name it realbox place the fakebox and in the init put this addAction ["Gear","Gear.sqf"]; and name it fakebox then save the code as Gear.sqf //this addAction ["Gear","Gear.sqf"]; _Player = _this select 1; realbox setpos position _player ; _Player action ["Gear", RealBox]; hint "Viewing the box..."; All it does is at the time of trying to open the fake box it moves the invisible box to the player so placing it within 2meters. Yeah this is nearly what I am after, though the only problem with this is that you can get the action to view the box contents from around 10 meters away... I think I need to sort out the animation states to get it right, as it looks a bit strange opening an ammo box from so far away, but thanks for the help :) Share this post Link to post Share on other sites
2nd ranger 275 Posted May 28, 2011 this addaction ["Gear","Gear.sqf",[], 6, true, true, "", "(_this distance (_target))<2"]; Should only get the action if you're within 2m. Share this post Link to post Share on other sites
f2k sel 145 Posted May 28, 2011 I was testing with the cargo container so it didn't look so bad. 2nd Ranger has the fix and it works well enough for the ammo crate but on the cargo container you either need to increase the range or place another object in front of the doors on the crate. It also has to be visible or it won't work. Share this post Link to post Share on other sites
Koni 1 Posted May 29, 2011 I was testing with the cargo container so it didn't look so bad. 2nd Ranger has the fix and it works well enough for the ammo crate but on the cargo container you either need to increase the range or place another object in front of the doors on the crate. It also has to be visible or it won't work. This now works exactly as I wanted it to, thanks 2nd Ranger and everyone else :D Share this post Link to post Share on other sites