Home   Help Search Login Register  

Author Topic: sidechat, globalchat, publicvariable - MP  (Read 4487 times)

0 Members and 1 Guest are viewing this topic.

Offline SniperAndy

  • Members
  • *
    • VBS Community
sidechat, globalchat, publicvariable - MP
« on: 30 Sep 2006, 17:24:42 »
Hi,
I been messing around with the stringtable tutorial that was put online on ofpec and hey, thanks. The problem I have now is that in my MP scenario the messages called from the stringtable are not send to all clients in the mission. I know I need to define the publicvariable but I don't seem to know what my variable is or how to set it.

I'm looking for a solution where I can have the whole thing in 1 trigger.
Like:

Code: [Select]
civ1 globalchat "Hey you, what are you looking at"; publicvariable.....
Is this possible? And if not, how would I go about getting this to work then?

Cheers... ;)
« Last Edit: 03 Oct 2006, 20:17:46 by SniperAndy »

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: sidechat, globalchat, public variable - one line
« Reply #1 on: 30 Sep 2006, 19:31:39 »
a possible solution:

use 2 triggers instead of one

first trigger as you already have, but in on activation put

Code: [Select]
firstchatline true; publicvariable "firstchatline"

then set up a second trigger. In the condition field simply put

Code: [Select]
firstchatline

and in the on activation you can call your globalchat command.

imho this should work for MP, but due to lag you'll have little desync between all clients, but i think this factor can be forgotten (would be in the size of a few dozens ms)

Offline JasonO

  • OFPEC Patron
  • ****
  • Oh no...
    • The New Life RPG
Re: sidechat, globalchat, public variable - one line
« Reply #2 on: 01 Oct 2006, 14:47:14 »
Myke, wouldnt that be a lot of triggers for a big amount of chat?

I havnt tested but this might work:

Code: [Select]
firstchatline = civ1 globalchat "Hey you, what are you looking at"; publicvariable"firstchatline"

Offline SniperAndy

  • Members
  • *
    • VBS Community
Re: sidechat, globalchat, public variable - one line
« Reply #3 on: 01 Oct 2006, 16:07:45 »
Thanks for the replies!
I wanted to avoid using 2 triggers. So I give the 2nd. one a try later today.

Thanks again, I'll post my results here... :good:

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: sidechat, globalchat, public variable - one line
« Reply #4 on: 01 Oct 2006, 16:20:54 »
yep true. It will double the amount of triggers and when you have a lot of sideradio/chat it will cover your map with triggers  :whistle:

Another solution might be (dunno how it works exactly but i know it can be done, somehow):

Use a script which contains all sideradio/chat lines you need.

Code: [Select]
#wait
@(sideradiovariable >= 0)
goto format [%1, "sideradiovariable"]

#1
civ1 globalchat "Hey you, what are you looking at"
sideradiovariable = 0
publicvariable "sideradiovariable"
goto "wait"

#2
soldier1 globalchat "I'm looking your stupid face"
sideradiovariable = 0
publicvariable "sideradiovariable"
goto "wait"
....
...
..
.

This code will not work since i dunno how exactly the FORMAT command goes together with the GOTO command, but i know it can be done.

Now in the triggers just set the sideradiovariable to the number which corresponds with the line in the script.
Start the script at the beginning of the mission.

Once again, the script above WILL NOT WORK AS IS!! But i know it can be done in this direction.

Offline SniperAndy

  • Members
  • *
    • VBS Community
Re: sidechat, globalchat, public variable - one line
« Reply #5 on: 03 Oct 2006, 14:33:07 »
Me again.... :whistle: So I tried:

Code: [Select]
msg1 = civ1 globalchat "Hey you, what are you looking at"; publicvariable "msg1"
With and without "" at the variable etc...
It doesn't work, all I get is this error when I try to save it (see attached image).

I gave the script some thoughts but wouldn't that be sitting there running all the time??
Also 2 Triggers are not a real solution. I would prefer if I could avoid using multiple triggers for the same event.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re: sidechat, globalchat, public variable - one line
« Reply #6 on: 03 Oct 2006, 18:59:08 »
Indeed it doesn't work due to the fact that strings cannot be PublicVariable'd.  ;)

In this case it's helpful to use a global array, where you put all your chat texts inside.
Initialize the array in init.sqs:

msg_array = ["Hey you, what are you looking at","why do you care about it","because you should secure the area","but you ordered me to watch a nasty Saddam Picture"]

Then you can use a numeric variable to select the chat lines from the array and publicVariable it:

msg_selector = 0; publicVariable msg_selector

:note - off course you set msg_selector to the message you want to broadcast - the first element of the
array would be 0, the second one would be 1 and so on.

