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!

[Add-On] Daily Reward Npc

Newbie Spellweaver
Joined
Aug 16, 2009
Messages
49
Reaction score
42
Well user can talk to the npc every 24hour for prize.

NPC Code
Code:
var status = 0;

function start() {
    cm.sendNext("I'm giving out free smeges to players everyday..");
}

function action(mode, type, selection) {
    if (mode == 0) {
        cm.sendOk("Fine, I'll give to other players if you don't want it..")
        cm.dispose();
    }else {
        if(mode > 0)
            status++;
        else if(mode < 0)
            cm.dispose();
        if (status == 1) {
            if (cm.getGiftLog('FreeGift') >= 1) {
                cm.sendOk("I'm sorry, You have already received your gift in this account today!! Please come back 24 hours later!!");
                cm.dispose();
            }else
                cm.sendYesNo("Grats, you haven't received your #r#e10#n#k free #v5072000# today, do you want to get your free gift now?");
        }else if (status == 2) {
            cm.gainItem(5072000, 10);
            cm.setBossLog('FreeGift');
            cm.sendOk("Congratulation!! You've reveived your #r#e10#n#k free #v5072000#!!");
            cm.dispose();
        } else
            cm.sendOk("Fine, I'll give to other players if you don't want it..")
    }
}

MapleCharacter.java
Code:
public int getBossLog(String bossid) {
        Connection con1 = DatabaseConnection.getConnection();
        try {
            int ret_count = 0;
            PreparedStatement ps;
            ps = con1.prepareStatement("select count(*) from bosslog where characterid = ? and bossid = ? and lastattempt >= subtime(current_timestamp, '1 0:0:0.0')");
            ps.setInt(1, id);
            ps.setString(2, bossid);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) 
                ret_count = rs.getInt(1);
            else
                ret_count = -1;
            rs.close();
            ps.close();
            return ret_count;
        } catch (Exception Ex) {
            return -1;
        }
    }

    public int getGiftLog(String bossid) {
        Connection con1 = DatabaseConnection.getConnection();
        try {
            int ret_count = 0;
            PreparedStatement ps;
            ps = con1.prepareStatement("select count(*) from bosslog where accountid = ? and bossid = ? and lastattempt >= subtime(current_timestamp, '1 0:0:0.0')");
            ps.setInt(1, accountid);
            ps.setString(2, bossid);
            ResultSet rs = ps.executeQuery();
            if (rs.next()) 
                ret_count = rs.getInt(1);
            else
                ret_count = -1;
            rs.close();
            ps.close();
            return ret_count;
        } catch (Exception Ex) {
            return -1;
        }
    }

    //setBossLog module
    public void setBossLog(String bossid) {
        Connection con1 = DatabaseConnection.getConnection();
        try {
            PreparedStatement ps;
            ps = con1.prepareStatement("insert into bosslog (accountid, characterid, bossid) values (?,?,?)");
            ps.setInt(1, accountid);
            ps.setInt(2, id);
            ps.setString(3, bossid);
            ps.executeUpdate();
            ps.close();
        } catch (Exception Ex) {
        }
    }

NPCConversationManager.java
Code:
public int getBossLog(String bossid) {
        return getPlayer().getBossLog(bossid);
    }

    public int getGiftLog(String bossid) {
        return getPlayer().getGiftLog(bossid);
    }

    @Override
    public void setBossLog(String bossid) {
        getPlayer().setBossLog(bossid);
    }

Mysql
Code:
CREATE TABLE `bosslog` (
`id` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
`accountid` INTEGER UNSIGNED NOT NULL,
`characterid` INTEGER UNSIGNED NOT NULL,
`bossid` VARCHAR(20) NOT NULL,
`lastattempt` TIMESTAMP NOT NULL,
PRIMARY KEY (`id`)
)
 
Last edited:
Legendary Battlemage
Loyal Member
Joined
Dec 13, 2010
Messages
649
Reaction score
140
I don't understand it. And I think i've seen something similar in several servers before. Anyway niceish job.
 
Custom Title Activated
Loyal Member
Joined
Mar 17, 2009
Messages
1,911
Reaction score
538
Looks great. Would be mad if it was a random prize each day.
 
Joined
Mar 1, 2010
Messages
394
Reaction score
41
He means, everyday you could get a completely random prize btw I've made something like when I was learning MapleJava but it completely sucked.
Did you make a set time limit on it?
 
Skilled Illusionist
Loyal Member
Joined
Dec 18, 2009
Messages
300
Reaction score
32
He means, everyday you could get a completely random prize btw I've made something like when I was learning MapleJava but it completely sucked.
Did you make a set time limit on it?

Eh.. If you read the code, it's not completely random prize. You can set it to whatever you want.
 
Junior Spellweaver
Joined
Apr 13, 2011
Messages
119
Reaction score
11
Yeah it would be better if it were random items. To make it random u could look at the gachapon script and follow that :D that. Also, u should check for ip as well. I see this as something that people can abuse. (Spam chars to gain items on a server I had before, peopel abused the starter pack because it gave 2 gachapon tickets.)
 
Experienced Elementalist
Joined
Apr 6, 2009
Messages
224
Reaction score
65
Good job on this Ryan, though I believe this is some of your older work, since I saw this a long time ago.
 
Skilled Illusionist
Joined
Dec 16, 2010
Messages
304
Reaction score
164
Excuse me if I'm wrong, but it looks like you didn't dispose after the last cm.sendOk in your npc script.
Anyways, looks nice. =) Maybe take a look at Osi's 'Kewl NPC Trader' and have it a different set of prizes each day.
 

idk

Initiate Mage
Joined
Apr 19, 2010
Messages
4
Reaction score
0
I remember it was in one of servers I played.
But not sure, until I see the NPC script text of "Our Website: #ewww.abidestory.no-ip.org#n\r\nBy clicking #rVote for Rewards#k Link!", I found out it was abidestory.
I downloaded abidestory v75 source, and check, its exactly same, in NPC 9300010.
leeched? another copy+paste w/o giving any credits. Or you were one of abidestory coders?
 
Legendary Battlemage
Loyal Member
Joined
Sep 28, 2008
Messages
600
Reaction score
291
This is from AbideStory repack..
 
Skilled Illusionist
Joined
Feb 18, 2010
Messages
320
Reaction score
112
I remember it was in one of servers I played.
But not sure, until I see the NPC script text of "Our Website: #ewww.abidestory.no-ip.org#n\r\nBy clicking #rVote for Rewards#k Link!", I found out it was abidestory.
I downloaded abidestory v75 source, and check, its exactly same, in NPC 9300010.
leeched? another copy+paste w/o giving any credits. Or you were one of abidestory coders?

This is from AbideStory repack..

No poop?
 
Newbie Spellweaver
Joined
Apr 1, 2011
Messages
88
Reaction score
0
Haha, Nice found there :) i thought that no-one would ever use AbideStory Repack o_O

---------- Post added at 06:22 PM ---------- Previous post was at 06:22 PM ----------

OMG 1 post from Averange Member :D:
 
Back
Top