Thread: Spam click protection?

Results 1 to 2 of 2
  1. #1 Spam click protection? 
    Registered Member
    Join Date
    Jul 2015
    Posts
    21
    Thanks given
    2
    Thanks received
    2
    Rep Power
    11
    [size=24pt]SOLVED, CAN SOMEONE EXPLAIN TO ME HOW TO ADD SPAM PROTECTION?[/size]
    I.e only allowing one click to be registered per second?

    Code:
    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: http://www.rune-server.org/runescape...nsformnpc.html

    Here's my firstclick:

    Code:
    		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);
    					switch(c.npcType){
    						case 43:
    							NPCTransform.TransformNPC(c,id,42, 893,"Baa!", "You obtain some wool.", 1737, 0 , 5);
    						break;
    					}
    					
    					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!
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Mar 2015
    Posts
    138
    Thanks given
    22
    Thanks received
    13
    Rep Power
    13
    Timer2 is measured in milliseconds I would assume so perhaps try making the number 5 into 5000 which would be 5 seconds, 10000 for 10 seconds etc.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

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


User Tag List

Similar Threads

  1. Sheep Shearing emote lol
    By Itz Matthew ♥ in forum Requests
    Replies: 0
    Last Post: 09-13-2009, 03:59 AM
  2. Sheep successfully sold and server raped
    By Shobaky in forum Humor
    Replies: 7
    Last Post: 04-24-2009, 12:12 PM
  3. Sheep Shearing
    By Core in forum Help
    Replies: 1
    Last Post: 01-23-2009, 09:52 AM
  4. Quest Tab - PkPnts, Time And Players Online
    By dandy kid in forum Tutorials
    Replies: 5
    Last Post: 10-05-2008, 09:55 AM
  5. The Difference Between Time and Memory Efficiency
    By Oblakastouf in forum Tutorials
    Replies: 23
    Last Post: 11-17-2007, 10:28 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •