wogz187 1086 Posted August 1, 2019 Null = this spawn {while {alive _this setfuel 1; sleep 60}}; Somehow, if you disregard the error after pasting into the init field, it will stick. And, after it's pasted successfully into the init of one vehicle, it will paste without error into other vehicles. It still doesn't activate the function though. 1 Share this post Link to post Share on other sites
avibird 1 154 Posted August 1, 2019 Lol it does for me all my vehicles get full tanks of fuel. Even if I manually deplete it through Zeus every minute it will fill the tanks for editor placed units. I tested it a few dozen times. The only vehicles that don't refuel is the patrol boats because I am using jebus to spawn the boat patrol there times in the mission and there is an issue carrying unit init box over when deleted at the start of mission with jebus. I already asked him on his thread about this issue. But the code above works. did you actually put it in the editor and run it to see if it works. Share this post Link to post Share on other sites
wogz187 1086 Posted August 1, 2019 @avibird 1, Quote did you actually put it in the editor and run it to see if it works. Absolutely. I have a test scenario dedicated to this topic. I pasted the code into the init of a quad-bike, depleted the quad-bike to 26% fuel and then hopped in the mission to drive past the 25% mark. Then I went to make coffee and had my son hold the "w" key while I did. At no point did the vehicle refuel. I'm not trying to mock you. I'm trying to help and to understand for myself. You got the benefit of the doubt and I wanted to see for myself.@Grumpy Old Man is likely correct that there is some bit of code or trigger hanging about that is actually responsible for the vehicle refueling you see. We participate in these discussions because we want people to succeed. 1 1 Share this post Link to post Share on other sites
avibird 1 154 Posted August 1, 2019 Never thought you were mocking me. Arma is a very strange bird when it comes to coding. It works for me and no other fuel script running in the mission% sure of that. I am not putting the code in the leader of a group init box I am putting it in the object init box. Are you putting the code in the soldier init box that is the leader or driving the vehicle? We are all hear for the love of the game and to help each other never thought you were mocking me. I would like to understand this as well this has me very confused 🤯 1 Share this post Link to post Share on other sites
Sgt. Dennenboom 98 Posted August 1, 2019 But to correct the code you're using (without regarding whether it's the best solution or not): In editor object init field: _null = this spawn {while {alive _this} do {_this setFuel 1; sleep 60;};}; 4 1 Share this post Link to post Share on other sites
avibird 1 154 Posted August 1, 2019 My code Null = this spawn {while {alive _this setfuel 1; sleep 60}}; Your code _null = this spawn {while {alive _this} do {_this setFuel 1; sleep 60;};}; Thank you for correcting my code error but it still works if you place in object init not unit init. I don't understand why people saying that it's not working for them unless they're not putting in the object in it. I will test your code snippet I report if any difference with how it works in the mission. Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted August 1, 2019 4 minutes ago, avibird 1 said: Thank you for correcting my code error but it still works if you place in object init not unit init. I don't understand why people saying that it's not working for them unless they're not putting in the object in it. Where exactly would be the difference between object and unit init? Are you sure you're still talking about arma here? Cheers 1 Share this post Link to post Share on other sites
wogz187 1086 Posted August 1, 2019 @Sgt. Dennenboom, Quote _null = this spawn {while {alive _this} do {_this setFuel 1; sleep 60;};}; Works great. Super-valuable asset. Thanks. 2 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted August 1, 2019 2 minutes ago, wogz187 said: @Sgt. Dennenboom, Quote _null = this spawn {while {alive _this} do {_this setFuel 1; sleep 60;};}; Works great. Super-valuable asset. Thanks. Guys i really just wondering , how much posts do you need for a piece of code or code correction.?! Instead of saying that it's not working , it's super easy for a lot of guys here , to share a solution and help everyone who is reading this now and in the future. 3 Share this post Link to post Share on other sites
avibird 1 154 Posted August 1, 2019 But it does work that is the issue we are trying to figure out why it works even though it has syntax errors. It still fills the tanks. And it took the last post to correct my syntax errors. So I don't understand my friend! The second code I posted works with errors for me but not for some others who attempted to use my second code I post it. 2 Share this post Link to post Share on other sites
avibird 1 154 Posted August 1, 2019 @Grumpy Old Man Can you explain the difference to me then between. 1.composition init box 2. Object init box 3 group leader init box When placing code ? Thank you in advance! Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted August 1, 2019 33 minutes ago, avibird 1 said: we are trying to figure out why it works even though it has syntax errors. Just to know, it doesn't really matter if it's working since there are errors. Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted August 2, 2019 11 hours ago, avibird 1 said: But it does work that is the issue we are trying to figure out why it works even though it has syntax errors. It still fills the tanks. And it took the last post to correct my syntax errors. So I don't understand my friend! The second code I posted works with errors for me but not for some others who attempted to use my second code I post it. It only works for you, so you either have some mods running that magically correct syntax errors or you have some working snippet that's being executed from a place that you overlooked or missed. You clearly should get an error trying to use the following snippet, at least on an empty mission in vanilla A3: Null = this spawn {while {alive _this setfuel 1; sleep 60}}; This snippet will not and can not work in any circumstance, since while requires do and expects bool. It's part of a construct and won't work on its own. Even when you ignore the pop up error after pasting the snippet into the objects init field and clicking "ok", the snippet won't execute at all and a vehicles fuel will drain normally without ever being refilled. As stated before you probably have some working snippet running elsewhere (trigger, object, .sqf), you could upload the mission for someone to find out if this is the case. Cheers 1 Share this post Link to post Share on other sites
avibird 1 154 Posted August 2, 2019 @Grumpy Old Man the code does and will work Null = this spawn {while {alive _this setfuel 1; sleep 60}}; Yes it has errors but if you put it in an object init and reduce the fuel at start of the mission it will fill the tank. If you go into Zeus and remove the fuel it will fill it up. I just made a new mission with four vehicles ACP truck bike and helicopter all with the code above. At start of the mission I put all the tanks down to 75% 50% 25% and 10%. All the tanks filled with fuel. I then went into Zeus dropped the fuel on all four vehicles 4 time each and all the tanks got filled with fuel. This was down on a new mission no other files or folders just mission sqf one playable unit for vehicles with crew. Mcc4 Zeus enhanced Eden enhance Achilles mods. No other script or snippet of code. It works. I don't know why but it does for sure I am not crazy. I also asked you to explain the difference between composition object and unit init box when it comes down to placing code? Share this post Link to post Share on other sites
Smart Games 76 Posted August 2, 2019 Null = this spawn { while {alive _this} do { _this setfuel 1; sleep 60; }; }; Share this post Link to post Share on other sites
avibird 1 154 Posted August 2, 2019 @Smart Games thank you already got the code adjusted with errors with this _null = this spawn {while {alive _this} do {_this setFuel 1; sleep 60;};}; I know an arma there's many different ways to implement code. Now which is the most efficient I have no clue. The issue that I have is some people are saying the the second code snippet does not work ? actually it does work yes it gives errors but still works. Their original code I post it at the top of the thread only filled the vehicles at start of mission we established that but the second coat even though gives errors as well does work tested it multiple times with no other files or folders in a empty world just with for vehicles and it works every time. I greatly appreciate people help me out getting this code correctly but never really answered my question why it still works in spite of the errors it's showing and why some people are persistent that it does not work. Share this post Link to post Share on other sites
Smart Games 76 Posted August 2, 2019 I read this topic 🙂 While: https://community.bistudio.com/wiki/while The syntax: while {condition} do {...}; Null = this spawn {while {alive _this setfuel 1; sleep 60}}; --> cant work Thats what the others mean... 1 Share this post Link to post Share on other sites
avibird 1 154 Posted August 2, 2019 I fully understand but all due respect. It does work. I don't know why. But it does lol. It doesn't make a difference at this point because somebody corrected the code and I have a good code block that gives new errors and works as well. Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted August 2, 2019 3 hours ago, avibird 1 said: errors and works as well. avibird , as said above it really doesn't matter if it's working since there are errors , because generally , having a spam of errors might also mess even with the performance. 2 Share this post Link to post Share on other sites
avibird 1 154 Posted August 3, 2019 Well after all that I hav a working code block to refill fuel on my search choppers vehicles and patrol boats in the mission. I greatly appreciate the help I got to get a working snippet error-free. This is always a learning process for me when it comes to coding and scripting well now to the night thing on the list. Thank you gentleman for the assist. PS I still want to know what is the difference between composition object and unit init box for code placement. 1 Share this post Link to post Share on other sites
GEORGE FLOROS GR 4207 Posted August 3, 2019 By the way you could use the EH instead of loops : this addeventhandler ["Fired",{ (_this select 0) setvehicleammo 1; systemchat "setvehicleammo 1"; }]; this addeventhandler ["Fuel", { (_this select 0) setfuel 1; systemchat "setfuel 1"; }]; 1 1 Share this post Link to post Share on other sites
avibird 1 154 Posted August 3, 2019 @GEORGE FLOROS GR if I wanted to use the eventhandler how and where do I run the code from. Mission init, Trigger object init ECT. 1 Share this post Link to post Share on other sites
Dedmen 2653 Posted August 3, 2019 10 hours ago, GEORGE FLOROS GR said: this addeventhandler ["Fuel" Don't think that's super helpful Quote Triggered when the unit's fuel status changes between completely empty / not empty (only useful if the event handler is assigned to a vehicle). 20 hours ago, avibird 1 said: The issue that I have is some people are saying the the second code snippet does not work ? actually it does work yes it gives errors but still works. Dude. The code has a syntax error. IT DOESN'T EVEN COMPILE AT ALL. IT CAN NEVER RUN. No idea what you are doing or what other mods and scripts you have running. But PLEASE stop stating that completely broken code works fine. It DOESN'T. Share this post Link to post Share on other sites
killzone_kid 1329 Posted August 3, 2019 57 minutes ago, Dedmen said: Don't think that's super helpful George Soros here is right, the wiki description is off, gonna edit it 1 Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted August 3, 2019 2 hours ago, Dedmen said: Dude. The code has a syntax error. IT DOESN'T EVEN COMPILE AT ALL. IT CAN NEVER RUN. More polite than what I would've said. Spoiler Cheers 1 Share this post Link to post Share on other sites