Loelein 0 Posted November 19, 2002 hi, after studying the editing references and downloading several sample missions i´ve tried to write a script to make a civilian follow my player, when their distance is longer than lets say 10 meters. (just to try out). it never worked so i copied a script from ofpec.com, which should type the current position of my player as a hint-text, but it did not work too. this was the script i tried: _me = _this select 0 #update _pos = getpos _me _x1 = _pos select 0 _y1 = _pos select 1 _z1 = _pos select 2 _stringpos = format["X: %1\nY: %2\nZ: %3\n",_x1,_y1,_z1] Hint _stringpos ~1 Goto "update" the error message was: ´_me = _this select 0 _me = _this select 0 ()then in between to vertical lines comes #) ´: error select: type object, needs list (the later two words i´ve translated from german, so i don´t know if they are correct) i think i´m to blame for i´ve no exact idea how to use the select order (and what for! also i´ve tried to make other soldiers salute or execute other animations, but they just did not anything. only the CombattoStand order works. i´ve tried in the init field of the soldiers, in the onactivation field of the waypoints and within a script (which, as you can guess, i did not expect to have written right) can you give me hints how to make it right and/or where to learn writing scripts (the correct syntax and the understanding at all) without bothering you with silly questions? with hope for help Loelein Share this post Link to post Share on other sites
BaronVonRed 0 Posted November 19, 2002 The problem is not with the script, but how you are calling it. In your script, this line: _me = _this select 0 means that you must pass the script an array at execution. Change it to: _me = _this Next, name your player in the name field (like MyPlayer). Then, in the trigger activation field: MyPlayer exec "scriptname.sqs" This will pass the name "MyPlayer" into the script as _this which will get assigned _me. Hope that helps! Share this post Link to post Share on other sites
Loelein 0 Posted November 19, 2002 thank you very much for your help baronvonred, i´ve tried and it worked perfectly. so you always have to combine the script with a trigger? next i´ve tried to bind it in the follow-script of a civilian i made a small trigger which is activated by the non-presece of the civ. it starts the following script: _h1 = _this #loop _x = (getpos h1 select 0) - (getpos roli select 0) _y = (getpos h1 select 2) - (getpos roli select 2) _dist = sqrt ((_x^2) + (_y^2)) _stringpos = format["Distanz: %1\n",_dist] hint _stringpos ? _dist > 10 : goto "ihmnach" goto "loop" #ihmnach hint "juhu" _h1 domove getpos roli goto "loop" the juhu was only to see, if it jumps to "ihmnach" and it jumps, but i think here i´ve the problem, that the script does not know who "roli" (my soldier) is. so once again: how can i teach him? (with select too?) greetings Loelein Share this post Link to post Share on other sites
Loelein 0 Posted November 19, 2002 ok, i´ve got it myself. i just altered the move line in: _h1 domove [getpos roli select 0, getpos roli select 1, getpos roli select 2] and now it works. sometimes thinking does not hurt too much. besides: i had to change the line: ? _dist > 10 : goto "ihmnach" in ? _dist < 10 : goto "ihmnach" for i wanted to follow my player when the distance gets over 10 meters. that is not very logic, isn´t it?? Share this post Link to post Share on other sites
Bart.Jan 0 Posted November 19, 2002 You can use "distance" command. Here is my version : calling : [target,tail] exec "follow.sqs" </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _trgt=_this select 0 _tail=_this select 1 #check ?(_trgt distance _tail)>10:_tail move getpos _trgt ~1 goto "check" <span id='postcolor'> For your situation target will be player and tail will be civilian. calling : [player,civilanName] exec "follow.sqs" Share this post Link to post Share on other sites
Bart.Jan 0 Posted November 19, 2002 And you don't have to use script for this. It can be done by one trigger : axis : 0,0 activated : repeatly condition : player distance civilianName > 10 on activation : civilianName move getpos player Share this post Link to post Share on other sites
Loelein 0 Posted November 19, 2002 thnx alot bart, i´m new in writing scripts and i´ve had some enlightments during my attempts. but the thing with distance in the trigger is super. may i ask from where you all have learned that? Share this post Link to post Share on other sites
Bart.Jan 0 Posted November 19, 2002 From official and Unofficial scripting reference and (of course) from scripts made by other  people. Share this post Link to post Share on other sites