Home   Help Search Login Register  

Author Topic: @ publicvariable on client is true  (Read 2740 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
@ publicvariable on client is true
« on: 21 Jan 2004, 21:02:31 »
Hey!

I've put together a little script and there's something wrong with it. Can't put my finger on it and thought you eagle eyes could spot it.

What the script does is it detects if any of certain units are close or far to certain units and then plays certain music accordingly.

I'm thinking it something about the safesongclient and dangersongclient variables in the @ lines, which are used to tell the clients when it's ok to resume reading the script.

The script used to play only on server, untill I added lines "safesongclient = false", "dangersongclient = false". Now it plays on neither server or client.

Thanks in advance.


Code: [Select]
safesongclient = false
dangersongclient = false
_safesongs = ["soft","smooth","kinky","wait"]
_dangersongs = ["hard","hard2","spirited","wait"]
_johtajat = [Davleman,Neveklovman,Kostman,Skaliceman,Pasekyman,Opatovman,Joudovman,Dolinaman,Mokropsyman,
Slapyman,Vidlakovman,Petroviceman,Mirovman,Modravaman,Mokravrataman,tempman_0,tempman_1,tempman_2,
tempman_3,tempman_4,tempman_5,tempman_6,tempman_7,tempman_8,tempman_9,Stsedloman,Okrouhloman,
Borman,Lipanyman,Lanyman,Bitovman,Malavesman,Velkavesman,Blataman,Loukovman,Vartaman,Troskyman,Kvildaman,
wtempman_0,wtempman_1,wtempman_2,wtempman_3,wtempman_4,wtempman_5,wtempman_6,wtempman_7,
wtempman_8,wtempman_9]
~5
#loop

?({_x distance (leader maingroup) > 400} count _johtajat) == (count _johtajat): goto "safesongs"
?({_x distance (leader maingroup) < 350} count _johtajat) > 0: goto "dangersongs"

~3
goto "loop"

#safesongs
?!(local server): goto "safesongswaitforclient"
_randomsafesongselect = random (count _safesongs)
_randomsafesongselect = _randomsafesongselect - (_randomsafesongselect mod 1)
randomsafesong = _safesongs select _randomsafesongselect
safesongclient = true
publicvariable "randomsafesong"
publicvariable "safesongclient"
~2

#safesongswaitforclient
@safesongclient
safesongclient = false
publicvariable "safesongclient"
?randomsafesong == "wait": goto "wait"
playmusic randomsafesong
goto "wait"


#dangersongs
?!(local server):goto "dangersongswaitforclient"
_randomdangersongselect = random (count _dangersongs)
_randomdangersongselect = _randomdangersongselect - (_randomdangersongselect mod 1)
randomdangersong = _dangersongs select _randomdangersongselect
dangersongclient = true
publicvariable "randomdangersong"
publicvariable "dangersongclient"
~2

#dangersongswaitforclient
@dangersongclient
dangersongclient = false
publicvariable "dangersongclient"
?randomdangersong == "wait": goto "wait"
playmusic randomdangersong
goto "wait"


#wait
_luuseri = [_johtajat,(leader maingroup)] call closesttarget
?_luuseri distance (leader maingroup) < 200: _johtajat = _johtajat - [_luuseri]
_count = 0
#waitloop
_count = _count +1
?({_x distance (leader maingroup) < 150} count _johtajat) > 0: goto "loop"
?_count > 120: goto "loop"
~1
goto "waitloop"


/edit
jesus, that one array sure messes up the format on the thread. Has something happened to the forum template or settings or something?
« Last Edit: 21 Jan 2004, 22:10:01 by Artak »
Not all is lost.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:@ publicvariable on client is true
« Reply #1 on: 21 Jan 2004, 21:43:55 »
Just glanced quickly at this, but, if safesongclient and dangersonclient are set as false at the start, maybe it is sticking at these points:

#safesongswaitforclient
@safesongclient

and


#dangersongswaitforclient
@dangersongclient


Seems to me they will never be true conditions till they are set true.

Maybe I missed somnething?


Planck
I know a little about a lot, and a lot about a little.

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:@ publicvariable on client is true
« Reply #2 on: 21 Jan 2004, 22:08:27 »
Thanks for the input Planck   :)

The variables 'safesongclient' and 'dangersongclient' are being set to true by server under bookmarks '#safesongs' and '#dangersongs' from where their new value (true) is being sent to the clients.

I don't think what you thought you saw is the clitch. Right now my eyes and brain hurt so much that I'm going to go to bed. If you still feel the way do, please say so and I'll check back in the morning and try to prove you wrong.  :D
Not all is lost.

Unnamed

  • Guest
