Jump to content
  • 0

(HELP) All good people come here, please...


Question

Posted

Hello all! It's a mission help to me:D

How can i make only todaypvps,todaypks,todaydeaths clear to 0? because this code is not working correctly. It's only make in navicat everywhere 0 but! after server restart points are back:(

package com.l2jfrozen.gameserver.model.entity;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Calendar;
import java.sql.SQLException;

import com.l2jfrozen.util.database.L2DatabaseFactory;
import com.l2jfrozen.gameserver.model.entity.Announcements;
import com.l2jfrozen.gameserver.thread.ThreadPoolManager;
import com.l2jfrozen.gameserver.model.L2World;
import com.l2jfrozen.gameserver.model.actor.instance.L2PcInstance;

public class PvpLordTask
{
   
   public static void newPvpLord(){
      
      int masterId = 0;
      int topTodayPvps = 0;
      Connection con = null;
      PreparedStatement state = null;
      ResultSet rset = null;
      
      try{
         con = L2DatabaseFactory.getInstance().getConnection();
         state = con.prepareStatement("SELECT obj_Id,todaypvps FROM characters ORDER BY todaypvps DESC LIMIT 1;");
         rset = state.executeQuery();
         if(rset.next())
         masterId = rset.getInt(1);
         
         if(masterId == 0)
            return;
         topTodayPvps = rset.getInt("todaypvps");
         
         state.close();
         rset.close();
         
         for(L2PcInstance p : L2World.getInstance().getAllPlayers()){
            if(p.getObjectId() == masterId)
            {
               p.sendMessage("You are the PvP Lord!");
               p.setPvpLord(true);
               p.broadcastUserInfo();
               
         state = con.prepareStatement("UPDATE characters SET pvplord=1 WHERE obj_Id=?");
         state.setInt(1, masterId);
         state.execute();
         state.close();
         
         state = con.prepareStatement("UPDATE characters SET todaypvps=0,todaypks=0,todaydeaths=0 WHERE obj_Id=?");
         state.setInt(1, masterId);
         state.execute();
         state.close();   
         
            }
            Announcements.getInstance().announceToAll("PvP Lord is : "+p.getName());
            Announcements.getInstance().announceToAll("Today PvPs: "+topTodayPvps);
         }
         }
               catch(Exception e){
                     e.printStackTrace();
                  }
                  finally{
                     try
                     {
                        con.close();
                     }
                     catch (SQLException e)
                     {
                        e.printStackTrace();
                     }
            }
            }
            }

Recommended Posts

  • 0
Posted

The point is that for offline players. The int "player.todaypvps) or whatever... from l2pcinstance won't be 0 doing that, not? And then when you do a server rr those values will be saved in db :s

  • 0
Posted

no, we are changing first online characters with the loop, so in game their points will be 0 and when they log out, their points in database will also update to 0.

Only offline characters are left, so we are making sql statement to correct this, my code should work :)

  • 0
Posted

omg man its working big thanks to ^Wyatt and to you vampir you help me every time:D

to not create new topic one question its simple:D

i have max_poly and i need my npc to dance in max_poly is abnormalEffect i now is danceStun but which id or something like that i need put in abnormalEffect?

because if i put danceStun i have error:D column row = 1 etc.

  • 0
Posted

and one problem:) if player with more todaypvps not online no one is pvp lord...

and then player which is pvp lord is online and have 1 todaypvps but is player who have 100 but this player is offline set pvp lord player who is pvp lord...

my english is bad, please say to me you understand me:D

  • 0
Posted

and one problem:) if player with more todaypvps not online no one is pvp lord...

and then player which is pvp lord is online and have 1 todaypvps but is player who have 100 but this player is offline set pvp lord player who is pvp lord...

my english is bad, please say to me you understand me:D

try to solve it by yourself(take a hour or 2) and then tell us result :)

  • 0
Posted

omg i do it my self:D all working, i set player.setPvpLord(false); in 23:59

and after that in 00:00 i maked

        L2PcInstance nPvpLord = L2World.getInstance().getPlayer(newPvpLord);

        if (nPvpLord == null || nPvpLord.isOnline() == 0)

etc...

big thanks to you and all who help me:D

can lock this!

Guest
This topic is now closed to further replies.


×
×
  • Create New...