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

@Dedmen dude lol yes it does work with errors. We have three sets of code it's the pits were talking about.

 

The original 

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

Code works only at the start of a mission.  Errors are shown.

 

The second code still has errors but works all tanks get filled with gas during a mission

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

 

 

The third correct with no errors

_null = this spawn {while {alive _this} do {_this setFuel 1; sleep 60;};};

 

 

All was tested on a empty map with four vehicles  no other folders in mission folder only mission.sqf

 

 

Please don't call me dude.  Go see for yourself please I don't care if it shows are has it works. As stated above I want the code with no errors because of performance and it drives me crazy seeing it when I preview the mission in the editor lol. Good day sir.

Share this post


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

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

This script is never going to work and it doesn't work due to wrong syntax.

Share this post


Link to post
Share on other sites

@GEORGE FLOROS GR put his foot down on this topic two days ago!

Quote

how much posts do you need for a piece of code or code correction.?!


@Sgt. Dennenboom, solved the issue with his cool snippet,

_null = this spawn {while {alive _this} do {_this setFuel 1; sleep 60;};};

 if @Dedmen & @killzone_kid can agree that @GEORGE FLOROS GR, EH is valid,

this addeventhandler ["Fired",{
    (_this select 0) setvehicleammo 1;
    systemchat "setvehicleammo 1";
}];

this addeventhandler ["Fuel", {
    (_this select 0) setfuel 1;
    systemchat "setfuel 1";
}];

the topic is super-solved.

Let's move this dead horse off GOM's yard before somebody catches a shoe to the head.

Edited by wogz187
you got the wiki updated though, so there's that...
  • Thanks 1

Share this post


Link to post
Share on other sites

@wogz187 have you personally put the code in the editor and see if it worked? Please do it does work yes you get errors but it works. 

 

@GEORGE FLOROS GR EH works but will only fire one store in the mission. If the vehicle loses a tank of gas and second time around it does not fire. I will do more testing to see if it fires a second time on the vehicles. 

 

The code does work with errors that's why this keeps on going cuz you persistent it doesn't work. Well put it in the editor and see. 

 

 

  • Like 1

Share this post


Link to post
Share on other sites
7 minutes ago, avibird 1 said:

The code does work with errors that's why this keeps on going cuz you persistent it doesn't work. Well put it in the editor and see.

Because it can't work, as stated multiple times, either you run some other snippet that's actually doing the job from a trigger, other .sqf file or any of your loaded mods is refueling your vehicles.

Vanilla A3, no mods, no scripts running, this snippet can't work.

 

Try this:

Null = this spawn {while {alive _this setfuel 1;systemchat "refilled"; sleep 3}};

You'll never see the systemchat because the snippet will not run, as @Dedmen stated, it won't even compile in the first place.

 

Cheers

Share this post


Link to post
Share on other sites
42 minutes ago, killzone_kid said:

showChat true;?

Returns true, yes, manually entered systemChat works and is visible.

Locally hosted MP returns false, yet systemChat still works, it's the broken while snippet that doesn't work (obviously).

Never had to manipulate showChat, systemChat and all other radio commands work out of the box.

Current contact stable build 1.94.145903, no mods.

 

Cheers

Share this post


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

@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.  

 

Where ever you want  , you can copy this in the init field of the vehicle or name the vehicle and add this in a script or even spawn this for every vehicle etc.

 

8 hours ago, Dedmen said:
18 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).

 

I don't see really any problem about it.

 

7 hours ago, killzone_kid said:
8 hours ago, Dedmen said:

Don't think that's super helpful

George Soros here is right, the wiki description is off, gonna edit it

Thanks !

Just curious where is that ( link ) ?

 

 

2 hours ago, avibird 1 said:

@GEORGE FLOROS GR EH works but will only fire one store in the mission. If the vehicle loses a tank of gas and second time around it does not fire. I will do more testing to see if it fires a second time on the vehicles. 

I don't think that this is possible , but i will check it though as well !

 

2 hours ago, wogz187 said:

Let's move this dead horse off GOM's yard before somebody catches a shoe to the head. 

Hahaha ! That was funny ! :rofl:

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites

Well thank you all for participating in this intellectual conversation and scripting 101 lesson. I now have two ways of giving vehicles unlimited fuel with no errors one with a snippet of code and the other using an EH (it does work that was my bad it was grumpy old man last code block that does not work. 

 

We can definitely put this to sleep I have my working codes and learned a little more about scripting😁

 

Sincerely avibird always lost in the editor with scripting.

 

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
1 hour ago, Grumpy Old Man said:

Returns true, yes, manually entered systemChat works and is visible.

Locally hosted MP returns false, yet systemChat still works, it's the broken while snippet that doesn't work (obviously).

Never had to manipulate showChat, systemChat and all other radio commands work out of the box.

Current contact stable build 1.94.145903, no mods.

 

Cheers

I’m just pulling your legs, man 🙂, that code is not gonna work in a million years!

  • Haha 3

Share this post


Link to post
Share on other sites
7 hours ago, killzone_kid said:

I’m just pulling your legs, man 🙂, that code is not gonna work in a million years!

Spoiler

b6IjQpE.jpg

 

Cheers

  • Haha 2

Share this post


Link to post
Share on other sites

So to finish this.

Fixed version of original script (bug was that exitWith returned nil):

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

Other possible variant:

_nul = this spawn {while {alive _this} do {_this setFuel 1; sleep 60;};};

Probably the best variant:

On 8/3/2019 at 4:00 AM, GEORGE FLOROS GR said:

this addeventhandler ["Fuel", { (_this select 0) setfuel 1; systemchat "setfuel 1"; }];

 

  • Like 3
  • Thanks 1

Share this post


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

×