Jump to content
  • 0

[HELP]Vote reward system plz help!


Question

Posted

Hy!

 

I have working on a vote reward system and i have a problem.

 

I have l2j freya system and in when I build i receive an error:

 

   [javac] D:\L2J\workspace\L2_GameServer\java\com\l2jserver\gameserver\instancemanager\AutoVoteRewardHandler.java:95: cannot find symbol

   [javac] symbol  : method addItem(java.lang.String,int,int[],com.l2jserver.gameserver.model.actor.instance.L2PcInstance,boolean)

   [javac] location: class com.l2jserver.gameserver.model.actor.instance.L2PcInstance

   [javac]                                                                        player.addItem("reward", itemId, itemCount, player, true);

 

And this is my AutoVoteRewardHandler.java file:

 

package com.l2jserver.gameserver.instancemanager;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;

import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.Announcements;
import com.l2jserver.gameserver.ThreadPoolManager;
import com.l2jserver.gameserver.model.L2ItemInstance;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;

/**
* @author Issle - Updater Kinho! V1.0
*
*/
public class AutoVoteRewardHandler
{
      private final String HOPZONE = "Config.HopZone_ID";
      // 60 * 1000(1000milliseconds = 1 second) = 60seconds
      private final int initialCheck = 60 * 1000;
      // 1800 * 1000(1000milliseconds = 1 second) = 1800seconds = 30minutes
      private final int delayForCheck = Config.Delay_for_check * 1000;
      private final int[] itemId = {Config.Reward_Item_Id};
      private final int[] itemCount = {Config.Reward_Item_Count};
      private final int[] maxStack = {Config.Max_Stack};
      private final int votesRequiredForReward = Config.Votes_Required;
      // do not change
      private int lastVoteCount = 0;
      
      private AutoVoteRewardHandler()
      {
              System.out.println("Vote Reward System Initiated.");
              ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck, delayForCheck);
      }
      
      private class AutoReward implements Runnable
      {
              public void run()
              {
                      int votes = getVotes();
                      System.out.println("Server Votes: " + votes);
                      if (votes != 0 && getLastVoteCount() != 0 && votes >= getLastVoteCount() + votesRequiredForReward)
                      {
                              Connection con = null;
                              try
                              {
                                      con = L2DatabaseFactory.getInstance().getConnection();
                                      PreparedStatement statement = con.prepareStatement("" +
                                                      "SELECT" +
                                                      "       characters.charId," +
                                                      "       characters.char_name" +
                                                      "FROM" +
                                                      "       characters.account_name = accounts.login" +
                                                      "WHERE" +
                                                      "       characters.onlinetime > 0" +
                                                      "GROUP BY" +
                                                      "       accounts.lastIP" +
                                                      "ORDER BY" +
                                                      "       characters.level" +
                                                      "DESC");
                                      ResultSet rset = statement.executeQuery();
                                      L2PcInstance player = null;
                                      L2ItemInstance item = null;
                                      while (rset.next())
                                      {
                                              player = L2World.getInstance().getPlayer("charId");
                                              if (player != null && !player.getClient().isDetached())
                                              {
                                                      for (int i = 0; i < itemId.length; i++)
                                                      {
                                                              item = player.getInventory().getItemByItemId(itemId[i]);
                                                              if (item == null || item.getCount() < maxStack[i])
                                                                      player.addItem("reward", itemId[i], itemCount, player, true);
                                                      }
                                              }
                                      }
                                      statement.close();
                              }
                              catch (SQLException e)
                              {
                                      e.printStackTrace();
                              }
                              finally
                              {
                          try { if (con != null) con.close(); } catch (SQLException e) { e.printStackTrace(); }
                              }
                              
                              setLastVoteCount(getLastVoteCount() + votesRequiredForReward);
                      }
                      Announcements.getInstance().announceToAll("Server Votes: " + votes + " | Next Reward on " + (getLastVoteCount() + votesRequiredForReward) + " Votes.");
                      if (getLastVoteCount() == 0)
                              setLastVoteCount(votes);
              }
      }
      
      private int getVotes()
      {
              URL url = null;
              InputStreamReader isr = null;
              BufferedReader in = null;
              try
              {
                      url = new URL(HOPZONE);
                      isr = new InputStreamReader(url.openStream());
                      in = new BufferedReader(isr);
                      String inputLine;
                      while ((inputLine = in.readLine()) != null)
                      {
                              if (inputLine.contains("moreinfo_total_rank_text"))
                                      return Integer.valueOf(inputLine.split(">")[2].replace("</div", ""));
                      }
              }
              catch (IOException e)
              {
                      e.printStackTrace();
              }
              finally
              {
                      try
                      {
                              in.close();
                      }
                      catch (IOException e)
                      {}
                      try
                      {
                              isr.close();
                      }
                      catch (IOException e)
                      {}
              }
              return 0;
      }
      
      private void setLastVoteCount(int voteCount)
      {
              lastVoteCount = voteCount;
      }
      
      private int getLastVoteCount()
      {
              return lastVoteCount;
      }
      
      public static AutoVoteRewardHandler getInstance()
      {
              return SingletonHolder._instance;
      }
      
      @SuppressWarnings("synthetic-access")
      private static class SingletonHolder
      {
              protected static final AutoVoteRewardHandler _instance = new AutoVoteRewardHandler();
      }
}

 

 

Please somebody help me if can!

 

Thanks a lot!

11 answers to this question

Recommended Posts

  • 0
Posted

First of all, insert your code at QUOTE/CODE.

 

Also before posting, read section rules, then you can expect help.

  • 0
Posted

First of all, insert your code at QUOTE/CODE.

 

Also before posting, read section rules, then you can expect help.

 

I alredy inserted, thx you said.

 

but I don't know why are you said read section rules... I read some days ago...

 

 

   * Before posting in this section ,you NEED to know how to edit codes <--- i know how to edit codes

   * Do not ask for support for projects which have a support forum <--- i think don't have a support forum for this

 

   * Last and the most important of them all, we will not code/create/implement for you, we will help you, but that dose not mean we will do stuff for you. <--- don't need te code,creat or implement code for me, i only need help...

 

From now on, support for pre-configured (Aka ready packs without having the source code) is forbidden. These packs are for personal use and they cant be updated, and edited from java side. Before asking help for your pack/project be sure that its already compiled; if not, then use the [English guide] or the [Greek guide].

Before making a new thread use the search function and look if there are already answered threads or duplicates.

Threads which already exist - or nonsense and non english will be locked/binned. <---- I work with l2j Freya last edition...

 

 

SORRY FOR BAD ENGLISH ALL:S

  • 0
Posted

Try this instead of the line you get the error:

 

 addItem("Loot", 9991, 1, this, true); 

 

but wait a minute are sure you get this error??? You leave it like this:

 

 player.addItem("reward", itemId, itemCount, player, true);

 

And expect to work? please give me some more info to help you!!!

  • 0
Posted

Try this instead of the line you get the error:

 

 addItem("Loot", 9991, 1, this, true); 

 

but wait a minute are sure you get this error??? You leave it like this:

 

 player.addItem("reward", itemId, itemCount, player, true);

 

And expect to work? please give me some more info to help you!!!

  • 0
Posted

addItem() exists whatever chronicle is, the only difference is the number/type of parameters entered.

 

So find occurences of addItem through the code, count the number/type of parameter inside, and verify if it matches.

 

------------------------------------------------------

 

Here are the 2 possibilities on Freya :

 

public void addItem(String process, L2ItemInstance item, L2Object reference, boolean sendMessage)

public L2ItemInstance addItem(String process, int itemId, long count, L2Object reference, boolean sendMessage)

 

The itemCount is wrong then, as in your vote system it's an array which is given, and it's a simple number which is asked in Freya. Update your vote system, or edit/add a new method in L2PcInstance to match with an array.

  • 0
Posted

addItem() exists whatever chronicle is, the only difference is the number/type of parameters entered.

 

So find occurences of addItem through the code, count the number/type of parameter inside, and verify if it matches.

 

------------------------------------------------------

 

Here are the 2 possibilities on Freya :

 

public void addItem(String process, L2ItemInstance item, L2Object reference, boolean sendMessage)

public L2ItemInstance addItem(String process, int itemId, long count, L2Object reference, boolean sendMessage)

 

The itemCount is wrong then, as in your vote system it's an array which is given, and it's a simple number which is asked in Freya. Update your vote system, or edit/add a new method in L2PcInstance to match with an array.

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


  • Posts

    • You think you have good “l2j” files until you try running a low-rate server.   Saying “there’s not a single L2 server out there worth mentioning” just shows you probably only know the first 10 servers on voting sites, the same voting sites that owned by them. You call the forum dead, yet you’re here discussing your next projects… From my perspective, you don’t seem ready to run any L2 server in 2025. Around 70% of players are here for RMT or ask for payment just to bring their clan, and you really think the community cares about Premium or donations or files quality? The other 20% spend their time downloading and deleting servers all day, playing for one day, then quitting for whatever random reason. And finally, the last 10% are the only ones who actually play because they genuinely like your features, your server files, and your overall project. Good luck 🙂
    • I genuinely admire your bravery - in an age where AI can whip up something better in under a minute, you still stubbornly try to sell these "projects" of yours on a forum that’s been clinically dead for years. That’s no longer determination, that’s digital archaeology. I just can’t tell whether you’re actually trying to make money, or simply testing how much we can endure before we ask an AI to generate you some actual talent.   And ofc AI will make it for free, $220 saved.
    • I’m glad I’m not the only one who appreciates Maxthor’s involvement in group gay orgies, he can’t be bothered to reply to messages, but covering the entire forum in gay lights is absolutely no issue for him. As for the project - the forum is packed with feedback from the testers, the lads are spending every spare moment fixing even the tiniest typo in an NPC’s text. I’ll share the links as soon as I get the green light. Edit: I forgot to add that the GM recruitment will begin once the links are released. Three people will be accepted, and they’ll work in a three-shift rotation so that there’s always a GM available online.
    • Added: a brand-new default dashboard template. You can now add multiple game/login server builds. Full support for running both PTS & L2J servers simultaneously, with switching between them. Payment systems: added OmegaPay and Pally (new PayPal-style API). Account history now stores everything: donations, items delivered to characters, referrals, transfers between game accounts, and coin transfers to another master account. Personal Promo Code System: you can create a promo code and assign it to a user or promoter. When donating, a player can enter this promo code to receive bonus coins, and the promo code owner also receives a bonus — all fully configurable in the admin panel.     Look demo site: demo
    • One of best project i play last few years
  • Topics

×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock