PYTHON Anti Flood (Client)

11/08/2014 19:24 WarXWar#1
Antiflood code for uichat.py

Code:
#----------------- MAIN CLASS -----------------------------------------------

	def __init__(self):
		ui.EditLine.__init__(self)
		self.SetWindowName("Chat Line")
		self.lastShoutTime = 0
		self.eventEscape = lambda *arg: None
		self.eventReturn = lambda *arg: None
		self.eventTab = None
		self.chatMode = chat.CHAT_TYPE_TALKING
		self.bCodePage = TRUE

		self.overTextLine = ui.TextLine()
		self.overTextLine.SetParent(self)
		self.overTextLine.SetPosition(-1, 0)
		self.overTextLine.SetFontColor(1.0, 1.0, 0.0)
		self.overTextLine.SetOutline()
		self.overTextLine.Hide()

		self.lastSentenceStack = []
		self.lastSentencePos = 0
		
		self.tempo = 0
		self.volte = 0

#--------------------------------------- OTHER FUNCTIONS -----------------

	def SendChat(self, text, type):
		import time
		net.SendChatPacket(text, type)
		self.tempo=int(time.clock())+15
		
	def __SendChatPacket(self, text, type):
		import player
		pg=player.GetName()
		if text[0] == '/':
			if pg.find("[") == -1:
				return
			
		if net.IsChatInsultIn(text):
			chat.AppendChat(chat.CHAT_TYPE_INFO, locale.CHAT_INSULT_STRING)
		else:
			if self.volte > 100:
				import time
				if int(time.clock()) > self.tempo:
					self.SendChat(text, type)
				else:
					chat.AppendChat(chat.CHAT_TYPE_INFO, "[Anti-Spam] Devi aspettare 15 secondi. Oppure riavvia il client.")
			else:
				self.volte=self.volte+1
				net.SendChatPacket(text, type)

uiinventory.py

Code:
#----------------- MAIN CLASS -----------------------------------------------

	def __init__(self):
		ui.ScriptWindow.__init__(self)
		self.questionDialog = None
		self.tooltipItem = None
		self.sellingSlotNumber = -1
		self.isLoaded = 0
		
		self.volte = 0
		self.tempo = 0


#--------------------------------------- OTHER FUNCTIONS -----------------

	def __SendUseItemToItemPacket(self, srcSlotPos, dstSlotPos):
		import time
		if int(time.clock()) > self.tempo:
			if uiPrivateShopBuilder.IsBuildingPrivateShop():
				chat.AppendChat(chat.CHAT_TYPE_INFO, locale.USE_ITEM_FAILURE_PRIVATE_SHOP)
			else:
				self.volte = self.volte + 1
				self.tempo = int(time.clock())+int(self.volte)/50
				net.SendItemUseToItemPacket(srcSlotPos, dstSlotPos)
		else:
			chat.AppendChat(chat.CHAT_TYPE_INFO, "[Anti-Switch] Devi aspettare " + str(int(self.volte) / 50) + " secondi! Oppure riavvia il client.")

Paride Spa...no aka The Lamer who use these tools to hack any server, say: goodbye!!!
11/08/2014 19:46 noahrmal#2
In my opinion this flooding is usefull because of getting kicked when you have got a black screen.