Jump to content
avibird 1

missing a Bracket in this code I don't know where it needs to be it all looks good to me. Help please and thank you!

Recommended Posts

0 = [this,"INIT=",[_proxyThis,]addeventhandler ["Fuel",{(_this select 0) setfuel 1; systemchat "setfuel 1";}];] spawn jebus_fnc_main;

I am missing a Bracket but have no clue where. I know it's a rookie mistake after all this years of playing but still a rookie when it comes to arma scripting.

 

I am using  0 = [this] spawn jebus_fnc_main;  to spawn in a unit

"INIT="     = Init string to run upon spawning  (Use "_proxyThis" where you would usually use "this" in a script or function call)

I want to add this when the unit respawns

a example  0 = [this, "INIT=", "[_proxyThis, 'agia'] execVM 'UPS.sqf'"] spawn jebus_fnc_main;

 

I want to add this to the respawned unit

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

Edited by avibird 1

Share this post


Link to post
Share on other sites

@avibird 1
 

I had to read some descriptions, but this should work.
If not... There are other ways to give a unit unlimited fuel.

 

//	No idea if this will work... I am away from ArmA.

0 =
[
	this,
	"INIT=", "_proxyThis addEventHandler ['Fuel', { (_this select 0) setFuel 1; }]; "
] spawn jebus_fnc_main;

 

  • Thanks 1

Share this post


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

0 = [this,"INIT=",[_proxyThis,]addeventhandler ["Fuel",{(_this select 0) setfuel 1; systemchat "setfuel 1";}];] spawn jebus_fnc_main;

 

Nothing about this seems to make any sense, I think this is more than just a bracket ...


Look at your parameters:

  1. this (good)
  2. "INIT=" (good)
  3. [_proxyThis,]addeventhandler ["Fuel",{(_this select 0) setfuel 1; systemchat "setfuel 1";}]; (bad)

    1. addeventhandler takes an object as its first parameter, not an array.

    2. "[_proxyThis,]", _proxyThis is undefined (you say its treated as "this" but you still use "this" rather than _proxyThis as the first parameter).

    3. "[_proxyThis,]" you have a comma after the first element with no second element of the array

    4. Why are you trying to assign an event handler to something as a parameter, unless you are trying to pass the handler id.

    5. "addeventhandler ["Fuel",{(_this select 0) setfuel 1; systemchat "setfuel 1";}];" you have a semi colon at the end of the element, that is like saying _array = [1,2,3;];

 

You should probably do something like what @Maff suggested.
Then do some more reading up on the wiki on how to script cause you will get generic error messages for a lot of different problems and will waste your time looking for some missing bracket or semi colon that does not exist.

Share this post


Link to post
Share on other sites

This is jebus script to use editor placed units respawn it works fine. This is from his example. The add eventhandler code I am trying to added back to the unit after it get killed.

 

Both of scripts on their own work fine in the unit init 100% on that but I am trying to  add the eventhandler once the helicopter is shot down.

 

This is his own words 

"INIT="     = Init string to run upon spawning  (Use "_proxyThis" where you would usually use "this" in a script or function call)

 

And this is an example he provides

0 = [this, "INIT=", "[_proxyThis, 'agia'] execVM 'UPS.sqf'"] spawn jebus_fnc_main;

 

Maybe it doesn't work for eventhandler code but I don't see why?

 

 

Share this post


Link to post
Share on other sites

It is asking for a string.

\jebus\fn_main.sqf

Is confusing to me.

Does my example not work?

Share this post


Link to post
Share on other sites

No sir 😥 

 

Both of then work fine on their own. Helicopter stays refueled the helicopter responds if it gets shot down but the refuel code does not work on respawn. 

 

In jeb's literature it says that it can and will allow custom code to respawn if you use that code block. Wife is yelling at me need to turn off  Arma and try tomorrow. 

Share this post


Link to post
Share on other sites

Both of then work fine on their own. Helicopter stays refueled the helicopter responds if it gets shot down but the refuel code does not work on respawn. 

 

In jeb's literature it says that it can and will allow custom code to respawn if you use that code block. Wife is yelling at me need to turn off  Arma and try tomorrow. 

Share this post


Link to post
Share on other sites

I think the issue is with his script as great as it is. If you're not familiar with it you should look at it many different functions. The units that respond back in don't keep its variable name and anything associated with it's init box. So you have to use his code to allow for these items to get respawned 

back to the unit. 

 

Off this topic. I think there's something funky going on with cup maps. Seek and destroy cycle waypoints on air vehicles still get delete it after a while is not a continuous loop however on vanilla maps I don't see the same issue I need to do some more tests in with vanilla maps versus cup maps. Who knows after the last contact engine update things always get broken 😡 lol

Share this post


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

I think the issue is with his script as great as it is.

The example @Maff gave worked fine for me, the event handler 'fuel' only gets activated when "Triggered when the vehicle's fuel status changes between non-empty and empty or between empty and non-empty."

I got your "systemchat 'setfuel 1';" twice, once for when the car ran out of gas and again after the code "(_this select 0) setFuel 1;" ran. Depending on the testing environment you might not get the system chat because the event handler is assigned to the vehicle, not to the player and systemChat has a local effect while setFuel has a global effect. So probably don't base your testing on that alone.

Share this post


Link to post
Share on other sites

I know they both work but I am trying to get the fuel script to respawn when the unit gets shot down. 

 

Jebus editor spawning is a very useful script. It does so many function even will spawn I unit back with it's editor place waypoints. Just can't figure out how to put the two codes together. I know it can be done but I'm usually lacking the how lol.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×