[RELEASE] Website/Ingame based points system

Status
Not open for further replies.
Newbie Spellweaver
Joined
Jul 22, 2007
Messages
9
Reaction score
0
Intro: Well this is my first release so no flaming guys. Please!

This basically lets you award points to users for something(such as website events, ingame events, reported a hacker etc) This is stored in a separate SQL Column in accounts table. Hence points can be awarded for website events as well. Now these points can be used for giving out unique stuff etc...

now to the code
First Execute this Query in your database:
Code:
ALTER TABLE `accounts` ADD COLUMN `points` int(11) DEFAULT '0';
then go to MapleCharacter.java
Scroll down till you see this:
Code:
 private int rank;
 private int rankMove;
 private int jobRank;
 private int jobRankMove;

and below that add:
Code:
private int points;

now ctrl+f(Search) for :
Code:
ps.close();

and insert the following code immediately below it

Code:
ps = con.prepareStatement("SELECT * FROM accounts WHERE points = ?");
                ps.setInt(1, ret.points);
                rs = ps.executeQuery();
                while (rs.next()) {
                        ret.points = rs.getInt("points");
                }

Now scroll down till you see this:
Code:
public boolean isGM() {
  return gm;
 }
and below that add:
Code:
public int getPoints() {
 return points;
}
public void addPoints(int addpoints) {
 points += addpoints;
}
public void removePoints(int removepoints) {
 if (points <= 0) {
 points = 0;
 } else if (removepoints >= points) {
 points = 0;
 } else {
 points -= removepoints;
}
}
Thats it.. your MapleCharacter is done
Now go to NPCConversationManager.java in net.sf.odinms.scripting.npc
scroll down till you see:
Code:
  public void gainExp(int gain) {
  getPlayer().gainExp(gain, true, true);
 }
and add the following below it
Code:
public int getPoints() {
 return getPlayer().getPoints();
}
public void addPoints(int points) {
 getPlayer().addPoints(points);
}
public void removePoints(int points) {
 getPlayer().removePoints(points);
}
The basis of it is done.. now you can close your NPCConversationManager.java
If you do want the commands for gm for adding and removing points.... scroll down
Open your CommandProcessor.java
Code:
else if(splitted[0].equals("!addpoints")) {
                                                 if(splitted.length == 3) {
 
                                    try { MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
                                    int points = Integer.parseInt(splitted[2]);
                                    victim.addPoints(points);
                                    mc.dropMessage(victim.getName()+" successfully credited with "+points+" points");
                                                 }    catch(NumberFormatException ioerror) {
                                                 mc.dropMessage("A number should be given o.o");
                                             }      
                                             } else {
                                                     mc.dropMessage("Syntax: !addpoints <Charname> <amt of points>");
                                             }       
                                             } else if (splitted[0].equals("!removepoints")) {
                                                 if(splitted.length == 3) {
                                    try { MapleCharacter victim = cserv.getPlayerStorage().getCharacterByName(splitted[1]);
                                    int repoints = Integer.parseInt(splitted[2]);
                                    victim.removePoints(repoints);
                                    mc.dropMessage(repoints+" points removed from "+victim.getName()+"'s account");
                                    }     catch(NumberFormatException ioerror1) {
                                            mc.dropMessage("A number should be given o.o");
                                    }
                                                 } else {
                                                     mc.dropMessage("Syntax: !removepoints <Charname> <points>");
                                                 }
                                }
GM Commands are:
!addpoints <Character Name> <No of points>
!addpoints is used to credit points into a user's account.
!removepoints <Character Name> <No of points>
!removepoints is used to remove points from a user's account.
Enjoy!
 
Last edited:
yes it does work 100%

uses:
Points can be used to buy nxcash
Can be used to buy rare stuff
Can be used for user of the month award
anything you ever want O_O
 
I already released the Donation Points system, it's actually the same... Just called Donation Points system but can also be used as a normal points system. You just coded it on a little bit other way.
 
I already released the Donation Points system, it's actually the same... Just called Donation Points system but can also be used as a normal points system. You just coded it on a little bit other way.
At least this one still works i supopse and it seems good, nice release =]
You can make loads of stuff out of this, but im gonna avoid donation.
 
Nice release, reminds me of donator points. I was thinking about making something like this, but u beat me to it :P.


Id use it, but i dont think it would be used often enough...so ill just stick with regular event methods :P
 
Actually this was not coded with donations in mind... I had this a long time ago in my friends server but i didnt release it here cuz my friends dumb GM's kept on putting an string value in the points field.... it kept on throwing up a runtime error. I decided i needed to know a bit more about exceptions O.o
 
o: You actually just saved me a bunch of time. I wanted to use this for my custom PQ ranknings o-o I'll just have to edit a little to give the whole party points. Thanks o_o
 
At least this one still works i supopse and it seems good, nice release =]
You can make loads of stuff out of this, but im gonna avoid donation.

The one I posted works too and it's actually the same. You can also make loads of stuff out of it, it's called Donation Points system but doesn't mean that you can only use it for donations. Well, what ever...
 
interesting,
@flav this is a php/web based point system whereas urs flav was a game based
 
Status
Not open for further replies.
Back