l2topzone.com
l2topzone.com
l2topzone.com
l2topzone.com
l2topzone.com
l2topzone.com
l2topzone.com

Author Topic: Vote reward using total votes FIX  (Read 22447 times)

0 Members and 1 Guest are viewing this topic.

Offlinexzone

  • Read our rules
  • Hero Member
  • *****
  • Posts: 663
  • L2topzone Votes: 53
  • Servers reviews: 159
  • Reputation: +10480/-0
    • l2topzone
Vote reward using total votes FIX
« on: March 23, 2016, 05:43:58 PM »
This method is deprecated and no longer supported by our website. Visit myhome reward section for the new method.

Hello,
Here I will give you few example of code to fix your vote rewards that use total votes from our website.
First you need to take the new link with total votes from your account section reward.
Add this link in your config file:
# Topzone: http://l2topzone.com
VotesSiteTopZoneUrl = http://l2topzone.com/tv.php?id= YOUR SERVER ID

That link will return total votes of your server without any formatting.
Lets start with l2jfrozen auto reward:
- find AutoVoteRewardHandler.java file in your project;
- find this code:
Code: [Select]
try
{
url = new URL(PowerPakConfig.VOTES_SITE_TOPZONE_URL);
con = url.openConnection();
con.addRequestProperty("User-Agent", "L2TopZone");
is = con.getInputStream();
isr = new InputStreamReader(is);
in = new BufferedReader(isr);
String inputLine;
while ((inputLine = in.readLine()) != null)
{
if (inputLine.contains("Votes"))
{
votes = Integer.valueOf(inputLine.split(">")[3].replace("</div", ""));
break;
}
}
}

-replace it with :
Code: [Select]
try
{
url = new URL(PowerPakConfig.VOTES_SITE_TOPZONE_URL);
con = url.openConnection();
con.addRequestProperty("User-Agent", "L2TopZone");
is = con.getInputStream();
isr = new InputStreamReader(is);
in = new BufferedReader(isr);
String inputLine;
while ((inputLine = in.readLine()) != null)
{
votes = Integer.valueOf(inputLine);
break;
}
}
- compile your server and you are ready.


L2jacis auto reward:

You must do the same with the config add the new link with total votes.
I found the code here [Java] Hopzone / Topzone adapted for Acis by heopas - Pastebin.com I don't know if the code you most of you use now but is just an example:
-find this code:

Code: [Select]
try
              {
                       URLConnection con = new URL(topzoneUrl).openConnection();
                      con.addRequestProperty("User-Agent", "Mozilla/4.76");
                      isr = new InputStreamReader(con.getInputStream());
                     br = new BufferedReader(isr);
                     
                       boolean got = false;
                     
                      String line;
                       while ((line = br.readLine()) != null)
                       {
                               if (line.contains("<div class=\"rank\"><div class=\"votes2\">Votes:<br>") && !got)
                               {
                                       got = true;
                                       int votes = Integer.valueOf(line.split("<div class=\"rank\"><div class=\"votes2\">Votes:<br>")[1].replace("</div></div>", ""));
                                       return votes;
                               }
                      }
                     
                       br.close();
                      isr.close();
               }
- with this code:

Code: [Select]
try
              {
                       URLConnection con = new URL(topzoneUrl).openConnection();
                       con.addRequestProperty("User-Agent", "L2TopZone");
                       isr = new InputStreamReader(con.getInputStream());
                       br = new BufferedReader(isr);

                       String line;
                       while ((line = br.readLine()) != null)
                       {
                               
                                       int votes = Integer.valueOf(line);
                                       return votes;
                             
                       }
                     
                       br.close();
                       isr.close();
               }
- compile and you are ready.

For any other vote rewards that do not fit with this 2 examples please post here your code and I will give you the solution.
Good luck.

Linkback: https://l2topzone.com/forum/index.php?topic=25668.0
« Last Edit: November 01, 2020, 04:10:01 AM by xzone »

l2topzone.com
l2topzone.com
l2topzone.com
l2topzone.com
l2topzone.com

