Online 1 Posted April 22, 2013 Hi Guys, i searched a loop function, but i am not sure what i need. I have a script to remove the nvgoggles, but after the respawn everyone has again the goggles. My .sqf { { if (side _x == east) then { _x unassignItem "NVGoggles"; _x removeItem "NVGoggles"; }; } foreach allunits; { if (side _y == west) then { _y unassignItem "NVGoggles"; _yremoveItem "NVGoggles"; }; } foreach allunits; }; I have also a virtual ammobox on my map and the people should take the normal gear, but only without the nvgoggles. The script works fine and it should only repeat every 5 or 10 seconds maybe. Regards Share this post Link to post Share on other sites
killzone_kid 1332 Posted April 22, 2013 _x is special variable, it is not a Cartesian coordinate so using _y in second loop do nothing. Share this post Link to post Share on other sites
mikie boy 18 Posted April 22, 2013 that should do it, since you are removing it from boths sides { _x unassignItem "NVGoggles"; _x removeItem "NVGoggles"; } foreach allunits; Share this post Link to post Share on other sites
Waffle_SS 11 Posted April 22, 2013 Just use <objectname> setVehicleInit "<delete NVGs>" Share this post Link to post Share on other sites
Online 1 Posted April 22, 2013 i had _x for both before, and this works for both sides. I know i have no loop included at the moment. I know that loop do nothing, because i ask how to loop this function. Share this post Link to post Share on other sites
bangabob 45 Posted April 22, 2013 Simple loop script while {true} do {Your script here ; Sleep 5;}; Share this post Link to post Share on other sites
Online 1 Posted April 22, 2013 Thanks Mikie boy, i will change it. I will try thy loop script. And if i use this, how fast will work this loop? Instant if a player try to get the goggles? Share this post Link to post Share on other sites
bangabob 45 Posted April 22, 2013 Every 5 seconds. Thus the sleep command at the end of each loop Share this post Link to post Share on other sites
Online 1 Posted April 22, 2013 Yes now i see, my fault :) ---------- Post added at 19:06 ---------- Previous post was at 19:04 ---------- Now i have this: while {true} do { _x unassignItem "NVGoggles"; _x removeItem "NVGoggles"; } foreach allunits; Sleep 5;}; But the script doesnt work now. Share this post Link to post Share on other sites
bangabob 45 Posted April 22, 2013 try putting this at the top of the script private [_x]; Share this post Link to post Share on other sites
Online 1 Posted April 22, 2013 while {true} do { private [_x]; _x unassignItem "NVGoggles"; _x removeItem "NVGoggles"; } foreach allunits; Sleep 5;}; Now change Share this post Link to post Share on other sites
bangabob 45 Posted April 22, 2013 while {true} do { { { if (side _x == east) then { _x unassignItem "NVGoggles"; _x removeItem "NVGoggles"; }; } foreach allunits; { if (side _y == west) then { _y unassignItem "NVGoggles"; _yremoveItem "NVGoggles"; }; } foreach allunits; }; Sleep 5;}; Try that. 1 Share this post Link to post Share on other sites
Online 1 Posted April 22, 2013 Okay just a second :) ---------- Post added at 19:24 ---------- Previous post was at 19:16 ---------- What the hell.. now the script doesnt work, i mean without the loop. I use the same script like in the beginning and now it doenst work, how can that happend? ---------- Post added at 19:37 ---------- Previous post was at 19:24 ---------- Perfect!! Now it works fine. :D I used this: while {true} do { { if (side _x == east) then { _x unassignItem "NVGoggles"; _x removeItem "NVGoggles"; }; } foreach allunits; { if (side _x == west) then { _x unassignItem "NVGoggles"; _x removeItem "NVGoggles"; }; } foreach allunits; Sleep 5;}; Really big thanks BangaBob! Share this post Link to post Share on other sites
killzone_kid 1332 Posted April 22, 2013 try putting this at the top of the scriptprivate [_x]; it is private ["_x"]; (quotation mark) and you also dont need it since _x is special variable it is private by default within the scope. Share this post Link to post Share on other sites
mikie boy 18 Posted April 22, 2013 Sorry didnt see the bit that you required a loop, in any case I don't seethe relevance of differentiating between side if you are taking the NV goggles from everyone. Would assume its pointless waste of cpu wizardry :) while {true} do { { _x unassignItem "NVGoggles"; _x removeItem "NVGoggles"; } foreach allunits; Sleep 5; }; If you dont need a loop to remove the goggles and only for respawn you could always just plop this into the init.sqf; RemoveGoggles= compile (preprocessFileLineNumbers "RemoveGoggles.sqf"); player addEventHandler ["Killed",{[_this select 0] spawn RemoveGoggles; }]; RemoveGoggles.sqf Waitunily {!isnull Player}; _respawnedDude = _this select 0; _respawnedDude unassignItem "NVGoggles"; _respawnedDude removeItem "NVGoggles"; not tested but just a thought :) Share this post Link to post Share on other sites
Harzach 2518 Posted April 22, 2013 *edit* - ninja'd by Mikie Share this post Link to post Share on other sites
Online 1 Posted April 23, 2013 It works fine now and i dont want to edit. "Dont change a running system" ;) Btw. i need the loop, because i have a virtual ammobox and the people should use every weapon and saved kits but only without the nv. Its a night mission and a lot more action if the people only use the lamp at the weapon. Share this post Link to post Share on other sites
bangabob 45 Posted April 23, 2013 BTW you can easily remove the NVgoggles from VAS. Search for the missionfolder/gear/config.sqf Iniside the config file just add "NVGoggles" to the bottom string //Items to remove from VAS vas_r_items = []; So it looks like //Items to remove from VAS vas_r_items = ["NVGoggles"]; Share this post Link to post Share on other sites
mikie boy 18 Posted April 23, 2013 Lol. Nice one. Online suggest u use that method instead of having an unnecessary loop. Share this post Link to post Share on other sites
Online 1 Posted April 23, 2013 I think i use at first my method and if i will have cpu or other problems, i will try the other one. Or i try this later, but for now it works. :) But the tip with the VAS is really helpful. Thanks to everyone!!! Share this post Link to post Share on other sites