Форум администраторов игровых серверов

Форум администраторов игровых серверов (https://forum.zone-game.info/TT.php)
-   Lineage II (https://forum.zone-game.info/forumdisplay.php?f=34)
-   -   Авто выдача бонуса. (https://forum.zone-game.info/showthread.php?t=12691)

Deron 20.02.2011 20:54

Авто выдача бонуса.
 
У меня возникла проблема с авто-выдачей бонуса L2Top.
Сборка: Madden Project на основе Фениксов.
Суть проблемы: Ошибка в ГС что не правильный ключ.
Сама ошибка:
Цитата:

20:53:36.333 VoteManager: Error url parse.
20:53:36.434 VoteManager: Error url parse.
Конфиг:
Цитата:

# Включена ли система Автоматической выдачи бонусов
L2VoteManagerEnable = True

# Период в минутах, между каждой проверкой L2Top'а (рекомендуется значение от 5 минут)
L2VoteManagerTime = 5

# ID сервера и Key для получения данных со страницы с голосами. Key вы можете поссмотреть в панеле управления сервером на L2Top.
L2TopID = 187*8
L2TopKey = cf3b539457dfb6ff824ed157729****

# ID предмета и Кол-во, выдаваемое за каждый голос.
L2VoteManagerRewardID = 4357
L2VoteManagerRewardCount = 5

Deron 21.02.2011 22:06

Re: Авто выдача бонуса.
 
Up.... =((((

APKO 21.02.2011 22:30

Re: Авто выдача бонуса.
 
возможно етот менедреж под старые сылки л2топа...

Deron 21.02.2011 22:35

Re: Авто выдача бонуса.
 
мейби а сайт не кто не знает этой тимы что бы исходы норм скачать? а то заходил на их сайт который указан при запуске сервер он в оффлайне :((

Deron 22.02.2011 22:48

Re: Авто выдача бонуса.
 
Скрипт проверил сылка указана нормально.

Ro_0TT 22.02.2011 22:52

Re: Авто выдача бонуса.
 
Скиньте в ПМ ссылку на свою статистику.

Добавлено через 51 минуту
Сверь..
 
package services;
 
import l2p.Config;
 
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.SQL.ResultSet;
import java.SQL.SQLException;
import java.SQL.TIMESTAMP;
import java.util.logging.Logger;
import java.util.concurrent.ScheduledFuture;
import java.net.URL;
 
import l2p.common.ThreadPoolManager;
import l2p.DATABASE.FiltredPreparedStatement;
import l2p.DATABASE.L2DatabaseFactory;
import l2p.DATABASE.ThreadConnection;
import l2p.extensions.scripts.Functions;
import l2p.extensions.scripts.ScriptFile;
import l2p.gameserver.model.L2ObjectsStorage;
import l2p.gameserver.model.L2Player;
import l2p.util.Rnd;
 
 
 
public class VoteManager extends Functions implements ScriptFile
{
	/* 
	 *	(c) Ro0TT
	 */
	private static Logger log = Logger.getLogger(VoteManager.class.getName());
	private static ScheduledFuture<?> _startTask;
 
	TIMESTAMP _lastVote;
	private String urlS = "";
 
	public class StartTask implements Runnable
	{
		public void run()
		{
			while (Config.L2VOTEMANAGER_ENABLE)
			{
				try
				{
					URL url = NEW URL(urlS);
					parse(url.openStream());
				}
				catch(Exception e)
				{
					log.warning("VoteManager: Error url parse.");
				}
 
				try
				{
					Thread.sleep(Config.L2VOTEMANAGER_TIME);
				}
				catch(InterruptedException e)
				{
					e.printStackTrace();
				}
			}
		}
 
	}
 
	public void onShutdown()
	{
	}
 
	public void onLoad()
	{
		try
		{
			ThreadConnection con = L2DatabaseFactory.getInstance().getConnection();
			FiltredPreparedStatement stm = con.prepareStatement("select max(votedate) from character_votes");
			ResultSet r = stm.executeQuery();
			IF(r.NEXT())
				_lastVote = NEW TIMESTAMP(r.getLong(1) * 1000);
			IF (_lastVote==NULL)
			{
				_lastVote = NEW TIMESTAMP(0);
			}
			r.close();
			stm.close();
			con.close();
		}
		catch(SQLException e)
		{
			log.warning("VoteManager: Error connection to database: "+e);
		}
 
		urlS = "http://l2top.ru/editServ/?adminAct=lastVotes&uid=" + Config.L2TOP_ID + "&key=" + Config.L2TOP_KEY;
 
 
		_startTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(NEW StartTask(), 1, 1);
	}
 
	public void onReload()
	{
		_startTask.cancel(TRUE);
		onLoad();
 
	}
 
	public void parse(InputStream IS) throws Exception 
	{
		BufferedReader reader = NEW BufferedReader(NEW InputStreamReader(IS,"windows-1251"));
		String line;
		INT votes = 0;
		TIMESTAMP LAST = _lastVote;
 
		while((line=reader.readLine()) != NULL)
		{
			IF (line.indexOf("\t") != -1)
			{
				TIMESTAMP voteDate = TIMESTAMP.valueOf(line.SUBSTRING(0,line.indexOf("\t")).TRIM());
				IF (voteDate.after(_lastVote))
				{
					IF(voteDate.after(LAST))
						LAST = voteDate;
 
					String charName = line.SUBSTRING(line.indexOf("\t")+1).toLowerCase();
					Store(charName, voteDate);
					votes++;
				}
			}
		}
		_lastVote = LAST;
		log.info("VoteManager: "+votes+" processed");
	}
 
	public void reward(L2Player player) 
	{
		IF(player != NULL)
		{
			player.getInventory().addItem(Config.L2VOTEMANAGER_REWARD_ID, Config.L2VOTEMANAGER_REWARD_KEY);
			IF (player.isOnline())
				player.sendMessage("Спасибо, что проголосовали за наш сервер!");
			player.store(TRUE);
		}
	}
 
	public void Store(String _charName, TIMESTAMP _votedate)
	{
		try
		{
			ThreadConnection con = L2DatabaseFactory.getInstance().getConnection();
			FiltredPreparedStatement stm = con.prepareStatement("insert into character_votes select ?,? from characters where not exists(select * from character_votes where votedate=? and charName =?) limit 1");
			stm.setLong(1, _votedate.getTime()/1000);
			stm.setString(2, _charName);
			stm.setLong(3, _votedate.getTime()/1000);
			stm.setString(4, _charName);
			BOOLEAN sendPrize  = stm.executeUpdate() > 0;
			stm.close();
			IF (sendPrize)
			{
				L2Player player = L2ObjectsStorage.getPlayer(_charName);
				IF(player != NULL)
					reward(player);
			}
		}
		catch (SQLException e)
		{
			log.warning("VoteManager: Error storing data "+e);
		}
	}
 
 
}
 
Code: SQL

Deron 22.02.2011 23:57

Re: Авто выдача бонуса.
 
Поставил этот скрипт пошли ошибки.

Цитата:

.\data\scripts\services\VoteManager.java:46: ';' expected
.\data\scripts\services\VoteManager.java:78: ';' expected
.\data\scripts\services\VoteManager.java:79: ';' expected
.\data\scripts\services\VoteManager.java:80: ';' expected
.\data\scripts\services\VoteManager.java:82: ';' expected
.\data\scripts\services\VoteManager.java:96: ')' expected
.\data\scripts\services\VoteManager.java:96: illegal start of expressi
.\data\scripts\services\VoteManager.java:96: not a statement
.\data\scripts\services\VoteManager.java:96: ';' expected
.\data\scripts\services\VoteManager.java:108: ';' expected
.\data\scripts\services\VoteManager.java:108: ')' expected
.\data\scripts\services\VoteManager.java:108: ')' expected
.\data\scripts\services\VoteManager.java:108: not a statement
.\data\scripts\services\VoteManager.java:108: not a statement
.\data\scripts\services\VoteManager.java:108: ';' expected
.\data\scripts\services\VoteManager.java:115: ';' expected
.\data\scripts\services\VoteManager.java:118: ';' expected
.\data\scripts\services\VoteManager.java:120: ';' expected
.\data\scripts\services\VoteManager.java:135: ';' expected
.\data\scripts\services\VoteManager.java:138: ';' expected
.\data\scripts\services\VoteManager.java:156: ';' expected
.\data\scripts\services\VoteManager.java:159: ';' expected
.\data\scripts\services\VoteManager.java:46: ';' expected
.\data\scripts\services\VoteManager.java:78: ';' expected
.\data\scripts\services\VoteManager.java:79: ';' expected
.\data\scripts\services\VoteManager.java:80: ';' expected
.\data\scripts\services\VoteManager.java:82: ';' expected
.\data\scripts\services\VoteManager.java:96: ')' expected
.\data\scripts\services\VoteManager.java:96: illegal start of expressi
.\data\scripts\services\VoteManager.java:96: not a statement
.\data\scripts\services\VoteManager.java:96: ';' expected
.\data\scripts\services\VoteManager.java:108: ';' expected
.\data\scripts\services\VoteManager.java:108: ')' expected
.\data\scripts\services\VoteManager.java:108: ')' expected
.\data\scripts\services\VoteManager.java:108: not a statement
.\data\scripts\services\VoteManager.java:108: not a statement
.\data\scripts\services\VoteManager.java:108: ';' expected
.\data\scripts\services\VoteManager.java:115: ';' expected
.\data\scripts\services\VoteManager.java:118: ';' expected
.\data\scripts\services\VoteManager.java:120: ';' expected
.\data\scripts\services\VoteManager.java:135: ';' expected
.\data\scripts\services\VoteManager.java:138: ';' expected
.\data\scripts\services\VoteManager.java:156: ';' expected
.\data\scripts\services\VoteManager.java:159: ';' expected
Добавлено через 3 минуты
До этого стоял вот такой:
Код HTML:

package services;

import l2p.Config;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.logging.Logger;
import java.util.concurrent.ScheduledFuture;
import java.net.URL;

import l2p.common.ThreadPoolManager;
import l2p.database.FiltredPreparedStatement;
import l2p.database.L2DatabaseFactory;
import l2p.database.ThreadConnection;
import l2p.extensions.scripts.Functions;
import l2p.extensions.scripts.ScriptFile;
import l2p.gameserver.model.L2ObjectsStorage;
import l2p.gameserver.model.L2Player;
import l2p.util.Rnd;



public class VoteManager extends Functions implements ScriptFile
{
        /*
        *        (c) Ro0TT
        */
        private static Logger log = Logger.getLogger(VoteManager.class.getName());
        private static ScheduledFuture<?> _startTask;
       
        Timestamp _lastVote;
        private String urlS = "";
       
        public class StartTask implements Runnable
        {
                public void run()
                {
                        while (Config.L2VOTEMANAGER_ENABLE)
                        {
                                try
                                {
                                        URL url = new URL(urlS);
                                        parse(url.openStream());
                                }
                                catch(Exception e)
                                {
                                        log.warning("VoteManager: Error url parse.");
                                }
                               
                                try
                                {
                                        Thread.sleep(Config.L2VOTEMANAGER_TIME);
                                }
                                catch(InterruptedException e)
                                {
                                        e.printStackTrace();
                                }
                        }
                }
               
        }
       
        public void onShutdown()
        {
        }

        public void onLoad()
        {
                try
                {
                        ThreadConnection con = L2DatabaseFactory.getInstance().getConnection();
                        FiltredPreparedStatement stm = con.prepareStatement("select max(votedate) from character_votes");
                        ResultSet r = stm.executeQuery();
                        if(r.next())
                                _lastVote = new Timestamp(r.getLong(1) * 1000);
                        if (_lastVote==null)
                        {
                                _lastVote = new Timestamp(0);
                        }
                        r.close();
                        stm.close();
                        con.close();
                }
                catch(SQLException e)
                {
                        log.warning("VoteManager: Error connection to database: "+e);
                }
               
                urlS = "http://l2top.ru/editServ/?adminAct=lastVotes&uid=" + Config.L2TOP_ID + "&key=" + Config.L2TOP_KEY;
               
       
                _startTask = ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new StartTask(), 1, 1);
        }

        public void onReload()
        {
                _startTask.cancel(true);
                onLoad();
       
        }
       
        public void parse(InputStream is) throws Exception
        {
                BufferedReader reader = new BufferedReader(new InputStreamReader(is,"windows-1251"));
                String line;
                int votes = 0;
                Timestamp last = _lastVote;

                while((line=reader.readLine()) != null)
                {
                        if (line.indexOf("\t") != -1)
                        {
                                Timestamp voteDate = Timestamp.valueOf(line.substring(0,line.indexOf("\t")).trim());
                                if (voteDate.after(_lastVote))
                                {
                                        if(voteDate.after(last))
                                                last = voteDate;

                                        String charName = line.substring(line.indexOf("\t")+1).toLowerCase();
                                        Store(charName, voteDate);
                                        votes++;
                                }
                        }
                }
                _lastVote = last;
                log.info("VoteManager: "+votes+" processed");
        }
       
        public void reward(L2Player player)
        {
                if(player != null)
                {
                        player.getInventory().addItem(Config.L2VOTEMANAGER_REWARD_ID, Config.L2VOTEMANAGER_REWARD_KEY);
                        if (player.isOnline())
                                player.sendMessage("Спасибо, что проголосовали за наш сервер!");
                        player.store(true);
                }
        }
       
        public void Store(String _charName, Timestamp _votedate)
        {
                try
                {
                        ThreadConnection con = L2DatabaseFactory.getInstance().getConnection();
                        FiltredPreparedStatement stm = con.prepareStatement("insert into character_votes select ?,? from characters where not exists(select * from character_votes where votedate=? and charName =?) limit 1");
                        stm.setLong(1, _votedate.getTime()/1000);
                        stm.setString(2, _charName);
                        stm.setLong(3, _votedate.getTime()/1000);
                        stm.setString(4, _charName);
                        boolean sendPrize  = stm.executeUpdate() > 0;
                        stm.close();
                        if (sendPrize)
                        {
                                L2Player player = L2ObjectsStorage.getPlayer(_charName);
                                if(player != null)
                                        reward(player);
                        }
                }
                catch (SQLException e)
                {
                        log.warning("VoteManager: Error storing data "+e);
                }
        }
       
       
}



Текущее время: 03:51. Часовой пояс GMT +3.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd. Перевод: zCarot