mattxr 9 Posted April 3, 2009 (edited) I need some help. Im trying to make a script which will create a waypoint for a group after clicking the map. Sla_force CentreCreate = createCenter east; _sla_force = createGroup east; _pos=_this select 0; _i=1; #loop _i=_i+1; _t="BMP2" createvehicle [0,0,0]; ; -- Driver -- "SoldierECrew" createunit [[0,0,0], _sla_force,"", *1.0, "CAPTAIN"]; _driver = nearestobject [[0,0,0],"SoldierECrew"]; _driver moveindriver _t; _t SetPos [((_pos select 0)+_i*10),(_pos select 1),(_pos select 2)]; _t setdir getdir player _t Lock FALSE; ; -- Gunner -- "SoldierECrew" createunit [[0,0,0], _sla_force,"", *1.0, "COLONEL"]; _gunner = nearestobject [[0,0,0],"SoldierECrew"]; _gunner moveingunner _t; ~0.1 ; -- Cargo -- "SquadLeaderE" createunit [[0,0,0], _sla_force,"", *1.0, "MAJOR"]; _cargo = nearestobject [[0,0,0],"SquadLeaderE"]; _cargo moveincargo _t; "SoldierEB" createunit [[0,0,0], _sla_force,"", *1.0, "CAPTAIN"]; _cargo = nearestobject [[0,0,0],"SoldierEB"]; _cargo moveincargo _t; "SoldierEMG" createunit [[0,0,0], _sla_force,"", *1.0, "CAPTAIN"]; _cargo = nearestobject [[0,0,0],"SoldierEMG"]; _cargo moveincargo _t; "SoldierEAT" createunit [[0,0,0], _sla_force,"", *1.0, "CAPTAIN"]; _cargo = nearestobject [[0,0,0],"SoldierEAT"]; _cargo moveincargo _t; "SoldierEAA" createunit [[0,0,0], _sla_force,"", *1.0, "CAPTAIN"]; _cargo = nearestobject [[0,0,0],"SoldierEAA"]; _cargo moveincargo _t; ?(_i <=2): goto "loop" ~0.1 _i=_i+1; _g="T72" createvehicle [0,0,0]; "SoldierECrew" createunit [[0,0,0], _sla_force,"", *1.0, "CAPTAIN"]; _driver = nearestobject [[0,0,0],"SoldierECrew"]; _driver moveindriver _g; _g SetPos [((_pos select 0)+_i*10),(_pos select 1),(_pos select 2)]; _g setdir getdir player _g Lock FALSE; ; -- Gunner -- "SoldierECrew" createunit [[0,0,0], _sla_force,"", *1.0, "CAPTAIN"]; _gunner = nearestobject [[0,0,0],"SoldierECrew"]; _gunner moveingunner _g; ~0.1 ; --Gunner -- "SoldierECrew" createunit [[0,0,0], _sla_force,"", *1.0, "COLONEL"]; _gunner = nearestobject [[0,0,0],"SoldierECrew"]; _gunner moveincommander _g; ~0.1 TitleText [format["Select a Move Point on the Map"], "PLAIN DOWN"] ~2 TitleText [format[" "], "PLAIN DOWN"] onMapSingleClick "["_pos2","_sla_force"] exec ""scripts\C\slaforce\movethere.sqs""" movethere _pos2=_this select 0; _sla_force=_this select 1; _sla_force addWaypoint[getpos _pos2,0] [_sla_force, 1] setWaypointType "SAD" exit; All the code works with the creation of the unit, but the waypoint at the end doesnt work. If i used this at the end of the main script it works but i dont want it to head towards the player but to where i click _sla_force addWaypoint[getpos player,0] [_sla_force, 1] setWaypointType "SAD" The script first runs by radiomenu which runs a script to allowe me to onsinglemapclick where i want them to spawn. Edited April 13, 2009 by W0lle Share this post Link to post Share on other sites
Rav_Raven 8 Posted April 3, 2009 (edited) Hi Matt. Script generation Waypoint receives as a parameter _pos2 (a coordinate position) and your script takes it as an object and takes the position coordinate of a position. This should read as follows: private ["_pos2","_sla_force"]; _pos2=_this select 0; _sla_force=_this select 1; _sla_force addWaypoint[_pos2,0] [_sla_force, 1] setWaypointType "SAD" exit; Besides the command onmapsingleclick coordinates stored in the variable _pos (not _pos2). Then your last line of the script should be: onMapSingleClick "[_pos, _sla_force] exec ""scripts\C\slaforce\movethere.sqs"""; Greetings from Argentina. Edited April 13, 2009 by W0lle Share this post Link to post Share on other sites
poweruser 10 Posted April 4, 2009 The onMapSingleClick command defines a statement which is executed every time you left-click on the map, you cannot use local variables of your script in it (like: _sla_force), as it simply cannot access it. Use a global variable for the group you create instead, e.g. sla_force Share this post Link to post Share on other sites
mattxr 9 Posted April 4, 2009 thanks for the replys, but it didnt seem to work. Share this post Link to post Share on other sites
cobra4v320 27 Posted July 20, 2009 (edited) Check this out here http://community.bistudio.com/wiki/onMapSingleClick 1. create a group and in the initalization line of the leader put grp1=group this 2. create a trigger 3. activation is radio alpha 4. in the activation field put: onMapSingleClick "grp1 move _pos; onMapSingleClick ''; true;" 5. make sure the trigger is set to repeatedly Now you can click on the map multiple times and grp1 will move to those locations. If you use the setbehavior command with the group leader it will apply to all of the memebers of the group, and while moving to the waypoint. Edited July 20, 2009 by cobra4v320 Share this post Link to post Share on other sites