PvP Event

Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    TranquilityStory JarrYD is offline
    MemberRank
    Jan 2010 Join Date
    764Posts

    PvP Event

    Nevermind used sql querys instead of hashmap..
    Thanks for those who helped

    Another question,
    How would I be able to use say c.getPlayer.gaineventpoints(1); with this sql query, because you cant add eventpoints through an sql query because it just gets rolled back to the users current value when @save.
    So pretty much this query gives me the winner but i need to work out how to use gaineventpoints or something similar to give the winner event points

    PHP Code:
    public void firstpvpwinner() { 
                    try { 
                        
                        
    String name ""
                
    Connection con DatabaseConnection.getConnection(); 
                
    PreparedStatement ps con.prepareStatement("SELECT eventpvpkills, name FROM characters ORDER BY eventpvpkills desc LIMIT 1"); 
                
    ResultSet rs ps.executeQuery(); 
                while(
    rs.next()) 
                { 
                               
                                   
    name rs.getString("name"); 
                                    
    int pvpkills rs.getInt("eventpvpkills"); 
                                   
    // WorldServer.Broadcast.broadcastMessage(null, MaplePacketCreator.serverNotice(6, "[Event] Player "+name+" - Kills " + pvpkills + ".").getBytes());
                                    
    WorldServer.Broadcast.broadcastMessage(nullMaplePacketCreator.serverNotice(6"[Event] Congratulations to "+name+" for winning the Auto PVP Event with " pvpkills " Kills.").getBytes());

                               
    //tried updating ep in this line but yeah..
                                  //PreparedStatement ps1 = con.prepareStatement("UPDATE characters SET eventpoints=3 ORDER BY eventpvpkills DESC LIMIT 1"); 
                                   //             ps1.executeUpdate(); 
                                   //             ps1.close(); 
               
                            

                         }catch (
    Exception ex) {
                    }
        } 
    Is it possible to use this somewhere in that firstpvpwinner but without the findchannel stuff, an easier method? I cant remember, because this isnt working for me atm
    PHP Code:
    int winnerID rs.getInt("id");
                        
    int ch ChannelServer.findChannel(winnerID);
                         
    MapleCharacter winner ChannelServer.getInstance(ch).getPlayerStorage().getCharacterById(winnerID);
                         
    winner.gaineventpoints(1); 


    And I want eventpvpkills to be set to 0 after relog. Is there a better way to do this instead of this line in playerloggedinhandler? Thanks

    PHP Code:
     if(player.getEventPvpKills() >= 0){
                
    player.setEventPvpKills(0);
                } 
    Last edited by JarrYD; 07-05-15 at 06:55 PM.


  2. #2
    Omega sunnyboy is offline
    MemberRank
    Mar 2010 Join Date
    6,109Posts

    Re: PvP Event

    Replied to your PM regarding this ~

  3. #3
    TranquilityStory JarrYD is offline
    MemberRank
    Jan 2010 Join Date
    764Posts

    Re: PvP Event

    Quote Originally Posted by sunnyboy View Post
    Replied to your PM regarding this ~
    thanks man

  4. #4
    TranquilityStory JarrYD is offline
    MemberRank
    Jan 2010 Join Date
    764Posts

    Re: PvP Event

    bump
    edited, need help

  5. #5
    TranquilityStory JarrYD is offline
    MemberRank
    Jan 2010 Join Date
    764Posts

    Re: PvP Event

    common guys someones gotta know a little something on hashmaps and shiz, im completely lost ahah

  6. #6
    Moderator Eric is offline
    ModeratorRank
    Jan 2010 Join Date
    DEV CityLocation
    3,188Posts

    Re: PvP Event

    Quote Originally Posted by JarrYD View Post
    common guys someones gotta know a little something on hashmaps and shiz, im completely lost ahah
    not quite understanding your problem. I'm assuming you want to call PVPEvent.addPVPEventKill from MaplePvp? If so, based off of your current code it seems you statically access a character with the parameter "int characterid". If so, change public void to public static void and then make your two ConcurrentHashMaps static to be accessed within the static void. Then in MaplePvp, just call PVPEvent.addPVPEventKill(chr.getId())

  7. #7
    TranquilityStory JarrYD is offline
    MemberRank
    Jan 2010 Join Date
    764Posts

    Re: PvP Event

    Quote Originally Posted by chunkarama View Post
    not quite understanding your problem. I'm assuming you want to call PVPEvent.addPVPEventKill from MaplePvp? If so, based off of your current code it seems you statically access a character with the parameter "int characterid". If so, change public void to public static void and then make your two ConcurrentHashMaps static to be accessed within the static void. Then in MaplePvp, just call PVPEvent.addPVPEventKill(chr.getId())
    Omg thanks man smart thinking, i think it just might work, except im now having trouble because im adding it into monsterbomb but MapleClient c isnt defined in that top bit and if I add it there it messes up the rest of the code
    Code:
     public static void monsterBomb(MapleCharacter player, MapleCharacter attackedPlayers, MapleMap map, AbstractDealDamageHandler.AttackInfo attack, int pvpType) {
    Edit:
    Actually ill add a playerisdead check in maplecharacter and add it in there and see if it works.
    Last edited by JarrYD; 02-05-15 at 05:49 AM.

  8. #8
    Moderator Eric is offline
    ModeratorRank
    Jan 2010 Join Date
    DEV CityLocation
    3,188Posts

    Re: PvP Event

    Quote Originally Posted by JarrYD View Post
    Omg thanks man smart thinking, i think it just might work, except im now having trouble because im adding it into monsterbomb but MapleClient c isnt defined in that top bit and if I add it there it messes up the rest of the code
    Code:
     public static void monsterBomb(MapleCharacter player, MapleCharacter attackedPlayers, MapleMap map, AbstractDealDamageHandler.AttackInfo attack, int pvpType) {
    Edit:
    Actually ill add a playerisdead check in maplecharacter and add it in there and see if it works.
    You don't need MapleClient c. You have player.getClient() and attackedPlayers.getClient() if you need the client directly, otherwise use attackPlayers/player. In your case it would be player.getId()

    Oh, and playerIsDead is equivalent to !player.isAlive().

  9. #9
    TranquilityStory JarrYD is offline
    MemberRank
    Jan 2010 Join Date
    764Posts

    Re: PvP Event

    Quote Originally Posted by chunkarama View Post
    not quite understanding your problem. I'm assuming you want to call PVPEvent.addPVPEventKill from MaplePvp? If so, based off of your current code it seems you statically access a character with the parameter "int characterid". If so, change public void to public static void and then make your two ConcurrentHashMaps static to be accessed within the static void. Then in MaplePvp, just call PVPEvent.addPVPEventKill(chr.getId())
    Ok so in those lines in the thread i changed these to
    Code:
      static ConcurrentHashMap<Integer, Integer> killLog;
           static ConcurrentHashMap<Integer, HashMap<Integer, Integer>> eventKillLog = new ConcurrentHashMap<Integer, HashMap<Integer, Integer>>();
    and

    Code:
    public static void addPVPEventKill(int characterid) {
                if (eventInProgress) {
                    if (killLog.containsKey(characterid)) {
                        killLog.put(characterid, killLog.get(characterid) + 1);
                    } else {
                        killLog.put(characterid, 1);
                    }
                }
            }
    and then called it like you said in maplecharacter under playerdead and if pvp is enabled

    I'll test it now and see if it works

    - - - Updated - - -

    Quote Originally Posted by chunkarama View Post
    You don't need MapleClient c. You have player.getClient() and attackedPlayers.getClient() if you need the client directly, otherwise use attackPlayers/player. In your case it would be player.getId()

    Oh, and playerIsDead is equivalent to !player.isAlive().
    oh alright thanks ill give that a check

    - - - Updated - - -

    Thanks worked!
    Now gotta work out how to compare the top 3 results :S and give winner, sent you a pm regarding it if you are able to be able to help:)

  10. #10
    TranquilityStory JarrYD is offline
    MemberRank
    Jan 2010 Join Date
    764Posts

    Re: PvP Event

    Bump, edited the thread if anyone can help me with this last part please, thanks <3

  11. #11
    TranquilityStory JarrYD is offline
    MemberRank
    Jan 2010 Join Date
    764Posts

    Re: PvP Event

    Really need help on this if someone can help me it will be really appreciated :/

  12. #12
    TranquilityStory JarrYD is offline
    MemberRank
    Jan 2010 Join Date
    764Posts

    Re: PvP Event

    Still stuck on this, trying to work it out but cant work out how to use the comparator method halp plz

  13. #13
    TranquilityStory JarrYD is offline
    MemberRank
    Jan 2010 Join Date
    764Posts

    Re: PvP Event

    Nevermind used sql querys instead of hashmap, thanks to those who helped.
    Last edited by JarrYD; 07-05-15 at 08:05 AM.

  14. #14
    TranquilityStory JarrYD is offline
    MemberRank
    Jan 2010 Join Date
    764Posts

    Re: PvP Event

    bump, updated thread.

  15. #15
    TranquilityStory JarrYD is offline
    MemberRank
    Jan 2010 Join Date
    764Posts

    Re: PvP Event

    Is it possible to use this somewhere in that firstpvpwinner but without the findchannel stuff, an easier method? I cant remember, because this isnt working for me atm
    PHP Code:
    int winnerID rs.getInt("id");
                        
    int ch ChannelServer.findChannel(winnerID);
                         
    MapleCharacter winner ChannelServer.getInstance(ch).getPlayerStorage().getCharacterById(winnerID);
                         
    winner.gaineventpoints(1); 



Page 1 of 2 12 LastLast

Advertisement