Home   Help Search Login Register  

Author Topic: DIALOGS IN MULTIPLAYER!?  (Read 2941 times)

0 Members and 1 Guest are viewing this topic.

Offline TheCaptain

  • Members
  • *
  • You and The Captain Can Make it Happen
DIALOGS IN MULTIPLAYER!?
« on: 25 Sep 2002, 06:40:05 »
Does the dialog function make a dialog on all machines? Here's the code I have written, and a trigegr activates it only on one player's machine:

"_ok = createDialog "DlgTutorial"
?(!_ok): hint "Fehler!"; exit

_index = lbAdd [104, "Commander"]"

And it makes it on all machines... any way around this? It's kind of a handicap...
The Captain

bn880

  • Guest
Re:DIALOGS IN MULTIPLAYER!?
« Reply #1 on: 05 Oct 2002, 22:50:50 »
Quote
Does the dialog function make a dialog on all machines?
Nope.

Quote
Here's the code I have written, and a trigegr activates it only on one player's machine:

"_ok = createDialog "DlgTutorial"
?(!_ok): hint "Fehler!"; exit

_index = lbAdd [104, "Commander"]"

And it makes it on all machines...

Well, the createDialog line must run on all machines then.  If it ran on just one it wouldn't pop up the dialog on all machines.  :)

Offline uiox

  • Contributing Member
  • **
Re:DIALOGS IN MULTIPLAYER!?
« Reply #2 on: 06 Oct 2002, 17:04:28 »
It depends what you want doing...

Who call? How?

Etc...

Offline TheCaptain

  • Members
  • *
  • You and The Captain Can Make it Happen
Re:DIALOGS IN MULTIPLAYER!?
« Reply #3 on: 10 Oct 2002, 03:09:02 »
It's so incredibly bizzare.

Someone on one team dies, so a script is executed for that player

?(!alive player): player exec "spectatordialog.sqs"

The script is called "addweapons.sqs", and is run when a single player dies.

I've also tried executing the createdialog script based on the player name, even putting it in the init line of just one unit, or having it in scripts executed by only one unti... I've tried everything, and I'm missing something very important. Can someone PLEASE post a working one machine example? It's really irritating me, because I have to create the dialog and then close it on all machines except the one that ran the script.

Terrible, I worked for weeks trying to figure out how to get the time/date/weather variables to update on all machiens at once, and now I can't figure out how to get the damn dialogs to appear on only one machine.
The Captain

Offline TheCaptain

  • Members
  • *
  • You and The Captain Can Make it Happen
Re:DIALOGS IN MULTIPLAYER!?
« Reply #4 on: 10 Oct 2002, 09:12:07 »
The only way around it that I know is with custom actions. I now know that those can be defined only on a specific machine (and the script only run there), which is the real only way to make the dialog on one machine. Everything else I've tried results in everyone getting the dialog. I was rather hoping that it could be called for one machine individually outside of player actions...

I'd say solved, but I want to know if there's a way outside of player actions to exec the script locally?
The Captain

bn880

  • Guest
Re:DIALOGS IN MULTIPLAYER!?
« Reply #5 on: 10 Oct 2002, 17:54:14 »
That's the problem  ;)

your check should be
?(!alive nameOfPlayer && local nameOfPlayer):

in that case what ever is executed will only be executed on the specified players machine.  You can NOT use Player, Player exists on every client.

Good luck

bn880

  • Guest
Re:DIALOGS IN MULTIPLAYER!?
« Reply #6 on: 10 Oct 2002, 18:03:28 »
Terrible, I worked for weeks trying to figure out how to get the time/date/weather variables to update on all machiens at once, and now I can't figure out how to get the damn dialogs to appear on only one machine.

I had the same problem about a year ago, man was it ever FRUSTRATING!  I was used to programming languages and could not figure out that PublicVariable is not a declaration, but a function.   :o

You will solve your problems, remember that even a units init field is executed on all machines for that unit, since all units are Public and synchronized.  You have to use the local check.

also,  Player exec "script.sqs"  is erroneous, [Player] exec "script.sqs" is better, but Player exists on all clients (just different one).

Pope_Zog

  • Guest
Re:DIALOGS IN MULTIPLAYER!?
« Reply #7 on: 10 Oct 2002, 22:59:17 »
> also,  Player exec "script.sqs"  is erroneous, [Player] exec "script.sqs" is better

