Home   Help Search Login Register  

Author Topic: Executing a script with addaction in MP  (Read 1772 times)

0 Members and 1 Guest are viewing this topic.

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Executing a script with addaction in MP
« on: 17 Oct 2003, 16:03:22 »
Hello folks,

As you know there's a command called addaction which adds a nice little action to the action menu. A script will be executed when the user selects the added action. Here's an example though you don't need it.

addtracking = (leader egrp1) addaction ["Start Tracking","tracking.sqs"]

I've got everything working just fine, but the problem is that I need this in a MP mission and was wondering if the script executed via an action from the action menu is always executed locally on the players machine who selects the action?

The script I have makes the leader of a group 'say' a sound. He can hear it but the rest of us can't. So, if the script is always executed locally on the players machine, how can I make it be executed globally, still using the action menu?
Not all is lost.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:Executing a script with addaction in MP
« Reply #1 on: 17 Oct 2003, 19:44:10 »
well i suppose the best way is to have the addaction declare a global variable (Ideally a boolean)  and then have all clients waiting for that global variable to become true to activate a script
Zeus ARMA2 server IP = 77.74.193.124 :2302
Teamspeak IP = 77.74.193.123

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:Executing a script with addaction in MP
« Reply #2 on: 17 Oct 2003, 21:43:36 »
Oh, right. Hmm.. maybe I could use a global boolean, in the script executed with addaction, to run a loop script on the server, just for playing the sound..? Guess it being ran on the server would make all clients hear it.  ???
Not all is lost.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:Executing a script with addaction in MP
« Reply #3 on: 18 Oct 2003, 00:48:06 »
No Artak, what Terox means is:

Each client executes a script by default - let's say:

<<default.sqs>>

@condition

blablabla

exit

Then there's the script, which is called by the action - let's say:

<<action1.sqs>>

condition = true
~0.5
publicVariable "condition"

exit


Now default.sqs will wait until the action has been triggered
Then the condition will become true, and as the action script
is only running local at the actionaire's machine, you need
to: publicVariable "thecondition"

After that, the condition will be true for the other clients aswell.

To indicate, which player would have to say something, it would
require some more tricky stuff, but as a hint in advance i would
say: a global array, in combination with a numeric variable, which would be defined local, to tell the other clients which
segment of the array should be taken to SAY the sound.

Nothing serverside needed here, as you want to play/say
a sound, which doesn't make sense on server only.

:edit - btw - with using a global variable and the other clients
waiting for it, you were already right

~S~ CD
« Last Edit: 18 Oct 2003, 00:49:18 by Chris Death »
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Commando

  • Guest
Re:Executing a script with addaction in MP
« Reply #4 on: 21 Oct 2003, 18:03:24 »
how does addaction work guys?

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:Executing a script with addaction in MP
« Reply #5 on: 22 Oct 2003, 14:45:36 »
Thanks a lot dudes  :-* It works almost like a charm. (some issues with lag, but nothing too bad)

I'm running a bit heavy script (read bad scripting) that acts as a tracking device. Toadlife has made an excellent tracking device, but to prove myself something of my manhood I needed to make my own :P

Now a script with a @ condition line is running on all clients except the one who has the tracking device (the tracking script plays the sound for him), which makes everyone hear it.



Commando, there's very much material on addaction in the editors depot and in the forums.
Search both with keyword addaction and you can't go wrong  ;)
« Last Edit: 22 Oct 2003, 14:46:04 by Artak »
Not all is lost.

Mike

  • Guest
Re:Executing a script with addaction in MP
« Reply #6 on: 23 Oct 2003, 03:34:46 »
condition = true
~0.5
publicVariable "condition"

Does waiting half a second help? ~0.5