- Joined
- Oct 21, 2008
- Messages
- 811
- Reaction score
- 350
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.
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~
Under :
Or w/e is the last private int in your MapleCharacter.java
WATCH OUT, do NOT paste this in the public static getDefault!
Find (ctrl + f) :
Scroll down till you see :
In this (^^^) part add :
Under :
Find (ctrl + f) :
Replace :
With :
Add :
Make sure that IF you use a different system name to also update all voids in NPCConversationmanager.java later on!
Under :
NPCConversationManager.java
Pay really close attention to the next parts!
Add :
Under :
About all purple parts, as you can see, it says : getPlayer(). in front of it,
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 :
To make it work in NPCConversationManager.java the (purple part) :
Should be changed to :
ALWAYS LOOK BACK ON WHAT YOU HAVE CODED.
Frequently asked questions (Which I think people would certainly ask) :
Credits to me.
Thanks for reading
Hope this helps alot of you.
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 :
Code:
Column Name, Datatype, Not NULL, Auto Increment, Flags, Default Value.
[COLOR="darkorange"]votingpoints[/COLOR] , INT(11) , (Enabled) , (Disabled) , (Both Disabled) , 0 << REALLY IMPORTANT!
Click apply changes and run the query.
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 :
Code:
private int [COLOR="darkorange"]votingpoints[/COLOR];
Under :
Code:
private int ci = 0;
WATCH OUT, do NOT paste this in the public static getDefault!
Find (ctrl + f) :
Code:
loadCharFromDB
Scroll down till you see :
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");
}
In this (^^^) part add :
Code:
ret.votingpoints = rs.getInt("[COLOR="DarkOrange"]votingpoints[/COLOR]");
Under :
Code:
ret.cardnx = rs.getInt("cardNX");
Find (ctrl + f) :
Code:
ps = con.prepareStatement("UPDATE accounts SET `paypalNX` = ?, `mPoints` = ?, `cardNX` = ? WHERE id = ?");
Replace :
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());
With :
Code:
ps = con.prepareStatement("UPDATE accounts SET `paypalNX` = ?, `mPoints` = ?, `cardNX` = ?, `[COLOR="darkorange"]votingpoints[/COLOR]` = ? WHERE id = ?");
ps.setInt(1, paypalnx);
ps.setInt(2, maplepoints);
ps.setInt(3, cardnx);
ps.setInt(4, [COLOR="DarkOrange"]votingpoints[/COLOR]);
ps.setInt(5, client.getAccID());
Add :
Code:
public void [COLOR="DarkOrange"]setvotingpoints[/COLOR](int newpoints) {
this.[COLOR="darkorange"]votingpoints[/COLOR] = newpoint;
}
public void [COLOR="darkorange"]gain1votingpoint[/COLOR]() {
this.[COLOR="darkorange"]votingpoints[/COLOR]++;
}
public void [COLOR="darkorange"]gainvotingpoints[/COLOR](int gainedpoints) {
this.[COLOR="darkorange"]votingpoints[/COLOR] += gainedpoints;
}
public int [COLOR="darkorange"]getvotingpoints[/COLOR]() {
return [COLOR="darkorange"]votingpoints[/COLOR];
}
Under :
Code:
public void setMarried(int m) {
this.married = m;
}
NPCConversationManager.java
Pay really close attention to the next parts!
Add :
Code:
public int [COLOR="DarkOrange"]getvotingpoints[/COLOR]() {
return getPlayer().[COLOR="DarkOrchid"]getvotingpoints[/COLOR]();
}
public void [COLOR="DarkOrange"]setvotingpoints[/COLOR](int newpoints) {
getPlayer().[COLOR="darkorchid"]setvotingpoints[/COLOR](newpoints);
}
public void [COLOR="darkorange"]gainvotingpoint1[/COLOR]() {
getPlayer().[COLOR="darkorchid"]gain1votingpoint[/COLOR]();
}
public void [COLOR="darkorange"]gainvotingpoints[/COLOR](int gainedpoints) {
getPlayer().[COLOR="DarkOrchid"]gainvotingpoints[/COLOR](gainedpoints);
chr.saveToDB(true); // No more stupid rollbacks ;) ~Deagan
if (gainedpoints > 0) {
getPlayer().message("Hi " + getPlayer().getName() + ",");
getPlayer().message("You have achieved : " + gainedpoints + " [COLOR="darkorange"]VotingPoint(s)[/COLOR],");
getPlayer().message("Which brings you to a total of : " + getPlayer().[COLOR="darkorchid"]getvotingpoints[/COLOR]() + " [COLOR="darkorange"]VotingPoints[/COLOR]~");
}
else {
getPlayer().message("Hi " + getPlayer().getName() + ",");
getPlayer().message("You have lost : " + gainedpoints + " [COLOR="darkorange"]VotingPoints[/COLOR],");
getPlayer().message("Which brings you to a total of : " + getPlayer().[COLOR="darkorchid"]getvotingpoints[/COLOR]() + " [COLOR="darkorange"]VotingPoints[/COLOR]~");
}
}
Under :
Code:
public void gainMeso(int gain) {
getPlayer().gainMeso(gain, true, false, true);
}
About all purple parts, as you can see, it says : getPlayer(). in front of it,
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 :
Code:
public void [COLOR="DarkOrange"]setvotingpoints[/COLOR](int newpoints) {
this.[COLOR="darkorange"]votingpoints[/COLOR] = newpoint;
}
Into :
Code:
public void [COLOR="DarkOrange"]setcookiepoints[/COLOR](int newpoints) {
this.[COLOR="darkorange"]cookiepoints[/COLOR] = newpoint;
}
To make it work in NPCConversationManager.java the (purple part) :
Code:
public void [COLOR="DarkOrange"]setvotingpoints[/COLOR](int newpoints) {
getPlayer().[COLOR="darkorchid"]setvotingpoints[/COLOR](newpoints);
}
Should be changed to :
Code:
public void [COLOR="DarkOrange"]setcookiepoints[/COLOR](int newpoints) {
getPlayer().[COLOR="darkorchid"]setcookiepoints[/COLOR](newpoints);
}
ALWAYS LOOK BACK ON WHAT YOU HAVE CODED.
Frequently asked questions (Which I think people would certainly ask) :
Code:
[SIZE="2"]-How do you add a playercommand to check your amount of [COLOR="DarkOrange"]votingpoints[/COLOR]?
Go into playercommand.java and add :
} else if (splitted[0].equals("@[COLOR="darkorange"]checkvotingpoints[/COLOR]")) {
player.message("Hello " + c.getPlayer().getName() + ", you currently have : " + c.getPlayer().[COLOR="DarkOrchid"]getvotingpoints[/COLOR]() + " [COLOR="DarkOrange"]votingpoints[/COLOR]~");[/SIZE]
Code:
[SIZE="2"]-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 MySQL[/SIZE]
Code:
[SIZE="2"]-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.[/SIZE]
Code:
[SIZE="2"]-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.[/SIZE]
Code:
[SIZE="2"]-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. [/SIZE]
Code:
[SIZE="2"]-Autoregister/siteregister doesn't work :O ZOMG!
Make sure you have set the default value of the MySQL column to 0.[/SIZE]
Code:
[SIZE="2"]-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.[/SIZE]
Code:
[SIZE="2"]-May I suck you off for making this?
Go ahead.[/SIZE]
Credits to me.
Thanks for reading
Hope this helps alot of you.