XMDM 1 Posted February 28, 2013 Does anybody have, or know how to create, a cleanup script that cleans up gear items that are left lying on the ground? I've searched and seen the few scripts that clean up ordinance, bodies, and blown up vehicles, but I'm looking for the ability to basically clean up weapons, mags, and all the standard gear items. I have a script that causes people to drop all their items on the ground, so a cleanup would be great. Thanks guys! Share this post Link to post Share on other sites
nimrod_z 8 Posted February 28, 2013 just put this in a script - name it -- clear_items _obj = _this select 0; // object center point for radius. _rad = _this select 1; // radius outwards from center point to clear items. _clear = nearestObjects [_obj,["weaponholder"],_rad + 50]; for "_i" from 0 to count _clear - 1 do { deleteVehicle (_clear select _i); sleep 0.056; }; and call it with -- [obj_name, radius] execVM "clear_items.sqf"; example [trig1,1000] execVM "clear_items.sqf"; Share this post Link to post Share on other sites
XMDM 1 Posted February 28, 2013 Will try it tomorrow...thank you. Sent from my HTC6435LVW using Tapatalk 2 Share this post Link to post Share on other sites
XMDM 1 Posted February 28, 2013 Worked very well...I think I'm going to figure out how to run it on an hourly loop and have it clean the map by quadrants. Thanks nimrod. Share this post Link to post Share on other sites
_Mofo_ 1 Posted February 28, 2013 FSM would work nicely for you here. Set a timestamp in your init code.. then in your condition check that { current time >= (60 minutes + timestamp) } Execute your FSM last in your server init.sqf Share this post Link to post Share on other sites
avibird 1 141 Posted February 28, 2013 XMDM if you can get it to work then an example would be great if you could post one. Share this post Link to post Share on other sites
nimrod_z 8 Posted February 28, 2013 (edited) Worked very well...I think I'm going to figure out how to run it on an hourly loop and have it clean the map by quadrants. Thanks nimrod. easy enough because that was a snipt of that exact code ;) _obj = _this select 0; // object center point for radius. _rad = _this select 1; // radius outwards from center point to clear items. sleep 1800; // or whatever time you want.. _clear = nearestObjects [_obj,["weaponholder"],_rad + 50]; for "_i" from 0 to count _clear - 1 do { deleteVehicle (_clear select _i); sleep 0.056; }; [] execVM "itemspawning_script.sqf"; just simpley call the clear script at the very end of your item spawning script, then the sleep takes effect in the clearing script for however long you set it, then clears map/area then calls the item spawning script again.. endless cycle.. Edited March 1, 2013 by Nimrod_Z Share this post Link to post Share on other sites
XMDM 1 Posted March 1, 2013 Nimrod you're awesome! On the topic of FSMs...that's my next feat. Very interested in learning how to create those. Sent from my Nexus 7 using Tapatalk HD Share this post Link to post Share on other sites
_Mofo_ 1 Posted March 1, 2013 I'm still learning FSM's myself, but I'm grasping them more and more as time passes. Main things to understand about FSM & debugging... writing "in" the FSM then executing the code makes it somewhat difficult to track bugs AND you can only "ctrl + z" back one time. /:| What I "typically" do when writing a block of code to execute is attach cheat engine to OA and set it up so that I can execute my test script... then write code (in a sqf) and execute it in game to more or less have a working live debugger. Once the code is good... then it goes to the appropriate place in the FSM. Share this post Link to post Share on other sites
Bernds 1 Posted March 1, 2013 May I ask why the sleep 0.056; is needed and why you take exactly this value inside your code? Is this just 'a value by nose' or is there a given rule for this sleep values? Sorry for asking this, I'm just wondering about. Share this post Link to post Share on other sites
tryteyker 28 Posted March 1, 2013 Mostly sleeps in while or for loops are just so the loop does not miss anything. Without sleeps, this would all happen at an instant, but this causes the game to miss things most of the time (as the game isn't as fast as the script). That's why you add a sleep in loops. Share this post Link to post Share on other sites
Bernds 1 Posted March 1, 2013 Ok, I understand the meaning of the sleep command. My questions went into the direction where that used value for that sleep came from. It seems to me that these are values each scripter must try out until the script is working inside the game as wanted. Correct? Or are there given values you have to use for different operations? Share this post Link to post Share on other sites
nimrod_z 8 Posted March 1, 2013 May I ask why the sleep 0.056; is needed and why you take exactly this value inside your code?Is this just 'a value by nose' or is there a given rule for this sleep values? Sorry for asking this, I'm just wondering about. it's just a small sleep value. could be any number you want. without the sleep it would start the spawning stuff again without the clearing being completely finished. the sleep lets the clearing finish then goes onto the spawning script. Share this post Link to post Share on other sites
Bernds 1 Posted March 2, 2013 Thanks for the infos! Share this post Link to post Share on other sites
Cowboy Pilot 10 Posted July 18, 2013 just put this in a script - name it -- clear_items _obj = _this select 0; // object center point for radius. _rad = _this select 1; // radius outwards from center point to clear items. _clear = nearestObjects [_obj,["weaponholder"],_rad + 50]; for "_i" from 0 to count _clear - 1 do { deleteVehicle (_clear select _i); sleep 0.056; }; and call it with -- [obj_name, radius] execVM "clear_items.sqf"; example [trig1,1000] execVM "clear_items.sqf"; Or you could just do (and to make this generic for those without that item spawning script): while {true} do { private ["_obj", "_rad"]; _obj = _this select 0; // object center point for radius. _rad = _this select 1; // radius outwards from center point to clear items. _clear = nearestObjects [_obj,["weaponholder"],_rad + 50]; for "_i" from 0 to count _clear - 1 do { deleteVehicle (_clear select _i); sleep 0.056; }; sleep 1800; }; Share this post Link to post Share on other sites