msg1 = msg_array select msg_selector
soldier1 globalchat msg1

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: sidechat, globalchat, public variable - one line
« Reply #7 on: 03 Oct 2006, 19:36:52 »
i think i was unclear with explaining my approach. (points up to my previous drawn script).

Indeed, the @ will let the script wait until the sideradiovariable becomes unequal 0. This will be done by triggers by using

Code: [Select]
sideradiovariable 3; publicvariable "sideradiovariable"
in the on activation field of the trigger. As now the sideradiovariable is unequal to zero, the script will continue. By using the variables value "3", the script should now read

Code: [Select]
goto "3"
and jump to the  corresponding part of the script. Now the sideradio command will be executed, the variable rested to "0" and the script lead to the wait part again, awaiting the next change of the variable.

For this, i would really like to know how to use the "format" command together with a "goto" command.

So the line
Code: [Select]
goto format [%1, "sideradiovarible"]

will be read as
Code: [Select]
goto "3"


True, you'll have a script waiting during the whole mission, but it is only one script, which in fact is the same as one single trigger more on the map.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re: sidechat, globalchat, public variable - one line
« Reply #8 on: 03 Oct 2006, 19:44:37 »
Off course this methods also works Myke, but imagine there were more than just
a couple of text-messages (well let's say 50).

How nice the script would explode in size having 50 different goto locations,
each simply featuring the same code over and over again.  ;)

Therefore an array can be used to shorten things up a little bit.

~S~ CD
Dont argue with idiots....they will bring you down to their level and beat you there with experience.

How to use Waypoint type Scripted

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: sidechat, globalchat, public variable - one line
« Reply #9 on: 03 Oct 2006, 19:52:03 »
you're right chris...as usual  :D

but (just to say a word for my way) if you take 50 messages, a array containing these messages would be close to "unreadable", as the script would be really long, but better read- and editable.

But i agree with you that the array will be the more elegant way to do it.  :good:

Offline SniperAndy

  • Members
  • *
    • VBS Community
Re: sidechat, globalchat, public variable - one line
« Reply #10 on: 03 Oct 2006, 20:15:00 »
I didn't think radio messages would be such a issue in OFP/VBS. I was under the impression it would be more easy to get this to work than the need of my stringtable, the array and broadcasting the public variables. Damn, I'm gonna give this a swing tomorrow in a test mission and see if I get this to work now.

How would I call the msg_selector to get my strings from the stringtable?
By adding the strings to the msg_array??

Thanks for the input so far guy.  :good:
I think this should be food for a nice tutorial.
Since I haven't found one yet that covers this for MP.

If I need more help I make sure I come back for more... :whistle:

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: sidechat, globalchat, publicvariable - MP
« Reply #11 on: 03 Oct 2006, 20:50:17 »
re-read chrisÂ's post again, itÂ's all in there.

the array:
Code: [Select]
msg_array = ["Hey you, what are you looking at","why do you care about it","because you should secure the area","but you ordered me to watch a nasty Saddam Picture"]

selecting the message:
Code: [Select]
msg_selector = 0; publicVariable msg_selector

msg_selector which is set now to the first entry of the msg_array ("Hey you, what are you looking at").
For selecting another message just replace with another number, i.e. msg_selector = 1would set the second message from the array.

Broadcasting the message:

Code: [Select]
msg1 = msg_array select msg_selector
soldier1 globalchat msg1

Offline SniperAndy

  • Members
  • *
    • VBS Community
Re: sidechat, globalchat, publicvariable - MP
« Reply #12 on: 04 Oct 2006, 13:37:09 »
Yes I know. I did understand that.
But I have my messages arranged in a stringtable now.
So in the array of the init.sqs would I still have to add all the text of the messages or can I add my strings from the stringtable to the array? That was the question. Because my array would become rather large if I have to add all the message to it witch then again makes the use of the stringtable..ehhh... useless in that case.

Thanks...

Offline myke13021

  • Contributing Member
  • **
  • Myke
Re: sidechat, globalchat, publicvariable - MP
« Reply #13 on: 04 Oct 2006, 21:27:13 »
well, infact CD is the specialist for arrays, butas far as i understand them, you can also fill it with the messages defined by the stringtable. But better wait for chris to verify this.

Offline SniperAndy

  • Members
  • *
    • VBS Community
Re: sidechat, globalchat, publicvariable - MP
« Reply #14 on: 05 Oct 2006, 12:52:38 »
/me knocks on the door of Chris...knock...knock...

I hope he can enlighten me.
Wanted to get this tested by our guys on the weekend so we can upload and keep the scenario on the server. Or better, I can go and tweak the reamining stuff  ;)

Thanks for your help Myke...