Ir para conteúdo

Featured Replies

Postado
  • Este é um post popular.

 

Como o nome do tópico diz, eu trouxe para vocês um sistema de anti bot.

Minha intenção é atualizar este código ao máximo, deixando o mesmo bastante customizável.

 

Quaisquer erros ou problemas por favor me deixe saber.

 

separador.png

ICNqazV.gif

 

Como ele funciona?

Após um jogador matar uma quantidade x de monstros, o sistema irá realizar uma verificação com ele para saber se o mesmo está ou não 100% afk.

Essa verificação é feita através de um channel que se abre após o jogador matar a quantidade de monstros, realizando uma pergunta para o jogador.

 

O que é possível configurar?

Praticamente tudo! Você também pode adicionar quantas perguntas desejar! Organizei o script para que qualquer um possa realizar as configurações que desejar. Confira:

ANTI_BOT_SYSTEM = {
	config = {
		minMonstersToCheck = 2, -- O sistema irá escolher aleatoriamente um número de monstros entre esses dois valores para verificar.
		maxMonstersToCheck = 4,
		channelId = 10, -- Id do channel que será aberto para realizar a verificação.
		timeToAnswer = 10, -- Quanto tempo em segundos o jogador tem para responder a verificação.
		monstersForNotCheck = {'rat', 'bug', 'tiger'}, -- Monstros que não serão verificados pelo sistema.
		notations = 3, -- Quantas notificações o jogador pode receber antes de ser banido.
		banDays = 1, -- Quantidade de dias o personagem vai ficar banido por utilizar bot.
		storageForNotations = 1222, -- Storage onde ficará salvo as notations.
		storageForOpenChat = 10383, -- Storage que permitira o chat ser aberto. (Aconselho não mudar).
	},
	questions = {
		[1] = {question = 'Digite quantas letras possui a palavra: Carro', answer = '5'},
		[2] = {question = 'O que significa Ying e Yang?', answer = 'bem e o mal'},
		[3] = {question = 'Qual é a cor do sol?', answer = 'amarelo'},
		--[numero seguinte] = {question = 'pergunta', answer = 'resposta'},
	},
	cache = {
		players = {
			--[player:getId()] = {count = 1}
		},
		question = 0,
	},
	messages = {
		reason = {msg = 'Você foi banido por utilizar bot 100% AFK.'},
		notation = {msg = 'Você foi penalizado e recebeu um notificação. Lembre-se que após receber 3 notificações você será banido. Você possui %d notificações no momento.', type = MESSAGE_EVENT_ADVANCE},
		attention = {msg = '[Anti-Bot] Atenção! Você só possui %d segundos para responder a verificação.', type = TALKTYPE_CHANNEL_O},
		channel_enter = {msg = '[Anti-Bot] Você está sobre suspeitas de uso aplicativos não autorizados.\nPor favor, confirme a verificação a seguir, você possui %d segundos para isso.', type = TALKTYPE_CHANNEL_O},
		channel_close = {msg = '[Anti-Bot] Para sua segurança, não é possivel fechar este channel antes da verificação. Por favor responda o que lhe foi perguntado para que não seja penalizado.', type = TALKTYPE_CHANNEL_O},
		wrong_answer = {msg = '[Anti-Bot] Resposta errada, por favor tente novamente.', type = TALKTYPE_CHANNEL_O},
		correct_answer = {msg = '[Anti-Bot] Você respondeu corretamente, obrigado e bom jogo! Você já pode fechar este channel.', type = TALKTYPE_CHANNEL_O},
		unconfirmed = {msg = 'Você não realizou a verificação corretamente, por isso você foi penalizado. Este channel já pode ser fechado.', type = TALKTYPE_CHANNEL_O},
	}
}

 

Tudo dentro desses espaços pode ser configurado sem nenhuma complicação!

 

Instalação:

 

Vá na pasta creaturescript/scripts do seu servidor e crie um arquivo com o nome de antibot.lua e adicione o seguinte conteúdo:

--[[
## SCRIPT BY: Pedriinz ##
## CONTACT SKYPE: pedrosz4 ##
]]

