OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: dmakatra on 13 Jun 2003, 20:04:21
-
Yea Im back again with a new Q. ItÂ's gonna be a whole lot of Qs these months cause I got this mission which is way over my OFP mind... but whatever. ;D :P
Any1 know how to make a clickable marker or sumthin like that? I wanna make this cause IÂ'm working on some kinda half-command-engine-dunno-watcha-really-gonna-call-it-thing. Like u click on a marker on the map itÂ'll return some sidechat message or sum script or sumthin. Any1 know how I can do this? And itÂ's a moving marker. I appriciate any help. Thx. :-*
-
One way is to have an array of your marker names:
_markers=["one","two","three"] or whatever....
and then determine if the map click position is within a certain distance (20 meters??) of a marker or find which marker is closest.
Using SnyPir's distancepos function:
_mappos=map click position
_dis=999999
_closest=""
{_d=[_mappos,getmarkerpos _x] call distancepos;if (_d<_dis) then {_dis=_d;_closest=_x}} foreach _markers
_closest will contain the name of the closest marker to the map click position. _dis will be its distance. If _dis is less than , say 20 meters, then that is the marker you clicked on. That prevents clicking 1km away from the nearest marker and having it select that marker.
Syntax may not be perfect but that should work. Could be a better way also.
-
dead dog is right ;D
but da syntax is... ;) ;D
u have 2 use onmapsingleclick command here
so
it starts like dat
onmapsingleclick "_pos exec {NEarest.sqs}"
now da script (nearest.sqs)
_pos = _this select 0
_dis=20
_closest=""
{_d=[_mappos,getmarkerpos _x] call distancepos;if (_d<_dis) then {_dis=_d;_closest=_x}} foreach _markers
? _dis > 20 : exit
.... rest ofscript : _closest is da chosen marker
:cheers:
LCD OUT
-
OK. Didnt understand much of that but u are the scripter master so what can go wrong? ;D I have to study my scritpin skills. :P
Cheers!
:cheers:
*adds to creds list* ;)