Jump to content

Recommended Posts

Quote

If action is added to player, condition is evaluated all the time.

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

actRevive = player addAction [format [localize "STR_action_revive", name cursorObject],
{
	[cursorObject, (_this select 0)] spawn Haz_fnc_revive;
}, [], 0, false, false, "", "_this distance cursorObject <= 4 && cursorObject getVariable [""isUnconscious"", FALSE] && !(cursorObject getVariable [""isBeingRevived"", FALSE])"];

OYXdBuw.jpg

 

Something soo simple...

Share this post


Link to post
Share on other sites
12 minutes ago, davidoss said:

Use cursorTarget instead of cursorObject

uh. no.

  • Haha 2

Share this post


Link to post
Share on other sites
8 hours ago, Dedmen said:

Just add the action to the target? Instead of yourself?

You are taking the name of the object that was being looked at when the action was added, not when the action is executed.

 

Or https://community.bistudio.com/wiki/setUserActionText

Yeah. That is one method. Anyway without doing it that way? I did try setUserActionText however still can't get it to update.

Share this post


Link to post
Share on other sites
actRevive = player addAction [
localize "STR_action_revive",
{
    [cursorObject, (_this select 0)] spawn Haz_fnc_revive;
}, [], 0, false, false, "", "_this distance cursorObject <= 4 && cursorObject getVariable [""isUnconscious"", FALSE] && !(cursorObject getVariable [""isBeingRevived"", FALSE])"];

[] spawn {
    while {alive player} do {
        waitUntil {sleep 1; !isNull cursorTarget && {cursorTarget getVariable ["isUnconscious", FALSE]}};
        player setUserActionText [ actRevive, format [localize "STR_action_revive", name cursorTarget];
    };
};

???

Share this post


Link to post
Share on other sites

No no. That is just a really bad idea. Thanks though. A while loop with a waitUntil? It really is Christmas. lol! :rofl:

Why does it get Error no vehicle? It is actually evaluating each time but the name part is failing?

Share this post


Link to post
Share on other sites
15 minutes ago, davidoss said:

actRevive = player addAction [
localize "STR_action_revive",
{
    [cursorObject, (_this select 0)] spawn Haz_fnc_revive;
}, [], 0, false, false, "", "_this distance cursorObject <= 4 && cursorObject getVariable [""isUnconscious"", FALSE] && !(cursorObject getVariable [""isBeingRevived"", FALSE])"];

[] spawn {
    while {alive player} do {
        waitUntil {sleep 1; !isNull cursorTarget && {cursorTarget getVariable ["isUnconscious", FALSE]}};
        player setUserActionText [ actRevive, format [localize "STR_action_revive", name cursorTarget];
    };
};

???

No need for a separate loop:

 

_ID = player addAction [name cursorObject,
{}, [], 0, false, false, "", "_target setUserActionText [_target getVariable ['TAG_fnc_myActionID',-1], name cursorObject];_target distance cursorObject <= 4"];
player setVariable ["TAG_fnc_myActionID",_ID];

Cheers

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Thank you @Grumpy Old Man! I ditched the getVariable, don't need that part.

_target setUserActionText [actRevive, format [localize ""STR_action_revive"", name cursorObject]];

Shame you can't directly get _id in the condition field. No big deal as ID to stored on actRevive handle so.

Quote

_target: Object - the object to which action is attached or, if the object is a unit inside of vehicle, the vehicle

_this: Object - caller person to whom the action is shown (or not shown if condition returns false)

_originalTarget: Object - the original object to which the action is attached, regardless if the object/unit is in a vehicle or not

 

Share this post


Link to post
Share on other sites
13 hours ago, davidoss said:

Use cursorTarget instead of cursorObject

It's not a problem if you don't aim at the primaryweapon of the "target"...

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

×