[Add-On] Daily Reward Npc

Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    Hardcore Member finalskillz is offline
    MemberRank
    Aug 2009 Join Date
    133Posts

    big grin [Add-On] Daily Reward Npc


    RaGEZONE Recommends

    RaGEZONE Recommends

    Well user can talk to the npc every 24hour for prize.

    NPC Code
    Spoiler:

    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
    Spoiler:

    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
    Spoiler:

    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
    Spoiler:

    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 by finalskillz; 17-04-11 at 07:04 AM.


  2. #2
    Alpha Member Soulfist is offline
    Alpha MaleRank
    Dec 2010 Join Date
    a hovelLocation
    1,835Posts

    Re: [Add-On] Daily Reward Npc

    I don't understand it. And I think i've seen something similar in several servers before. Anyway niceish job.

  3. #3
    Gamma Sparrow is offline
    GammaRank
    Mar 2009 Join Date
    SydneyLocation
    2,968Posts

    Re: [Add-On] Daily Reward Npc

    Looks great. Would be mad if it was a random prize each day.

  4. #4
    Hardcore Member finalskillz is offline
    MemberRank
    Aug 2009 Join Date
    133Posts

    Re: [Add-On] Daily Reward Npc

    ^You can change the prize :)

  5. #5
    Account Inactive xnicnicx is offline
    InactiveRank
    Mar 2010 Join Date
    AustraliaLocation
    638Posts

    Re: [Add-On] Daily Reward Npc

    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?

  6. #6
    Account Inactive Hennessy`' is offline
    InactiveRank
    Dec 2009 Join Date
    in a CaveLocation
    2,298Posts

    Re: [Add-On] Daily Reward Npc

    Quote Originally Posted by xnicnicx View Post
    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.
    F U N <3

  7. #7
    Ultimate Member MsDerp is offline
    MemberRank
    Apr 2011 Join Date
    152Posts

    Re: [Add-On] Daily Reward Npc

    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.)

  8. #8
    Account Upgraded | Title Enabled! LuckySage is offline
    True MemberRank
    Apr 2009 Join Date
    The NetherlandsLocation
    520Posts

    Re: [Add-On] Daily Reward Npc

    Good job on this Ryan, though I believe this is some of your older work, since I saw this a long time ago.

  9. #9
    Account Upgraded | Title Enabled! Sharky is offline
    True MemberRank
    Dec 2010 Join Date
    Ur Mom's Pants.Location
    927Posts

    Re: [Add-On] Daily Reward Npc

    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.

  10. #10
    Account Inactive idk is offline
    InactiveRank
    Apr 2010 Join Date
    8Posts

    Re: [Add-On] Daily Reward Npc

    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?

  11. #11
    Account Inactive xnicnicx is offline
    InactiveRank
    Mar 2010 Join Date
    AustraliaLocation
    638Posts

    Re: [Add-On] Daily Reward Npc

    Quote Originally Posted by Hennessy`' View Post
    Eh.. If you read the code, it's not completely random prize. You can set it to whatever you want.
    Lols, I was answering an other guys + I already know that f3

    @MsDerp Pretty good Idea, but I cbfed doing that.

  12. #12
    I'm overrated. Fraysa is offline
    GammaRank
    Apr 2008 Join Date
    4,817Posts

    Re: [Add-On] Daily Reward Npc

    Oh nice, samiliar to my Pandora Box.

    Yeah, I'm back.

  13. #13
    Account Upgraded | Title Enabled! AuroX is offline
    True MemberRank
    Sep 2008 Join Date
    1,435Posts

    Re: [Add-On] Daily Reward Npc

    This is from AbideStory repack..

  14. #14
    Account Inactive Spiderman is offline
    InactiveRank
    Feb 2010 Join Date
    my comfy chairLocation
    420Posts

    Re: [Add-On] Daily Reward Npc

    Quote Originally Posted by idk View Post
    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?
    Quote Originally Posted by AuroX View Post
    This is from AbideStory repack..
    No shit?

  15. #15
    Account Inactive Xuraz is offline
    InactiveRank
    Apr 2011 Join Date
    SwedenLocation
    177Posts

    Re: [Add-On] Daily Reward Npc

    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




Page 1 of 2 12 LastLast

Advertisement