I beg to differ. It's not erroneous. The variable is accessible as _this. Why should one have to pass single parameters as an array? ;)

Pope Zog

bn880

  • Guest
Re:DIALOGS IN MULTIPLAYER!?
« Reply #8 on: 11 Oct 2002, 00:10:52 »
Well technically you are suppost to enclose the parameters passed in, in [].

It may work after all but it confuses people, novice scripters will think that it will be the unit executing the script.  I urge you to use the proper syntax to keep confusion away.  That's all.

So for what he thought it would do, it was wrong....
« Last Edit: 11 Oct 2002, 00:11:37 by bn880 »

Offline Sui

  • Former Staff
  • ****
    • OFPEC
Re:DIALOGS IN MULTIPLAYER!?
« Reply #9 on: 11 Oct 2002, 02:00:56 »
Well technically you are suppost to enclose the parameters passed in, in [].

Not at all... an array is used to pass multiple parameters... that's all ;)

It's a little known fact that you don't need to pass an array to a script. There's nothing wrong or "unproper" about passing a single element to a script outside of an array...

Though you're probably right about confusing newer scripters ;D

bn880

  • Guest
Re:DIALOGS IN MULTIPLAYER!?
« Reply #10 on: 11 Oct 2002, 02:13:34 »
Actually yes, you are right Sui, I just looked at the cmdRef again.

The confusion is the problem though.  :)

Offline TheCaptain

  • Members
  • *
  • You and The Captain Can Make it Happen
Re:DIALOGS IN MULTIPLAYER!?
« Reply #11 on: 11 Oct 2002, 05:46:35 »
Actually, when I said alive player, I was referring to the player's name, "W1, W2, W3"

By the way, Bn880, I looked at your marker/dialog script sync last night after I posted, and it made a world of difference.

"OH!", I said, "If you only tell ONE machine to give a player an action, the other people don't see it too..." - One problem I was having. That damn 3 meter range that you can see other people's actions was endlessly infuriating, because in my multiplayer mod, you have specific classes with about one special ability (I'm simplifying). When 8 players stand together... well... Everyone can execute anyone else's scripts.

Suicide bomber was funny before I caught the bug. =)

The workaround was to say "If you're not the player executing the script, when you ruin it, pop up a message", but that is, of course, needless when you can just add them locally.

Ironic, since I spent about a month trying to get functions like setrain/time/fog/etc to be public, not private. Also, a lot of scripts I execute as either player or [], but I just now realized the disctinction that the runner if the script is irrelevant unless it's being used in the script. Thanks for the disctinction.


This:

?(!alive nameOfPlayer && local nameOfPlayer):

VERY helpful. Didn't think about using local on the player's name. Thanks, all of you.


OFPEC is tylenol for my scripting.
The Captain

Offline uiox

  • Contributing Member
  • **
Re:DIALOGS IN MULTIPLAYER!?
« Reply #12 on: 11 Oct 2002, 20:23:47 »
Quote
Everyone can execute anyone else's scripts.

In addaction script you have automatically 3 parameters:

_this select 0   owner of action
_this select 1   unit that call action
_this select 2   index of action

In all your action scripts you put this :
? _this select 0 != _this select 1 : exit

If you use a lot of action commands some tips :

switch on/off

_Owner = _this select 0
_Caller = _this select 1
_id = _this select 2
? _caller != _Owner : exit

_Owner removeaction _id

? SwitchOn :   _aD= _Owner addaction ["Switch on", "ThisScript.sqs"] ;SwitchOn = false ;exit

_aD= _Owner addaction ["Switch off", "ThisScript.sqs"]
SwitchOn =true

You can add action to object, trigger, vehicle, gun, logic.

With 2 triggers you can manage the detection area.

One present for intall action and set the index
Index = Object addaction [ ]
One not present for desinstall
Object removeaction Index
« Last Edit: 11 Oct 2002, 20:45:18 by uiox »

Offline TheCaptain

  • Members
  • *
  • You and The Captain Can Make it Happen
Re:DIALOGS IN MULTIPLAYER!?
« Reply #13 on: 12 Oct 2002, 12:43:01 »
Wow, that's essential. Thanks!
The Captain