S
Shadow_
Guest
just told myself why don't share it, maybe its coding is not good enough because i wrote it a year ago, but it works perfectly, if you want to change the effect choose effect easy to see between another effects like this flaming orcs.
in creaturescripts/scripts/antibot.lua
add this script:
and antibot2.lua
in login.lua add those lines near the end.
and in creaturescripts.xml add those lines too.
now in data/talkactions/scripts
create new file with name antibot.lua and add this code inside.
and another file with name botnotations.lua and add this code inside it :
and in talkactions.xml
so you are done, now if you want to configure:
auto-ban options -- goto this file data/creaturescripts/antibot2.lua and in /talkactions/antibot.lua
monsters killed to start anti-bot check up -- goto this file data/creaturescripts/antibot.lua
Note : always keep the storages the same between the 3 files ( i know it is better to do a config but didn't bother as it works good ).
in creaturescripts/scripts/antibot.lua
add this script:
Lua:
-- Anti-Bot System by Carcoo (Shadow_)
local symbols = {"*", "^", "¿", "%", "&", "$"}
local timeToKick = 2 * 60 --2 minutes
local killStorage = 94727
local codeStorage = 94728
local kickStorage = 94729
local timesStorage = 94731
local storageForNotations = 94736
local notations = 10
local minMonstersToCheck = 600
local maxMonstersToCheck = 700
local random = math.random(minMonstersToCheck, maxMonstersToCheck)
function onKill(player, target)
if (not player:isPlayer()) or player:getGroup():getAccess() then
player:setStorageValue(killStorage, 0)
return true
end
if player:getStorageValue(kickStorage) > 1 and os.time() >= player:getStorageValue(kickStorage) then
local tmp = {killStorage, kickStorage, timesStorage, codeStorage}
for i = 1, #tmp do
player:setStorageValue(tmp[i], 0)
end
local timeNow = os.time()
if (isPlayer(cid) == FALSE) then
return true
end
if player:getStorageValue(storageForNotations) < notations then
if player:getStorageValue(storageForNotations) ~= -1 then
player:setStorageValue(storageForNotations, math.max(player:getStorageValue(storageForNotations) + 1))
else
player:setStorageValue(storageForNotations, 1)
end
player:teleportTo(player:getTown():getTemplePosition())
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format('You have been penalized and received a notation. Remember that after receiving 5 notations you will be banned. You currently have %d notations.', math.max(player:getStorageValue(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
return true
end
if target:isPlayer() then
return true
end
local stor = player:getStorageValue(killStorage)+1
if stor < random then
player:setStorageValue(killStorage, stor)
end
if (stor +1) >= random then
(player:getPosition()):sendMagicEffect(171)
player:say("[ANTI-BOT]", TALKTYPE_MONSTER_SAY)
local code, set = "", 0
set = math.random(1, 100000)
local s, e = 1, 1
for i = 1, string.len(set) do
code = (code == "" and string.sub(set, s, e) or code .. symbols[math.random(#symbols)] .. string.sub(set, s, e))
s, e = s + 1, e + 1
end
player:setStorageValue(codeStorage, set)
player:setStorageValue(kickStorage, os.time() + timeToKick)
player:setStorageValue(killStorage, 0)
player:say(""..player:getStorageValue(codeStorage).."", TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "[Anti-Bot]: Please say !antibot followed by your code without symbols.")
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Here is your code! !antibot "..player:getStorageValue(codeStorage).." Type in the numbers without symbols.")
end
return true
end
Lua:
-- Anti-Bot System by Carcoo (Shadow_)
local killStorage = 94727
local codeStorage = 94728
local kickStorage = 94729
local timesStorage = 94731
local storageForNotations = 94736
local notations = 10
local banDays = 1
local reason = "Botting."
function onThink(player, interval)
if player:getStorageValue(kickStorage) > 1 and os.time() >= player:getStorageValue(kickStorage) then
local tmp = {killStorage, kickStorage, timesStorage, codeStorage}
for i = 1, #tmp do
player:setStorageValue(tmp[i], 0)
end
local timeNow = os.time()
if (not player:isPlayer()) then
return true
end
if player:getStorageValue(storageForNotations) < notations then
if player:getStorageValue(storageForNotations) ~= -1 then
player:setStorageValue(storageForNotations, math.max(player:getStorageValue(storageForNotations) + 1))
else
player:setStorageValue(storageForNotations, 1)
end
player:teleportTo(player:getTown():getTemplePosition())
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format('You have been penalized and received a notation. Remember that after receiving 5 notations you will be banned. You currently have %d notations.', math.max(player:getStorageValue(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(reason)..", "..timeNow..", "..timeNow + (banDays * 86400) ..", 1)")
player:remove()
end
return true
end
return true
end
Lua:
player:registerEvent("Antibot")
player:registerEvent("Antibot2")
Code:
<event type="kill" name="Antibot" script="antibot.lua" />
<event type="think" name="Antibot2" script="antibot2.lua" />
create new file with name antibot.lua and add this code inside.
Lua:
-- Anti-Bot System by Carcoo (Shadow_)
local killStorage = 94727
local codeStorage = 94728
local kickStorage = 94729
local timesStorage = 94731
local times = 10
local symbols = {"*", "^", "¿", "%", "&", "$"}
local storageForNotations = 94736
local notations = 5
local banDays = 1
local reason = "Botting."
function onSay(player, words, param)
if player:getStorageValue(codeStorage) == 0 then
player:sendCancelMessage("Not yet.")
return false
elseif tonumber(param) == tonumber(player:getStorageValue(codeStorage)) then
player:setStorageValue(codeStorage, 0)
player:setStorageValue(kickStorage, 0)
player:setStorageValue(timesStorage, 0)
player:say('Correct Answer',TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "[Antibot]: Enjoy your time!")
return false
else
if player:getStorageValue(timesStorage) < 0 then player:setStorageValue(timesStorage, 0) end
player:setStorageValue(timesStorage, player:getStorageValue(timesStorage) + 1)
if player:getStorageValue(timesStorage) == times then
player:setStorageValue(codeStorage, 0)
player:setStorageValue(kickStorage, 0)
player:setStorageValue(timesStorage, 0)
local timeNow = os.time()
if (isPlayer(cid) == FALSE) then
return true
end
if player:getStorageValue(storageForNotations) < notations then
if player:getStorageValue(storageForNotations) ~= -1 then
player:setStorageValue(storageForNotations, math.max(player:getStorageValue(storageForNotations) + 1))
else
player:setStorageValue(storageForNotations, 1)
end
player:teleportTo(player:getTown():getTemplePosition())
player:sendTextMessage(MESSAGE_EVENT_ADVANCE, string.format('You have been penalized and received a notation. Remember that after receiving 5 notations you will be banned. You currently have %d notations.', math.max(player:getStorageValue(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(reason)..", "..timeNow..", "..timeNow + (banDays * 86400) ..", 1)")
player:remove()
end
return false
else
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "[Antibot]: You have " .. times - player:getStorageValue(timesStorage) .. " opportunities to try it again.")
player:say('Incorrect Answer',TALKTYPE_MONSTER_SAY)
player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Here is your code! !antibot "..player:getStorageValue(codeStorage).." Type in the numbers without symbols.")
return false
end
end
return false
end
Lua:
function onSay(player, words, param)
player:sendTextMessage(TALKTYPE_MONSTER_SAY, "You have".. player:getStorageValue(94735).." botting notations.")
return false
end
Code:
<talkaction words="!antibot" separator=" " script="antibot.lua"/>
<talkaction words="!notations" script="notations.lua"/>
auto-ban options -- goto this file data/creaturescripts/antibot2.lua and in /talkactions/antibot.lua
monsters killed to start anti-bot check up -- goto this file data/creaturescripts/antibot.lua
Note : always keep the storages the same between the 3 files ( i know it is better to do a config but didn't bother as it works good ).