[Release] Better jail - works even after someone relogs

Results 1 to 22 of 22
  1. #1
    Account Upgraded | Title Enabled! WlZET is offline
    MemberRank
    Apr 2009 Join Date
    479Posts

    [Release] Better jail - works even after someone relogs

    In MapleCharacter:

    Add this variable:

    PHP Code:
    private int jailtime
    Add this in loadCharFromDb:

    PHP Code:
    ret.jailtime rs.getInt("jailtime"); 
    Add this with all the other things in saveToDb (I don't feel like showing you how to add...)

    PHP Code:
    jailtime 
    Add these methods in MapleCharacter:

    PHP Code:
        public void setJailTime(int x) {
            
    this.jailtime x;
        }

        public 
    int getJailTime() {
            return 
    this.jailtime;
        }

        public 
    boolean inJail() {
            return 
    getMapId() == 200090300;
        }

        public 
    void jail(int minutes) {
            
    changeMap(2000903000);
            
    this.canTalk false;
            
    jailTimeReset();
            
    setJailTime(minutes);
        }

        public 
    void unJail() {
            if (
    getMapId() == 200090300) {
                
    changeMap(1000000000);
                
    this.canTalk true;
                
    dropMessage("You have been unjailed");
            }
        }

        public 
    void jailTimeReset() {
            
    TimerManager.getInstance().schedule(new Runnable() {

                public 
    void run() {
                    if (
    inJail() && getJailTime() > 0) { // If not in Jail Map / do not have any jail time does nothing
                        
    setJailTime(getJailTime() - 1);
                        
    dropMessage(5"One minute has passed. You now have " getJailTime() + " minutes left to go.");
                        
    jailTimeReset();
                        if (
    getJailTime() <= 0) {
                            
    unJail();
                        }
                    }
                }
            }, 
    60 1000);
        } 
    Add this in PlayerLoggedInHandler:

    PHP Code:
            if (player.inJail() && player.getJailTime() > 0) {
                
    player.message("You have scheduled jailtime for " player.getJailTime() + " minutes. You will have to make up for jail-time you have missed if you have log off.");
                
    player.jailTimeReset();
            } 
    Add these commands to temp jail / perm jail:

    PHP Code:
            } else if (splitted[0].equals("!permjail")) {
                
    MapleCharacter victim cserv.getPlayerStorage().getCharacterByName(splitted[1]);
                if (
    victim != null) {
                    
    victim.jail(-1);
                    
    victim.message("You have been permenently jailed, but your account is not banned. This character will not be available any longer.");
                } else {
                    
    player.message("The player is not in this channel or offline.");
                }

            } else if (
    splitted[0].equals("!tempjail")) {
                
    MapleCharacter victim cserv.getPlayerStorage().getCharacterByName(splitted[1]);
                if (
    victim != null) {
                    if (!
    splitted[3].equalsIgnoreCase("quiet")) {
                        try {
                            
    cserv.getWorldInterface().broadcastMessage(player.getName(), MaplePacketCreator.serverNotice(6ServerConstants.SERVER_NAME " Jail: " victim.getName() + " has been jailed for " splitted[2] + " minutes. Reason: " StringUtil.joinStringFrom(splitted4)).getBytes());
                        } catch (
    RemoteException e) {
                            
    c.getChannelServer().reconnectWorld();
                        }
                    }
                    
    victim.jail(Integer.parseInt(splitted[2]));
                    
    mc.dropMessage(victim.getName() + " was  temporary jailed! for " splitted[2] + " minutes.");
                    
    victim.dropMessage(5"You have been temporary jailed for " splitted[2] + " minutes. You will have to make up for minutes you have missed if you log off.");
                } else {
                    
    mc.dropMessage(splitted[1] + " not found!");
                } 
    Last edited by WlZET; 22-03-10 at 01:23 AM.


  2. #2
    Account Upgraded | Title Enabled! Soul is offline
    MemberRank
    Aug 2009 Join Date
    645Posts

    Re: [Release] Better jail

    Good job rich :)

  3. #3
    Account Upgraded | Title Enabled! redeemer34 is offline
    MemberRank
    Aug 2008 Join Date
    335Posts

    Re: [Release] Better jail - works even after someone relogs

    Its kinda mean that they have to be in-game to take up time, but it's pretty cool otherwise.

  4. #4
    Infraction Banned rice is offline
    MemberRank
    Nov 2009 Join Date
    2,905Posts

    Re: [Release] Better jail - works even after someone relogs

    good job, but if you wanted to do what your title says, just make a Boolean and throw an if then statement into playerloggedinhwndler.
    if (player.shouldBeJailed() == true) {
    player.warpToJailMap();
    }
    Posted via Mobile Device

  5. #5
    Valued Member GoldenKevin is offline
    MemberRank
    Oct 2008 Join Date
    117Posts

    Re: [Release] Better jail - works even after someone relogs

    Quote Originally Posted by theRice View Post
    good job, but if you wanted to do what your title says, just make a Boolean and throw an if then statement into playerloggedinhwndler.
    if (player.shouldBeJailed() == true) {
    player.warpToJailMap();
    }
    Posted via Mobile Device
    I lol when people use logic like yours. "== true"? Makes the code redundant and slower, because it has to check if the boolean expression is equal to true. "true == true" will return "true" anyway, so why do something like that?

  6. #6
    Valued Member GoldenKevin is offline
    MemberRank
    Oct 2008 Join Date
    117Posts

    Re: [Release] Better jail - works even after someone relogs

    Quote Originally Posted by theRice View Post
    good job, but if you wanted to do what your title says, just make a Boolean and throw an if then statement into playerloggedinhwndler.
    if (player.shouldBeJailed() == true) {
    player.warpToJailMap();
    }
    Posted via Mobile Device
    I lol when people use logic like yours. "== true"? Makes the code redundant and slower, because it has to check if the boolean expression is equal to true. "true == true" will return "true" anyway, so why do something like that?

  7. #7
    Account Upgraded | Title Enabled! WlZET is offline
    MemberRank
    Apr 2009 Join Date
    479Posts

    Re: [Release] Better jail - works even after someone relogs

    Quote Originally Posted by GoldenKevin View Post
    I lol when people use logic like yours. "== true"? Makes the code redundant and slower, because it has to check if the boolean expression is equal to true. "true == true" will return "true" anyway, so why do something like that?
    lol double post

  8. #8
    DIGLETT MASTER - UG LDR blawgwarmzz is offline
    MemberRank
    Sep 2009 Join Date
    undagrounmdLocation
    297Posts

    Re: [Release] Better jail - works even after someone relogs

    Quote Originally Posted by theRice View Post
    good job, but if you wanted to do what your title says, just make a Boolean and throw an if then statement into playerloggedinhwndler.
    if (player.shouldBeJailed() == true) {
    player.warpToJailMap();
    }
    Posted via Mobile Device
    goldenkevin tells the truth but theres more to it

    that wouldn't work because they'd only be warped to the jailmap and jailtime wouldnt reset, making them trapped there (problems with old jail were the same). The way rich did is the way that works. and therefore your statement makes no sense, if he wanted to do what the title says he'd do anything but that
    Last edited by blawgwarmzz; 21-03-10 at 05:50 AM.

  9. #9
    Account Upgraded | Title Enabled! Emilyx3 is offline
    MemberRank
    Apr 2009 Join Date
    393Posts

    Re: [Release] Better jail - works even after someone relogs

    I see a mem leak:
    Code:
    public void jailTimeReset() {
            TimerManager.getInstance().schedule(new Runnable() {
    
                public void run() {
                    if (inJail() && getJailTime() > 0) { // If not in Jail Map / do not have any jail time does nothing
                        setJailTime(getJailTime() - 1);
                        dropMessage(5, "One minute has passed. You now have " + getJailTime() + " minutes left to go.");
                        jailTimeReset();
                        if (getJailTime() <= 0) {
                            unJail();
                        }
                    }
                }
            }, 1 * 60 * 1000);
        }
    Use this enough times or if jailed people relog enough times and you'll have tons of scheduled
    "if (inJail() && getJailTime() > 0)" checks, that wind up doing nothing anyway.

    Also, for !permjail, you forgot to include jailTheNoob() in MapleCharacter.java.

  10. #10
    Account Upgraded | Title Enabled! PinkGatsby is offline
    MemberRank
    Mar 2009 Join Date
    AmericaLocation
    434Posts

    Re: [Release] Better jail - works even after someone relogs

    Quote Originally Posted by GoldenKevin View Post
    I lol when people use logic like yours. "== true"? Makes the code redundant and slower, because it has to check if the boolean expression is equal to true. "true == true" will return "true" anyway, so why do something like that?
    You're too focused on performance, the difference would probably be less than a thousandth of a microsecond. If it makes it easier for the developer then he/she should continue using '== true/false'.

  11. #11
    Gamma Sparrow is offline
    MemberRank
    Mar 2009 Join Date
    SydneyLocation
    2,960Posts

    Re: [Release] Better jail - works even after someone relogs

    Quote Originally Posted by WlZET View Post
    In MapleCharacter:

    Add this variable:

    PHP Code:
    private int jailtime
    Add this in loadCharFromDb:

    PHP Code:
    ret.jailtime rs.getInt("jailtime"); 
    Add this with all the other things in saveToDb (I don't feel like showing you how to add...)

    PHP Code:
    jailtime 
    Add these methods in MapleCharacter:

    PHP Code:
        public void setJailTime(int x) {
            
    this.jailtime x;
        }

        public 
    int getJailTime() {
            return 
    this.jailtime;
        }

        public 
    boolean inJail() {
            return 
    getMapId() == 200090300;
        }

        public 
    void jail(int minutes) {
            
    changeMap(2000903000);
            
    this.canTalk false;
            
    jailTimeReset();
            
    setJailTime(minutes);
        }

        public 
    void unJail() {
            if (
    getMapId() == 200090300) {
                
    changeMap(1000000000);
                
    this.canTalk true;
                
    dropMessage("You have been unjailed");
            }
        }

        public 
    void jailTimeReset() {
            
    TimerManager.getInstance().schedule(new Runnable() {

                public 
    void run() {
                    if (
    inJail() && getJailTime() > 0) { // If not in Jail Map / do not have any jail time does nothing
                        
    setJailTime(getJailTime() - 1);
                        
    dropMessage(5"One minute has passed. You now have " getJailTime() + " minutes left to go.");
                        
    jailTimeReset();
                        if (
    getJailTime() <= 0) {
                            
    unJail();
                        }
                    }
                }
            }, 
    60 1000);
        } 
    Add this in PlayerLoggedInHandler:

    PHP Code:
            if (player.inJail() && player.getJailTime() > 0) {
                
    player.message("You have scheduled jailtime for " player.getJailTime() + " minutes. You will have to make up for jail-time you have missed if you have log off.");
                
    player.jailTimeReset();
            } 
    Add these commands to temp jail / perm jail:

    PHP Code:
            } else if (splitted[0].equals("!permjail")) {
                
    MapleCharacter victim cserv.getPlayerStorage().getCharacterByName(splitted[1]);
                if (
    victim != null) {
                    
    victim.jailTheNoob(-1);
                    
    victim.message("You have been permenently jailed, but your account is not banned. This character will not be available any longer.");
                } else {
                    
    player.message("The player is not in this channel or offline.");
                }

            } else if (
    splitted[0].equals("!tempjail")) {
                
    MapleCharacter victim cserv.getPlayerStorage().getCharacterByName(splitted[1]);
                if (
    victim != null) {
                    if (!
    splitted[3].equalsIgnoreCase("quiet")) {
                        try {
                            
    cserv.getWorldInterface().broadcastMessage(player.getName(), MaplePacketCreator.serverNotice(6ServerConstants.SERVER_NAME " Jail: " victim.getName() + " has been jailed for " splitted[2] + " minutes. Reason: " StringUtil.joinStringFrom(splitted4)).getBytes());
                        } catch (
    RemoteException e) {
                            
    c.getChannelServer().reconnectWorld();
                        }
                    }
                    
    victim.jail(Integer.parseInt(splitted[2]));
                    
    mc.dropMessage(victim.getName() + " was  temporary jailed! for " splitted[2] + " minutes.");
                    
    victim.dropMessage(5"You have been temporary jailed for " splitted[2] + " minutes. You will have to make up for minutes you have missed if you log off.");
                } else {
                    
    mc.dropMessage(splitted[1] + " not found!");
                } 
    Nice Job :) Btw, the Trade and Cash button are disabled right?

  12. #12
    Account Upgraded | Title Enabled! WlZET is offline
    MemberRank
    Apr 2009 Join Date
    479Posts

    Re: [Release] Better jail - works even after someone relogs

    Quote Originally Posted by SirDanielot View Post
    Nice Job :) Btw, the Trade and Cash button are disabled right?
    The map I used already has them disabled.

  13. #13
    Infraction Banned rice is offline
    MemberRank
    Nov 2009 Join Date
    2,905Posts

    Re: [Release] Better jail - works even after someone relogs

    Quote Originally Posted by SirDanielot View Post
    Nice Job :) Btw, the Trade and Cash button are disabled right?
    I hate it when you people quote the whole damn release.
    Last edited by rice; 21-03-10 at 10:27 AM.

  14. #14
    Banned waijoobenmi is offline
    BannedRank
    Mar 2010 Join Date
    29Posts

    Re: [Release] Better jail - works even after someone relogs

    Quote Originally Posted by theRice View Post
    I hate it when you people quote the whole damn release.
    Who cares what you hate, idiot.

  15. #15
    Account Upgraded | Title Enabled! mariokiller64 is offline
    MemberRank
    Oct 2006 Join Date
    392Posts

    Re: [Release] Better jail - works even after someone relogs

    Yeah, where is the Jailthenoob function...

  16. #16
    Account Upgraded | Title Enabled! WlZET is offline
    MemberRank
    Apr 2009 Join Date
    479Posts

    Re: [Release] Better jail - works even after someone relogs

    Quote Originally Posted by mariokiller64 View Post
    Yeah, where is the Jailthenoob function...
    Use the "jail" function.

  17. #17
    while(true) spam(); kevintjuh93 is offline
    MemberRank
    Jun 2008 Join Date
    The NetherlandsLocation
    4,119Posts

    Re: [Release] Better jail - works even after someone relogs

    Quote Originally Posted by PinkGatsby View Post
    You're too focused on performance, the difference would probably be less than a thousandth of a microsecond. If it makes it easier for the developer then he/she should continue using '== true/false'.
    It still counts and anyways what is so hard about:
    if (shouldBeJailed) {
    }
    or
    if (!shouldBeJailed) {
    }

  18. #18
    Account Upgraded | Title Enabled! PinkGatsby is offline
    MemberRank
    Mar 2009 Join Date
    AmericaLocation
    434Posts

    Re: [Release] Better jail - works even after someone relogs

    Quote Originally Posted by kevintjuh93 View Post
    It still counts and anyways what is so hard about:
    if (shouldBeJailed) {
    }
    or
    if (!shouldBeJailed) {
    }
    Did you not understand the last point I made ?

  19. #19
    bleh.... Shawn is offline
    MemberRank
    Oct 2008 Join Date
    Mississauga, CaLocation
    5,904Posts

    Re: [Release] Better jail - works even after someone relogs

    Quote Originally Posted by waijoobenmi View Post
    Who cares what you hate, idiot.
    I do o.0

  20. #20
    Valued Member tonynguyenpro is offline
    MemberRank
    Aug 2009 Join Date
    137Posts

    Re: [Release] Better jail - works even after someone relogs

    nice job

  21. #21
    Account Upgraded | Title Enabled! WlZET is offline
    MemberRank
    Apr 2009 Join Date
    479Posts

    Re: [Release] Better jail - works even after someone relogs

    Quote Originally Posted by kevintjuh93 View Post
    It still counts and anyways what is so hard about:
    if (shouldBeJailed) {
    }
    or
    if (!shouldBeJailed) {
    }
    They won't get out anyway so it doesn't matter..

  22. #22
    Account Upgraded | Title Enabled! .:LastBreath:. is offline
    MemberRank
    Oct 2009 Join Date
    Under your bedLocation
    1,315Posts

    Re: [Release] Better jail - works even after someone relogs

    Nice release



Advertisement