We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
[CODE] Money for Groups; By dip00ts
Topic Started: Jan 23 2010, 01:02 AM (208 Views)
Reid
Member Avatar
È una trappola!

This topic has been moved from our official support board.

Originally posted by: dip00ts
[CODE
 
Money for Groups]This isn't really my own code, simply took Gornakle's code and edited it to fit my own needs, figured I'd share with you guys.

Please note: I only added ONE line of code, so I don't deserve much credit. It is rather useful though, if you need it (like I did)

Code Name: Money for Groups

Description: Simple money code by Gornakle, modified so that different groups can recieve different rates. Good for RPGs where you want to have jobs available; for example, a Warrior could make $200 per post, while a Wizard make $100 per post, and an Assassin makes $1000 per post.

Preview of it in Use:
http://z8.invisionfree.com/Moneygroupcodet...php?showtopic=1

Where it goes:
ADMIN CP > SKINNING & STYLES > WRAPPERS > FOOTER

Quote:
 

<script type="text/javascript">
// Money code for Groups
// Original Simple Money Code By Gornakle of InvisionFree.com
// Modification For Groups By Dip00ts

sign = '$'
name = 'Money'
PerPost = 100
default_amount = 0

MID=[]
MID["member1"] = 20
MID["member2"] = -30
MID["member3"] = 120


function injectMoney() {
d = document.getElementsByTagName('td');
for( i in d ){
if (d.innerHTML.match("Group: Group Name"))
// For Altering Purposes
{
dc = d.className;
if(/post(1|2)/.test(dc) && d.width != '100%') {
span = d.getElementsByTagName('span')[0];
s = d.getElementsByTagName('span')[0].innerHTML;
pcount = /Posts: ([\d|,| |.]+)</.exec(s)[1];
pcount = parseInt(pcount.replace(/[^\d]/g,''));
uname = d[i-2].innerHTML.replace(/<[^>]+>/g,'').replace(/ /g,'');
if(MID[uname]) money = (parseInt(MID[uname]) + (pcount * PerPost)) + parseInt(default_amount);
else money = (pcount * PerPost) + parseInt(default_amount);
if(s.match('<!-- placeholder -->')) {
span.innerHTML = s.replace("<!-- placeholder -->", name + ": " + sign + money + "<br><!-- placeholder -->");
continue; }
newHTML = name + ": " + sign + money + "<br><!-- placeholder -->";
span.innerHTML = s.replace(/(Joined: [^<]+)/, '$1<br><br>' + newHTML.replace(/\$/, '&#'+'36;'));
}}}} injectMoney();
</script>


Instructions:
Edit what is in red to fit what you need.
Edit what is in green to add/subtract funds from certain members within that group.

This code only works for ONE group. For each group, copy and paste the code, and edit accordingly.

If you have many groups, it might be a good idea to get a file host and host the script externally.

If you have multiple groups with similar names (for example, my forum had the group "The Shooting Star", and the group "The Shooting Star Captain") you may have some problems (in my case, "The Shooting Star Captain" would recieve two separate funds, one for "The Shooting Star" and one for "The Shooting Star Captain".) Here is what you do.

Find the line "//For Altering Purposes" in the code.
Replace it with this:

Quote:
 
{if (d.innerHTML.match("Group: Group Name You Do Not Want Included"))
{}
else


then add another "}" to the blue part of the code.
So, for my forum, I replaced it with that, and put "The Shooting Star Captain" in. That way, the two group funds were kept separate.

Also, if you want to make it so that all but one group makes money (for example, the admin group, or a "spammer" group) you can replace the "//For Altering Purposes" line with:

Quote:
 
}
else


and fill in the "Group Name" with the name of the group you want excluded.

I am currently working on a way to shorten the script by only using one (possibly with a switch code).


Copyright:
Most of the credit should go to Gornakle. I am only just learning Javascript and I was looking for a way to give different groups different money rates, so I figured out how to set it to find out what a person's group is. I really didn't do much, but it's a nice effect.

I hope this is easy to understand, and that I don't get in trouble for modifying Gornakle's mod. :)
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
« Previous Topic · Codes & Modifications · Next Topic »
Add Reply