Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Web How to add a custom reward/voting system. (NON TIMED)

I'm sexy and I know it :)
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 :
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];
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:
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];
    }
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 [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.




 
Junior Spellweaver
Joined
Jul 11, 2008
Messages
118
Reaction score
16
Wasnt this in the release section? Btw its bad convention not to capitalize method names after the first word... Not a flame, just saying.
 
Newbie Spellweaver
Joined
Aug 7, 2009
Messages
6
Reaction score
0
OMG, i have tested it and it work.

Thank dude.

Thanks
KiNdAnGeL
 
Initiate Mage
Joined
Aug 27, 2008
Messages
4
Reaction score
0
when i relog i no longer have points. Anyone know how to fix?

---------- Post added at 03:00 AM ---------- Previous post was at 02:49 AM ----------

when i relog i no longer have points. Anyone know how to fix?

nvm i figured it out! Thanks for the tut!
 
Initiate Mage
Joined
Jan 21, 2010
Messages
1
Reaction score
0
heyy um i think this a great release and i would just like 2 say thx a lot!! im just curious cuz i made my pserver 2day and i have no experience whatsoever with anything 2 do with maplestory private servers... after i compiled all these codes and everything, what npc do i use in my server for the vote point system??

thanks in advance =D
 
Skilled Illusionist
Joined
Dec 25, 2008
Messages
306
Reaction score
4
Whats wrong with this?

PHP:
if (cm.getPlayer().getvotepoints() >= 1) {
            cm.gainMeso(500000);
            cm.gainvotepoints(-1);
            cm.sendOk("Well done!, Here is your #rMoney#k");
            cm.dispose();
        } else {
            cm.sendOk(" Sorry. You do not have enough Vote Points. ");
            cm.dispose();
        }

It work. gives you 500.000 mesos but after it gives you the money it doesn't pop anything and say well done here is your poop. Also lets say i got 1 point in my account so i use that for 1 time and the 2nd time it says sorry cuz i dont have anymore points right. but i go check in the DB and the points are still there? and then i relog the char and i can get 500.000 again from the npc. like wtf?
 
Newbie Spellweaver
Joined
Jul 17, 2008
Messages
9
Reaction score
0
It cant find symbol Newpoint here...
anyone knows how to fix ?

---------- Post added at 01:33 PM ---------- Previous post was at 01:32 PM ----------

Well.. It cant find symbol "newpoints" here

Anyone know how to fix ?

---------- Post added at 01:35 PM ---------- Previous post was at 01:33 PM ----------

Well.. It cant find symbol "newpoints" here

Anyone know how to fix ?
 
Newbie Spellweaver
Joined
Jul 17, 2008
Messages
9
Reaction score
0
Code:
symbol  : variable newpoint
location: class client.MapleCharacter
        this.FascinationPoints = newpoint;

This is the problem :O
 
Newbie Spellweaver
Joined
Nov 7, 2009
Messages
37
Reaction score
29
Code:
symbol  : variable newpoint
location: class client.MapleCharacter
        this.FascinationPoints = newpoint;

This is the problem :O

Add private int newpoint; at the top under private int votingpoints; is how I fixed it, not sure if it's the fix though.
 
Initiate Mage
Joined
Dec 1, 2009
Messages
3
Reaction score
0
public void setMarried(int m) {
this.married = m;
}

i cant find this in maplecharacter.java anyhelp im new on this :)

---------- Post added at 01:56 AM ---------- Previous post was at 01:32 AM ----------

sorry for double posts and playercommand.java :D?
 
Back
Top