Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
CuddleTank001

Globally executing actions

Recommended Posts

I know that it's been asked a lot of times, and i personally viewed a lot of topics but i still can't seem to understand it.

im making a heli pilot training mission, with a lot of actions that can be triggered from the co-pilot seat, but when i trigger them,  they only happen for me and not the pilot, but when i type the script in the debug console, and globally execute it, it works for both of us.

Player addAction ["<t color='#FFFF00'>ENG</t>",{vehicle player setHitPointDamage ["hitengine", 1]},nil,0,false,true,"","_this == _Target turretunit [0]",15, false];

This is one of the scripts, the other are similar.

so can i please get help?

Share this post


Link to post
Share on other sites

what mans

5 minutes ago, CuddleTank001 said:

they only happen for me and not the pilot

 

5 minutes ago, CuddleTank001 said:

it works for both of us

 

does your script not execute or is the action missing for copilot? deliver infos please and don't let us ask everything...

 

aslo what is this or better what should it be?

8 minutes ago, CuddleTank001 said:

"_this == _Target turretunit [0]"

 

Share this post


Link to post
Share on other sites

the answer is in your question! Scripts called from addAction are only called localy so you have to remote execute them. In your case however setHitPointDamage has global effect but requires to be executed where the argument is local. A vehicle is always local to its driver's machine. So this

Player addAction ["<t color='#FFFF00'>ENG</t>",{[vehicle player],{(_this select 0)setHitPointDamage ["hitengine", 1]}RemoteExec["Call",(vehicle player)]}

,nil,0,false,true,"","_this == _Target turretunit [0]",15, false];

Should do the trick.

Share this post


Link to post
Share on other sites
3 minutes ago, sarogahtyp said:

what mans

 

 

does your script not execute or is the action missing for copilot? deliver infos please and don't let us ask everything...

 

aslo what is this or better what should it be?

 

I missed it, as @sarogahtyp said, what is this?

Share this post


Link to post
Share on other sites

setHitPointDamage is AL EG. No need to remoteExec it on addAction code.

 

Share this post


Link to post
Share on other sites

Ah you want to check that the player is in the copilot seat.
I think it should be "player == _Target turretunit [0]" then (not sure)

Share this post


Link to post
Share on other sites
2 minutes ago, pierremgi said:

setHitPointDamage is AL EG. No need to remoteExec it on addAction code.

 

Well yes but AL means the argument (in this case the heli) has to be local to where the script is called. If the action is for the copilot, then the vehicle won't be local to their machine if there's a human player in the pilot seat.

Share this post


Link to post
Share on other sites
11 hours ago, Mr H. said:

Well yes but AL means the argument (in this case the heli) has to be local to where the script is called. If the action is for the copilot, then the vehicle won't be local to their machine if there's a human player in the pilot seat.

Right

In fact the code should be applied to the heli, not the player, and refer to parameters.

 

0=this addAction ["<t color='#FFFF00'>ENG</t>",{
  params ["_target", "_caller"];
  [_target,{_this setHitPointDamage ["hitengine",1]}] remoteExec ["Call",_target]},nil,0,false,true,"","_this == _Target turretunit [0]"];

 

EDITED

For console, replace this by the helo's name.

 

  • Like 1

Share this post


Link to post
Share on other sites
15 hours ago, sarogahtyp said:

what mans

15 hours ago, CuddleTank001 said:

they only happen for me and not the pilot

 

15 hours ago, CuddleTank001 said:

it works for both of us

 

does your script not execute or is the action missing for copilot? deliver infos please and don't let us ask everything...

 

aslo what is this or better what should it be?

15 hours ago, CuddleTank001 said:

"_this == _Target turretunit [0]"

 

when i activate the action the ENG turns red for me and stops spinning, but nothing happens at the pilot's screen, so basically the script works for me, but not the pilot.
I am the co pilot, and as when i globally execute the script from the debug console, it works for both me and him.
This is make the command exclusive to the co-pilot.

 

15 hours ago, Mr H. said:

the answer is in your question! Scripts called from addAction are only called localy so you have to remote execute them. In your case however setHitPointDamage has global effect but requires to be executed where the argument is local. A vehicle is always local to its driver's machine. So this


Player addAction ["<t color='#FFFF00'>ENG</t>",{[vehicle player],{(_this select 0)setHitPointDamage ["hitengine", 1]}RemoteExec["Call",(vehicle player)]}

,nil,0,false,true,"","_this == _Target turretunit [0]",15, false];

Should do the trick.

that gave me an error, the error says, ERROR: general error in expression.

 

15 hours ago, Mr H. said:

Well yes but AL means the argument (in this case the heli) has to be local to where the script is called. If the action is for the copilot, then the vehicle won't be local to their machine if there's a human player in the pilot seat.

yeah this is the problem that im trying to solve

 

15 hours ago, pierremgi said:

this addAction ["<t color='#FFFF00'>ENG</t>",{
  params ["_target", "_caller"];

  [_target,{_this setHitPointDamage ["hitengine", 1]}] remoteExec ["Call",_target]

}  ,nil,0,false,true,"","_this == _Target turretunit [0]",15, false];

and this one gives me a missing ] error

Share this post


Link to post
Share on other sites

A typo somewhere. Test:

0 = this addAction ["<t color='#FFFF00'>ENG</t>",{params ["_target", "_caller"];[_target,["hitengine",1]] remoteExecCall ["setHitPointDamage",_target]},nil,0,false,true,"","_this == _target turretunit [0]"];

Share this post


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

A typo somewhere. Test:

0 = this addAction ["<t color='#FFFF00'>ENG</t>",{params ["_target", "_caller"];[_target,["hitengine",1]] remoteExecCall ["setHitPointDamage",_target]},nil,0,false,true,"","_this == _target turretunit [0]"];

so should i just throw that in my "OnPlayerRespawn.sqf"?

or do I have to plant it in the heli's init?

Share this post


Link to post
Share on other sites

heli's init. As said, this refers to the helicopter, now.

Share this post


Link to post
Share on other sites
2 minutes ago, pierremgi said:

heli's init. As said, this refers to the helicopter, now.

well the thing is, this heli well be respawning all the time, so how can i make it respawn with the same init every time?

EDIT: and it also gives me an error stating "invalid number in expression"

Share this post


Link to post
Share on other sites

For some boring reason, this forum editor adds invisible character sometimes. Here between the code and the last ;

try:

0 = this addAction ["<t color='#FFFF00'>ENG</t>",{params ["_target", "_caller"];[_target,["hitengine",1]] remoteExecCall ["setHitPointDamage",_target]},nil,0,false,true,"","_this == _target turretunit [0]"]

or recopy this code manually!

 

For vehicle respawn, I worked on it so:

- you can try to add the code in the BI vehicle respawn module;

- or use my script, perhaps more complex than your aim, or my module.

Share this post


Link to post
Share on other sites

×