This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..
Question
NumL0ck
i prefet to be pvp lord in 16:17 but nothing i wait 10 minutes BUT NOTHING... :((
this is code...
package com.l2jfrozen.gameserver.model.entity; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.util.Calendar; 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; /** + * + * @author Fanky + */ public class PvpLordTask { public static void getInstance() { ThreadPoolManager.getInstance().scheduleGeneral(new Runnable() { public void run() { String currentPvpLord = null, newPvpLord = null; int topTodayPvps = 0; Connection con = null; try { con = L2DatabaseFactory.getInstance().getConnection(); PreparedStatement stm = con.prepareStatement("SELECT char_name FROM characters WHERE pvplord=? AND accesslevel=?"); stm.setInt(1, 1); stm.setInt(2, 1); ResultSet rSet = stm.executeQuery(); if (rSet.next()) { currentPvpLord = rSet.getString("char_name"); } rSet.close(); stm.close(); if (currentPvpLord != null) { boolean cont = false; L2PcInstance cPvpLord = L2World.getInstance().getPlayer(currentPvpLord); if (cPvpLord == null || cPvpLord.isOnline() == 0) { cont = true; } else { cPvpLord.setPvpLord(false); cPvpLord.broadcastUserInfo(); } if (cont) { stm = con.prepareStatement("UPDATE characters SET pvplord=? WHERE char_name=?"); stm.setInt(1, 0); stm.setString(2, currentPvpLord); stm.execute(); stm.close(); } } stm = con.prepareStatement("SELECT todaypvps,char_name FROM characters WHERE accesslevel=? ORDER BY todaypvps DESC LIMIT 1"); stm.setInt(1, 0); rSet = stm.executeQuery(); if (rSet.next()) { newPvpLord = rSet.getString("char_name"); topTodayPvps = rSet.getInt("todaypvps"); } rSet.close(); stm.close(); boolean cont = false; L2PcInstance nPvpLord = L2World.getInstance().getPlayer(newPvpLord); if (nPvpLord == null || nPvpLord.isOnline() == 0) { cont = true; } else { nPvpLord.setPvpLord(true); nPvpLord.broadcastUserInfo(); } if (cont) { stm = con.prepareStatement("UPDATE characters SET pvplord=? WHERE char_name=?"); stm.setInt(1, 1); stm.setString(2, newPvpLord); stm.execute(); stm.close(); } stm = con.prepareStatement("UPDATE characters SET todaypvps=?,todaypks=?,todaydeaths=?"); stm.setInt(1, 0); stm.execute(); stm.close(); Announcements.getInstance().announceToAll("New PvP Lord: "+newPvpLord); Announcements.getInstance().announceToAll(newPvpLord+", Today PvPs: "+topTodayPvps); } catch (Exception e) { } finally { try { con.close(); } catch (Exception e) { } } } } , getValidationTime()); } private static long getValidationTime() { Calendar cld = Calendar.getInstance(); cld.set(Calendar.HOUR_OF_DAY, 16); cld.set(Calendar.MINUTE, 17); long time = cld.getTimeInMillis(); if (System.currentTimeMillis()-time <= 0) { return time; } return 0; } }11 answers to this question
Recommended Posts