jeppelykke 0 Posted June 27, 2003 Hey Hey, Am working on a random spawns on my DM map, how ever i seems to run into a problem that my "random 10" do not work, what am doing wrong, this is my entire script. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> #start westspawn = random 10 eastspawn = random 10 ? westspawn == 1 : "respawn_west" setMarkerPos getMarkerPos "respawn1" ? westspawn == 2 : "respawn_west" setMarkerPos getMarkerPos "respawn2" ? westspawn == 3 : "respawn_west" setMarkerPos getMarkerPos "respawn3" ? westspawn == 4 : "respawn_west" setMarkerPos getMarkerPos "respawn4" ? westspawn == 5 : "respawn_west" setMarkerPos getMarkerPos "respawn5" ? westspawn == 6 : "respawn_west" setMarkerPos getMarkerPos "respawn6" ? westspawn == 7 : "respawn_west" setMarkerPos getMarkerPos "respawn7" ? westspawn == 8 : "respawn_west" setMarkerPos getMarkerPos "respawn8" ? westspawn == 9 : "respawn_west" setMarkerPos getMarkerPos "respawn9" ? westspawn == 10 : "respawn_west" setMarkerPos getMarkerPos "respawn10" ? eastspawn == 1 : "respawn_east" setMarkerPos getMarkerPos "respawn1" ? eastspawn == 2 : "respawn_east" setMarkerPos getMarkerPos "respawn2" ? eastspawn == 3 : "respawn_east" setMarkerPos getMarkerPos "respawn3" ? eastspawn == 4 : "respawn_east" setMarkerPos getMarkerPos "respawn4" ? eastspawn == 5 : "respawn_east" setMarkerPos getMarkerPos "respawn5" ? eastspawn == 6 : "respawn_east" setMarkerPos getMarkerPos "respawn6" ? eastspawn == 7 : "respawn_east" setMarkerPos getMarkerPos "respawn7" ? eastspawn == 8 : "respawn_east" setMarkerPos getMarkerPos "respawn8" ? eastspawn == 9 : "respawn_east" setMarkerPos getMarkerPos "respawn9" ? eastspawn == 10 : "respawn_east" setMarkerPos getMarkerPos "respawn10" ~10 goto "start" Yes, I have markers named spawn 1 to 10, and respawn markers also made. How ever i tryed even replaceing the marker setpos with: ? westspawn == 1 : hint "1" ? westspawn == 2 : hint "2" ect..... But they don't work, So what am doing wrong  Best Regards Jeppe Lykke, Denmark Share this post Link to post Share on other sites
bn880 5 Posted June 27, 2003 random 10 gives you any float value between 0 and 10. It will be a one in a million shot that it will ever be exactly 1 or 2 or 3 etc. You could do with <= or >= and have Goto statements at the end of each ?(). Share this post Link to post Share on other sites
jeppelykke 0 Posted June 27, 2003 Oh crap, that sucks Ok thanx mate! Best Regards Jeppe Lykke, Denmark Share this post Link to post Share on other sites
Bart.Jan 0 Posted June 27, 2003 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> #start westspawn = random 10 eastspawn = random 10 westspawn=westspawn-(westspawn%1) eastspawn=eastspawn-(eastspawn%1) _w=format["respawn%1",westspawn] _e=format["respawn%1",eastspawn] "respawn_west" setMarkerPos getMarkerPos _w "respawn_east" setMarkerPos getMarkerPos _e ~10 goto "start" But there can be both respawns at the same place in the same time. Â Share this post Link to post Share on other sites
bn880 5 Posted June 27, 2003 or <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> respawns=["respawn1","respawn2","respawn3","respawn4","respawn5","respawn6","respawn7","respawn8","respawn9","respawn10"]; #start westspawn = random 10 eastspawn = random 10 "respawn_west" setMarkerPos getMarkerPos (respawns select (westspawn - 0.5)) "respawn_east" setMarkerPos getMarkerPos (respawns select (eastspawn - 0.5)) ~10 goto "start" Share this post Link to post Share on other sites
KTottE 0 Posted July 2, 2003 Why not use the mod command? So do'er like this: _wholeInteger = _number mod 1 Then you will have a whole integer to work with, I.E 1, 2, 3, 4... edit To make it easier for you: _wholeIntegerWestSpawn = westspawn mod 1 Share this post Link to post Share on other sites
Bart.Jan 0 Posted July 2, 2003 Why not use the mod command?So do'er like this: _wholeInteger = _number mod 1 Then you will have a whole integer to work with, I.E 1, 2, 3, 4... edit To make it easier for you: _wholeIntegerWestSpawn = westspawn mod 1 0.999 mod 1 = 0.999 1.5 mod 1 = 0.5 9.25 mod 1 = 0.25 10 mod 1 = 0 Share this post Link to post Share on other sites
KTottE 0 Posted July 2, 2003 Have you tested that in OFP? Because # mod 1 has worked for me in the past... Share this post Link to post Share on other sites
Trapper 0 Posted July 2, 2003 just replace == in every line with <= and your script will work. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ? westspawn <= 1 : "respawn_west" setMarkerPos getMarkerPos "respawn1" Share this post Link to post Share on other sites
raedor 8 Posted July 2, 2003 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_num = random 20 _rest = _num mod 1 _num = _num - _rest that's what u need... Share this post Link to post Share on other sites
bn880 5 Posted July 2, 2003 I think the lesson from this thread is there are numerous ways to solve this problem, and this member has probably solved his a long time ago. Share this post Link to post Share on other sites
raedor 8 Posted July 2, 2003 maybe... but with my version he can use his old script. Share this post Link to post Share on other sites
Bart.Jan 0 Posted July 2, 2003 Have you tested that in OFP?Because # mod 1 has worked for me in the past... Yes, I tested it in OFP. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> a mod b Operand types:   a: Number   b: Number Type of returned value:   Number Description:   remainder of a divided by b. Note remainer is calculated in real domain. Example:   3 mod 2 , result is 1 Share this post Link to post Share on other sites