Home   Help Search Login Register  

Author Topic: OnMapSingleClick SetMarkerPos help  (Read 1142 times)

0 Members and 1 Guest are viewing this topic.

Offline Ding

  • Contributing Member
  • **
  • Jurassic Park
OnMapSingleClick SetMarkerPos help
« on: 24 Aug 2008, 13:04:10 »
Im trying to make a marker change location when there is a single click on the map yet it does not seem to work atall

Code: [Select]
OnMapSingleClick {"Pos1" setMarkerPos GetMarkerPos "Pos2"}
is the first one I tried to use with no luck atall, I then tried switching the quotations and brackets in a number of combinations but nothing seems to work I keep getting an error saying

Code: [Select]
Error GetMarkerPos: type code expected string
Its also activated on Radio Alpha if that is of any significance.
"If I remain lost and die on a cross, atleast I wasn't born in a manger"

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: OnMapSingleClick SetMarkerPos help
« Reply #1 on: 24 Aug 2008, 13:10:46 »
That is because onMapSingleClick is one of those archaic hacks that BIS gave us sometime back in OFP 1.46, and hasn't seen fit to fix since (like addAction :D) -> in other words, it doesn't use the {} code brackets, but "" quotes.

Code: [Select]
onMapSingleClick """markername"" setmarkerpos getmarkerpos ""markername2"""
In other words, for every string inside the quotes "", you need to add double quotes "" (which is why there are double quotes around the marker names). Something with no strings makes a lot more sense: onMapSingleClick "unit1 domove getpos unit2".

However, why activate this strange code with onMapSingleClick? usually you want to move markers TO the position you clicked, no? In that case you can use the local variable _pos, which funnily enough is called just that within the quotes ->

Code: [Select]
onMapSingleClick """markername"" setmarkerpos _pos"
Good luck!

Wolfrug out.
« Last Edit: 24 Aug 2008, 13:16:53 by Wolfrug »
"When 900 years YOU reach, look as good you will not!"

Offline Ding

  • Contributing Member
  • **
  • Jurassic Park
Re: OnMapSingleClick SetMarkerPos help
« Reply #2 on: 24 Aug 2008, 20:19:38 »
ah thanks for the speedy reply that explains alot :D
"If I remain lost and die on a cross, atleast I wasn't born in a manger"