ANTI_BOT_SYSTEM = {
	config = {
		minMonstersToCheck = 2, -- O sistema irá escolher aleatoriamente um número de monstros entre esses dois valores para verificar.
		maxMonstersToCheck = 4,
		channelId = 10, -- Id do channel que será aberto para realizar a verificação.
		timeToAnswer = 10, -- Quanto tempo em segundos o jogador tem para responder a verificação.
		monstersForNotCheck = {'rat', 'bug', 'tiger'}, -- Monstros que não serão verificados pelo sistema.
		notations = 3, -- Quantas notificações o jogador pode receber antes de ser banido.
		banDays = 1, -- Quantidade de dias o personagem vai ficar banido por utilizar bot.
		storageForNotations = 1222, -- Storage onde ficará salvo as notations.
		storageForOpenChat = 10383, -- Storage que permitira o chat ser aberto. (Aconselho não mudar).
	},
	questions = {
		[1] = {question = 'Digite quantas letras possui a palavra: Carro', answer = '5'},
		[2] = {question = 'O que significa Ying e Yang?', answer = 'bem e o mal'},
		[3] = {question = 'Qual é a cor do sol?', answer = 'amarelo'},
		--[numero seguinte] = {question = 'pergunta', answer = 'resposta'},
	},
	cache = {
		players = {
			--[player:getId()] = {count = 1}
		},
		question = 0,
	},
	messages = {
		reason = {msg = 'Você foi banido por utilizar bot 100% AFK.'},
		notation = {msg = 'Você foi penalizado e recebeu um notificação. Lembre-se que após receber 3 notificações você será banido. Você possui %d notificações no momento.', type = MESSAGE_EVENT_ADVANCE},
		attention = {msg = '[Anti-Bot] Atenção! Você só possui %d segundos para responder a verificação.', type = TALKTYPE_CHANNEL_O},
		channel_enter = {msg = '[Anti-Bot] Você está sobre suspeitas de uso aplicativos não autorizados.\nPor favor, confirme a verificação a seguir, você possui %d segundos para isso.', type = TALKTYPE_CHANNEL_O},
		channel_close = {msg = '[Anti-Bot] Para sua segurança, não é possivel fechar este channel antes da verificação. Por favor responda o que lhe foi perguntado para que não seja penalizado.', type = TALKTYPE_CHANNEL_O},
		wrong_answer = {msg = '[Anti-Bot] Resposta errada, por favor tente novamente.', type = TALKTYPE_CHANNEL_O},
		correct_answer = {msg = '[Anti-Bot] Você respondeu corretamente, obrigado e bom jogo! Você já pode fechar este channel.', type = TALKTYPE_CHANNEL_O},
		unconfirmed = {msg = 'Você não realizou a verificação corretamente, por isso você foi penalizado. Este channel já pode ser fechado.', type = TALKTYPE_CHANNEL_O},
	}
}

function vericationBot(cid)
	local player = Player(cid)
	local timeNow = os.time()
	if not player then
		return true
	end

	if not ANTI_BOT_SYSTEM.cache.players[player:getId()] or ANTI_BOT_SYSTEM.cache.players[player:getId()].verified == false then
		return true
	else
		player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.unconfirmed.msg, ANTI_BOT_SYSTEM.messages.unconfirmed.type, ANTI_BOT_SYSTEM.config.channelId)
		ANTI_BOT_SYSTEM.cache.players[player:getId()] = nil
		if player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations) < ANTI_BOT_SYSTEM.config.notations then
			if player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations) ~= -1 then
				player:setStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations, math.max(player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations) + 1))
			else
				player:setStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations, 1)
			end
			player:teleportTo(player:getTown():getTemplePosition())
			player:sendTextMessage(ANTI_BOT_SYSTEM.messages.notation.type, string.format(ANTI_BOT_SYSTEM.messages.notation.msg, math.max(player:getStorageValue(ANTI_BOT_SYSTEM.config.storageForNotations))))
		else
			player:teleportTo(player:getTown():getTemplePosition())
			db.query("INSERT INTO `account_bans` (`account_id`, `reason`, `banned_at`, `expires_at`, `banned_by`) VALUES (" ..getAccountNumberByPlayerName(player:getName())..", "..db.escapeString(ANTI_BOT_SYSTEM.messages.reason.msg)..", "..timeNow..", "..timeNow + (ANTI_BOT_SYSTEM.config.banDays * 86400) ..", 1)")
			player:remove()
		end
	end
	return true
end

function onKill(creature, target)
	local targetMonster = target:getMonster()
	local player = creature:getPlayer()
	local random = math.random(ANTI_BOT_SYSTEM.config.minMonstersToCheck, ANTI_BOT_SYSTEM.config.maxMonstersToCheck)
	if not targetMonster then
		return true
	end
	if isInArray(ANTI_BOT_SYSTEM.config.monstersForNotCheck, targetMonster:getName():lower()) then
		return true
	end
	if not ANTI_BOT_SYSTEM.cache.players[player:getId()] then
		ANTI_BOT_SYSTEM.cache.players[player:getId()] = {count = 1, verified = false}
	else
		if ANTI_BOT_SYSTEM.cache.players[player:getId()].count >= random then
			ANTI_BOT_SYSTEM.cache.players[player:getId()] = {count = math.max(ANTI_BOT_SYSTEM.cache.players[player:getId()].count), verified = true}
			player:openChannel(ANTI_BOT_SYSTEM.config.channelId)
			player:getPosition():sendMagicEffect(CONST_ME_TUTORIALSQUARE)
		else
			ANTI_BOT_SYSTEM.cache.players[player:getId()] = {count = math.max(ANTI_BOT_SYSTEM.cache.players[player:getId()].count) + 1, verified = false}
		end
	end

	return true
