Welcome Guest [Log In] [Register]
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] Even simpler money code; yup XP
Topic Started: May 27 2004, 08:23 AM (69,605 Views)
Gornakle
Member Avatar
Member
 *   *   *   *   *  
NOTE: This is not a shop/item/RPG whatever code. Just money. Also, no, you can't have a seperate amount of money per regular post, new topic or new poll.
To use this code, go to the "Board wrappers" section in the Admin CP, then copy/paste it into the "Footer" area.

Code:
 
<script type="text/javascript">
// Money code
// By Gornakle of InvisionFree.com

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

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

// No need to edit below this line

function injectMoney() {
d = document.getElementsByTagName('td');
for( i in d ) {
dc = d[i].className;
if(/post(1|2)/.test(dc) && d[i].width != '100%') {
span = d[i].getElementsByTagName('span')[0];
s = d[i].getElementsByTagName('span')[0].innerHTML;
pcount = /Posts: ([\d|,| |.]+)</.exec(s)[1];
pcount = parseInt(pcount.replace(/[^\d]/g,''));
uname = d[i-2].innerHTML.replace(/<[^>]+>/g,'').replace(/&nbsp;/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>


Posted Image

This code will add a basic virtual money system to your board. A line will be added to every member's post details (as shown in the preview) indicating how much 'money' he or she has. This amount is determined by the amount of posts made plus the amount of money every member gets by default (this can be set by changing the 'PerPost' and 'default_amount' variables).

An admin may also choose to edit the amount of money of a member manually. To do this, replace 'member1', 'member2' etc. with the names of the members you want to add or subtract money from. So for example if you want to add $100 to the member 'YourName', you would use this:

Code:
 
MID["YourName"] = 100


Or if you want to subtract $100 from that member, you'd use a negative number, such as:

Code:
 
MID["YourName"] = -100


To add a new member to edit, simply add another line.
Offline Profile Quote Post Goto Top
 
kb31685
Member
 *   *  
Nice code, I will use it if you can make it automatically update & give people money for posts. :/
Offline Profile Quote Post Goto Top
 
MM23
Member Avatar
Darkness Initiate
 *   *  
Yeah, people don't want to give money for each person. That's a little too... hard XD
Offline Profile Quote Post Goto Top
 
Gornakle
Member Avatar
Member
 *   *   *   *   *  
kb31685
May 27, 2004 11:40 AM
Nice code, I will use it if you can make it automatically update & give people money for posts. :/

That's where wwx's Simple money code comes in. Mine was mostly made for small boards.

If anyone wants, I could update it to add an amount of money for each post a user makes, on top of the current amount.
Offline Profile Quote Post Goto Top
 
MM23
Member Avatar
Darkness Initiate
 *   *  
I see the use now. I guess you could do that, but otherwise, yeah. For example, every post gives you $2, so if you had 3000 posts you'd have $6000. That'd work well :D
Offline Profile Quote Post Goto Top
 
kb31685
Member
 *   *  
Gornakle
May 27, 2004 12:12 PM
kb31685
May 27, 2004 11:40 AM
Nice code, I will use it if you can make it automatically update & give people money for posts. :/

That's where wwx's Simple money code comes in. Mine was mostly made for small boards.

If anyone wants, I could update it to add an amount of money for each post a user makes, on top of the current amount.

Yeah, I'm using the simple money code now, but I really can't use it for anything since you can't edit anyone's cash without changing their post count. <_<

I tried putting in both codes to see if that would somehow work, but it just went with the first code & ignored whatever amounts I put in with your code, so I took that out.

If you could somehow combine codes so that you can specify someone's amount, but then it'd automatically go up after each post, that'd be awesome! :yes:
Offline Profile Quote Post Goto Top
 
ultimo91
I'm Rick James B*tch
 *  
You know if you wanted to increase indivual money accounts.
Then all you had to do was enable the first money code made.
Then go to Find/Edit/Suspend Users type in the member's
name that money account that you want to increase and click
Find.And then scroll down to where you see Number of Member
Post.And then just increase to whatever number you'd like.
And the money account would automatically increase with
the member's post number.
Offline Profile Quote Post Goto Top
 
whythiswhy
Member
 *   *  
Gornakle
May 27, 2004 02:12 PM
kb31685
May 27, 2004 11:40 AM
Nice code, I will use it if you can make it automatically update & give people money for posts. :/

That's where wwx's Simple money code comes in. Mine was mostly made for small boards.

If anyone wants, I could update it to add an amount of money for each post a user makes, on top of the current amount.

oh, that would rock... could you do that please?
Offline Profile Quote Post Goto Top
 
AfterHuman333
Your Lover
 *  
Actually, this is a good idea. So you don't have to go fool with people's post count.
Offline Profile Quote Post Goto Top
 
Gornakle
Member Avatar
Member
 *   *   *   *   *  
Code updated. Anymore requests? :)
Offline Profile Quote Post Goto Top
 
kb31685
Member
 *   *  
Thanks! It's not showing up on my board though. :/ Do you know any codes that it interferes with? How about the pet/element one? :ermm:
Offline Profile Quote Post Goto Top
 
kb31685
Member
 *   *  
I figured out what it was... It was the code to insert group icons & keep your pips.

But now the money isn't on a separate line -- how can you fix that?

Looks like this: Posted Image
Offline Profile Quote Post Goto Top
 
Gornakle
Member Avatar
Member
 *   *   *   *   *  
Indeed strange. But there's an easy fix. Change:
Code:
 
var name = "Money";

to:
Code:
 
var name = "<br><br>Money";

Adds two new line characters.
Offline Profile Quote Post Goto Top
 
whoknows?notme
whoknows?notme
 *  
What could this code useful for? BTW i have a question for the shop coming out, when you buy something is it going to dectuct money by itself?
Offline Profile Quote Post Goto Top
 
Gornakle
Member Avatar
Member
 *   *   *   *   *  
So you don't have to mess with postcounts to deduct or add money. A couple of members found it to usefull, so I thought I'd post it here.

And yes, the shop is completely automated.
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · Code Snippets · Next Topic »
Add Reply