OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting Multiplayer => Topic started by: icarus_uk 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 ?
-
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
-
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?
-
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
-
Quality. Ive not tested it in mplayer yet, but its still working in the editor. Which is a good sign :)
-
Just noticed a syntax typo: :-[
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:
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
-
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.
-
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:
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:
onMapSingleClick {a = (_pos select 0); b = (_pos select 1); clicked = true; "publicVariable _x" forEach [a,b,clicked]}
~S~ CD
-
I already tried and it gave me errors.
The {brackets} however do work.