end

Após feito isso, abre o arquivo creaturescript/creaturescript.xml e adicione esta linha:

 

	<!-- Anti Bot by Pedriinz -->
	<event type="kill" name="AntiBot" script="antibot.lua" />	

Feito isso, abra o arquivo: creaturescript/scripts/others/login.lua e registre o script com a tag:

'AntiBot',

Exemplo:

local events = {
    'ElementalSpheresOverlords',
    'BigfootBurdenVersperoth',
    'Razzagorn',
    'Shatterer',
    'Zamulosh', 
    'The Hunger',
    'AntiBot',
}

Agora, abre o arquivo chatchannels/chatchannels.xml e adicione a seguinte tag:

<channel id="10" name="Anti Bot" public="1" script="antibot.lua" />

Lembre-se que o ID deve ser o mesmo que você configurou no script principal lá em cima.

 

Agora abra a pasta chatchannels/scripts/ crie um script chamado antibot.lua e adicione:

function onJoin(player)
    if not player then
        return true
    end

    if not ANTI_BOT_SYSTEM.cache.players[player:getId()] or ANTI_BOT_SYSTEM.cache.players[player:getId()].verified == false then
        player:popupFYI('You can\'t open this channel.')
        return false
    end

    addEvent(function() player:sendChannelMessage("", string.format(ANTI_BOT_SYSTEM.messages.channel_enter.msg, ANTI_BOT_SYSTEM.config.timeToAnswer), ANTI_BOT_SYSTEM.messages.channel_enter.type, ANTI_BOT_SYSTEM.config.channelId) end, 300)
    addEvent(function()
            local random = math.random(#ANTI_BOT_SYSTEM.questions)
            player:sendChannelMessage("", ANTI_BOT_SYSTEM.questions[random].question, TALKTYPE_CHANNEL_R1, ANTI_BOT_SYSTEM.config.channelId)
            ANTI_BOT_SYSTEM.cache.question = random
        end, 2000)  
    addEvent(vericationBot, ANTI_BOT_SYSTEM.config.timeToAnswer * 1000, player:getId())
    return true
end

function onLeave(player)
    if not player then
        return true
    end

    if ANTI_BOT_SYSTEM.cache.players[player:getId()] then
        player:openChannel(ANTI_BOT_SYSTEM.config.channelId)
        addEvent(function() player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.channel_close.msg, ANTI_BOT_SYSTEM.messages.channel_close.type, ANTI_BOT_SYSTEM.config.channelId) end, 300)
    end
end

function onSpeak(player, type, message)

    player:sendChannelMessage(player:getName(), message, TALKTYPE_CHANNEL_Y, ANTI_BOT_SYSTEM.config.channelId)

    if message ~= ANTI_BOT_SYSTEM.questions[ANTI_BOT_SYSTEM.cache.question].answer then
       addEvent(function() player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.wrong_answer.msg, ANTI_BOT_SYSTEM.messages.wrong_answer.type, ANTI_BOT_SYSTEM.config.channelId) end, 300)
    else
        addEvent(function() player:sendChannelMessage("", ANTI_BOT_SYSTEM.messages.correct_answer.msg, ANTI_BOT_SYSTEM.messages.correct_answer.type, ANTI_BOT_SYSTEM.config.channelId) end, 300)
        ANTI_BOT_SYSTEM.cache.players[player:getId()] = nil
    end
    return false
end

Pronto! O seu antibot foi instalado com sucesso!

O código foi totalmente feito por mim, então os créditos são meus.

 

Qualquer sugestão para melhorias, por favor poste para que eu possa fazer :3

Abraços! B-)

  • Respostas 21
  • Visualizações 5.5k
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • local config = { ['qual a cor do sol?'] = {anwser = 'amarelo'} } local msgs = getnewmessages('Anti Bot') for i = 0, msgs.count - 1 do local question = config[msgs[0].text] if question then

  • ? Não polua meu tópico com seus comentários. Acredite, você não está me ensinando nada.

  • ? kk

Postado
  • Autor
9 minutos atrás, vankk disse:

local config = {
	['qual a cor do sol?'] = {anwser = 'amarelo'}
}

local msgs = getnewmessages('Anti Bot')
for i = 0, msgs.count - 1 do
	local question = config[msgs[0].text]
	if question then
        say(question.anwser)
    end
end

?

 

?

Não polua meu tópico com seus comentários.

Acredite, você não está me ensinando nada.

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo