Jump to content
Low Fat Milk

Addaction with cooldown script not appearing in init

Recommended Posts

I have been working on this for a few days now following some other examples I've seen but cant seem to get this to work.

Trying to make a addAction that hides an object for a limited time, hides the interaction for a longer time, but re-enables both. Using the syntax of the wiki stops the addAction from even showing up on the object however. If anyone has some pointers or even better a fix I'd appreciate it.
 

this addAction

[

    "<t color='#FF0000>WARNING Shield Override WARNING</t>",

    {

        params ["_target", "_caller", "_arguments"];

        _target setVariable ["ShieldReset",false];

        [Shield_1, true] remoteExec ["hideObjectGlobal", 0];

        Sleep 10;

        [Shield_1, false] remoteExec ["hideObjectGlobal", 0];

        sleep 10;

        _target setVariable ["ShieldReset",true];

    },

    nil,

    1.5,

    true,

    true,

    "",

    "_target getVariable ['ShieldReset',true]",

    5,

    false,

    "",

    ""

];

Share this post


Link to post
Share on other sites

There's a single quote missing after your color code.

"<t color='#FF0000>WARNING Shield Override WARNING</t>",
  
  //  SHOULD BE
  
"<t color='#FF0000'>WARNING Shield Override WARNING</t>",
  • Like 2

Share this post


Link to post
Share on other sites

params ["_target", "_caller","_id", "_arguments"]; // just to be sure there is no mistake

 

then:

[Shield_1, true] remoteExec ["hideObjectGlobal", 0]; // NO Don't use global command for hideObject everywhere

 

[Shield_1,TRUE] remoteExec ["hideObject",0]; // fine

or

[Shield_1,TRUE] remoteExec ["hideObjectGlobal",2];  // from server

 

On the other hand:

_target setVariable ["ShieldReset",true];  // sets the variable locally (where is the addAction code running from (caller's PC), so not set on other PCs)

_target setVariable ["ShieldReset",false,true];  // for server + clients

same for:

_target setVariable ["ShieldReset",true,true];  of course

(getvariable doesn't need this extra parameter, no sense here)

  • Like 2

Share this post


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

There's a single quote missing after your color code.


"<t color='#FF0000>WARNING Shield Override WARNING</t>",
  
  //  SHOULD BE
  
"<t color='#FF0000'>WARNING Shield Override WARNING</t>",

Thank you so much. I missed that dang thing for hours

Share this post


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

params ["_target", "_caller","_id", "_arguments"]; // just to be sure there is no mistake

 

then:

[Shield_1, true] remoteExec ["hideObjectGlobal", 0]; // NO Don't use global command for hideObject everywhere

 

[Shield_1,TRUE] remoteExec ["hideObject",0]; // fine

or

[Shield_1,TRUE] remoteExec ["hideObjectGlobal",2];  // from server

 

On the other hand:

_target setVariable ["ShieldReset",true];  // sets the variable locally (where is the addAction code running from (caller's PC), so not set on other PCs)

_target setVariable ["ShieldReset",false,true];  // for server + clients

same for:

_target setVariable ["ShieldReset",true,true];  of course

(getvariable doesn't need this extra parameter, no sense here)

Thanks for the improvements, I really appreciate it! Curious though is hide object global not useful in this situation or just that particular line?

Share this post


Link to post
Share on other sites

More exactly:

hideObjectGlobal is OK in MP but its a SE (server execution command) and you are not on server when running an addAction as client (except for hosted server). So the remote execution on 2 (server)

 

You can also remoteExec on each client (0 as 2nd param) but you need to use hideObject (so local command) . hideObject is LE: Local Effect, the reason why you need to remote exec everywhere.

This local execution worth for plenty of objects to hide, just as reminder. In this case, you can avoid desync. Not really the case if you have just one target!

 

 

  • Like 2

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

×