Re:@ publicvariable on client is true
« Reply #3 on: 21 Jan 2004, 22:45:40 »
Cant help much with Multiplayer :(

But if you want to debug your @'s try something like:

Code: [Select]
@(Call {Hint Format ["Safe Song=%1",safesongclient] ; safesongclient})
It will still return safesongclient for the wait condition, but you can do other stuff at the same time.

Edit:

Removed spurious comments

Edit:

I think I will stick with........Wow this MP stuff is tricky.
« Last Edit: 22 Jan 2004, 01:16:04 by Unnamed »

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:@ publicvariable on client is true
« Reply #4 on: 22 Jan 2004, 00:30:47 »
Hello Artak,

i'll start working in 5 hours, and still got no sleep yet.

If your problem hasn't been solved then, i'll have a quick
look onto it.  ;)

soz i can't do it now, but i already slept 2 hours tooooo long
past morning  :D

~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 Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:@ publicvariable on client is true
« Reply #5 on: 22 Jan 2004, 00:57:14 »
Ok......I had a better look at it, I understand now how the @safesongclient and @dangersongclient statements are supposed to work.

Still haven't found out why it doesn't work.

Is there any error message at all?


Planck
I know a little about a lot, and a lot about a little.

deaddog

  • Guest
Re:@ publicvariable on client is true
« Reply #6 on: 22 Jan 2004, 01:48:28 »
One potential problem:

The server sets the variable true and the clients wait condition is satisfied.  The client immediately sets the variable to false but the server has to wait two seconds.  It will then get stuck on its wait condition because the variable has been set to false by the client.


Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re:@ publicvariable on client is true
« Reply #7 on: 22 Jan 2004, 01:51:50 »
Uh huh.......I was leaning towards a timing issue.


Planck
I know a little about a lot, and a lot about a little.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:@ publicvariable on client is true
« Reply #8 on: 22 Jan 2004, 07:51:21 »
Morning Artak,

Well, as deaddog already said:

server sets safesongclient true - client makes it false, while
server waits 2 seconds - server will wait forever @safesongclient

Solution:

don't publicVariable "safesongclient" on clientside.

You did fine on serverside, but after #safesongswaitforclient
you do publicVariable "safesongclient" again.
:note - this line will be executed everywhere, therefore the
first client, executing it will set it to false globally.

Just remove the publicVariable and it should be fine.

Off course the same occurs at #dangersongswaitforclient

:edit - btw, the script, like you made it, even works in singleplayer and when playing alone on a non-dedicated
server.

~S~ CD
« Last Edit: 22 Jan 2004, 07:53:50 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

Offline Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:@ publicvariable on client is true
« Reply #9 on: 22 Jan 2004, 10:32:17 »
Riiight!
Thanks guys, it's all clear to me now!  :-*

I'll fix the script and give it a go when I get home in a few hours and then report back here.
Not all is lost.

Offline Terox

  • Former Staff
  • ****
  • Follow the Sappers!
    • zeus-community.net
Re:@ publicvariable on client is true
« Reply #10 on: 22 Jan 2004, 15:53:28 »
a tip on optimisation, you PV twice in two lines, this means that each PV will be sent in two packets, its better to place both these variables in an array and then PV foreach _X of that array

change
Code: [Select]
publicvariable "randomsafesong"
publicvariable "safesongclient"

to
Code: [Select]
{PublicVariable _x;}foreach["safesongclient","randomsafesong"]

« Last Edit: 22 Jan 2004, 16:15:49 by Terox »
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:@ publicvariable on client is true
« Reply #11 on: 22 Jan 2004, 18:46:23 »
Thanks for the tip Terox. Done.

However, the problem is not solved. Now the server can hear the music (I managed to have it like this before) but the client doesn't.
What I have now is:

Code: [Select]
safesongclient = false
dangersongclient = false
_safesongs = ["soft","smooth","kinky","wait"]
_dangersongs = ["hard","hard2","spirited","wait"]
_johtajat = [Davleman,Neveklovman,Kostman,Skaliceman,Pasekyman,Opatovman,Joudovman,Dolinaman,
Mokropsyman,Slapyman,Vidlakovman,Petroviceman,Mirovman,Modravaman,Mokravrataman,tempman_0,
tempman_1,tempman_2,tempman_3,tempman_4,tempman_5,tempman_6,tempman_7,tempman_8,
tempman_9,Stsedloman,Okrouhloman,Borman,Lipanyman,Lanyman,Bitovman,Malavesman,Velkavesman,
Blataman,Loukovman,Vartaman,Troskyman,Kvildaman,wtempman_0,wtempman_1,wtempman_2,
wtempman_3,wtempman_4,wtempman_5,wtempman_6,wtempman_7,wtempman_8,wtempman_9]
~5
#loop

