Home   Help Search Login Register  

Author Topic: publicvariable command?  (Read 1692 times)

0 Members and 1 Guest are viewing this topic.

Offline beno_83au

  • Members
  • *
publicvariable command?
« on: 30 Jun 2009, 14:14:55 »
Will a publicvariable command work if it is used in an "On Activation" field of a trigger to make that trigger work on all computers in MP?
If so, would the command publicvariable "vel" be correct (trigger name being vel)?

If I have to put it in a script, could someone please show me how (incl. the "On Activation" field in the trigger if it's more than an exec "....sqs" command).

Cheers.

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: publicvariable command?
« Reply #1 on: 30 Jun 2009, 16:40:24 »
A trigger placed in the editor will always run on all machines, so there shouldn't be any need to use publicVariable to make them MP-compatible. A simple
Code: [Select]
vel = 12 in the activation will record the value on every machine.

The only time you need to use publicVariable with a trigger activation is if the activation calls a script that is only to be run on the server (e.g. has
Code: (sqf) [Select]
if (!isServer) exitWith {}; or
Code: (sqs) [Select]
? !isServer : exit at the top of it), which then publicVariables a value so that all machines can see it.

There are reasons for dealing with triggers in either way in MP. It really depends on the situation (but you might as well try the simpler method first and if it doesn't work as you'd like to, consider the latter one).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline beno_83au

  • Members
  • *
Re: publicvariable command?
« Reply #2 on: 06 Jul 2009, 13:46:45 »
Hey cheers, that really cleared up the whole deal with the trigger. I'm not really one for scripting, I guess I'll get there someday, so it's good to know that the trigger will do the job.