My task: My code: (Saved to onSendChatMessage and onChat) Code: http://pastebin.com/L6ZnDTVs Result: Please help. I've never even seen this error before...
2869 lines of macro code...? I am not even sure whether the mod is able to handle such sizes, that may very well be the cause. Use arrays and FOR loops instead, they can save you over 2000 lines.
Match the first name with regular expressions, store this match in a list entry and replace the matched username with nothing. Repeat until 0 users are left in the original chat message.
have you tried looking in the "scripts" section? I'm pretty confident there's a few scripts using arrays, you can get an idea on how to use them. If you still can't, write here the line of code that doesn't do what it's supposed to do and we'll try help you figure out what's wrong with the syntax
If only i knew what doesnt work... Im great at troubleshooting, just not when its on overflow error or a "Stack error in script". I dont even know how to begin to decipher that...
I'm taking a shot in the dark here...but since your script is so long and being repeated so quickly, maybe that's causing the error? But I definitely advise taking 314 and Expipi's notes and rewriting the script to use FOR loops and arrays.
Okay... I don't know if I can though. My problem is this: when there are 4 people in /near and I look for 5 people, it gives an error. So I set it up to look for a certain number of players, and then if the number of players it's looking for is greater than the number of players, it lowers the number of players it looks for. Then it does all the com *note for later (ignore this)* scan each name separately Make 1 12 search instead of a 12,11,10. Scan test the 12 number of players and if result is #dis1 then set 12 to 0, continue until players exist = players scanned.
Code: if(%@&endfriend1%="") match(%CHAT%, "^/nearbypass (.*)",{&friend1}) set(@&endfriend1,%&friend1%) else if(%@&endfriend2%="") match(%CHAT%, "^/nearbypass (.*)",{&friend2}) set(@&endfriend2,%&friend2%) else if(%@&endfriend3%="") match(%CHAT%, "^/nearbypass (.*)",{&friend3}) set(@&endfriend3,%&friend3%) else if(%@&endfriend4%="") match(%CHAT%, "^/nearbypass (.*)",{&friend4}) set(@&endfriend4,%&friend4%) else if(%@&endfriend5%="") match(%CHAT%, "^/nearbypass (.*)",{&friend5}) set(@&endfriend5,%&friend5%) else if(%@&endfriend6%="") match(%CHAT%, "^/nearbypass (.*)",{&friend6}) set(@&endfriend6,%&friend6%) else if(%@&endfriend7%="") match(%CHAT%, "^/nearbypass (.*)",{&friend7}) set(@&endfriend7,%&friend7%) else if(%@&endfriend8%="") match(%CHAT%, "^/nearbypass (.*)",{&friend8}) set(@&endfriend8,%&friend8%) else if(%@&endfriend9%="") match(%CHAT%, "^/nearbypass (.*)",{&friend9}) set(@&endfriend9,%&friend9%) else if(%@&endfriend10%="") match(%CHAT%, "^/nearbypass (.*)",{&friend10}) set(@&endfriend10,%&friend10%) endif endif endif endif endif endif endif endif endif endif I may still be a little tired right now and thus make a few mistakes, but this is the (untested) code that should have the same functionality if you adjust the rest of your script. Code: FOR(#i, 1, 10, 1) IF(%@&endfriend[%#i%]%="") MATCH(%CHAT%, "^/nearbypass (.*)",{@&endfriend[%#i%]}) BREAK ENDIF NEXT Replace all endfriendx with endfriend[x], x is a number from 1 to 10. Arrays work a lot better here. I removed the SET() line because it should be possible to set the array variable directly in the MATCH() command. Use this array pattern everywhere and you should be able to remove a lot of code.
I did that, and it helped A LOT!!! but what is wrong with it now? New stuff is after the "//123~~~~~~~~~~" Code: $${ //for help in game use "/help endnear" IF(%KEYNAME%=="onSendChatMessage") ifmatches(%CHAT%, "^/nearbypass ") if(%@&endfriend1%="") match(%CHAT%, "^/nearbypass (.*)",{&friend1}) set(@&endfriend1,%&friend1%) else if(%@&endfriend2%="") match(%CHAT%, "^/nearbypass (.*)",{&friend2}) set(@&endfriend2,%&friend2%) else if(%@&endfriend3%="") match(%CHAT%, "^/nearbypass (.*)",{&friend3}) set(@&endfriend3,%&friend3%) else if(%@&endfriend4%="") match(%CHAT%, "^/nearbypass (.*)",{&friend4}) set(@&endfriend4,%&friend4%) else if(%@&endfriend5%="") match(%CHAT%, "^/nearbypass (.*)",{&friend5}) set(@&endfriend5,%&friend5%) else if(%@&endfriend6%="") match(%CHAT%, "^/nearbypass (.*)",{&friend6}) set(@&endfriend6,%&friend6%) else if(%@&endfriend7%="") match(%CHAT%, "^/nearbypass (.*)",{&friend7}) set(@&endfriend7,%&friend7%) else if(%@&endfriend8%="") match(%CHAT%, "^/nearbypass (.*)",{&friend8}) set(@&endfriend8,%&friend8%) else if(%@&endfriend9%="") match(%CHAT%, "^/nearbypass (.*)",{&friend9}) set(@&endfriend9,%&friend9%) else if(%@&endfriend10%="") match(%CHAT%, "^/nearbypass (.*)",{&friend10}) set(@&endfriend10,%&friend10%) endif endif endif endif endif endif endif endif endif endif filter endif //editable command ifmatches(%CHAT%, "^/help endnear") log(To hide the name of someone use "/nearbypass <name>") //nicknames... log(To show a prevoiusly hidden name use "/nearbyshow <name>") //nicknames... log(To see the current list of hidden names use "/nearbylist") log(To edit the minimum distance names will appear use "/nearbydis <distnace>") log(To start the macro use "/nearbygo") log(To stop the macro use "/nearbystop") filter endif ifmatches(%CHAT%, "^/nearbygo") do echo(/near 5000) wait(12000t) loop filter endif ifmatches(%CHAT%, "^/nearbystop") stop; endif ifmatches(%CHAT%, "^/nearbyshow ") match(%CHAT%, "^/nearbyshow (.*)",{&delplayer}) if(%@&endfriend1%=%&delplayer%) set(@&endfriend1,"") else if(%@&endfriend2%=%&delplayer%) set(@&endfriend2,"") else if(%@&endfriend3%=%&delplayer%) set(@&endfriend3,"") else if(%@&endfriend4%=%&delplayer%) set(@&endfriend4,"") else if(%@&endfriend5%=%&delplayer%) set(@&endfriend5,"") else if(%@&endfriend6%=%&delplayer%) set(@&endfriend6,"") else if(%@&endfriend7%=%&delplayer%) set(@&endfriend7,"") else if(%@&endfriend8%=%&delplayer%) set(@&endfriend8,"") else if(%@&endfriend9%=%&delplayer%) set(@&endfriend9,"") else if(%@&endfriend10%=%&delplayer%) set(@&endfriend10,"") else log(Error: No hidden players by that name were found) endif endif endif endif endif endif endif endif endif endif filter endif ifmatches(%CHAT%, "^/nearbylist") log(Hidden Players: %@&endfriend1% %@&endfriend2% %@&endfriend3% %@&endfriend4% %@&endfriend5% %@&endfriend6% %@&endfriend7% %@&endfriend8% %@&endfriend9% %@&endfriend10%) filter endif ifmatches(%CHAT%, "^/nearbydis ") match(%CHAT%, "^/nearbydis ([0-9]+)",{#dis}) set(@#minenddistance,%#dis%) filter endif endif //123~~~~~~~~~~ IF(%KEYNAME%=="onChat") for(#r,1,12,1) set(#ni[%#r%],1) set(#ni[%#r%]sum,0) next ifcontains(%@&clean%, "Players nearby") match(%@&clean%, "Players nearby\: ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)",{&nick1,#dis1,&nick2,#dis2,&nick3,#dis3,&nick4,#dis4,&nick5,#dis5,&nick6,#dis6,&nick7,#dis7,&nick8,#dis8,&nick9,#dis9,&nick10,#dis10,&nick11,#dis11,&nick12,#dis12}) if(%&nick1%!="#dis1") for(#e,1,12,1) for(#q,1,10,1) if(%&nick[%#e%]%!=%endfriend[%#q%]%) if(%dis[%#e%]%<%@#minenddistance%) set(#ni[%#e%][%#q%],0) endif endif next set(#ni[%#e%]sum,%#ni[%#e%]sum%+#ni[%#e%][%#q%]) if(#ni[%#e%]sum=0) log(%&nick[%#e%]% %#dis[%#e%]%) // playsound(custom.alert) endif next else ifcontains(%@&clean%, "Players nearby") match(%@&clean%, "Players nearby\: ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)",{&nick1,#dis1,&nick2,#dis2,&nick3,#dis3,&nick4,#dis4,&nick5,#dis5,&nick6,#dis6,&nick7,#dis7,&nick8,#dis8,&nick9,#dis9,&nick10,#dis10,&nick11,#dis11}) if(%&nick1%!="#dis1") for(#e,1,11,1) for(#q,1,10,1) if(%&nick[%#e%]%!=%endfriend[%#q%]%) if(%dis[%#e%]%<%@#minenddistance%) set(#ni[%#e%][%#q%],0) endif endif next set(#ni[%#e%]sum,%#ni[%#e%]sum%+#ni[%#e%][%#q%]) if(#ni[%#e%]sum=0) log(%&nick[%#e%]% %#dis[%#e%]%) // playsound(custom.alert) endif next else ifcontains(%@&clean%, "Players nearby") match(%@&clean%, "Players nearby\: ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)",{&nick1,#dis1,&nick2,#dis2,&nick3,#dis3,&nick4,#dis4,&nick5,#dis5,&nick6,#dis6,&nick7,#dis7,&nick8,#dis8,&nick9,#dis9,&nick10,#dis10}) if(%&nick1%!="#dis1") for(#e,1,10,1) for(#q,1,10,1) if(%&nick[%#e%]%!=%endfriend[%#q%]%) if(%dis[%#e%]%<%@#minenddistance%) set(#ni[%#e%][%#q%],0) endif endif next set(#ni[%#e%]sum,%#ni[%#e%]sum%+#ni[%#e%][%#q%]) if(#ni[%#e%]sum=0) log(%&nick[%#e%]% %#dis[%#e%]%) // playsound(custom.alert) endif next else ifcontains(%@&clean%, "Players nearby") match(%@&clean%, "Players nearby\: ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)",{&nick1,#dis1,&nick2,#dis2,&nick3,#dis3,&nick4,#dis4,&nick5,#dis5,&nick6,#dis6,&nick7,#dis7,&nick8,#dis8,&nick9,#dis9}) if(%&nick1%!="#dis1") for(#e,1,9,1) for(#q,1,10,1) if(%&nick[%#e%]%!=%endfriend[%#q%]%) if(%dis[%#e%]%<%@#minenddistance%) set(#ni[%#e%][%#q%],0) endif endif next set(#ni[%#e%]sum,%#ni[%#e%]sum%+#ni[%#e%][%#q%]) if(#ni[%#e%]sum=0) log(%&nick[%#e%]% %#dis[%#e%]%) // playsound(custom.alert) endif next else ifcontains(%@&clean%, "Players nearby") match(%@&clean%, "Players nearby\: ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)",{&nick1,#dis1,&nick2,#dis2,&nick3,#dis3,&nick4,#dis4,&nick5,#dis5,&nick6,#dis6,&nick7,#dis7,&nick8,#dis8}) if(%&nick1%!="#dis1") for(#e,1,8,1) for(#q,1,10,1) if(%&nick[%#e%]%!=%endfriend[%#q%]%) if(%dis[%#e%]%<%@#minenddistance%) set(#ni[%#e%][%#q%],0) endif endif next set(#ni[%#e%]sum,%#ni[%#e%]sum%+#ni[%#e%][%#q%]) if(#ni[%#e%]sum=0) log(%&nick[%#e%]% %#dis[%#e%]%) // playsound(custom.alert) endif next else ifcontains(%@&clean%, "Players nearby") match(%@&clean%, "Players nearby\: ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)",{&nick1,#dis1,&nick2,#dis2,&nick3,#dis3,&nick4,#dis4,&nick5,#dis5,&nick6,#dis6,&nick7,#dis7}) if(%&nick1%!="#dis1") for(#e,1,7,1) for(#q,1,10,1) if(%&nick[%#e%]%!=%endfriend[%#q%]%) if(%dis[%#e%]%<%@#minenddistance%) set(#ni[%#e%][%#q%],0) endif endif next set(#ni[%#e%]sum,%#ni[%#e%]sum%+#ni[%#e%][%#q%]) if(#ni[%#e%]sum=0) log(%&nick[%#e%]% %#dis[%#e%]%) // playsound(custom.alert) endif next else ifcontains(%@&clean%, "Players nearby") match(%@&clean%, "Players nearby\: ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)",{&nick1,#dis1,&nick2,#dis2,&nick3,#dis3,&nick4,#dis4,&nick5,#dis5,&nick6,#dis6}) if(%&nick1%!="#dis1") for(#e,1,6,1) for(#q,1,10,1) if(%&nick[%#e%]%!=%endfriend[%#q%]%) if(%dis[%#e%]%<%@#minenddistance%) set(#ni[%#e%][%#q%],0) endif endif next set(#ni[%#e%]sum,%#ni[%#e%]sum%+#ni[%#e%][%#q%]) if(#ni[%#e%]sum=0) log(%&nick[%#e%]% %#dis[%#e%]%) // playsound(custom.alert) endif next else ifcontains(%@&clean%, "Players nearby") match(%@&clean%, "Players nearby\: ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)",{&nick1,#dis1,&nick2,#dis2,&nick3,#dis3,&nick4,#dis4,&nick5,#dis5}) if(%&nick1%!="#dis1") for(#e,1,5,1) for(#q,1,10,1) if(%&nick[%#e%]%!=%endfriend[%#q%]%) if(%dis[%#e%]%<%@#minenddistance%) set(#ni[%#e%][%#q%],0) endif endif next set(#ni[%#e%]sum,%#ni[%#e%]sum%+#ni[%#e%][%#q%]) if(#ni[%#e%]sum=0) log(%&nick[%#e%]% %#dis[%#e%]%) // playsound(custom.alert) endif next else ifcontains(%@&clean%, "Players nearby") match(%@&clean%, "Players nearby\: ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)",{&nick1,#dis1,&nick2,#dis2,&nick3,#dis3,&nick4,#dis4}) if(%&nick1%!="#dis1") for(#e,1,4,1) for(#q,1,10,1) if(%&nick[%#e%]%!=%endfriend[%#q%]%) if(%dis[%#e%]%<%@#minenddistance%) set(#ni[%#e%][%#q%],0) endif endif next set(#ni[%#e%]sum,%#ni[%#e%]sum%+#ni[%#e%][%#q%]) if(#ni[%#e%]sum=0) log(%&nick[%#e%]% %#dis[%#e%]%) // playsound(custom.alert) endif next else ifcontains(%@&clean%, "Players nearby") match(%@&clean%, "Players nearby\: ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)",{&nick1,#dis1,&nick2,#dis2,&nick3,#dis3}) if(%&nick1%!="#dis1") for(#e,1,3,1) for(#q,1,10,1) if(%&nick[%#e%]%!=%endfriend[%#q%]%) if(%dis[%#e%]%<%@#minenddistance%) set(#ni[%#e%][%#q%],0) endif endif next set(#ni[%#e%]sum,%#ni[%#e%]sum%+#ni[%#e%][%#q%]) if(#ni[%#e%]sum=0) log(%&nick[%#e%]% %#dis[%#e%]%) // playsound(custom.alert) endif next else ifcontains(%@&clean%, "Players nearby") match(%@&clean%, "Players nearby\: ((.*))\(([0-9]+)m\)\, ((.*))\(([0-9]+)m\)",{&nick1,#dis1,&nick2,#dis2}) if(%&nick1%!="#dis1") for(#e,1,2,1) for(#q,1,10,1) if(%&nick[%#e%]%!=%endfriend[%#q%]%) if(%dis[%#e%]%<%@#minenddistance%) set(#ni[%#e%][%#q%],0) endif endif next set(#ni[%#e%]sum,%#ni[%#e%]sum%+#ni[%#e%][%#q%]) if(#ni[%#e%]sum=0) log(%&nick[%#e%]% %#dis[%#e%]%) // playsound(custom.alert) endif next else ifcontains(%@&clean%, "Players nearby") match(%@&clean%, "Players nearby\: ((.*))\(([0-9]+)m\)",{&nick1,#dis1}) if(%&nick1%!="#dis1") for(#e,1,1,1) for(#q,1,10,1) if(%&nick[%#e%]%!=%endfriend[%#q%]%) if(%dis[%#e%]%<%@#minenddistance%) set(#ni[%#e%][%#q%],0) endif endif next set(#ni[%#e%]sum,%#ni[%#e%]sum%+#ni[%#e%][%#q%]) if(#ni[%#e%]sum=0) log(%&nick[%#e%]% %#dis[%#e%]%) // playsound(custom.alert) endif next endif endif endif endif endif endif endif endif endif endif endif endif endif endif endif endif endif endif endif endif endif endif endif endif endif }$$