Jump to content
avibird 1

help with message error when setting fuel to full for a vehicle ? code works but still get an error.

Recommended Posts

nul = this spawn { waitUntil { if !(alive _this) exitWith {}; if (fuel _this < 0.25) then { _this setFuel 1 }; false } };

 

This code works for multiple air and ground patrol vehicle but still have a error message. I hate to see them lol.

Share this post


Link to post
Share on other sites

Emmm...show us the error message, please.

Share this post


Link to post
Share on other sites

When test playing the mission in the editor. At the start of the mission the code flashes on the screen it just says error. Or if I delete a vehicle with the code inside from Zeus during the mission is flash's again it's just the code with a error message attached to it at the end. unfortunately I can't take a screenshot right now I'm away from my computer I won't have access for a week or so.  Like I said it works the vehicles have unlimited fuel. 

Share this post


Link to post
Share on other sites

@avibird 1

I don't get an error with your script in the init of a vehicle. If the vehicle has less than 1/4 tank of gas at initialization, it fills the tank, no error. But, as is, it can only fire at initialization and not when the fuel drops. Is that what you want to do? Have the vehicle refuel when it reaches 1/4 tank? 

Maybe I'm wrong but I think the "waitUntil" only applies to the empty {}. So the second part of the script will only apply at start up.

  • Like 2

Share this post


Link to post
Share on other sites

Yes I want gas to never run out. I have two search choppers that use seek and destroy waypoints around a prison camp. The choppers use a trigger with skip waypoint type when a few guard towers get taking down by the pow's the choppers will circle around the prison camp and will engage if the pow's start taking down more prison guards and reinforcements.  I gave one chopper less the 1/4 tank and the other full at mission start.  When I run the mission using Zeus and check up on the choppers the fuel tanks are full. 

 

I get a message error at the start and if I delete one of the choppers from Zeus. When I switch into a pilot using Zeus the tank is full.

 

Mod's used 

CBA

Mcc4

Cup maps units weapons vehicles ECT

Zeus enhance

Eden enhance

Achilles 

 

Share this post


Link to post
Share on other sites

I need to check that out but I am sure it fills the tanks. I'm away from my computer for a while to review it again to see if it does fill the tank during the mission 

Share this post


Link to post
Share on other sites

///function in init.sqf 

 

1)

fnc_fuel =

{

_car = _this;

waituntil {fuel _car < 0.25};

_car setfuel 1;

_car spawn fnc_fuel; ///optional

};

 

or

 

2)

fnc_fuel =

{

_car = _this;

if (fuel _car < 0.25) then

{_car setfuel 1};

_car spawn fnc_fuel; ///optional

};

 

///call function in vehicle init

nul = this spawn fnc_fuel;

 

 

Do you want something like that?

Share this post


Link to post
Share on other sites

@Smart Games thank you yes! I need for the two choppers and a few jeeps that patrol around the pow camp and the resistant safe House where the pow need to get to end the mission plus a few other mission objectives.  The mission from start to end takes about  3-4 hrs. 

 

I am a little old school I don't like using scripts that spawn in all the units on the map/mission. I like to see the units and waypoints on the map. I use Stand Alone GAIA and jebus with good old waypoints most of the time.

 

I just need unlimited fuel for some vehicles. 

Share this post


Link to post
Share on other sites

@avibird 1, @Smart Games,

I wrote,

