Home   Help Search Login Register  

Author Topic: OnMapClick and making it public  (Read 2040 times)

0 Members and 1 Guest are viewing this topic.

Offline icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
OnMapClick and making it public
« on: 21 Feb 2004, 03:06:21 »
I have a script that relies on a map click.

I know that map clicks are client side only, and have to then be made public to everyone else and the server, the question is how I do this.

OnMapClick parses the variable _pos to another script, where it is made into a public variable.

But how do I make all the server, and the other clients know that the click has happened, and this needs to run the relative script using the variable _pos ?

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:OnMapClick and making it public
« Reply #1 on: 23 Feb 2004, 14:05:36 »
What about this one:


a = 0
b = 0
clicked = false

onMapSingleClick {a = (_pos select 0); b = (_pos select 1); clicked = true"publicVariable _x" forEach [a,b,clicked]}

@clicked

onMapSingleClick {}
_pos = [a,b]


And voilla - you have transferred the position array _pos to
every participiant in the network, and all were waiting for
the click to be clicked wherever  ;)

~S~ CD
« Last Edit: 23 Feb 2004, 17:59:16 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 icarus_uk

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:OnMapClick and making it public
« Reply #2 on: 24 Feb 2004, 16:31:21 »
Ok, part of my brain dribbled out of the side of my head because of that.

My current mapclick script looks like this;


hint "select map location"

onMapSingleClick {[_pos] exec "radio_arty.sqs"}

exit


Now where do I add in your lines of code?

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:OnMapClick and making it public
« Reply #3 on: 24 Feb 2004, 16:48:01 »
Code: [Select]
a = 0
b = 0
clicked = false

onMapSingleClick {a = (_pos select 0); b = (_pos select 1); clicked = true"publicVariable _x" forEach [a,b,clicked]}

@clicked

onMapSingleClick {}
_pos = [a,b]

[_pos] exec "radio_arty.sqs"

or instead of the last two lines you could also say:

[a,b] exec "radio_arty.sqs"

The difference would then be:

using [_pos] exec "blabla"

would look in radio_arty.sqs like:

_whatevernameyouchoose = _this select 0

result is a 2d array

using [a,b] exec "blabla"

would look in radio_arty.sqs like:

_posa = _this select 0
_posb = _this select 1

result is:

a seperate x/y coordinate splitted into two numeric variables

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

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:OnMapClick and making it public
« Reply #4 on: 24 Feb 2004, 17:36:47 »
Quality.  Ive not tested it in mplayer yet, but its still working in the editor.  Which is a good sign :)

Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:OnMapClick and making it public
« Reply #5 on: 24 Feb 2004, 18:16:56 »
Just noticed a syntax typo:  :-[

Code: [Select]
onMapSingleClick {a = (_pos select 0); b = (_pos select 1); clicked = true"publicVariable _x" forEach [a,b,clicked]}

between: clicked = true

and: "publicVariable .....

i was missing a semicolon.

correct line is:

Code: [Select]
onMapSingleClick {a = (_pos select 0); b = (_pos select 1); clicked = true; "publicVariable _x" forEach [a,b,clicked]}

Just in case you haven't already noticed my typo by yourself

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

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:OnMapClick and making it public
« Reply #6 on: 24 Feb 2004, 19:42:35 »
Hehe yes I did.

I also had to move the

"publicVariable _x" forEach [a,b,clicked]

outside of the map click {}'s as it didnt work. Publicvariable needs to have the varaible in "quotes",  and

"publicVariable "_x"" forEach [a,b,clicked]

Wasnt working.  So I now just do them all seperately one after the other, not as a foreach.


Offline Chris Death

  • Former Staff
  • ****
  • Finally Death's gonna get ya
    • OFPEC
Re:OnMapClick and making it public
« Reply #7 on: 24 Feb 2004, 21:58:46 »
Nah icarus, i don't think so

publicVariable might not been working upon the missing
semicolon.

It's always allowed to use one pair of quotation marks "",
and it's allowed to use endless (not sure if really endless),
{} brackets.

Maybe you could also try to leave out the quotation marks and
replace it by those brackets:

Code: [Select]
onMapSingleClick {a = (_pos select 0); b = (_pos select 1); clicked = true; {publicVariable _x} forEach [a,b,clicked]}

But still i say this one should work too:

Code: [Select]
onMapSingleClick {a = (_pos select 0); b = (_pos select 1); clicked = true; "publicVariable _x" forEach [a,b,clicked]}

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

  • Members
  • *
  • LiarLiarPants Inflame True
    • [furryclan]
Re:OnMapClick and making it public
« Reply #8 on: 25 Feb 2004, 00:19:41 »
I already tried and it gave me errors.

The {brackets} however do work.
« Last Edit: 25 Feb 2004, 00:21:58 by [icarus_uk] »