Welcome, guest! Please login or register.

    * Shoutbox

    RefreshHistory
    • B50: Sever error what happen
      May 22, 2018, 08:23:40 PM
    • The Soul: 10 years later
      May 21, 2018, 05:23:10 PM
    • The Soul: wow people are still here?
      May 21, 2018, 05:19:27 PM
    • Wilkooo: and apologies to the OG forum guys on behalf of that fudgewit dr house that pretty much killed this entire domain
      May 21, 2018, 04:14:28 PM
    • Wilkooo: shoutout to all those that played back in the beginning, all new people that hang around now seem to be pretty braindead
      May 21, 2018, 04:13:54 PM
    • Wilkooo: born sep 2016 - died whenever pink eggs resigned
      May 21, 2018, 04:11:29 PM
    • Wilkooo: Rip moparscape rsps
      May 21, 2018, 04:11:10 PM
    • puta loca: or what section can i ask this
      May 21, 2018, 05:45:08 AM
    • puta loca: does someoen has platinum ps v2 files?
      May 21, 2018, 05:44:59 AM
    • w azza 3: server down??
      May 21, 2018, 05:07:47 AM
    • charmie: rippppppppppppppppppppppppppppppppppppppppppppppp
      May 20, 2018, 09:03:41 PM
    • Tesco Value: eco reset? :o
      May 20, 2018, 08:54:27 PM
    • Tesco Value: aw is server down? :P
      May 20, 2018, 08:54:03 PM
    • mandmgalaxy: is the game down?
      May 20, 2018, 08:05:07 PM
    • bliss death: i believe 95% of the community disliked this change heavily as it came out of nowhere. and the fact you clear ironmen banks as well. terrible change. disappointed.
      May 20, 2018, 06:08:36 PM
    • bliss death: just wondering when the server is gonna be fixed and reverted
      May 20, 2018, 06:07:36 PM
    • Saltyspade10: I'll be back ;)
      May 15, 2018, 04:43:53 PM
    • Nunubuffs:[link]
      May 15, 2018, 12:06:25 PM
    • Nunubuffs: .info god
      May 15, 2018, 12:05:40 PM
    • Nunubuffs: Www.scaperune
      May 15, 2018, 12:05:25 PM

    Author Topic: Spam click protection?  (Read 665 times)

    0 Members and 1 Guest are viewing this topic.

    OfflineMiraak

    • First Time Poster
    • *
    • Posts: 3
    • Thanks: +0/-0
      • View Profile
    Spam click protection?
    « on: July 22, 2015, 04:05:04 AM »
    SOLVED, CAN SOMEONE EXPLAIN TO ME HOW TO ADD SPAM PROTECTION?
     I.e only allowing one click to be registered per second?



    Quote
    I'm using this class to handle sheap shearing

    Code: [Select]
    package ardi.model.npcs;

    import ardi.model.npcs.NPCHandler;
    import ardi.model.players.Client;
    import ardi.event.*;

    public class NPCTransform {

    public static void TransformNPC(final Client c, final int i, final int newId, int anim, final String forceChat, final String msg, final int addItem, final int timer , final int timer2) {
    if (c == null || i < 0 || NPCHandler.npcs[i].lastTransformed < 0)
    return;
    NPCHandler.npcs[i].transformTime = timer2*1000;
    //int npcId = NPCHandler.npcs[i].npcId;
    //final int x = NPCHandler.npcs[i].getX(), y = NPCHandler.npcs[i].getY();

    if (anim != -1)
    c.startAnimation(anim);

    CycleEventHandler.getSingleton().addEvent(c, new CycleEvent() {
    @Override
    public void execute(CycleEventContainer container) {
    if (addItem != -1)
    c.getItems().addItem(addItem, 1);
    if (forceChat.length() > 1)
    NPCHandler.npcs[i].forceChat(forceChat);
    if (msg.length() > 1)
    c.sendMessage(msg);
    NPCHandler.npcs[i].requestTransform(newId);

    container.stop();
    }
    @Override
    public void stop() {
    NPCHandler.npcs[i].lastTransformed = (int) System.currentTimeMillis();
    }
    }, timer);
    }
    }

    Originally provided here: https://www.rune-server.ee/runescape-development/google/snippets/507558-pi-transformnpc.html

    Here's my firstclick:

    Code: [Select]
    case FIRST_CLICK:
    c.npcClickIndex = c.inStream.readSignedWordBigEndian();
    c.npcType = NPCHandler.npcs[c.npcClickIndex].npcType;
    int id = NPCHandler.npcs[c.npcClickIndex].npcId;
    if (c.goodDistance(NPCHandler.npcs[c.npcClickIndex].getX(),
    NPCHandler.npcs[c.npcClickIndex].getY(), c.getX(),
    c.getY(), 2)) {
    c.turnPlayerTo(NPCHandler.npcs[c.npcClickIndex].getX(),
    NPCHandler.npcs[c.npcClickIndex].getY());
    NPCHandler.npcs[c.npcClickIndex].facePlayer(c.playerId);
    c.getActions().firstClickNpc(c.npcType);
    [B][COLOR="#FF0000"]switch(c.npcType){
    case 43:
    NPCTransform.TransformNPC(c,id,42, 893,"Baa!", "You obtain some wool.", 1737, 0 , 5);
    break;
    }[/COLOR][/B]

    c.sendMessage("List Id: " + Integer.toString(id));
    c.sendMessage("NPC Id: " + Integer.toString(c.npcType));
    c.sendMessage("NPC Id2: " + Integer.toString(NPCHandler.npcs[id].npcType));
    } else {

    The issue is, the code isn't working as expected. I suppose timer is for how long it should take for the sheep to revert back to woolen state and timer2 is the delay from click to transformation?
    This is what happens:



    a) The sheep can only be shorn once, even after reverting to its wooly state b)The sheep always returns to wooly state very rapidly
    I've tried playing around with the timer values but I can't seem to make sense of it.

    In addition can someone please clearly explain how this cycleevent/timing/container stuff works? Something tells me I'll be needing to use this a lot, but I just cant wrap my head around it right now.

    THANKS!
    « Last Edit: July 22, 2015, 08:00:08 AM by Miraak »
    RS2Ad banner

     

    Copyright © 2017 MoparScape. All rights reserved.
    Powered by SMFPacks SEO Pro Mod |
    SimplePortal 2.3.5 © 2008-2012, SimplePortal