refuelTRIG = {

_veh=[car1, car2, car3];


waitUntil {
sleep 1;
    fuel _veh < 0.25
    };
Hint "Fuel up";
_veh setFuel 1;

Which is basically the same as Smart Games. But neither mine or theirs actually seems to work. No errors, but no result, either. For this case, you can use a trigger with,
condition NONE, this in condition field, (repeatable if necessary)

fuel chopper < 0.5

and ON Activation

chopper setFuel 1;

That'll do it.

  • Like 1

Share this post


Link to post
Share on other sites
9 hours ago, wogz187 said:

 


_veh=[car1, car2, car3];

//snip

fuel _veh < 0.25

So

fuel [car1, car2, car3] < 0.25

There is error in your code, fuel expects a vehicle, yet your supplying an array.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
14 hours ago, avibird 1 said:

if !(alive _this) exitWith {};

This doesn't exit your loop. You need to return "true" to exit the waitUntil. So exitWith {true};

 

13 hours ago, wogz187 said:

Maybe I'm wrong but I think the "waitUntil" only applies to the empty {}

You're wrong.

 

I don't see anything otherwise wrong with the script in first post.

How about you finally:

14 hours ago, TURCO_AR said:

show us the error message, please.

 

And in more detail than

 

14 hours ago, avibird 1 said:

flashes on the screen it just says error

or

13 hours ago, avibird 1 said:

I get a message error

 

If you don't know how to explain it to us, then show a screenshot.
Also I'd recommend to add a  "sleep 5" before the false; to make it a bit more performance friendly. don't need to check every frame if fuel is low, it doesn't empty that fast.

  • Like 1

Share this post


Link to post
Share on other sites

The script comes from here.

@Dedmen,

Quote

"You're wrong."

Unsurprising, I know.

It's a proper script, I can see that much. It even returns a boolean at the end which pleases KK and GOM immensely. I don't understand the usage though because it doesn't fire from the vehicle init (I tried) after initialization. If the vehicle starts with less than 1/4 tank, it fills up. If the vehicle reaches less than 1/4 tank mid mission, nothing.

What I can't recreate is the error in question.

@Larrow,
Thanks,

fuel [car1, car2, car3] < 0.25

But what does that do? Does it wait for all the vehicles listed to be below 1/4 tank? Or any of them? And once one vehicle is identified as low on fuel, how do we gas up that single vehicle? And at what point does this solution become untenable because too many vehicle fuel states are being tracked simultaneously?

I know it's a lot of (probably stupid) questions but I'm earnestly working toward understanding.

Share this post


Link to post
Share on other sites

@Smart Games@Larrow @Dedmen 

I know there are many ways to do things in arma. Some more efficient than others while others just a very simple way of writing code and implementing it.  I've been playing this game for a very long time but still a novelist with codeine and language. Most of what you guys talk about is really above my head lol.

 

But this simple code works just fine! It's not the original code posted above because that code only initiates at the start of the mission as pointed out to me.

 

New code snippet. Put this in object init

 

Null = this spawn {while {alive _this setfuel 1; sleep 60}}; 

 

Question should I set the sleep longer like 3 to 5 minutes would that inc overall game performance by not checking for fuel every 60 seconds. 

 

This is another question unrelated to this. How do I retrieve steam screenshots and post it here so you guys can see the error from the original message lol. I've never posted a screenshot before lol don't judge 😂

 

 

 

 

 

 

  • Like 3

Share this post


Link to post
Share on other sites

Set a hotkey in the steam settings 🙂

 

If you close the game, steam will show you all the screenshots you made

--> export it

 

or play the game in window mode an use the snipping tool 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

The new code Null = this spawn {while {alive _this setfuel 1; sleep 60}};  work well however if you attempted to use it with jebus script or will not work I think because of the whole spawning system he built into jebus! But that is a question for him and his script. 

 

The about code works if you want to give a editor placed unit unlimited fuel. 

 

I am going to see if I copy the code into a unit using jebus from the Zeus interface I'm positive it will work I think the issue is with jebus spawning system in the script it's probably not copying the unit init information just like custom unit names don't carry over using jebus.

 

 

  • Thanks 1

Share this post


Link to post
Share on other sites

Definitely works if you add the code line through Zeus if using jebus script. Will ask him if there is a  simple fix probably not his script is very complex and does so much more then just spawning in units.

Share this post


Link to post
Share on other sites
14 hours ago, wogz187 said:

If the vehicle reaches less than 1/4 tank mid mission, nothing.

I think I know. exitWith {} might return nil. Since Arma 1.94 (last update) returning nil in a waitUntil is an error. Previously it was handled as a "false".
The old code was wrong anyway, the exitWith needs to return true to exit the waitUntil, old code caused infinite loop and since the last game update (which's aim was to fix infinite waitUntil loops) it's an error.

 

14 hours ago, wogz187 said:

But what does that do?

Nothing, it's a syntax error. Like Larrow already said. This construct doesn't exist.

 

13 hours ago, avibird 1 said:

But this simple code works just fine!

no it doesn't.


This:

13 hours ago, avibird 1 said:

Null = this spawn {while {alive _this setfuel 1; sleep 60}}; 

script has a syntax error. The while syntax is incorrect.

https://community.bistudio.com/wiki/while

 

13 hours ago, avibird 1 said:

Question should I set the sleep longer like 3 to 5 minutes would that inc overall game performance by not checking for fuel every 60 seconds. 

It would improve performance a tiiiiny bit. But a few microseconds of CPU time, every 60 seconds is already immeasurably low. So.. Doesn't make much sense.

 

13 hours ago, avibird 1 said:

How do I retrieve steam screenshots and post it here so you guys can see the error from the original message lol.

Go to your steam profile, to your screenshots and just share a link to the screenshot.

 

 

11 hours ago, avibird 1 said:

The new code Null = this spawn {while {alive _this setfuel 1; sleep 60}};  work well

Doesn't make any sense, that code clearly has a syntax error.

  • Like 1

Share this post


Link to post
Share on other sites

Well it does work. My two choppers and 6 vehicles gets full tank of gas at the strat of mission and when I use Zeus to take fuel away from them it fills back up. The only vehicles that will not work is the patrol boat because it's uses jebus to spawn it and I am having a issues with that because not the spawning system he has.

 

This does work if you put it in a vehicle init. That is just placed down in the editor and no spawning.

 

 

Null = this spawn {while {alive _this setfuel 1; sleep 60}}; 

 

Share this post


Link to post
Share on other sites

As I said, your script has multiple syntax errors. It can't work. No idea what you are doing, but that script there doesn't work.

Share this post


Link to post
Share on other sites
43 minutes ago, Dedmen said:

As I said, your script has multiple syntax errors. It can't work. No idea what you are doing, but that script there doesn't work.

 

I'm not even able to put this into a vehicles init field without getting an error pop up when hitting "ok".

Maybe there's a forgotten but functional snippet somewhere buried beneath the chaos inside this mission, heh.

 

Cheers

 

  • Like 1

Share this post


Link to post
Share on other sites

Gentleman I am not talking about this code 

nul = this spawn { waitUntil { if !(alive _this) exitWith {}; if (fuel _this < 0.25) then { _this setFuel 1 }; false } };

 

 

I am referring to this one

Null = this spawn {while {alive _this setfuel 1; sleep 60}};  

 

 

I stated that the first code only gives fuel at the start of a mission but the second one give my vehicles unlimited fuel for the mission but does not work with jebus editor place units spawning.

 

If someone has a better code that is more efficient and does not have some any syntax errors please share with me. 

Share this post


Link to post
Share on other sites

As people have been saying: that second bit of code cannot possibly work, the syntax is completely out of whack

Share this post


Link to post
Share on other sites

Lol but it does? I will check it again. I will let the mission run for a few hrs and just up on the birds and patrol vehicle but I am positive it works. Please if somebody has a better code with correct syntax please share. 🤪👀😁

Share this post


Link to post
Share on other sites

Call me crazy but this code definitely works. I started all vehicles with. 10% fuel check it at the start of mission with Zeus full tank for all. I manually empty the tanks down to 5% from Zeus and after a minute the fuel tanks are full.

 

Please see this code

 

Null = this spawn {while {alive _this setfuel 1; sleep 60}};  

 

 

 

 

 

 

Share this post


Link to post
Share on other sites
Guest
This topic is now closed to further replies.

×