|
Cool. Will do, Mr. Helpful.
|
|
|
|
|
Post it here when you are done =P
|
AFK Aug 2011 - ???
I'll be actively developing codes, tutorials, and templates when I return, later this year.
|
|
|
|
Was a little confused, here. Variable declarations how? Like var; ? And with the curly braces, you do just mean the opening brace of the block, right? 'cause there's nothing wrong with {}; =p
Beyond that, I certainly like the approach.
|
|
|
|
Was a little confused, here. Variable declarations how? Like var; ? And with the curly braces, you do just mean the opening brace of the block, right? 'cause there's nothing wrong with {}; =p Beyond that, I certainly like the approach. I dunno what I was trying to write when I said separate variable declarations. I think I was talking about object literals. And yeah, I meant left parenthesis/braces only of course. Although it isn't necessarily suggested to include semicolons after right braces/parentheses either.
|
AFK Aug 2011 - ???
I'll be actively developing codes, tutorials, and templates when I return, later this year.
|
|
|
|
|
|
So, you're saying that if I were to use alert(ubbc_string); right below that variable's declaration, that I would get a single alert box with [ubbc=whatever] as the text? Because that is sooo not what happens. lol
|
Do or do not. There is no try.
The Realms Beyond Demon Guardians
|
|
|
|
javascript:alert(aTD[1].innerHTML.match(/<img/g)); On v1, I ran that in the URL bar. Gave me a giant list of <img,<img,<img,<img,<img, etc. Which means it returned a match of all the image tags in aTD[1]'s innerHTML (the menu). It's actually an array, because watch: javascript:alert(aTD[1].innerHTML.match(/<img/g).join("\n\n")); That now returns a giant list with line breaks between them instead of commas. So, the array should return something like this for you: TDs .innerHTML = "[ubbc=aklfjdklj][ubbc=1243lj][ubbc=asfdklfjdklj][ubbc=aasdklj]";
var ubbc_string = TDs.innerHTML.match(/\[ubbc=(\w+)\]/gi); alert(ubbc_string); // alerts: [ubbc=aklfjdklj],[ubbc=1243lj],[ubbc=asfdklfjdklj],[ubbc=aasdklj]
So yeah, does that help? >.< I'm not sure what you're doing exactly, 'cause you only gave us a portion of the code.
Edit: Oh, and a small tip:
if(TDs[a].innerHTML.match(/\[ubbc=(\w+)\]/gi)) { if(aTD[a].colSpan=="3" && aTD[a].vAlign=="top") {
Switch the order of those two conditionals. Everything on ProBoards is inside a table, so you're going to be doing massive repetitive checks of the innerHTML, which is a very resource intensive process. If we only check a small amount of cells (the second conditional), then the script should execute much faster and be less resource intensive.
Last Edit: Apr 10, 2009 18:45:39 GMT by Chris
|
|
|
|
|
The idea is that the ubbc code is supposed to pass the name of the person being attacked to the script. The script will then modify stats accordingly. EDIT: I hope the spacing and tabs look okay. I posted this from my phone. The actual code I'm using is: <script type="text/javascript"> var needlvl = "50"; var karmamod = "2.9"; var statmax = "999"; var health = "9"; var magic = "2"; var attack = "7"; var defense = "6"; var agility = "4"; var intelligence = "5"; var usermax = "(admin|username2|username3|username4|username5)"; var monmax = "999999"; var sign = "$"; var money = "10"; var TDs = document.getElementsByTagName("TD"); var maxusers = new RegExp("action=viewprofile&user="+usermax, "gi"); function Attack(a){ var attk_string = TDs[a].innerHTML.match(/\[attack=(\w+)\]/gi); if(TDs[a].innerHTML.match(/\[attack=(\w+)\]/gi)) { if(TDs[a].vAlign=="top" && TDs[a].colSpan=="3") { TDs[a].innerHTML=TDs[a].innerHTML.replace(/\[attack\=(\w+)\]/gi,'You have attacked '+attk_string[1]); Attack(a); } } } if(location.href.match(/action=(display|viewprofile|search2|recent|post)/i)) { for(a=0;a<TDs.length;a++) { if(TDs[a].width=="20%" && TDs[a].innerHTML.match(/Posts:/i)) { if(TDs[a].getElementsByTagName("A")[0].href.match(maxusers) || TDs[a].getElementsByTagName("A")[1].href.match(maxusers)) { var lvl2 = "999"; var hp = statmax; var mp = statmax; var attk = statmax; var def = statmax; var agl = statmax; var itl = statmax; var mon = monmax; } else { if(TDs[a].innerHTML.match(/Karma: (\d+)/i)) { var karma = RegExp.$1; } if(TDs[a].innerHTML.match(/Posts: (\d+),(\d+)/i)) { var posts = RegExp.$1 + RegExp.$2; } else if(TDs[a].innerHTML.match(/Posts: (\d+)/i)) { var posts = RegExp.$1; } var lvl = parseInt(posts)/needlvl; var rep = parseInt(karma*karmamod); if(rep<"999") { if(rep<"3") { var rep2 = "3"; } else { for(karm=0;rep>karm;karm++) { var rep2 = parseInt(karm)+1; } } } else { var rep2 = "999"; } if(lvl<"999") { if(lvl<"1") { var lvl2 = "1"; } else { for(lev=0;lvl>lev;lev++) { var lvl2 = parseInt(lev)+1; } } } else { var lvl2 = "999"; } var hp = parseInt(rep2)*health; var mp = parseInt(lvl2)*magic; var attk = parseInt(rep2)*attack; var def = parseInt(lvl2)*defense; var agl = parseInt(rep2)*agility; var itl = parseInt(lvl2)*intelligence; var mon = parseInt(posts)*money; if(hp > statmax){hp = statmax;} if(mp > statmax){mp = statmax;} if(attk > statmax){attk = statmax;} if(def > statmax){def = statmax;} if(agl > statmax){agl = statmax;} if(itl > statmax){itl = statmax;} if(mon > monmax){mon = monmax;} } var stat_menu = "<br /><table border='0' cellpadding='1' cellspacing='0' width='75%'>"; stat_menu += "<tr><td align='center' colspan='2'><a onclick='hideshowstats(this)'>"; stat_menu +="<b><u>Show RPG Stats</u></b></a></td></tr><tr style='display: none;'>"; stat_menu +="<td align='left'>Level: </td><td align='left'> "+lvl2+"</td></tr>"; stat_menu +="<tr style='display: none;'><td align='left'>HP: </td>"; stat_menu +="<td align='left'> "+hp+"</td></tr><tr style='display: none;'>"; stat_menu +="<td align='left'>MP: </td><td align='left'> "+mp+"</td></tr>"; stat_menu +="<tr style='display: none;'><td align='left'>Attack: </td>"; stat_menu +="<td align='left'> "+attk+"</td></tr><tr style='display: none;'>"; stat_menu +="<td align='left'>Defense: </td><td align='left'> "+def+"</td>"; stat_menu +="</tr><tr style='display: none;'><td align='left'>Agility: </td>"; stat_menu +="<td align='left'> "+agl+"</td></tr><tr style='display: none;'>"; stat_menu +="<td align='left'>Intelligence: </td><td align='left'> "+itl+"</td>"; stat_menu +="</tr><tr style='display: none;'><td align='left'>Money: </td>"; stat_menu +="<td align='left'> "+sign+mon+"</td></tr></table>"; TDs[a].innerHTML+=stat_menu; } Attack(a); } if(document.postForm) { dpF=document.postForm; dpF.color.parentNode.innerHTML+='<a href=javascript:add("[attack=]","")><img src="http://demonguardians.110mb.com/images/attack.jpg" alt="Attack User" /></a>'; } function hideshowstats(ext) { if(ext.parentNode.parentNode.parentNode.rows[1].style.display=="none") { ext.innerHTML="<b><u>Hide RPG Stats</u></b>"; ext.parentNode.parentNode.parentNode.rows[1].style.display=""; ext.parentNode.parentNode.parentNode.rows[2].style.display=""; ext.parentNode.parentNode.parentNode.rows[3].style.display=""; ext.parentNode.parentNode.parentNode.rows[4].style.display=""; ext.parentNode.parentNode.parentNode.rows[5].style.display=""; ext.parentNode.parentNode.parentNode.rows[6].style.display=""; ext.parentNode.parentNode.parentNode.rows[7].style.display=""; ext.parentNode.parentNode.parentNode.rows[8].style.display=""; } else { ext.innerHTML="<b><u>Show RPG Stats</u></b>"; ext.parentNode.parentNode.parentNode.rows[1].style.display="none"; ext.parentNode.parentNode.parentNode.rows[2].style.display="none"; ext.parentNode.parentNode.parentNode.rows[3].style.display="none"; ext.parentNode.parentNode.parentNode.rows[4].style.display="none"; ext.parentNode.parentNode.parentNode.rows[5].style.display="none"; ext.parentNode.parentNode.parentNode.rows[6].style.display="none"; ext.parentNode.parentNode.parentNode.rows[7].style.display="none"; ext.parentNode.parentNode.parentNode.rows[8].style.display="none"; } } } </script>
Last Edit: Apr 10, 2009 22:34:55 GMT by chaoskreator
|
Do or do not. There is no try.
The Realms Beyond Demon Guardians
|
|
|
|
I'm gonna do a bunch of clean up and post my changes in red. You're using my really old base, and it is extremely poor. >.< That code was 2005 or 2004 I think. Hopefully I don't break anything. Now, we need to do what you're talking about. As it stands, I don't see any array of user data for it to update.... So yeah, totally confused there.
Last Edit: Apr 11, 2009 4:34:26 GMT by Chris
|
|
|
|
|
|
Sorry about stretching the page, there. I'll fix that in a little while. Okay, so I'll work from the code above. I'm also going to make my own thread for this project so as not to keep mucking up other people's threads.
|
Do or do not. There is no try.
The Realms Beyond Demon Guardians
|
|
|
|
Best lesson on here *thumbs up*
|
|
|
|