OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: Artak 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?
-
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
-
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. ???
-
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
-
how does addaction work guys?
-
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 ;)
-
condition = true
~0.5
publicVariable "condition"
Does waiting half a second help? ~0.5