Jump to content
  • 0

[help] Pvp lord engine ValidationTime


Question

Posted

i found http://maxcheaters.com/forum/index.php?topic=238056.0 and added to my pack and period change not working.

code:

/* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/
package com.l2jfrozen.gameserver.model.entity;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.Calendar;
import java.util.logging.Logger;

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;
import com.l2jfrozen.gameserver.network.serverpackets.SocialAction;

/**
*
* @author  Fanky
*/
public class PvpLordTask
{
static String INSERT_DATA = "REPLACE INTO characters_custom_data (obj_Id, char_name, hero, noble, donator, hero_end_date) VALUES (?,?,?,?,?,?)";

protected static final Logger _log = Logger.getLogger(PvpLordTask.class.getName());

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, 0);
				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.setIsHero(false);
						cPvpLord.getAppearance().setNameColor(0xFFFFFF);
						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.broadcastPacket(new SocialAction(nPvpLord.getObjectId(), 16));
					nPvpLord.setIsHero(true);
					nPvpLord.getAppearance().setNameColor(0xFF6633);
					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=?");
				stm.setInt(1, 0);

				stm.execute();
				stm.close();

				Announcements.getInstance().announceToAll("New pvp lord: " + 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, 14);
	cld.set(Calendar.MINUTE, 40);

	long time = cld.getTimeInMillis();
	if (System.currentTimeMillis()-time <= 0)
	{
		return time - System.currentTimeMillis();
	}

	return 0;
}
}

 

and i thing something wrong with that place:

 	private static long getValidationTime()
{
	Calendar cld = Calendar.getInstance();
	cld.set(Calendar.HOUR_OF_DAY, 14);
	cld.set(Calendar.MINUTE, 40);

	long time = cld.getTimeInMillis();
	if (System.currentTimeMillis()-time <= 0)
	{
		return time - System.currentTimeMillis();
	}

	return 0;
}

help me :)

3 answers to this question

Recommended Posts

  • 0
Posted

Please give us some info, wich pack are you using, etc..

 

He uses the Forbidden One !

import com.l2jfrozen.util.database.L2DatabaseFactory;

 


 

Ask to Fanky directly, or post directly in the custom topic, as he is the dev of that custom. If we fix here, someone else will ask again. If Fanky fixes it, then custom will work for everyone. Added to that, it's perhaps a "normal" behaviour. I'm lazy to verify.

  • 0
Posted

He uses the Forbidden One !

import com.l2jfrozen.util.database.L2DatabaseFactory;

 


 

Ask to Fanky directly, or post directly in the custom topic, as he is the dev of that custom. If we fix here, someone else will ask again. If Fanky fixes it, then custom will work for everyone. Added to that, it's perhaps a "normal" behaviour. I'm lazy to verify.

 

he ignoring me, 1 week ago i posted this bug in orginal topic and no reply... please help me here :/

 

Please give us some info, wich pack are you using, etc..

I using L2jFrozen

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

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