Nome: Oneshot's Anti-bot
Autor: Oneshot
Tipo: Sistema
Descrição
Este é um sistema de anti-bot simples, que envia um código numérico de 6 dígitos para cada jogador online e pede para que, através de um comando, este código de verificação seja ativado. O jogador tem um limite de tempo para fazer isso, e caso não faça, este é banido por um tempo configurável ou então, preso em um certo lugar do mapa.
Instalação
1. Em data/lib, crie um arquivo chamado antibot.lua e cole o conteúdo abaixo:
ANTIBOT_STORAGE_1 = 109001 ANTIBOT_STORAGE_2 = 109002 ANTIBOT_STORAGE_3 = 109003 ANTIBOT_TYPE = 2 -- [1] = Banimento, [2] = Prisão ANTIBOT_DURATION = 120 -- Em segundos ANTIBOT_DURATION_DELAY = 10 -- Em segundos ANTIBOT_MESSAGE = "[Oneshot's Anti-bot]\nSeu código de verificação é %s, responda através do comando !antibot, caso contrário, será ".. (ANTIBOT_TYPE == 1 and "banido" or "preso") ..".\nVocê têm %s segundos." ANTIBOT_BAN_TIME = 24 * 60 * 60 ANTIBOT_PRISON = {x = 1019, y = 867, z = 7} ANTIBOT_PRISON_FROMPOSITION = {x = 1018, y = 865, z = 7} ANTIBOT_PRISON_TOPOSITION = {x = 1020, y = 869, z = 7} ANTIBOT_PRISON_DURATION = 3 * 60 * 60 ANTIBOT_TEMPLE = {x = 1027, y = 912, z = 5} function AntiBot(cid) if not isCreature(cid) then return end local time = getCreatureStorage(cid, ANTIBOT_STORAGE_1) local answer = getCreatureStorage(cid, ANTIBOT_STORAGE_2) if getPlayerAccess(cid) >= 3 or not(getPlayerAccountManager(cid) == MANAGER_NONE) then return end if isInRange(getThingPosition(cid), ANTIBOT_PRISON_FROMPOSITION, ANTIBOT_PRISON_TOPOSITION) then return end if time == -1 and answer == -1 then return end if os.time() >= time then doCreatureSetStorage(cid, ANTIBOT_STORAGE_1, -1) doCreatureSetStorage(cid, ANTIBOT_STORAGE_2, -1) doBroadcastMessage("[ANTI-BOT] O jogador ".. getCreatureName(cid) .." foi ".. (ANTIBOT_TYPE == 1 and "banido" or "preso") .." por uso de bot.") if ANTIBOT_TYPE == 1 then doAddAccountBanishment(getPlayerGUID(cid), 0, (os.time() + ANTIBOT_BAN_TIME), 12, 3, "[ANTI-BOT]") doRemoveCreature(cid) else doTeleportThing(cid, ANTIBOT_PRISON) doCreatureSetStorage(cid, ANTIBOT_STORAGE_3, os.time() + ANTIBOT_PRISON_DURATION) addEvent(function() if isCreature(cid) then doTeleportThing(cid, ANTIBOT_TEMPLE) end end, ANTIBOT_PRISON_DURATION * 1000) end else doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, ANTIBOT_MESSAGE:format(answer, (time - os.time()))) addEvent(AntiBot, ANTIBOT_DURATION_DELAY * 1000, cid) end end
2. Crie um arquivo chamado antibot.lua em data/globalevents/scripts, cole o conteúdo abaixo
function onThink(interval) for _, cid in ipairs(getPlayersOnline()) do local answer = math.random(100000, 999999) doCreatureSetStorage(cid, ANTIBOT_STORAGE_1, os.time() + ANTIBOT_DURATION) doCreatureSetStorage(cid, ANTIBOT_STORAGE_2, answer) AntiBot(cid) end return true end
Adicione a seguinte linha em globalevents.xml
<globalevent name="antibot" interval="900" event="script" value="antibot.lua"/>
3. Crie um arquivo em data/creaturescripts/scripts, cole o conteúdo abaixo
function onLogin(cid) local time = getCreatureStorage(cid, ANTIBOT_STORAGE_1) local answer = getCreatureStorage(cid, ANTIBOT_STORAGE_2) if answer == -1 then return true end if isInRange(getThingPosition(cid), ANTIBOT_PRISON_FROMPOSITION, ANTIBOT_PRISON_TOPOSITION) then if os.time() > getCreatureStorage(cid, ANTIBOT_STORAGE_3) then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Seu tempo de prisão acabou.") doTeleportThing(cid, ANTIBOT_TEMPLE) else doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você ainda está preso por uso de bot.") end return true end if os.time() > ANTIBOT_STORAGE_1 then doCreatureSetStorage(cid, ANTIBOT_STORAGE_1, os.time() + ANTIBOT_DURATION) return true end AntiBot(cid) return true end
Adicione a seguinte linha em seu creaturescripts.xml
<event type="login" name="Antibot" event="script" value="antibot.lua"/>
4. Crie um arquivo chamado antibot.lua em data/talkactions/scripts, cole o conteúdo abaixo
function onSay(cid, words, param, channel) param = tonumber(param) or "" local time = getCreatureStorage(cid, ANTIBOT_STORAGE_1) local answer = getCreatureStorage(cid, ANTIBOT_STORAGE_2) if time == -1 and answer == -1 then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "O anti-bot não está ativado.") return true end if param == "" then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Digite uma senha de verificação válida.") return true end if param ~= answer then doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você digitou a senha incorreta. Digite corretamente, caso contrário, será banido.") return true end doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Ótimo! Você digitou a resposta correta. O anti-bot foi desativado.") doCreatureSetStorage(cid, ANTIBOT_STORAGE_1, -1) doCreatureSetStorage(cid, ANTIBOT_STORAGE_2, -1) return true end
Adicione a seguinte linha em seu talkactions.xml
<talkaction words="!antibot" event="script" value="antibot.lua"/>
Você pode fazer várias configurações na lib do sistema
ANTIBOT_STORAGE_1 = 109001 ANTIBOT_STORAGE_2 = 109002 ANTIBOT_STORAGE_3 = 109003 ANTIBOT_TYPE = 2 -- [1] = Banimento, [2] = Prisão ANTIBOT_DURATION = 120 -- Em segundos ANTIBOT_DURATION_DELAY = 10 -- Em segundos ANTIBOT_MESSAGE = "[Oneshot's Anti-bot]\nSeu código de verificação é %s, responda através do comando !antibot, caso contrário, será ".. (ANTIBOT_TYPE == 1 and "banido" or "preso") ..".\nVocê têm %s segundos." ANTIBOT_BAN_TIME = 24 * 60 * 60 ANTIBOT_PRISON = {x = 1019, y = 867, z = 7} ANTIBOT_PRISON_FROMPOSITION = {x = 1018, y = 865, z = 7} ANTIBOT_PRISON_TOPOSITION = {x = 1020, y = 869, z = 7} ANTIBOT_PRISON_DURATION = 3 * 60 * 60 ANTIBOT_TEMPLE = {x = 1027, y = 912, z = 5}
Como a duração do ban, a posição da prisão, o tempo de prisão, dentre outras coisas.
Como não consegui fazer funcionar o banimento de um jogador só na versão 0.3.6pl1, sendo isto possível apenas na 0.4.0, resolvi colocar para o tipo de banimento ser na conta toda.
Abraços.