?({_x distance (leader maingroup) > 400} count _johtajat) == (count _johtajat): goto "safesongs"
?({_x distance (leader maingroup) < 350} count _johtajat) > 0: goto "dangersongs"

~3
goto "loop"

#safesongs
?!(local server): goto "safesongswaitforclient"
_randomsafesongselect = random (count _safesongs)
_randomsafesongselect = _randomsafesongselect - (_randomsafesongselect mod 1)
randomsafesong = _safesongs select _randomsafesongselect
safesongclient = true
{PublicVariable _x} foreach ["safesongclient","randomsafesong"]
~2

#safesongswaitforclient
@safesongclient
?!(local server): hint "vitun musiikki"
?(local server): safesongclient = false; publicvariable "safesongclient"
?randomsafesong == "wait": goto "wait"
playmusic randomsafesong
?!(local server): hint "vitun musiikki 2"
goto "wait"


#dangersongs
?!(local server):goto "dangersongswaitforclient"
_randomdangersongselect = random (count _dangersongs)
_randomdangersongselect = _randomdangersongselect - (_randomdangersongselect mod 1)
randomdangersong = _dangersongs select _randomdangersongselect
dangersongclient = true
{PublicVariable _x} foreach ["dangersongclient","randomdangersong"]
~2

#dangersongswaitforclient
@dangersongclient
?(local server): dangersongclient = false; publicvariable "safesongclient"
?randomdangersong == "wait": goto "wait"
playmusic randomdangersong
goto "wait"


#wait
_luuseri = [_johtajat,(leader maingroup)] call closesttarget
?_luuseri distance (leader maingroup) < 200: _johtajat = _johtajat - [_luuseri]
_count = 0
#waitloop
_count = _count +1
?({_x distance (leader maingroup) < 150} count _johtajat) > 0: goto "loop"
?_count > 120: goto "loop"
~1
goto "waitloop"

It's as if the client never even gets the publicvariables.  :-[

/edit
I added a hint under the bookmark #safesongs and now I know the script goes at least to that point with on clients. My friend reported seeing the hint but still no music. I'll be working with this for the next couple of hours.

/edit
Also tried the hint in a new place. Now right after the playmusic command. It's now becaming clear to me that the command is executed on the clients as well, but for some reason they just can't hear the music still..
Continuing the debugging.
* Artak feels like he's writing a freaking diary

/edit
Even tried making every damn variable global in the script. I guess it only shows I'm out of ideas and how despetately I want it to work :P
(It didn't work btw   ;D ::))
« Last Edit: 22 Jan 2004, 20:38:47 by Artak »
Not all is lost.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:@ publicvariable on client is true
« Reply #12 on: 22 Jan 2004, 21:19:07 »
hmm - could it be that you define randomsafesong
and randomdangersong only on serverside ?

Let the script make a dummyrun thru your head, and
think about, that randomdangersong and randomsafesong
do not become defined on clientside.

You need to publicVariable the result of your variables:
_randomsafesongselect and _randomdangersongselect
to the clients, so that on clientside you just need to do

randomsafesong = _safesongs select _randomsafesongselect
or
randomdangersong = _dangersongs select _randomdangersongselect

You need to do it that way, because the way you are trying
it doesn't work in multiplayer.
You cannot publicVariable "strings"
like you did with:
randomsafesong and randomdangersong

~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 Artak

  • The old beanbag shaker
  • Former Staff
  • ****
  • You want to talk about it, yes?
    • OFP Team Finlanders
Re:@ publicvariable on client is true
« Reply #13 on: 22 Jan 2004, 21:31:08 »
That's what I thought too. But it felt like too much work, so I decided to wait until someone smarter than me tells it to my face.
You recon that's my last alternative? Could I do something amazing like make the song names array  
safesongs = [soft,smooth,kinky,wait]  
and then in the script use something like  
playmusic format insert a clever way to add quotes around the song name here?
« Last Edit: 22 Jan 2004, 21:31:38 by Artak »
Not all is lost.

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:@ publicvariable on client is true
« Reply #14 on: 22 Jan 2004, 21:37:18 »
You don't need it that complicated Artak.

All you need to do is: tell them clients the result of your
random array counter:

_randomsafesongselect = random (count _safesongs)
_randomsafesongselect = _randomsafesongselect - (_randomsafesongselect mod 1)

publicVariable "_randomsafesongselect"


This is a numeric value, and can be sent thru.

Now all you need to do on clientside is:

select your song from the array on clientside (not only on serverside).

~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