Jump to content
Sign in to follow this  
Ajira

What am i doing wrong ?

Recommended Posts

I'm trying to clean up the junk that is left on the floor when you change weapons at an ammo box. But somehow it's not working..

In the player's "init':

this AddEventHandler ["LoadOutChanged",{{deleteVehicle _x} forEach ((getPos player) nearObjects ["WeaponHolder",20])}]; 

anybody got an idea ? :confused:

Share this post


Link to post
Share on other sites

Well if you guys know another way to clean up the junk that is left behind when using an ammobox, then i'm all ears :)

Share this post


Link to post
Share on other sites

Try a global nearsObject like:

_list = getpos player nearObjects 20;

then substract the common types ("Air","Car","Structure"...).

Share this post


Link to post
Share on other sites

Well, to delete the nearest Weaponholder is no problem:

_weaponholders = nearestObjects[player,["WeaponHolder"],5];
deleteVehicle _weaponholders select 0;

This would delete the nearest WeaponHolder.

Your problem atm is to detect when the players loadout changed. Have no idea how to do that without hax0ring.

Share this post


Link to post
Share on other sites

Would it work if I set a loop on the ammobox like this ?

while {alive _this} do {
 _return = _this execVM "scripts\misc_loadammo.sqf"; //refill the ammobox.

 _weaponholders = nearestObjects[_this, ["WeaponHolder"], 5];
 {
   deleteVehicle _x;
 } foreach ( _weaponholders select 0);

 sleep 60;
}

Share this post


Link to post
Share on other sites

That last post about the topic title is likely to attract an argument mate, prob best edit it out, we're all good people here afterall so be friendly ;)

Ajira The code looks good to me very nice and tidy solution you've taught me some stuff. Variable _weaponholders becomes and array full of nearestobject(s) of type "WeaponHolder"(s) and then you delete the first entry which is obviously the junk on the floor.

It looks ok to me how did it get on in testing?

Share this post


Link to post
Share on other sites
Not putting enough detail in the title of the tread?

lol Wastelander.

while {alive _this} do {
 _return = _this execVM "scripts\misc_loadammo.sqf"; //refill the ammobox.

 _weaponholders = nearestObjects[_this, ["WeaponHolder"], 5];
 {
   deleteVehicle _x;
 } foreach ( _weaponholders select 0);

 sleep 60;
}  

That should work fine.

Edited by Rommel

Share this post


Link to post
Share on other sites

Yep it works just fine. Stuff stays on the ground for about a minute and then poofs. :D

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  

×