LightBringer 0 Posted March 20, 2003 Hey, i made a race with skodas, through the whole island of wisnorsk... Is it possible, to make a stopwatch, then add triggers, which when are activated, they show the elapsed time for the crossing unit? If yes, please write it to me... CU. Share this post Link to post Share on other sites
Guest jacobaby Posted March 20, 2003 It should be easy enough. I havent tried this, but it will give you the idea. For each car execute a script at the start of the race. ( [this] exec "script.sqs" in the INIT field of each car) In the script, use something LIKE this;</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _car = _this @ _car distance (getmarkerpos Checkpoint1) <10 hint format ["%1 Passed Checkpoint 1\n\nTime = %2",name driver _car,_time] @ _car distance (getmarkerpos Checkpoint2) <10 hint format ["%1 Passed Checkpoint 2\n\nTime = %2",name driver _car,_time] <span id='postcolor'> I think that will work as long as the reserved variable _time isnt stopped by the @ command. You will soon see. You will obviously need some markers named at each checkpoint. If you wanted a list of each timed section at the end, use a line like; </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _checkp1 = _time _checkp2 = _time <span id='postcolor'> AFTER each WAIT (@) command, then at the end of the race you could display the figures;</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> hint format ["Checkpoint 1 = %1\nCheckpoint2 = %2",_checkp1,_checkp2] <span id='postcolor'> etc etc Hope that gets you started TJ Share this post Link to post Share on other sites
LightBringer 0 Posted March 20, 2003 Okay, i'm currently here (I need to change the marker to an object, called "checkpoint x"): </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_car = _this if (_car distance Checkpoint1 < 5) then goto "wp1" #wp1 hint format ["%1 Passed Checkpoint 1\n\nTime = %2",name driver _car,_time] if (_car distance Checkpoint2 < 5) then goto "wp2" #wp2 hint format ["%1 Passed Checkpoint 2\n\nTime = %2",name driver _car,_time]<span id='postcolor'> But the "hint" lines seems to be wrong... I'm researching the error, if any idea, post it plz. CU. Share this post Link to post Share on other sites
Guest jacobaby Posted March 20, 2003 no, you need to use a wait command '@' instead of 'if' because the script will just carry on through. also it will prevent missing out WP's. Theres no error with the hint, that will work fine. TJ Share this post Link to post Share on other sites
LightBringer 0 Posted March 20, 2003 This is my final version, and working really nicely (you must complete a checkpoint before the next one - this is good, becaus then you can't cheat): </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_car = racecar_1 _driver = driver racecar_1 #check1 ?(_car distance checkpoint1 < 10):goto "wp1" goto "check1" #wp1 hint format ["%1 is at the I.\checkpoint!\n\nTime = %2",_driver,time] #check2 ?(_car distance checkpoint2 < 10):goto "wp2" goto "check2" #wp2 hint format ["%1 is at the II.\checkpoint!\n\nTime = %2",_driver,time] ... <span id='postcolor'> I use for the time this format: (time - 8), because there is 8 seconds for startup the engines, and the countdown untill start... It is a really usefull idea, to use the pavement itself, for checkpoints! You can use the Object ID command as well... You need to do a new sqs file for each of the racecars... (copy & paste power...) Thx for the first helping! CU. Share this post Link to post Share on other sites
Guest jacobaby Posted March 21, 2003 No no no no no..................:( Sorry but that just isnt right.</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE"> check1 ?(_car distance checkpoint1 < 10):goto "wp1" goto "check1" <span id='postcolor'> That is an infinite loop. If you insist on doing it that silly way instead of using a WAIT "@" command then you must use a delay in the loop. ( ~0.1) Secondly, you DO NOT need a seperate script for each car. The variables you used are local to the script and as such only apply to the car that executes it. You should use the time as a local variable too (_time). To get around the 8 second delay, just execute the scripts at the moment the Start is triggered. If you use "name _driver" you will avoid all the useless side info in the hint. I dont mean to nag at you, but you might as well get it right. TJ Share this post Link to post Share on other sites
LightBringer 0 Posted March 21, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (jacobaby @ Mar. 21 2003,01:39)</td></tr><tr><td id="QUOTE">No no no no no..................:( Sorry but that just isnt right.</span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote </td></tr><tr><td id="QUOTE"> check1 ?(_car distance checkpoint1 < 10):goto "wp1" goto "check1" <span id='postcolor'> That is an infinite loop. If you insist on doing it that silly way instead of using a WAIT "@" command then you must use a delay in the loop. ( ~0.1)<span id='postcolor'> Why do you say this? Ever tried to use my way? If yes, why saying these things? It is NOT an infinite loop. It is looping until the car is at the checkpoint. If the car goes near to the checkpoint, then as you can see, the loop is over, because of the _goto "wp1"_ order! We are useing this mission since yesterday, with no errors, so don't say, that this is a wrong version. Maybe not the best for this case, but working. Try it, then you can see, it's working well... CU. Share this post Link to post Share on other sites
Guest jacobaby Posted March 21, 2003 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (LightBringer @ Mar. 21 2003,13:21)</td></tr><tr><td id="QUOTE">1)Why do you say this? Ever tried to use my way? If yes, why saying these things? 2)It is NOT an infinite loop. It is looping until the car is at the checkpoint. If the car goes near to the checkpoint, then as you can see, the loop is over, because of the _goto "wp1"_ order! 3)We are useing this mission since yesterday, with no errors, so don't say, that this is a wrong version. Maybe not the best for this case, but working. Try it, then you can see, it's working well... CU.<span id='postcolor'> 1) I say it because I am sure you have put a lot of effort into the mission. Why settle for bad scripting when it is so simple? 2) It CAN be an infinite loop if the car doesnt make it to the checkpoint. Then the game crashes to desktop. OFP has enough of that WITHOUT DOING IT DELIBERATELY 3) I'm glad you dont work for me with that attitude!! Trust me, I have made 100's of missions, all for MP (well, a couple of SP ones, check Avon Ladys MOM section for her reviews). A few MP ones here; Check bottom of page If a thing is worth doing, it is worth doing right. And NEXT time you make a mission, you will have the extra know-how from the start. Geez, I would of been GLAD of the help! TJ Share this post Link to post Share on other sites
LightBringer 0 Posted March 21, 2003 jaco: I tried to use again your version... but not working for me... i use in the cars init field: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">[this] exec "cp.sqs"<span id='postcolor'> in cp.sqs: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE">_car = _this _name = name _this @ _car distance check1 < 10 hint format ["%1 at the I.\ncheckpoint!\n\nTIME = %2",_name,(time - 8)]<span id='postcolor'> And the ofp says: _car distance check1 <|#| 10 - Error, Type: Number, expected Object or something like that... but the error point is that. CU. Share this post Link to post Share on other sites
vektorboson 8 Posted March 21, 2003 @Lightbringer Why don't you just trust TJ? He knows what he is doing and the suggestions he made you are very fine, regarding improving your own skills in scripting. As for your problem, why don't you try this exec "cp.sqs" so without the brackets? Share this post Link to post Share on other sites
RED 0 Posted March 22, 2003 Change it to: </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> _car = _this _name = name _this @ (_car distance check1) < 10 hint format ["%1 at the I.\ncheckpoint!\n\nTIME = %2",_name,(time - 8)] <span id='postcolor'> RED Share this post Link to post Share on other sites
Guest jacobaby Posted March 22, 2003 As Bigpoppa says, you only need the [] brackets if you need an array to fire the script. If you do define an array, then your opening line of the script needs to be different. i.e _this becomes _this select 0 </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Quote (LightBringer @ Mar. 21 2003,22:32)</td></tr><tr><td id="QUOTE">@ _car distance check1 < 10 _car distance check1 <|#| 10 - Error, Type: Number, expected Object<span id='postcolor'> I think you get this error because check1 is not recognised as an object. The distance command returns the distance between 2 objects, so make sure CHECK1 is an object. I had to say "whoops" when I checked my original post, as markers are NOT objects and dont return the correct result. I think it is better to put the calculation in brackets () and then the maths ( < 10 ) Â it makes it clearer, although I think it would work without it. Like this; </span><table border="0" align="center" width="95%" cellpadding="3" cellspacing="1"><tr><td>Code Sample </td></tr><tr><td id="CODE"> @ (_car distance check1) < 10 <span id='postcolor'> Share this post Link to post Share on other sites
RED 0 Posted March 22, 2003 I think you have to put "_car distance check1" in brackets as that produces the number which will be checked to see if it is less than 10 meters away. RED Share this post Link to post Share on other sites
Guest jacobaby Posted March 22, 2003 LOL i just noticed another thing, I mentioned before too. the variable TIME is global and starts as the mission starts. the variable _time in a script is local to that script and starts to count when the script is executed. Using it as a local to script variable will give you better control of it, and you can then use the DIFFERENT variable from each car to do a finishing table or results script if you so desire. TJ Share this post Link to post Share on other sites