07-28-2013, 07:50 PM
Доброго времени суток !
Есть эвент "Викторина", который перекочевал во многие сборки из La2Base.
Использую Scoria, решил немного адаптировать..
Проблема в том, что в игре, ответы в трейд и любые чаты - викторина не овспринимает, то есть все работает как надо, но ответить на вопросы - нельзя.
Проверял перепроверял тысячу раз все методы, и никак не могу вкурить в чем дело..
Помогите разобраться пожалуйста!
Есть эвент "Викторина", который перекочевал во многие сборки из La2Base.
Использую Scoria, решил немного адаптировать..
Проблема в том, что в игре, ответы в трейд и любые чаты - викторина не овспринимает, то есть все работает как надо, но ответить на вопросы - нельзя.
Проверял перепроверял тысячу раз все методы, и никак не могу вкурить в чем дело..
Помогите разобраться пожалуйста!
Код:
public class Viktorina
{
private static int _qcount = 0;
private static int _ccount = 0;
private static int _rcount = 0;
private static int _nonanswered = 0;
private static boolean _questtime = false;
private static boolean _hintallowed = false;
private static String _cquestion;
private static String _canswer;
private static String _lastanswer;
private static Viktorina _instance;
private static String Chatstatus;
private static long _qtime = 0L;
public int _nextq = 0;
public static boolean _started = false;
private static ScheduledFuture _hintTask;
private static ScheduledFuture _answerTask;
private static ScheduledFuture _questionTask;
private static ScheduledFuture _stopTask;
private class tquestNow implements Runnable
{
public void run()
{
try
{
_Viktorina.askNow();
}
catch(SQLException e){e.printStackTrace();}
}
private Viktorina _Viktorina;
protected tquestNow()
{
_Viktorina = Viktorina.this;
}
}
private class thintNow implements Runnable
{
public void run()
{
_Viktorina.hint();
}
private Viktorina _Viktorina;
protected thintNow(Viktorina Viktorina2)
{
_Viktorina = Viktorina2;
}
}
private class tanswerNow implements Runnable
{
public void run()
{
try
{
_Viktorina.answerNow(true);
}
catch (SQLException e)
{
e.printStackTrace();
}
}
private Viktorina _Viktorina;
protected tanswerNow()
{
_Viktorina = Viktorina.this;
}
}
private class tstopNow implements Runnable
{
public void run()
{
try
{
_Viktorina.stopGame(null);
}
catch (SQLException e)
{
e.printStackTrace();
}
}
private Viktorina _Viktorina;
protected tstopNow()
{
_Viktorina = Viktorina.this;
}
}
public Viktorina(){}
public static Viktorina getInstance()
{
if(_instance == null)
{
_instance = new Viktorina();
_log.info("Quiz Event initialized.");
}
return _instance;
}
public boolean askNow() throws SQLException
{
boolean flag = getRndQuestion();
if (flag)
{
if (_canswer.length() < 5)
{
sayToAll((new StringBuilder()).append("\u0412\u043D\u0438\u043C\u0430\u043D\u0438\u0435, \u0432\u043E\u043F\u0440\u043E\u0441. \u043E\u0442\u0432\u0435\u0442 \u043D\u0430 \u043D\u0435\u0433\u043E \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u0442 ").append(_canswer.length()).append(" \u0431\u0443\u043A\u0432\u044B").toString());
sayToAll(_cquestion);
}
else
{
sayToAll((new StringBuilder()).append("\u0412\u043D\u0438\u043C\u0430\u043D\u0438\u0435, \u0432\u043E\u043F\u0440\u043E\u0441. \u043E\u0442\u0432\u0435\u0442 \u043D\u0430 \u043D\u0435\u0433\u043E \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u0442 ").append(_canswer.length()).append(" \u0431\u0443\u043A\u0432").toString());
sayToAll(_cquestion);
}
_qtime = Calendar.getInstance().getTimeInMillis();
_ccount++;
}
_questtime = true;
_hintallowed = true;
_answerTask = ThreadPoolManager.getInstance().scheduleGeneral(_instance.new tanswerNow(), Config.VIKTORINA_WAIT_ANSWER * 1000);
return flag;
}
public int nextQuest()
{
_nextq+=1;
if (_nextq > _qcount) _nextq=1;
return _nextq;
}
private static boolean getQuestionCount()
{
boolean flag = true;
try
{
Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("SELECT id FROM viktorina;");
ResultSet rset;
rset = statement.executeQuery();
while(rset.next())
{
int chest = rset.getInt("id");
_qcount++;
}
_log.config((new StringBuilder()).append("[Quiz Event] Questions loaded : ").append(_qcount).append(".").toString());
rset.close();
statement.close();
con.close();
}
catch (Exception e)
{
_log.severe((new StringBuilder()).append("[Quiz Event] Error count viktorina table : ").append(e).toString());
flag = false;
}
return flag;
}
private static boolean getRndQuestion() throws SQLException
{
Connection connection = null;
boolean flag = true;
connection = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement preparedstatement = connection.prepareStatement("SELECT * FROM `viktorina` WHERE `id` = ?");
//System.out.println((new StringBuilder()).append("rand ").append(rand).toString());
int rand = Rnd.get(1, _qcount);
preparedstatement.setInt(1, rand);
ResultSet resultset = preparedstatement.executeQuery();
if (resultset.next())
{
_cquestion = resultset.getString("question");
_canswer = resultset.getString("answer");
}
resultset.close();
preparedstatement.close();
try
{
connection.close();
}
catch (Exception e)
{
_log.severe((new StringBuilder()).append("[Quiz Event] Could not get question : ").append(e).toString());
flag = false;
connection.close();
}
return flag;
}
public boolean checkAnswer(String s, L2PcInstance l2pcinstance) throws SQLException
{
boolean flag = true;
int i = 3;
if(s.equalsIgnoreCase(_canswer) && _questtime)
{
_answerTask.cancel(true);
_qtime = Calendar.getInstance().getTimeInMillis() - _qtime;
if(Math.round((double)_qtime * 0.0015D) > (long)Math.round(Config.VIKTORINA_WAIT_ANSWER))
{
if((i -= 2) < 1)
i = 1;
}
else
if(Math.round((double)_qtime * 0.0030000000000000001D) > (long)Math.round(Config.VIKTORINA_WAIT_ANSWER) && --i < 1)
i = 1;
answerNow(false);
String s1;
if(l2pcinstance.getAppearance().getSex())
s1 = (new StringBuilder()).append("\u041F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u044B\u0439 \u043E\u0442\u0432\u0435\u0442 \u0434\u0430\u043B\u0430 ").append(l2pcinstance.getName()).append(", \u0438 \u043E\u043D\u0430 \u0437\u0430\u0440\u0430\u0431\u0430\u0442\u044B\u0432\u0430\u0435\u0442 ").toString();
else
s1 = (new StringBuilder()).append("\u041F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u044B\u0439 \u043E\u0442\u0432\u0435\u0442 \u0434\u0430\u043B ").append(l2pcinstance.getName()).append(", \u0438 \u043E\u043D \u0437\u0430\u0440\u0430\u0431\u0430\u0442\u044B\u0432\u0430\u0435\u0442 ").toString();
if(i == 1)
sayToAll((new StringBuilder()).append(s1).append(i).append(" \u043E\u0447\u043A\u043E").toString());
else
sayToAll((new StringBuilder()).append(s1).append(i).append(" \u043E\u0447\u043A\u0430").toString());
int j = setRate(l2pcinstance.getName(), i, true);
if(Config.VIKTORINA_REWARD_RIGHT)
l2pcinstance.addItem("win", Config.VIKTORINA_REWARD_ID, Config.VIKTORINA_REWARD_COUNT, null, true);
if(j == Config.VIKTORINA_ANS_COUNT_1)
{
sayToAll((new StringBuilder()).append("\u041F\u043E\u0442\u0440\u044F\u0441\u0430\u044E\u0449\u0435. ").append(l2pcinstance.getName()).append(" \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043D\u0430 ").append(Config.VIKTORINA_ANS_COUNT_1).append(" \u0432\u043E\u043F\u0440\u043E\u0441\u0430 \u043F\u043E\u0434\u0440\u044F\u0434 ").toString());
sayToAll("\u0418 \u0437\u0430\u0440\u0430\u0431\u0430\u0442\u044B\u0432\u0430\u0435\u0442 \u043D\u0430\u0433\u0440\u0430\u0434\u0443.");
l2pcinstance.addItem("win", Config.VIKTORINA_REWARD_ID_1, Config.VIKTORINA_REWARD_COUNT_1, null, true);
} else
if(j == Config.VIKTORINA_ANS_COUNT_2)
{
sayToAll((new StringBuilder()).append("\u041F\u043E\u0442\u0440\u044F\u0441\u0430\u044E\u0449\u0435. ").append(l2pcinstance.getName()).append(" \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043D\u0430 ").append(Config.VIKTORINA_ANS_COUNT_2).append(" \u0432\u043E\u043F\u0440\u043E\u0441\u043E\u0432 \u043F\u043E\u0434\u0440\u044F\u0434 ").toString());
sayToAll("\u0418 \u0437\u0430\u0440\u0430\u0431\u0430\u0442\u044B\u0432\u0430\u0435\u0442 \u043D\u0430\u0433\u0440\u0430\u0434\u0443.");
l2pcinstance.addItem("win", Config.VIKTORINA_REWARD_ID_2, Config.VIKTORINA_REWARD_COUNT_2, null, true);
} else
if(j == Config.VIKTORINA_ANS_COUNT_3)
{
sayToAll((new StringBuilder()).append("\u041F\u043E\u0442\u0440\u044F\u0441\u0430\u044E\u0449\u0435. ").append(l2pcinstance.getName()).append(" \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043D\u0430 ").append(Config.VIKTORINA_ANS_COUNT_3).append(" \u0432\u043E\u043F\u0440\u043E\u0441\u043E\u0432 \u043F\u043E\u0434\u0440\u044F\u0434 ").toString());
sayToAll("\u0418 \u0437\u0430\u0440\u0430\u0431\u0430\u0442\u044B\u0432\u0430\u0435\u0442 \u043D\u0430\u0433\u0440\u0430\u0434\u0443.");
l2pcinstance.addItem("win", Config.VIKTORINA_REWARD_ID_3, Config.VIKTORINA_REWARD_COUNT_3, null, true);
}
}
return flag;
}
public void stat(L2PcInstance l2pcinstance) throws SQLException
{
Connection connection = null;
int i = 0;
int j = 0;
connection = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement preparedstatement = connection.prepareStatement("SELECT * FROM `viktorina_stat` WHERE `name` = ?");
preparedstatement.setString(1, l2pcinstance.getName());
ResultSet resultset = preparedstatement.executeQuery();
if (resultset.next())
{
i = resultset.getInt("last");
j = resultset.getInt("rate");
}
l2pcinstance.sendMessage((new StringBuilder()).append("\u0412 \u0434\u0430\u043D\u043D\u044B\u0439 \u043C\u043E\u043C\u0435\u043D\u0442 \u0443 \u0432\u0430\u0441 ").append(j).append(" \u043E\u0447\u043A\u043E\u0432").toString());
if (i < 5)
l2pcinstance.sendMessage((new StringBuilder()).append("\u0412\u044B \u043E\u0442\u0432\u0435\u0442\u0438\u043B\u0438 \u043F\u043E\u0434\u0440\u044F\u0434 \u043D\u0430 ").append(i).append(" \u0432\u043E\u043F\u0440\u043E\u0441\u0430").toString());
else
l2pcinstance.sendMessage((new StringBuilder()).append("\u0412\u044B \u043E\u0442\u0432\u0435\u0442\u0438\u043B\u0438 \u043F\u043E\u0434\u0440\u044F\u0434 \u043D\u0430 ").append(i).append(" \u0432\u043E\u043F\u0440\u043E\u0441\u043E\u0432").toString());
try
{
connection.close();
}
catch (Exception e)
{
_log.severe((new StringBuilder()).append("[Quiz Event] Could not get char stat from DB : ").append(e).toString());
connection.close();
}
}
public void help(L2PcInstance l2pcinstance)
{
l2pcinstance.sendMessage("\u041F\u0440\u0430\u0432\u0438\u043B\u0430 \u043F\u0440\u043E\u0441\u0442\u044B. \u0412 \u0442\u0440\u0435\u0439\u0434-\u0447\u0430\u0442\u0435 \u0437\u0430\u0434\u0430\u044E\u0442\u0441\u044F \u0432\u043E\u043F\u0440\u043E\u0441\u044B");
l2pcinstance.sendMessage("\u0412\u044B \u0434\u043E\u043B\u0436\u043D\u044B \u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u043E \u0438 \u0431\u044B\u0441\u0442\u0440\u043E \u043E\u0442\u0432\u0435\u0447\u0430\u0442\u044C \u043D\u0430 \u043D\u0438\u0445.");
l2pcinstance.sendMessage("\u041F\u0435\u0440\u0432\u044B\u0439 \u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u044B\u0439 \u043E\u0442\u0432\u0435\u0442 \u043F\u0440\u0438\u043D\u043E\u0441\u0438\u0442 \u0412\u0430\u043C \u043F\u043E\u0431\u0435\u0434\u0443");
l2pcinstance.sendMessage((new StringBuilder()).append("\u0437\u0430 ").append(Config.VIKTORINA_ANS_COUNT_1).append(", ").append(Config.VIKTORINA_ANS_COUNT_2).append(" \u0438 ").append(Config.VIKTORINA_ANS_COUNT_3).append(" \u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u044B\u0445 \u043E\u0442\u0432\u0435\u0442\u043E\u0432 \u043F\u043E\u0434\u0440\u044F\u0434 \u0432\u044B\u0434\u0430\u0435\u0442\u0441\u044F \u043C\u0430\u043B\u0435\u043D\u044C\u043A\u043E\u0435 \u043F\u043E\u043E\u0449\u0440\u0435\u043D\u0438\u0435").toString());
l2pcinstance.sendMessage((new StringBuilder()).append("\u0441\u0432\u043E\u044E \u0441\u0442\u0430\u0442\u0438\u0441\u0442\u0438\u043A\u0443 \u0432\u044B \u043C\u043E\u0436\u0435\u0442\u0435 \u043F\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C \u043D\u0430\u0431\u0440\u0430\u0432 !stat \u0432 \u0442\u0440\u0435\u0439\u0434\u0447\u0430\u0442\u0435. \u041D\u0430\u0431\u0440\u0430\u0432 !hint \u0432\u044B \u043C\u043E\u0436\u0435\u0442\u0435 \u0437\u0430\u043F\u0440\u043E\u0441\u0438\u0442\u044C \u043F\u043E\u0434\u0441\u043A\u0430\u0437\u043A\u0443, \u043A\u043E\u0442\u043E\u0440\u0430\u044F \u043F\u043E\u044F\u0432\u0438\u0442\u0441\u044F \u0447\u0435\u0440\u0435\u0437 ").append(Config.VIKTORINA_HINTTIME).append(" \u0441\u0435\u043A\u0443\u043D\u0434.").toString());
l2pcinstance.sendMessage("\u041F\u0440\u0438\u044F\u0442\u043D\u043E\u0439 \u0438\u0433\u0440\u044B.");
if(_questtime)
{
l2pcinstance.sendMessage((new StringBuilder()).append("\u041E\u0442\u0432\u0435\u0442 \u043D\u0430 \u0442\u0435\u043A\u0443\u0449\u0438\u0439 \u0432\u043E\u043F\u0440\u043E\u0441 \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u0442 ").append(_canswer.length()).append(" \u0431\u0443\u043A\u0432. \u0412\u043E\u043F\u0440\u043E\u0441:").toString());
l2pcinstance.sendMessage(_cquestion);
}
else
{
l2pcinstance.sendMessage("\u041D\u0430 \u0434\u0430\u043D\u043D\u044B\u0439 \u043C\u043E\u043C\u0435\u043D\u0442 \u0432\u043E\u043F\u0440\u043E\u0441 \u043D\u0435 \u0437\u0430\u0434\u0430\u043D");
}
}
private static int setRate(String s, int i, boolean flag) throws SQLException
{
Connection connection = null;
int j = 0;
connection = L2DatabaseFactory.getInstance().getConnection();
if (s != _lastanswer)
{
PreparedStatement preparedstatement = connection.prepareStatement((new StringBuilder()).append("SELECT * FROM `viktorina_stat` WHERE `name` = '").append(_lastanswer).append("'").toString());
ResultSet resultset = preparedstatement.executeQuery();
if (resultset.next())
{
PreparedStatement preparedstatement1 = connection.prepareStatement((new StringBuilder()).append("UPDATE `viktorina_stat` SET `last` = 0 WHERE `name` = '").append(_lastanswer).append("'").toString());
preparedstatement1.execute();
}
_lastanswer = s;
}
if (flag)
{
PreparedStatement preparedstatement2 = connection.prepareStatement((new StringBuilder()).append("SELECT * FROM `viktorina_stat` WHERE `name` = '").append(s).append("'").toString());
ResultSet resultset1 = preparedstatement2.executeQuery();
if (resultset1.next())
{
j = resultset1.getInt("last") + 1;
int k = resultset1.getInt("rate");
PreparedStatement preparedstatement3 = connection.prepareStatement("UPDATE `viktorina_stat` SET `rate` =? WHERE `name` = ?;");
preparedstatement3.setInt(1, k + i);
preparedstatement3.setString(2, s);
preparedstatement3.execute();
k = resultset1.getInt("last");
preparedstatement3 = connection.prepareStatement("UPDATE `viktorina_stat` SET `last` =? WHERE `name` = ?;");
preparedstatement3.setInt(1, k + 1);
preparedstatement3.setString(2, s);
preparedstatement3.execute();
}
else
{
PreparedStatement preparedstatement4 = connection.prepareStatement("INSERT INTO `viktorina_stat` (id, `name`, `rate`, `last`) VALUES (NULL, ?, ?, ?);");
preparedstatement4.setString(1, s);
preparedstatement4.setInt(2, i);
preparedstatement4.setInt(3, 1);
preparedstatement4.execute();
j = 1;
}
}
try
{
connection.close();
}
catch (Exception e)
{
_log.severe((new StringBuilder()).append("[Quiz Event] Could not save stat to DB : ").append(e).toString());
connection.close();
}
return j;
}
private static boolean sayToAll(String s)
{
CreatureSay creaturesay = new CreatureSay(0, 8, Config.VIKTORINA_SYSTEM_NAME, s);
L2PcInstance l2pcinstance;
for(Iterator iterator = L2World.getInstance().getAllPlayers().iterator(); iterator.hasNext(); l2pcinstance.sendPacket(creaturesay))
l2pcinstance = (L2PcInstance)iterator.next();
return true;
}
public void next(L2PcInstance l2pcinstance) throws SQLException
{
if(_questtime)
{
_questionTask.cancel(true);
_answerTask.cancel(true);
answerNow(true);
l2pcinstance.sendMessage("\u0412\u043E\u043F\u0440\u043E\u0441 \u043F\u0440\u043E\u043F\u0443\u0449\u0435\u043D, \u0437\u0430\u0434\u0430\u044E \u0441\u043B\u0435\u0434\u0443\u044E\u0449\u0438\u0439");
}
else
{
l2pcinstance.sendMessage("\u0412\u043E\u043F\u0440\u043E\u0441 \u0435\u0449\u0435 \u043D\u0435 \u0437\u0430\u0434\u0430\u043D");
}
}
public void hint()
{
if(_questtime)
{
int i = Rnd.get(_canswer.length() - 1) + 1;
String s = "";
if(_canswer.length() <= 4)
{
for(int j = 1; j <= _canswer.length(); j++)
if(j == i)
s = (new StringBuilder()).append(s).append(_canswer.charAt(j - 1)).toString();
else
s = (new StringBuilder()).append(s).append(".").toString();
}
else if(_canswer.length() <= 8)
{
int k;
for(k = Rnd.get(_canswer.length() - 1) + 1; k == i; k = Rnd.get(_canswer.length() - 1) + 1);
for(int i1 = 1; i1 <= _canswer.length(); i1++)
if(i1 == i || i1 == k)
s = (new StringBuilder()).append(s).append(_canswer.charAt(i1 - 1)).toString();
else
s = (new StringBuilder()).append(s).append(".").toString();
}
else
{
int l = Rnd.get(_canswer.length() - 1) + 1;
int j1 = Rnd.get(_canswer.length() - 1) + 1;
for(int k1 = 5; (l == i || j1 == i || l == j1) && k1 > 0; k1--)
{
j1 = Rnd.get(_canswer.length() - 1) + 1;
l = Rnd.get(_canswer.length() - 1) + 1;
}
for(int l1 = 1; l1 <= _canswer.length(); l1++)
if(l1 == i || l1 == l || l1 == j1)
s = (new StringBuilder()).append(s).append(_canswer.charAt(l1 - 1)).toString();
else
s = (new StringBuilder()).append(s).append(".").toString();
}
sayToAll((new StringBuilder()).append("\u043F\u043E\u0434\u0441\u043A\u0430\u0437\u043A\u0430: ").append(s).toString());
_hintallowed = true;
}
}
public void statistic(L2PcInstance l2pcinstance)
{
if(_started)
{
l2pcinstance.sendMessage((new StringBuilder()).append("\u0412 \u0431\u0430\u0437\u0435 \u0432\u043E\u043F\u0440\u043E\u0441\u043E\u0432: ").append(_qcount).toString());
l2pcinstance.sendMessage((new StringBuilder()).append("\u0417\u0430\u0434\u0430\u043D\u043E \u0432\u043E\u043F\u0440\u043E\u0441\u043E\u0432: ").append(_ccount).toString());
l2pcinstance.sendMessage((new StringBuilder()).append("\u041F\u043E\u043B\u0443\u0447\u0435\u043D\u043E \u043E\u0442\u0432\u0435\u0442\u043E\u0432: ").append(_rcount).toString());
l2pcinstance.sendMessage((new StringBuilder()).append("\u041D\u0435\u043E\u0442\u0432\u0435\u0447\u0435\u043D\u043D\u044B\u0445 \u0432\u043E\u043F\u0440\u043E\u0441\u043E\u0432: ").append(_nonanswered).toString());
} else
{
l2pcinstance.sendMessage("\u0412\u0438\u043A\u0442\u043E\u0440\u0438\u043D\u0430 \u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D\u0430");
}
}
public boolean startGame(L2PcInstance l2pcinstance, String s) throws SQLException
{
boolean flag = true;
if (_started && l2pcinstance != null)
l2pcinstance.sendMessage("\u0412\u0438\u043A\u0442\u043E\u0440\u0438\u043D\u0430 \u0443\u0436\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D\u0430.");
Connection connection = null;
connection = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement preparedstatement = connection.prepareStatement("UPDATE `viktorina_stat` SET `last` = 0 WHERE `last` <>0");
preparedstatement.execute();
try
{
connection.close();
}
catch (Exception e)
{
_log.severe((new StringBuilder()).append("[Quiz Event] Could not save stat to DB : ").append(e).toString());
connection.close();
}
flag = getQuestionCount();
if (_qcount > 0)
{
if (Config.VIKTORINA_SWITCH_CHAT)
{
Chatstatus = Config.DEFAULT_TRADE_CHAT;
Config.DEFAULT_TRADE_CHAT = "on";
}
if (l2pcinstance != null)
l2pcinstance.sendMessage((new StringBuilder()).append("\u0412\u0438\u043A\u0442\u043E\u0440\u0438\u043D\u0430 \u0438\u043D\u0438\u0446\u0438\u0430\u043B\u0438\u0437\u0438\u0440\u043E\u0432\u0430\u043D\u0430. \u0432 \u0431\u0430\u0437\u0435 ").append(_qcount).append(" \u0432\u043E\u043F\u0440\u043E\u0441\u043E\u0432").toString());
_started = true;
Announcements.getInstance().announceToAll("\u0412\u043D\u0438\u043C\u0430\u043D\u0438\u0435. \u041D\u0430\u0447\u0438\u043D\u0430\u0435\u0442\u0441\u044F \u0432\u0438\u043A\u0442\u043E\u0440\u0438\u043D\u0430. \u041E\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043D\u0438\u043C\u0430\u043D\u0438\u0435 \u043D\u0430 \u0442\u0440\u0435\u0439\u0434-\u0447\u0430\u0442");
sayToAll("\u041D\u0430\u0447\u0438\u043D\u0430\u0435\u043C \u043D\u0430\u0448\u0443 \u0432\u0438\u043A\u0442\u043E\u0440\u0438\u043D\u0443. \u041F\u0440\u0430\u0432\u0438\u043B\u0430 \u043F\u0440\u043E\u0441\u0442\u044B");
sayToAll("\u042F \u0431\u0443\u0434\u0443 \u0437\u0430\u0434\u0430\u0432\u0430\u0442\u044C \u0432\u0430\u043C \u0432\u043E\u043F\u0440\u043E\u0441\u044B, \u0430 \u0432\u044B \u043E\u0442\u0432\u0435\u0447\u0430\u0442\u044C \u0432 \u0442\u0440\u0435\u0439\u0434 \u0447\u0430\u0442.");
sayToAll("\u0417\u0430\u0441\u0447\u0438\u0442\u044B\u0432\u0430\u0435\u0442\u0441\u044F \u0442\u043E\u043B\u044C\u043A\u043E \u043F\u0435\u0440\u0432\u044B\u0439 \u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u044B\u0439 \u043E\u0442\u0432\u0435\u0442. \u043F\u043E\u0434\u0440\u043E\u0431\u043D\u0430\u044F \u0441\u043F\u0440\u0430\u0432\u043A\u0430 - !help");
_questionTask = ThreadPoolManager.getInstance().scheduleGeneral(_instance.new tquestNow(), Config.VIKTORINA_WAIT_NEXT * 1000);
int i = 0;
try
{
i = Integer.parseInt(s);
}
catch (NumberFormatException numberformatexception)
{
_log.warning((new StringBuilder()).append("[Quiz Event] Error in StopTime : ").append(numberformatexception).toString());
}
if (i != 0)
_stopTask = ThreadPoolManager.getInstance().scheduleGeneral(_instance.new tstopNow(), i * 60000);
}
else
{
if (l2pcinstance != null)
l2pcinstance.sendMessage("\u041D\u0435\u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E \u0437\u0430\u043F\u0443\u0441\u0442\u0438\u0442\u044C \u0432\u0438\u043A\u0442\u043E\u0440\u0438\u043D\u0443, \u0442\u0430\u043A \u043A\u0430\u043A \u0432 \u0431\u0430\u0437\u0435 \u0434\u0430\u043D\u043D\u044B\u0445 \u043D\u0435 \u0441\u043E\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044F \u0432\u043E\u043F\u0440\u043E\u0441\u043E\u0432");
_log.warning("[Quiz Event] Questions database is empty!");
}
return flag;
}
public void showHint(L2PcInstance l2pcinstance)
{
if(_hintallowed)
{
l2pcinstance.sendMessage((new StringBuilder()).append("\u0412\u044B \u0437\u0430\u043F\u0440\u043E\u0441\u0438\u043B\u0438 \u043F\u043E\u0434\u0441\u043A\u0430\u0437\u043A\u0443. \u043E\u043D\u0430 \u0431\u0443\u0434\u0435\u0442 \u043F\u043E\u043A\u0430\u0437\u0430\u043D\u0430 \u0447\u0435\u0440\u0435\u0437 ").append(Config.VIKTORINA_HINTTIME).append(" \u0441\u0435\u043A\u0443\u043D\u0434").toString());
_hintTask = ThreadPoolManager.getInstance().scheduleGeneral(new thintNow(_instance), Config.VIKTORINA_HINTTIME * 1000);
_hintallowed = false;
} else
{
l2pcinstance.sendMessage("\u041F\u043E\u0434\u0441\u043A\u0430\u0437\u043A\u0443 \u0443\u0436\u0435 \u043F\u0440\u043E\u0441\u0438\u043B\u0438 \u0438\u043B\u0438 \u0432\u043E\u043F\u0440\u043E\u0441 \u043D\u0435 \u0437\u0430\u0434\u0430\u043D. \u041F\u043E\u0434\u043E\u0436\u0434\u0438\u0442\u0435 \u043D\u0435\u043C\u043D\u043E\u0433\u043E");
}
}
public boolean stopGame(L2PcInstance l2pcinstance) throws SQLException
{
if (_started)
{
if (Config.VIKTORINA_SWITCH_CHAT)
Config.DEFAULT_TRADE_CHAT = Chatstatus;
if (_questionTask != null)
_questionTask.cancel(true);
if (_answerTask != null)
_answerTask.cancel(true);
if (_hintTask != null)
_hintTask.cancel(true);
if (_stopTask != null)
_stopTask.cancel(false);
if (l2pcinstance != null)
l2pcinstance.sendMessage("\u0412\u0438\u043A\u0442\u043E\u0440\u0438\u043D\u0430 \u043E\u0442\u043A\u043B\u044E\u0447\u0435\u043D\u0430.");
_started = false;
sayToAll((new StringBuilder()).append("\u0412\u0438\u043A\u0442\u043E\u0440\u0438\u043D\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043D\u0430. \u0412\u0441\u0435\u0433\u043E \u0431\u044B\u043B\u043E \u0437\u0430\u0434\u0430\u043D\u043E ").append(_ccount).append(" \u0432\u043E\u043F\u0440\u043E\u0441\u043E\u0432").toString());
sayToAll((new StringBuilder()).append("\u041D\u0430 ").append(_rcount).append(" \u0438\u0437 \u043D\u0438\u0445 \u0431\u044B\u043B\u0438 \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u044B \u0432\u0435\u0440\u043D\u044B\u0435 \u043E\u0442\u0432\u0435\u0442\u044B").toString());
getTop(5);
sayToAll("\u0412\u0441\u0435\u043C \u0441\u043F\u0430\u0441\u0438\u0431\u043E \u0437\u0430 \u0443\u0447\u0430\u0441\u0442\u0438\u0435");
Announcements.getInstance().announceToAll("\u0412\u0438\u043A\u0442\u043E\u0440\u0438\u043D\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0435\u043D\u0430");
}
else
if (l2pcinstance != null)
l2pcinstance.sendMessage("\u0412\u0438\u043A\u0442\u043E\u0440\u0438\u043D\u0430 \u043D\u0435 \u0437\u0430\u043F\u0443\u0449\u0435\u043D\u0430.");
return _started;
}
public void answerMe(L2PcInstance l2pcinstance)
{
l2pcinstance.sendMessage((new StringBuilder()).append("\u043E\u0442\u0432\u0435\u0442 \u043D\u0430 \u0442\u0435\u043A\u0443\u0449\u0438\u0439 \u0432\u043E\u043F\u0440\u043E\u0441: ").append(_canswer).toString());
}
public boolean answerNow(boolean flag) throws SQLException
{
boolean flag1 = true;
if (_hintTask != null)
_hintTask.cancel(true);
_questtime = false;
if (flag)
{
_nonanswered++;
sayToAll((new StringBuilder()).append("\u041D\u0438\u043A\u0442\u043E \u043D\u0435 \u043E\u0442\u0432\u0435\u0442\u0438\u043B \u043D\u0430 \u0432\u043E\u043F\u0440\u043E\u0441. \u041F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u044B\u0439 \u043E\u0442\u0432\u0435\u0442: ").append(_canswer).toString());
setRate("", 0, false);
}
else
{
_nonanswered = 0;
sayToAll((new StringBuilder()).append("\u043F\u0440\u0430\u0432\u0438\u043B\u044C\u043D\u044B\u0439 \u043E\u0442\u0432\u0435\u0442: ").append(_canswer).toString());
_rcount++;
}
if (_nonanswered == Config.VIKTORINA_AUTOSTOP && Config.VIKTORINA_AUTOSTOP != 0)
{
sayToAll("\u0412\u0438\u043A\u0442\u043E\u0440\u0438\u043D\u0430 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442\u0441\u044F, \u0442\u0430\u043A \u043A\u0430\u043A \u043D\u0438\u043A\u0442\u043E \u043D\u0435 \u043E\u0442\u0432\u0435\u0447\u0430\u0435\u0442 \u043D\u0430 \u0432\u043E\u043F\u0440\u043E\u0441\u044B");
stopGame(null);
}
else
{
_hintallowed = false;
_questionTask = ThreadPoolManager.getInstance().scheduleGeneral(_instance.new tquestNow(), Config.VIKTORINA_WAIT_NEXT * 1000);
}
return flag1;
}
public void getTop(int i) throws SQLException
{
Connection connection = null;
connection = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement preparedstatement = connection.prepareStatement("SELECT * FROM `viktorina_stat` ORDER BY `viktorina_stat`.`rate` DESC LIMIT 0 , ?");
preparedstatement.setInt(1, i);
ResultSet resultset = preparedstatement.executeQuery();
sayToAll((new StringBuilder()).append(i).append(" \u043B\u0438\u0434\u0435\u0440\u043E\u0432").toString());
for (int j = 1; j <= i; j++)
if (resultset.next())
sayToAll((new StringBuilder()).append(j).append(". ").append(resultset.getString("name")).append(", ").append(resultset.getInt("rate")).append(" \u043E\u0447\u043A\u043E\u0432").toString());
try
{
connection.close();
}
catch (Exception e)
{
_log.severe((new StringBuilder()).append("[Quiz Event] Could not get top players from DB : ").append(e).toString());
connection.close();
}
}
}
clan: Soprano :redlol: