Jump to content

[Share]New HOPZONE vote reward system


Recommended Posts

still getting error.

 

this is how it looks like for me. [ gameserver\data\scripts\custom\AutoVoteRewardHandler\AutoVoteRewardHandler.java

 

    /*
     * This is a script completely developed by Rain^ (?)
     * You are not allowed to sell any copies of it.
     * Since 2.0 (by Zoey76 for L2J Forums):
     * Added logger instead of System.out.println()
     * Moved to Datapack.
     * Reworked AutoReward class.
     * Reworked getVotes() method.
     * Time is in minutes instead of milliseconds.
     * Uses different a-beep-t for each item.
     * Only rewards online players, not offline shops.
     * Rewarded players count.
     */
    package custom.VoteEngine;
     
    import java.io.*;
    import java.net.*;
    import java.util.Collection;
    import java.util.logging.Level;
    import java.util.logging.Logger;
     
    import net.sf.l2j.gameserver.Announcements;
    import net.sf.l2j.gameserver.ThreadPoolManager;
    import net.sf.l2j.gameserver.model.L2World;
    import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
     
    /**
     * @author Zoey76
     * @version 2.0
     */
    public class AutoVoteRewardHandler
    {
            protected static final Logger _log = Logger.getLogger(AutoVoteRewardHandler.class.getName());
            //URL from your server site at HopZone.net
            //Example: http://l2.hopzone.net/lineage2/moreinfo/YourServer/ID.html
            private final static String _url = "http://l2.hopzone.net/lineage2/details/91914/L2NetherWorld";//Add your URL from HopZone here!
            //Reward all online players each '_votesRequiredForReward' votes.
            private final int _votesRequiredForReward = 1;//
            //Initial check, time in minutes:
            //Default: 1 minute
            private final int initialCheck = 5;
            //Delay interval, time in minutes (do not set it too low):
            //Default: 10 minutes
            private final int delayForCheck = 5;
           
            //Item Id, A-beep-t.
            private final static int[][] ITEMs =
            {
                    { 5575, 10 }, //10 Ancient Adena
                    { 57, 1000000 }, //1kk Adena
            };
           
            //Do not change
            private int _lastVoteCount = 0;
           
            private AutoVoteRewardHandler()
            {
                    _log.info("[AutoVoteRewardHandler]: Vote Reward System Initiated.");
                    ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(new AutoReward(), initialCheck * 60000, delayForCheck * 60000);
            }
           
            private class AutoReward implements Runnable
            {
                    public void run()
                    {
                            int votes = getVotes();
                            int rewardedPlayers = 0;
                            if (votes > -1)
                            {
                                    if  ((getLastVoteCount() != 0) && (votes >= (getLastVoteCount() + _votesRequiredForReward)))
                                    {
                                            Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
                                            for (L2PcInstance player : pls)
                                            {
                                                    if ((player != null) && !player.getClient().isDetached())
                                                    {
                                                            for (int[] reward : ITEMs)
                                                            {
                                                                    if (player.getInventory().validateCapacityByItemId(reward[0]))
                                                                    {
                                                                            player.addItem("reward", reward[0], reward[1], player, true);
                                                                    }
                                                            }
                                                            rewardedPlayers++;
                                                    }
                                            }
                                            setLastVoteCount(getLastVoteCount() + _votesRequiredForReward);
                                    }
                                    else if (getLastVoteCount() == 0)
                                    {
                                            setLastVoteCount(votes);
                                    }
                                    _log.info("[AutoVoteRewardHandler]: Server Votes: " + votes + ", Rewarded players: " + rewardedPlayers);
                                    Announcements.getInstance();
			    Announcements.announceToAll("Server Votes: " + votes + " | Next Reward on " + (getLastVoteCount() + _votesRequiredForReward) + " votes!");
                            }
                            else
                            {
                                    _log.log(Level.WARNING, "[AutoVoteRewardHandler]: Error retreiving server votes count!");
                            }
                    }
            }
           
            private static int getVotes()
            {
                    InputStreamReader isr = null;
                    BufferedReader in = null;
                    int votes = -1;
                    try
                    {
                    URLConnection conn = new URL(_url).openConnection();
                    conn.addRequestProperty("User-Agent", "Mozilla/4.76");
                    isr = new InputStreamReader(conn.getInputStream());
                    in = new BufferedReader(isr);
                            String inputLine;
                            while (((inputLine = in.readLine()) != null) && (votes == -1))
                            {
                                    if (inputLine.contains("Anonymous User Votes"))
                                    {
                                            try
                                            {
                                                    votes = Integer.valueOf(inputLine.split(">")[2].replace("</span", ""));
                                            }
                                            catch (Exception e)
                                            {
                                            }
                                    }
                            }
                            in.close();
                    }
                    catch (Exception e)
                    {
                            _log.log(Level.WARNING, "[AutoVoteRewardHandler]: " + e.getMessage(), e);
                    }
                    return votes;
            }
           
            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();
            }
           
            public static void main(String[] args)
            {
                    //System.out.println("Server votes: " + getVotes());//Just a test.
                    AutoVoteRewardHandler.getInstance();
            }
    }

 

this error i get

 

error2.png

 

Error on: D:\Lineage2 Server\SERVER acis\gameserver\data\scripts\custom\AutoVoteRewardHandler\AutoVoteRewardHandler.java.error.log

Line: -1 - Column: -1

 

java.lang.ClassNotFoundException: custom.AutoVoteRewardHandler.AutoVoteRewardHandler

 

 

whole day i try to make it work and still errors :D

Link to comment
Share on other sites

Well, my bad.

 

package custom.VoteEngine;

 

Folder name should be VoteEngine and not AutoVoteRewardHandler. So simply rename it.. :P

 

One guy at aCis forum asked about the same, the same error. That's not you, olo? ^^

Link to comment
Share on other sites

got 2 errors pls help me

 

----------
1. ERROR in /AutoVoteRewardHandler.java (at line 72)
Collection<L2PcInstance> pls = L2World.getInstance().getAllPlayers().values();
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Type mismatch: cannot convert from L2PcInstance[] to Collection<L2PcInstance>
----------
2. ERROR in /AutoVoteRewardHandler.java (at line 95)
Announcements.announceToAll("Server Votes: " + votes + " | Next Reward on " + (getLastVoteCount() + _votesRequiredForReward) + " votes!");
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Cannot make a static reference to the non-static method announceToAll(String) from the type Announcements
----------
2 problems (2 errors)Type mismatch: cannot convert from com.l2jserver.gameserver.model.actor.instance.L2PcInstance[] to java.util.Collection<com.l2jserver.gameserver.model.actor.instance.L2PcInstance>
Cannot make a static reference to the non-static method announceToAll(java.lang.String) from the type com.l2jserver.gameserver.Announcements
Failed executing script: /root/quitt/game/data/scripts/custom/VoteEngine/AutoVoteRewardHandler.java. See AutoVoteRewardHandler.java.error.log for details.

Link to comment
Share on other sites

got 2 errors pls help me

 

At least you could tell us what pack/chronicle are you using. Also, you SHOULD create a new topic in Request Help section and not here.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




  • Posts

    • Thank you for your reply. I have removed it from the L2Server.exe file, but the L2Server still crashes. It doesn't crash if I don't start l2npc, otherwise it will crash within a few days at the latest.
    • Welcome to my store :  https://topestore.mysellix.io/fr/ 2015-2022 Aged Discord Account 2015 Discord Account : 50.99 $ 2016 Discord Account : 10$ 2017 Discord Account :3.99 $ 2018 Discord Account : 3.50$ 2019 Discord Account : 2.70 $ 2020 Discord Account :1.50$ 2021 Discord Account :0.99$ 2022 Discord Account :0.70$ Warranty :Lifetime Payment Methods : Crypto/ PayPal Contact Me On Discord Or Telegram Discord : @ultrasstore11 Telegram : https://t.me/ultrastore1 Welcome to my store :  https://topestore.mysellix.io/fr/ 2015-2022 Aged Discord Account 2015 Discord Account : 50.99 $ 2016 Discord Account : 10$ 2017 Discord Account :3.99 $ 2018 Discord Account : 3.50$ 2019 Discord Account : 2.70 $ 2020 Discord Account :1.50$ 2021 Discord Account :0.99$ 2022 Discord Account :0.70$ Warranty :Lifetime Payment Methods : Crypto/ PayPal Contact Me On Discord Or Telegram Discord : @ultrasstore11
    • L2 ArenaWar: Low Rate PvP Server with Free Buffs & Autofarm [PVP]⚔️ [Free]🆓 Classic Interlude with  3x XP rates! Free starter pack(no grade) to kickstart your adventure! Autofarm for convenient grinding! Free buffs to keep you fighting fit! (2 job buffs) No experience loss on death! (Except with Karma) Clear Karma system to keep things fair! ⚖️ Active community of 800-1k players! Join our Discord to learn more! >> Discord <<     Server website: https://l2arenawar.com/en/    
    • This is dedication! 2 years working on a problem. Congratulations!
    • You indeed have to save player position over Enterworld to properly clean it up later (if you don't, even trying to delete packet content would eventually keep it up), that's what we do with debug packet (which is a reusable Map of ExServerPrimitive packets) on aCis.   It doesn't solve the FPS stuttering - more you draw/delete lines, more your client becomes laggy. It's like if client wasn't deleting drawn points/lines properly, but instead simply hide them and redrawn content above.   If you got a solution, I would happy to integrate it.   You should check aCis#Player _debug packet integration, it allows very big amount of lines/points to be drawn, it is also reusable.   https://gitlab.com/Tryskell/acis_public/-/blob/master/aCis_gameserver/java/net/sf/l2j/gameserver/model/actor/Player.java?ref_type=heads https://gitlab.com/Tryskell/acis_public/-/blob/master/aCis_gameserver/java/net/sf/l2j/gameserver/network/clientpackets/EnterWorld.java?ref_type=heads  
  • Topics

×
×
  • Create New...