Offlinel2indigo

  • Newbie
  • *
  • Posts: 19
  • L2topzone Votes: 48
  • Servers reviews: 1
  • Reputation: +0/-0
  • L2topzone.com
    Re: Vote reward using total votes FIX
    « Reply #1 on: March 24, 2016, 03:42:10 PM »
    It is working properly now. Great job xzone!

    Offlinexzone

    • Read our rules
    • Hero Member
    • *****
    • Posts: 663
    • L2topzone Votes: 53
    • Servers reviews: 159
    • Reputation: +10480/-0
      • l2topzone
    Re: Vote reward using total votes FIX
    « Reply #2 on: March 24, 2016, 04:10:43 PM »
    It is working properly now. Great job xzone!
    Glad to hear that. Thank you.

    Offlinexzone

    • Read our rules
    • Hero Member
    • *****
    • Posts: 663
    • L2topzone Votes: 53
    • Servers reviews: 159
    • Reputation: +10480/-0
      • l2topzone
    Re: Vote reward using total votes FIX
    « Reply #3 on: March 29, 2016, 09:56:41 AM »
    Hello,
    Try to replace this line:

    Code: [Select]
    VoteHtmlPatch = http://l2topzone.com/totalvotes.php?id=9466
    with

    Code: [Select]
    VoteHtmlPatch = http://l2topzone.com/tv.php?id=9466
    And your java script:
    Code: [Select]
    if (Config.VOTE_REWARD_TOPZONE_ENABLE)
    {
    // for TopZone
    if (inputLine.contains("<tr><td><div align=\"center\"><b><font style=\"font-size:14px;color:#018BC1;\""))
    {
    return Integer.valueOf(inputLine.split(">")[5].replace("</font", ""));
    }
    }

    with:
    Code: [Select]
    if (Config.VOTE_REWARD_TOPZONE_ENABLE)
    {
    // for TopZone
    return Integer.valueOf(inputLine);
    }

    Also to get votes from our website and avoid website DDOS protection you must use :
    Code: [Select]
    con.addRequestProperty("User-Agent", "L2TopZone");
    Hope this will help you. Please replay if is working for you.

    Offlinekris131

    • Newbie
    • *
    • Posts: 1
    • L2topzone Votes: 1
    • Servers reviews: 0
    • Reputation: +0/-0
    • L2topzone.com
      Re: Vote reward using total votes FIX
      « Reply #4 on: March 29, 2016, 10:24:12 AM »
      Man you are the best see its worked -> http://prntscr.com/allb5o

       but when i will add my server on topzone what link i will add there on votehtmlpatch can u give me frm 1 random server 1 link?


      Tanks you very mutch!! <3
      « Last Edit: March 29, 2016, 10:24:33 AM by kris131 »

      Offlinexzone

      • Read our rules
      • Hero Member
      • *****
      • Posts: 663
      • L2topzone Votes: 53
      • Servers reviews: 159
      • Reputation: +10480/-0
        • l2topzone
      Re: Vote reward using total votes FIX
      « Reply #5 on: March 29, 2016, 10:58:42 AM »
      After you add your server you will gone get access to "my home" where you have a reward section with few tools to help you implement your vote reward.

      OfflineLine2NoCustomPvP

      • Newbie
      • *
      • Posts: 2
      • L2topzone Votes: 167
      • Servers reviews: 1
      • Reputation: +0/-0
      • L2topzone.com
        Re: Vote reward using total votes FIX
        « Reply #6 on: April 03, 2016, 09:53:34 PM »
        thx , I was already concerned about giving offline haha changed the location good Xzone!  :P

        Offlinexzone

        • Read our rules
        • Hero Member
        • *****
        • Posts: 663
        • L2topzone Votes: 53
        • Servers reviews: 159
        • Reputation: +10480/-0
          • l2topzone
        Re: Vote reward using total votes FIX
        « Reply #7 on: April 04, 2016, 03:13:09 AM »
        thx , I was already concerned about giving offline haha changed the location good Xzone!  :P
        You're welcome. Thank you.

        Offlinejean

        • Newbie
        • *
        • Posts: 19
        • L2topzone Votes: 17
        • Servers reviews: 0
        • Reputation: +0/-0
        • L2topzone.com
          Re: Vote reward using total votes FIX
          « Reply #8 on: May 09, 2016, 05:30:26 AM »
          ok i just replaced your new solution and its working flewless thanks zone

          Offlinexzone

          • Read our rules
          • Hero Member
          • *****
          • Posts: 663
          • L2topzone Votes: 53
          • Servers reviews: 159
          • Reputation: +10480/-0
            • l2topzone
          Re: Vote reward using total votes FIX
          « Reply #9 on: May 09, 2016, 01:26:36 PM »
          ok i just replaced your new solution and its working flewless thanks zone
          You're welcome

          OfflineMarGaZeaS

          • Newbie
          • *
          • Posts: 6
          • L2topzone Votes: 79
          • Servers reviews: 0
          • Reputation: +0/-0
          • L2topzone.com
            Re: Vote reward using total votes FIX
            « Reply #10 on: May 11, 2016, 12:09:13 PM »
            i have this project with l2jacis 360 version. pls help me :D
            http://l2topzone.com/forum/l2-server-support-and-problems/9/vote-system-problem/25961/

            OfflineGryzla

            • Newbie
            • *
            • Posts: 2
            • L2topzone Votes: 0
            • Servers reviews: 0
            • Reputation: +0/-0
            • L2topzone.com
              Re: Vote reward using total votes FIX
              « Reply #11 on: June 12, 2016, 04:27:49 PM »
              Hello, i am getting this msg at gsconsole http://prntscr.com/bfkmsc
              I compiled w/o any errors but when the server is running , i am getting no announcements and no errors at gsconsole.

              Using l2acis 350rev and this http://pastebin.com/gy0Tk91W

              Tried many other methods but nothing , even these at this topic.

              Thank you .

              Offlinexzone

              • Read our rules
              • Hero Member
              • *****
              • Posts: 663
              • L2topzone Votes: 53
              • Servers reviews: 159
              • Reputation: +10480/-0
                • l2topzone
              Re: Vote reward using total votes FIX
              « Reply #12 on: June 13, 2016, 05:40:30 AM »
              Hello,
              The code we have provide in this example was only for info purpose. We never test that code. If you have test that code and is not working can be 2 problem:
              - code is old and is not working any more;
              - you have implemented wrong.
              My advice for you is to search a bit more to find other shared code for the vote reward or maybe read again this topic and see if you have missed any step from our tutorial.

              Good luck.

              OfflineGryzla

              • Newbie
              • *
              • Posts: 2
              • L2topzone Votes: 0
              • Servers reviews: 0
              • Reputation: +0/-0
              • L2topzone.com
                Re: Vote reward using total votes FIX
                « Reply #13 on: June 14, 2016, 06:00:17 PM »
                This code works for me for acis 350 , for those who want to use it , here's a pastebin link http://pastebin.com/LQe5ngcr

                Have a nice day.

                OfflineHaris Sevinc

                • Newbie
                • *
                • Posts: 3
                • L2topzone Votes: 3
                • Servers reviews: 0
                • Reputation: +0/-0
                • L2topzone.com
                  Re: Vote reward using total votes FIX
                  « Reply #14 on: October 11, 2016, 08:14:50 PM »
                  Hello,
                  Try to replace this line:

                  Code: [Select]
                  VoteHtmlPatch = http://l2topzone.com/totalvotes.php?id=9466
                  with

                  Code: [Select]
                  VoteHtmlPatch = http://l2topzone.com/tv.php?id=9466
                  And your java script:
                  Code: [Select]
                  if (Config.VOTE_REWARD_TOPZONE_ENABLE)
                  {
                  // for TopZone
                  if (inputLine.contains("<tr><td><div align=\"center\"><b><font style=\"font-size:14px;color:#018BC1;\""))
                  {
                  return Integer.valueOf(inputLine.split(">")[5].replace("</font", ""));
                  }
                  }

                  with:
                  Code: [Select]
                  if (Config.VOTE_REWARD_TOPZONE_ENABLE)
                  {
                  // for TopZone
                  return Integer.valueOf(inputLine);
                  }

                  Also to get votes from our website and avoid website DDOS protection you must use :
                  Code: [Select]
                  con.addRequestProperty("User-Agent", "L2TopZone");
                  Hope this will help you. Please replay if is working for you.


                  Hi there, it's started to working. Now the server can reach total votes, everything okay but its not seen player votes, givin error as " u didnt vote " but im voting.

                  and what you mean with " add this to java script " which folder is it?

                  Thanks
                  « Last Edit: October 11, 2016, 08:16:26 PM by Haris Sevinc »

                  Offlinexzone

                  • Read our rules
                  • Hero Member
                  • *****
                  • Posts: 663
                  • L2topzone Votes: 53
                  • Servers reviews: 159
                  • Reputation: +10480/-0
                    • l2topzone
                  Re: Vote reward using total votes FIX
                  « Reply #15 on: October 12, 2016, 03:18:48 AM »
                  Hello,
                  depend of what l2j are you using and what vote reward. If you are using eclipse for editing try to use global search.

                  Here you have some info about this search Eclipse find in project? - Stack Overflow

                  OfflineHaris Sevinc

                  • Newbie
                  • *
                  • Posts: 3
                  • L2topzone Votes: 3
                  • Servers reviews: 0
                  • Reputation: +0/-0
                  • L2topzone.com
                    Re: Vote reward using total votes FIX
                    « Reply #16 on: October 12, 2016, 09:10:15 AM »
                    hi,

                    im using l2j frozen. Do you mean gameserver.java? or java script engine or i have to find any file named java.script ?

                    edit: there is no file exist as java script
                    « Last Edit: October 12, 2016, 09:16:59 AM by Haris Sevinc »

                    Offlinexzone

                    • Read our rules
                    • Hero Member
                    • *****
                    • Posts: 663
                    • L2topzone Votes: 53
                    • Servers reviews: 159
                    • Reputation: +10480/-0
                      • l2topzone
                    Re: Vote reward using total votes FIX
                    « Reply #17 on: October 12, 2016, 10:38:03 AM »
                    Hello,
                    Must find a file like this AutoVoteRewardHandler.java in this file you can find lines we have post above, but you must have the source in order to edit this files.

                    OfflineHaris Sevinc

                    • Newbie
                    • *
                    • Posts: 3
                    • L2topzone Votes: 3
                    • Servers reviews: 0
                    • Reputation: +0/-0
                    • L2topzone.com
                      Re: Vote reward using total votes FIX
                      « Reply #18 on: October 12, 2016, 10:48:27 AM »
                      "
                      Quote
                      And your java script
                      " ah that u mean autovote.java? mmmh..

                      i just think about there is an other file named as java.script or smthng.

                      Okay thanks

                      Offlinexzone

                      • Read our rules
                      • Hero Member
                      • *****
                      • Posts: 663
                      • L2topzone Votes: 53
                      • Servers reviews: 159
                      • Reputation: +10480/-0
                        • l2topzone
                      Re: Vote reward using total votes FIX
                      « Reply #19 on: October 13, 2016, 02:35:23 AM »
                      You're welcome

                       

                      Sitemap