Home   Help Search Login Register  

Author Topic: Global Action  (Read 1924 times)

0 Members and 1 Guest are viewing this topic.

Offline aceking

  • Members
  • *
Global Action
« on: 05 Mar 2009, 17:18:56 »
Hi,
Can anyone help me create an action on an object (any object), where the action simply makes target1=true, and can only be activated only once. I also want the script to be run on everybody, not just the person that initiates the action. Thanks.

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Global Action
« Reply #1 on: 05 Mar 2009, 21:40:27 »
This addaction ["acekingsaction", "actionscript.sqf"]

actionscript.sqf
Code: [Select]
acekingsobject removeaction 0;
target1=true;
publicVariable "target1";
« Last Edit: 05 Mar 2009, 21:42:19 by laggy »
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline aceking

  • Members
  • *
Re: Global Action
« Reply #2 on: 05 Mar 2009, 22:13:45 »
hhmm, I thought the addAction script was only locally run. Does adding that [publicVariable "target1";] make it so that when someone activates the action, it will run for everybody?
Also, I was gonna make a caputure AI action script as well:
Code: [Select]
?!(side player == WEST) or !(alive prisoner): exit

civ5 say "Sample2";

titletext ["The Queen of Spades has been escorted to the building courtyard","plain"];

prisoner setCaptive true;
prisoner setUnitPos "UP";
[prisoner] join group player;
prisoner setPos [2876.44,3508.52,1.96];
[] exec "trigger6.sqs";
prisoner removeAction capture;
Would I just have to add:
Code: [Select]
publicVariable "prisoner";at the end of it like how you did for target1?

Offline laggy

  • Members
  • *
  • "Behold a pale horse"
Re: Global Action
« Reply #3 on: 05 Mar 2009, 22:41:10 »
Yes publicVariable makes sure the variable is broadcasted to ALL computers.
In your case ALL clients (and server) will have target1=true happening on their computer.

The easiest way to accomplish what you want (I think), is to:

Place a trigger in the mission with a condition, that is activated by an action script using publicVariable.
In that trigger I would then execute the script with the "civ5 say "Sample2"" stuff.

That way everyone will hear the talk and all, because the broadcasted variable will start a trigger that exists for ALL.

« Last Edit: 05 Mar 2009, 22:48:38 by laggy »
And I looked and beheld a pale horse and his name that sat on him was Death and Hell followed with him.

Offline Deadfast

  • Members
  • *
Re: Global Action
« Reply #4 on: 05 Mar 2009, 22:48:15 »
Careful with the removeAction - it's local only.

If you're gonna use that trigger put the removeAction there.

Offline aceking

  • Members
  • *
Re: Global Action
« Reply #5 on: 13 Mar 2009, 21:31:20 »
Okay, what I ended up doing is creating an addAction command on the unit "prisoner":
Code: [Select]
capture = this addAction ["Capture Queen of Hearts", "trigger1.sqs"]
trigger1.sqs:
Code: [Select]
?!(alive prisoner): exit
target1 = true;
publicVariable "target1";
titletext ["The Queen of Spades has been escorted to the building courtyard","plain"];
exit;

Then I added a trigger with the condition:
Code: [Select]
target1And activation line:
Code: [Select]
prisoner setCaptive true;
[prisoner] join group player;
prisoner setPos [2876.44,3508.52,1.96];
[] exec "trigger6.sqs";
prisoner removeAction capture;
hint "The Queen of Hearts has been captured";

And trigger6.sqs is:
Code: [Select]
prisoner enableAI "MOVE";
commandStop prisoner;
Because the prisoner unit is initially set to
Code: [Select]
disableAI "MOVE"

Basically I would want the group leader of the player who initiates the capture action to take control of the prisoner unit. I was wondering if this way would work to do exacly that. Would this way work, or would the capture script run on everybody on the server and cause everyone to gain control of the prisoner unit?
I would also like the titletext script:
Code: [Select]
titletext ["The Queen of Spades has been escorted to the building courtyard","plain"];to run privately only to the player who initiates the action

and the hint script:
Code: [Select]
hint "The Queen of Hearts has been captured";to show up for everybody
« Last Edit: 13 Mar 2009, 21:41:16 by aceking »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Global Action
« Reply #6 on: 25 Mar 2009, 21:05:42 »
actionscript.sqf
Code: [Select]
acekingsobject removeaction 0;
target1=true;
publicVariable "target1";
Please, please, please never, ever, ever, remove an action based on a constant number. This will cause no end of problems if you ever run your script with any other script or addon that uses actions! You can also read the object (thing that the action was placed on) and the actor (person who performed the action) automatically too, which makes your action a lot more generic and reusable for more than one object!
Code: (actionscript.sqf) [Select]
_object = _this select 0;
_actor = _this select 1;
_actionIndex = _this select 2;

_object removeAction _actionIndex;
target1=true;
publicVariable "target1";
This exact same mistake caused Warfare to really annoy myself, and others, by being incompatible with a number of addons!
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)