Thread: Prevent Massing on Graham's Event Manager (Perfect for Event Driven Skills)

Page 1 of 3 123 LastLast
Results 1 to 10 of 21
  1. #1 Prevent events from being called if the user has moved/clicked another object 
    Registered Member
    Zaga's Avatar
    Join Date
    Jan 2010
    Posts
    514
    Thanks given
    89
    Thanks received
    47
    Rep Power
    149
    Purpose: To eliminate the need for process timers in skills
    Difficulty: 1
    Assumed Knowledge: Basic Java skills
    Classes Modified: Client.java, Event.java
    Tested On(if it applies): Devolution



    Say goodbye to process timers for your skills. You can now use Graham's Event Manager for almost any skill which requires a timer!

    In the past you would have to have variables to prevent massers from reaching the event call, because once they did there was no turning back.

    The solution I found was to assign an auth code to clicks on Packet 98 (The 'Walk On' packet), and then when the event was called, have it check the auth code and make sure the player hasn't moved or clicked an object since then.

    NOTE: To fully implement this with some skills you will need to call an auth refresh on teleports, item dropping, action button clicking, etc.

    Further explanation:
    Quote Originally Posted by Zaga View Post
    Lets say you use an event to decide when a player will get an ore while mining. If they send multiple requests to mine then all of those events will be called around the same time giving them fast ores.

    This is just an easy way to prevent massing without having to setup a whole bunch of variables like "isMining = true;"

    It will only call the last event, while all the ones before that will be ignored since they don't have the latest auth.


    How to implement it:

    1
    Code:
    public int clickauth;
    2
    This generates the auth code itself. It generates a number between 1 and 1 billion.
    Code:
      case 98: // walk on command
    
            Random r = new Random();
            clickauth = r.nextInt(1000000000);


    3
    In event.java
    Add this:
    Code:
        public Event(int tick, int auth) {
            this.authcode = auth;
            this.tick = tick;
            this.lastRun = System.currentTimeMillis();
        }
    Under
    Code:
        public Event(int tick) {
            this.tick = tick;
            this.lastRun = System.currentTimeMillis();
        }
    Also make sure you declare this in event.java as well.
    Code:
    public int authcode;
    And you're done.

    Now to use it do something like this...
    Code:
    server.registerEvent(new Event([TIMEHERE], clickauth) {
            public void execute() {
                if (clickauth == this.authcode){
                [Whatever you want to happen once the event is called...]
                }
                server.deregisterEvent(this);
                }
        });

    The blue is setting the auth code int in event.java.

    The green is your current auth code.
    And the red is simply comparing the auth code int in the event.java to your current one. If they match then the event is called as normal.

    Credits:
    Graham for supplying the Event Manager
    Zaga for implementing the Auth System


    Reply With Quote  
     

  2. #2  
    Registered Member
    Sanity's Avatar
    Join Date
    Dec 2008
    Posts
    2,062
    Thanks given
    22
    Thanks received
    362
    Rep Power
    762
    Good concept, but I would suggest using a long or an integer as apposed to a String, considering you are randomizing a long, then converting it to a String.

    If you do stay with a String, use the Object.equals(Object2) instead of "==".
    Reply With Quote  
     

  3. #3  
    Registered Member
    Zaga's Avatar
    Join Date
    Jan 2010
    Posts
    514
    Thanks given
    89
    Thanks received
    47
    Rep Power
    149
    Quote Originally Posted by Sanity View Post
    Good concept, but I would suggest using a long or an integer as apposed to a String, considering you are randomizing a long, then converting it to a String.

    If you do stay with a String, use the Object.equals(Object2) instead of "==".
    Good point, I'll make the changes now.


    Reply With Quote  
     

  4. #4  
    Donator


    Join Date
    Feb 2009
    Age
    30
    Posts
    2,128
    Thanks given
    261
    Thanks received
    280
    Rep Power
    563
    Nice thanks for this
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    May 2008
    Posts
    2,327
    Thanks given
    55
    Thanks received
    67
    Rep Power
    0
    how would they mass?
    Reply With Quote  
     

  6. #6  
    Registered Member
    Zaga's Avatar
    Join Date
    Jan 2010
    Posts
    514
    Thanks given
    89
    Thanks received
    47
    Rep Power
    149
    Quote Originally Posted by silabgarza View Post
    how would they mass?
    Lets say you use an event to decide when a player will get an ore while mining. If they send multiple requests to mine then all of those events will be called around the same time giving them fast ores.

    This is just an easy way to prevent massing without having to setup a whole bunch of variables like "isMining = true;"

    It will only call the last event, while all the ones before that will be ignored since they don't have the latest auth.


    Reply With Quote  
     

  7. #7  
    Banned

    Join Date
    Jul 2009
    Posts
    915
    Thanks given
    1
    Thanks received
    10
    Rep Power
    0
    wow, very nice.
    Reply With Quote  
     

  8. #8  
    :doge:

    Join Date
    Jan 2009
    Posts
    3,758
    Thanks given
    221
    Thanks received
    817
    Rep Power
    2116
    edit: nvm read wrong, nice work
    Reply With Quote  
     

  9. Thankful user:


  10. #9  
    Registered Member
    Join Date
    Aug 2009
    Posts
    76
    Thanks given
    4
    Thanks received
    4
    Rep Power
    19
    nice work bro, keep up the good work with sythril.
    Reply With Quote  
     

  11. #10  
    Registered Member
    Zaga's Avatar
    Join Date
    Jan 2010
    Posts
    514
    Thanks given
    89
    Thanks received
    47
    Rep Power
    149
    Quote Originally Posted by Wogpk View Post
    nice work bro, keep up the good work with sythril.
    Thanks.

    Good luck with Zion as well.


    Reply With Quote  
     

Page 1 of 3 123 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •