Post by content on Jun 7, 2015 17:16:20 GMT 1
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.
votingpoints , 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 votingpoints;Or w/e your system is called~
Under :
Code:
private int ci = 0;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) :
Code:
loadCharFromDBScroll 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("votingpoints");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` = ?, `votingpoints` = ? WHERE id = ?");
ps.setInt(1, paypalnx);
ps.setInt(2, maplepoints);
ps.setInt(3, cardnx);
ps.setInt(4, votingpoints);
ps.setInt(5, client.getAccID());Add :
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;
}Make sure that IF you use a different system name to also update all voids in NPCConversationmanager.java later on!
Under :
Code:
public void setMarried(int m) {
this.married = m;
}
NPCConversationManager.java
Pay really close attention to the next parts!
Add :
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~");
}
}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 setvotingpoints(int newpoints) {
this.votingpoints = newpoint;
}Into :
Code:
public void setcookiepoints(int newpoints) {
this.cookiepoints = newpoint;
}To make it work in NPCConversationManager.java the (purple part) :
Code:
public void setvotingpoints(int newpoints) {
getPlayer().setvotingpoints(newpoints);
}Should be changed to :
Code:
public void setcookiepoints(int newpoints) {
getPlayer().setcookiepoints(newpoints);
.