Hi Ragezone,
I was browsing the forums the other day,
and I saw that alot of people don't know how to make a custom reward system/voting system.
With a reward system I mean having a column in MySQL which is editable with, in most cases, npc's.
That's why I decided to make a tutorial on how to make a custom system, didn't know in which section to post so I did it in both, hope you'll forgive me.
Blue = required.
Red = extra info.
Orange = optional / own customization.
We're going to make a custom votingpoints system~
Let's get started.
MySQL Column 'votingpoints'
DO THIS WHEN THE SERVER = DOWN!
~Go into the MySQL query browser and right click on accounts > edit table, a window should pop up.
Scroll down the list and add a column by clicking in the emty space under the last column.
These are the things you should enter :
Click apply changes and run the query.Code:Column Name, Datatype, Not NULL, Auto Increment, Flags, Default Value. votingpoints , INT(11) , (Enabled) , (Disabled) , (Both Disabled) , 0 << REALLY IMPORTANT!
Your column in MySQL has been created. :)
MapleCharacter.java
Open up netbeans and make your way to MapleCharacter.java , located in net\sf\odinms\client for ThePack/Xotic and client for BubblesDev.
Open it.
Now do the following :
Add :
Or w/e your system is called~Code:private int votingpoints;
Under :
Or w/e is the last private int in your MapleCharacter.javaCode:private int ci = 0;
WATCH OUT, do NOT paste this in the public static getDefault!
Find (ctrl + f) :
Scroll down till you see :Code:loadCharFromDB
In this (^^^) part add :Code:rs = ps.executeQuery(); while (rs.next()) { ret.getClient().setAccountName(rs.getString("name")); ret.paypalnx = rs.getInt("paypalNX"); ret.maplepoints = rs.getInt("mPoints"); ret.cardnx = rs.getInt("cardNX"); }
Under :Code:ret.votingpoints = rs.getInt("votingpoints");
Find (ctrl + f) :Code:ret.cardnx = rs.getInt("cardNX");
Replace :Code:ps = con.prepareStatement("UPDATE accounts SET `paypalNX` = ?, `mPoints` = ?, `cardNX` = ? WHERE id = ?");
With :Code:ps = con.prepareStatement("UPDATE accounts SET `paypalNX` = ?, `mPoints` = ?, `cardNX` = ? WHERE id = ?"); ps.setInt(1, paypalnx); ps.setInt(2, maplepoints); ps.setInt(3, cardnx); ps.setInt(4, client.getAccID());
Add :Code:ps = con.prepareStatement("UPDATE accounts SET `paypalNX` = ?, `mPoints` = ?, `cardNX` = ?, `votingpoints` = ? WHERE id = ?"); ps.setInt(1, paypalnx); ps.setInt(2, maplepoints); ps.setInt(3, cardnx); ps.setInt(4, votingpoints); ps.setInt(5, client.getAccID());
Make sure that IF you use a different system name to also update all voids in NPCConversationmanager.java later on!Code:public void setvotingpoints(int newpoints) { this.votingpoints = newpoint; } public void gain1votingpoint() { this.votingpoints++; } public void gainvotingpoints(int gainedpoints) { this.votingpoints += gainedpoints; } public int getvotingpoints() { return votingpoints; }
Under :
Code:public void setMarried(int m) { this.married = m; }
NPCConversationManager.java
Pay really close attention to the next parts!
Add :
Under :Code:public int getvotingpoints() { return getPlayer().getvotingpoints(); } public void setvotingpoints(int newpoints) { getPlayer().setvotingpoints(newpoints); } public void gainvotingpoint1() { getPlayer().gain1votingpoint(); } public void gainvotingpoints(int gainedpoints) { getPlayer().gainvotingpoints(gainedpoints); chr.saveToDB(true); // No more stupid rollbacks ;) ~Deagan if (gainedpoints > 0) { getPlayer().message("Hi " + getPlayer().getName() + ","); getPlayer().message("You have achieved : " + gainedpoints + " VotingPoint(s),"); getPlayer().message("Which brings you to a total of : " + getPlayer().getvotingpoints() + " VotingPoints~"); } else { getPlayer().message("Hi " + getPlayer().getName() + ","); getPlayer().message("You have lost : " + gainedpoints + " VotingPoints,"); getPlayer().message("Which brings you to a total of : " + getPlayer().getvotingpoints() + " VotingPoints~"); } }
About all purple parts, as you can see, it says : getPlayer(). in front of it,Code:public void gainMeso(int gain) { getPlayer().gainMeso(gain, true, false, true); }
which means it redirects to MapleCharacter.java
To make these purple parts work change them to what you changed in NPCConversationManager.java
Example :
In MapleCharacter you changed :
Into :Code:public void setvotingpoints(int newpoints) { this.votingpoints = newpoint; }
To make it work in NPCConversationManager.java the (purple part) :Code:public void setcookiepoints(int newpoints) { this.cookiepoints = newpoint; }
Should be changed to :Code:public void setvotingpoints(int newpoints) { getPlayer().setvotingpoints(newpoints); }
ALWAYS LOOK BACK ON WHAT YOU HAVE CODED.Code:public void setcookiepoints(int newpoints) { getPlayer().setcookiepoints(newpoints); }
Frequently asked questions (Which I think people would certainly ask) :
Code:-How do you add a playercommand to check your amount of votingpoints? Go into playercommand.java and add : } else if (splitted[0].equals("@checkvotingpoints")) { player.message("Hello " + c.getPlayer().getName() + ", you currently have : " + c.getPlayer().getvotingpoints() + " votingpoints~");Code:-How does this 'system' work, I added it but nothing changed in game =O I am not making the npc's for you, but I can tell you how, make a npc which uses one of the npcconversationmanager voids, examples : cm.getvotingpoints(); // Shows you how much votingpoints you have. cm.setvotingpoints(1000); // Sets your votingpoints to 1000, directly into MySQL cm.gainvotingpoints(100); // Adds or removes 100 votingpoints on top of what's already in MySQL cm.gainvotingpoint1(); // Adds 1 votingpoint on top of what's already in MySQLCode:-I am having errors when compiling? Scan all MapleCharacter.java and NPCConversationManager.java additions and see if the, taken into consideration in the purple parts, voids arn't different from eachother. If you're using a different source you might have to add new imports.Code:-I am still getting errors, can you teamview me and help me set it up? No I will NOT teamviewing you, post your problem in the comments and I or someone else will help you out, if possible.Code:-Did you make this? HarleyQuin said you only use scripts of him :S Yes I made this, HarleyQuin is a fucked up fag which let me host his fail server for 3 months then deleted all files I coded, then says I am the money-stealing scumbag which steals his scripts.Code:-Autoregister/siteregister doesn't work :O ZOMG! Make sure you have set the default value of the MySQL column to 0.Code:-Why are you releasing this, it's basically spoonfeeding all leechers on this forum. Might be, but I feel like every single server owner has the right to have some customization in his/her server.Code:-May I suck you off for making this? Go ahead.
Credits to me.
Thanks for reading :)
Hope this helps alot of you.



Reply With Quote


