• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

[LUA] Anti cave-bot system (really easy and cool!) - Paying $10 USD

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,764
Solutions
1
Reaction score
227
Location
Chile, Santiago
Well the idea is to activate an event between 22:00 pm to 9:00 am which ask all players online a random questions (summations, multiplications or divisions) every 1 hour, the player have 3 minutes to answer the question, if he doesn't answer, he is teleported to jail (x,y,z) for 3 hours.

Send me PM with the script (tested and working 100% fine)... And also give me your paypal email address to pay you.

Also rep++.
 
It miss the part of multiplications and divisions xD

Change
LUA:
local result = first_num+second_num

With
LUA:
local result = math.ceil((math.random(3) == 1 and first_num + second_num or math.random(3) == 2 and first_num * second_num or first_num / second_num))
 
Cykotitan my dear, is it easy to make this script work like this?

Player don't answer to the anti-bot, then script change SQL column "botter" from 0 to 1

So, player can hunt with bot if he wants to, but I'll make a separate highscores for botters and non-botters, also maybe a "[botter]" onLook, u know haha, that would be lovely :], just change botter from 0 to 1, the rest I'll try to do here
 
Cykotitan my dear, is it easy to make this script work like this?

Player don't answer to the anti-bot, then script change SQL column "botter" from 0 to 1

So, player can hunt with bot if he wants to, but I'll make a separate highscores for botters and non-botters, also maybe a "[botter]" onLook, u know haha, that would be lovely :], just change botter from 0 to 1, the rest I'll try to do here
LUA:
db.executeQuery('UPDATE players SET botter=1 WHERE id='..getPlayerGUID(cid))
 
[20:52:09.406] [Error - CreatureScript Interface]
[20:52:09.406] data/creaturescripts/scripts/antibot.lua:onLogin
[20:52:09.406] Description:
[20:52:09.406] data/creaturescripts/scripts/antibot.lua:28: attempt to compare number with string
[20:52:09.406] stack traceback:
[20:52:09.406] data/creaturescripts/scripts/antibot.lua:28: in function <data/creaturescripts/scripts/antibot.lua:14>

Bug?
 
21:04 Yunie Anti Bot System: Wrong answer!
21:04 Yunie Anti Bot System: You had already got 7 wrong answers! The limit is 3.


only wrong answer, even with correct answer and don't prision after 3 wrong answers

21:02 Yunie Anti Bot System: Hello, Dankoo! You have 3 minute(s) to answer how much is 2 * 4. To answer say: !antibot 'number.
21:02 Yunie Anti Bot System: Example: 20+20 = 40, then you would say !antibot '40.
21:03 Yunie Anti Bot System: Wrong answer!
21:03 Yunie Anti Bot System: You had already got 0 wrong answers! The limit is 3.
21:03 Tavaren Knight [64]: !antibot '8
21:03 Yunie Anti Bot System: Wrong answer!
21:03 Yunie Anti Bot System: You had already got 1 wrong answers! The limit is 3.
21:03 Tavaren Knight [64]: !antibot 8
21:04 Yunie Anti Bot System: Wrong answer!
21:04 Yunie Anti Bot System: You had already got 2 wrong answers! The limit is 3.
21:04 Tavaren Knight [64]: !antibot '8'

Got up to 7 wrong answers without being prisioned as well '-'

-- edit --

21:12 Time limit! You have been tagged as BOTTER because you answered wrong too many times.

I received this message after some time, but the good answer isn't working.. The script is setting botter to 1, so far almost so good :}

:3
 
Last edited:
Cyk, idea:

Player can easily make an elfbot script to bypass this system, it would be great if something like this was implemented:

If player answet the anti-bot system in less than 1 second, then record on a log

22:32 Player Dankoo answered the anti-bot system in less than one second, (or even better, in 0.32 seconds)

also, the talkaction script is working properly for everyone? :s

LUA:
-- local variables
local storages = {first_num = 20123, second_num = 20124, result = 20125, answer = 20126, prisioned = 20127, prisiontime = 20128, wrong_answers = 20129}
-- end local variables

function onSay(cid, words, param)
local first_num, second_num, result, answer, prisioned = getPlayerStorageValue(cid,storages.first_num), getPlayerStorageValue(cid,storages.second_num), getPlayerStorageValue(cid,storages.second_num), getPlayerStorageValue(cid,storages.result), getPlayerStorageValue(cid,storages.answer), getPlayerStorageValue(cid,storages.prisioned)


param = tonumber(param)

if (prisioned ~= 1 and answer ~= 1 and result > 0) then
if (param == result) then
if (getPlayerStorageValue(cid,storages.wrong_answers) <= 3) then
doPlayerSendTextMessage(cid, 20, "Yunie Anti Bot System: Right answer, thank you for answering.")
setPlayerStorageValue(cid,storages.wrong_answers,0)
setPlayerStorageValue(cid,storages.answer,1)
setPlayerStorageValue(cid,storages.first_num,0)
setPlayerStorageValue(cid,storages.second_num,0)
setPlayerStorageValue(cid,storages.result,0)
else
doPlayerSendTextMessage(cid, 20, "Yunie Anti Bot System: Right answer, but you had already answered more than 3 wrong times.")
end
else
doPlayerSendTextMessage(cid, 20, "Yunie Anti Bot System: Wrong answer!")
wrong_answers_now = getPlayerStorageValue(cid,storages.wrong_answers)
setPlayerStorageValue(cid,storages.wrong_answers,wrong_answers_now+1)
doPlayerSendTextMessage(cid, 20, "Yunie Anti Bot System: You had already got ".. getPlayerStorageValue(cid,storages.wrong_answers).." wrong answers! The limit is 3.")
end
end
end

I've searched in the original topic and ppl was complying and nobody found a solution for wrong asnwer thing

aaand, another thing...

the multiplication and division stuff is buggy: You have 3 minute(s) to answer how much is 3 / 4.

The answer is 0.75, but you can't write this value in teh talkaction

oh for fuck sake I'm having a fucking brainstorm here :}

we could combine this script with the afk script, so player can bot at the trainers or stay away if he wants to:

http://otland.net/f81/0-4-0-3-6-afk-system-100739/

If player is AFK, skip check :}}}}}
 
Last edited:
Then the division should be replaced, and about the 2*8 or 2+8 part it should be like "2asdh+29ak" and say "don't consider the letters) and the answer should be 31, and the letters should be random letters.
 
b06f9715facd0cb5bcb739c952452416.gif
 
LUA:
local time = {22, 08}

local mintoanswer = 3 -- minutes to answer anti bot system
local delayAntiBot = 60 -- minutes of delay of delayAntiBot
local maxgroupid = 1 -- groupid higher than this don't have antiBotSystem Activated
local prisonpos = {x=494, y=538, z=9} -- if don't answer, go to this pos
local prisonminutes = 180 -- time inside the prison
local templepos = {x=498, y=541, z=9} -- after the prisonminutes, back to this position (temple is recommended)

local storages = {first_num = 3, second_num = 4, result = 5, answer = 6, prisoned = 7, prisontime = 8, wrong_answers = 9}

prisonEvent, antiBotEvent, checkAnswerEvent = {}, {}, {}

local function checkprisoned(cid)
	if getCreatureStorage(cid, storages.prisoned) == 1 then
		if os.time() >= getCreatureStorage(cid, storages.prisontime) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You had completed your time here in the prison! You may now relog to go to the city.')
		else
			prisonEvent[cid] = addEvent(checkprisoned, 1000, cid)
		end
	end
end

local function checkAnswer(cid)
	local wrong = getCreatureStorage(cid, storages.wrong_answers)
	if wrong > 3 or (getCreatureStorage(cid, storages.answer) ~= 1 and getCreatureStorage(cid, storages.prisoned) ~= 1 and getCreatureStorage(cid, storages.result) ~= -1) then
		doTeleportThing(cid, prisonpos)
		doCreatureSetStorage(cid, storages.prisoned, 1)
		doCreatureSetStorage(cid, storages.prisontime, os.time() + prisonminutes * 60)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, wrong > 3 and 'Time limit! You have been prisoned for '.. prisonminutes ..' minute(s) because you answered wrong too many times.' or 'Time limit! You had been prisoned for '.. prisonminutes ..' minute(s).')
		prisonEvent[cid] = addEvent(checkprisoned, 1000, cid)
	else
		doCreatureSetStorage(cid, storages.prisoned)
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Anti Bot System: You are ok, but in some minutes you are going to be asked again.')
	end
	doCreatureSetStorage(cid, storages.first_num)
	doCreatureSetStorage(cid, storages.second_num)
	doCreatureSetStorage(cid, storages.result)
	doCreatureSetStorage(cid, storages.answer)
	doCreatureSetStorage(cid, storages.wrong_answers)
end

local function append(l)
	local s = ''
	for i = 1, math.random(l) do
		s = s .. string.char(math.random(2) == 1 and math.random(65, 90) or math.random(97, 122))
	end
	return s
end

local function antiBot(cid)
	if not getTileInfo(getThingPos(cid)).protection and getCreatureStorage(cid, storages.prisoned) ~= 1 then
		local r, first, second = math.random(3), math.random(9), math.random(9)
		r = r==1 and '+' or r==2 and '*' or '-'
		local s = append(2) .. first .. append(4) .. r .. append(2) .. second .. append(4)
		doCreatureSetStorage(cid, storages.first_num, first)
		doCreatureSetStorage(cid, storages.second_num, second)
		doCreatureSetStorage(cid, storages.result, math.ceil(loadstring('return '..first..r..second)()))
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Anti Bot System: Hello, '..getCreatureName(cid)..'! You have '.. mintoanswer ..' minute(s) to answer how much is '.. s ..'. To answer say: !antibot number.')
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Anti Bot System: Example: 20+20 = 40, then you would say !antibot \'40.')
		checkAnswerEvent[cid] = addEvent(checkAnswer, mintoanswer*60*1000, cid)
	end
	antiBotEvent[cid] = addEvent(antiBot, delayAntiBot*60*1000, cid)
end

function onLogin(cid)
	registerCreatureEvent(cid, 'Logout')
	if getCreatureStorage(cid, storages.prisoned) == 1 then
		if os.time() >= getCreatureStorage(cid, storages.prisontime) then
			doCreatureSetStorage(cid, storages.prisontime)
			doCreatureSetStorage(cid, storages.prisoned)
			doTeleportThing(cid, templepos)
		else
			prisonEvent[cid] = addEvent(checkprisoned, 1000, cid)
			doTeleportThing(cid, prisonpos)
		end
	end

	local n = tonumber(os.date('%H'))
	if (n >= time[1] or n < time[2]) and getPlayerGroupId(cid) <= maxgroupid then
		antiBotEvent[cid] = addEvent(antiBot, 1000, cid)
	end
	return true
end

function onLogout(cid)
	if prisonEvent[cid] then
		stopEvent(prisonEvent[cid])
		prisonEvent[cid] = nil
	end
	if antiBotEvent[cid] then
		stopEvent(antiBotEvent[cid])
		antiBotEvent[cid] = nil
	end
	if checkAnswerEvent[cid] then
		stopEvent(checkAnswerEvent[cid])
		checkAnswerEvent[cid] = nil
	end
	doCreatureSetStorage(cid, storages.first_num)
	doCreatureSetStorage(cid, storages.second_num)
	doCreatureSetStorage(cid, storages.result)
	doCreatureSetStorage(cid, storages.answer)
	doCreatureSetStorage(cid, storages.wrong_answers)
	return true
end
Code:
	<event type="login" name="Login" event="script" value="antibot.lua"/>
	<event type="logout" name="Logout" event="script" value="antibot.lua"/>
Code:
local storages = {first_num = 3, second_num = 4, result = 5, answer = 6, prisoned = 7, prisontime = 8, wrong_answers = 9}

function onSay(cid, words, param)
	param = tonumber(param)
	if not param then
		return true
	end

	local result = getCreatureStorage(cid, storages.result)
	if getCreatureStorage(cid, storages.prisoned) ~= 1 and getCreatureStorage(cid, storages.answer)  ~= 1 and result ~= -1 then
		if getCreatureStorage(cid, storages.wrong_answers) == 3 then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Anti Bot System: You have answered wrong too many times.")
		elseif param == result then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Anti Bot System: Right answer, thank you for answering.")
			doCreatureSetStorage(cid, storages.wrong_answers)
			doCreatureSetStorage(cid, storages.answer, 1)
			doCreatureSetStorage(cid, storages.first_num)
			doCreatureSetStorage(cid, storages.second_num)
			doCreatureSetStorage(cid, storages.result)
		else
			local wrong = math.max(0, getCreatureStorage(cid, storages.wrong_answers)) + 1
			doCreatureSetStorage(cid, storages.wrong_answers, wrong)
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, wrong == 3 and "Anti Bot System: You have answered wrong too many times." or "Anti Bot System: Wrong answer, you have " .. 3 - wrong .. " more tries.")
		end
	end
	return true
end
 
Cykotitan, I've tried this:

LUA:
local time = {22, 08}
 
local mintoanswer = 5 -- minutes to answer anti bot system
local delayAntiBot = 60 -- minutes of delay of delayAntiBot
local maxgroupid = 1 -- groupid higher than this don't have antiBotSystem Activated
local prisonpos = {x=494, y=538, z=9} -- if don't answer, go to this pos
local prisonminutes = 180 -- time inside the prison
local botter = 15850 -- time inside the prison
local templepos = {x=498, y=541, z=9} -- after the prisonminutes, back to this position (temple is recommended)
 
local storages = {first_num = 3, second_num = 4, result = 5, answer = 6, prisoned = 7, prisontime = 8, wrong_answers = 9}
 
prisonEvent, antiBotEvent, checkAnswerEvent = {}, {}, {}
 
local function checkprisoned(cid)
	if getCreatureStorage(cid, storages.prisoned) == 1 then
		if os.time() >= getCreatureStorage(cid, storages.prisontime) then
			doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You had completed your time here in the prison! You may now relog to go to the city.')
		else
			prisonEvent[cid] = addEvent(checkprisoned, 1000, cid)
		end
	end
end
 
local function checkAnswer(cid)
	local wrong = getCreatureStorage(cid, storages.wrong_answers)
	if wrong > 5 or (getCreatureStorage(cid, storages.answer) ~= 1 and getCreatureStorage(cid, storages.prisoned) ~= 1 and getCreatureStorage(cid, storages.result) ~= -1) then
		doCreatureSetStorage(cid, botter, 1)
		db.query('UPDATE players SET botter=1 WHERE id='..getPlayerGUID(cid))
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, wrong > 5 and 'Time limit! You have been tagged as BOTTER because you answered wrong too many times.' or 'Time limit! You had been tagged as BOTTER.')
	else
		doCreatureSetStorage(cid, storages.prisoned)
	end
	doCreatureSetStorage(cid, storages.first_num)
	doCreatureSetStorage(cid, storages.second_num)
	doCreatureSetStorage(cid, storages.result)
	doCreatureSetStorage(cid, storages.answer)
	doCreatureSetStorage(cid, storages.wrong_answers)
end
 
local function append(l)
	local s = ''
	for i = 1, math.random(l) do
		s = s .. string.char(math.random(2) == 1 and math.random(65, 90) or math.random(97, 122))
	end
	return s
end
 
local function antiBot(cid)
	if getCreatureStorage(cid, botter) == -1 and getCreatureStorage(cid, 38417) == -1 then
		local r, first, second = math.random(3), math.random(9), math.random(9)
		r = r==1 and '+' or r==2 and '*' or '-'
		local s = append(2) .. first .. append(4) .. r .. append(2) .. second .. append(4)
		doCreatureSetStorage(cid, storages.first_num, first)
		doCreatureSetStorage(cid, storages.second_num, second)
		doCreatureSetStorage(cid, storages.result, math.ceil(loadstring('return '..first..r..second)()))
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Anti Bot System: You have '.. mintoanswer ..' minutes to answer how much is '.. s ..'. (Desconsider the letters) To answer say: !antibot number (In case you want to be AFK or train skills, use !afk on)')
		doPlayerSendTextMessage(cid, 22, 'Anti Bot System: Example: P8VM-O2W, desconsidering the letters it is 8-2, wich is 6, then you would say !antibot 6  ... Where* multiply / divide - subtract + sum')
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Anti Bot System: Você tem '.. mintoanswer ..' minutos para responder quanto é '.. s ..'. (Desconsidere as letras) Para responder digite: !antibot número (Caso deseje treinar skill ou ficar afk utilize !afk on)')
		doPlayerSendTextMessage(cid, 22, 'Anti Bot System: Exemplo: P8VM-O2W, desconsiderando as letras dá 8-2, que é igual a 6, então você deve responder !antibot 6  ... Sendo * multiplicar / dividir - subtrair + somar')
		checkAnswerEvent[cid] = addEvent(checkAnswer, mintoanswer*60*1000, cid)
	end
	antiBotEvent[cid] = addEvent(antiBot, delayAntiBot*60*1000, cid)
end
 
function onAttack(cid, target)
	local n = tonumber(os.date('%H'))
	if (n >= time[1] or n < time[2]) and getPlayerGroupId(cid) <= maxgroupid then
  if not isPlayer(target) then
  if getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE and getCreatureStorage(cid, 38417) == -1 then
	antiBotEvent[cid] = addEvent(antiBot, 1000, cid)
	end
	end
  end
  
return true
end
 
function onLogin(cid)
	registerCreatureEvent(cid, 'Logout')
	if getCreatureStorage(cid, storages.prisoned) == 1 then
		if os.time() >= getCreatureStorage(cid, storages.prisontime) then
			doCreatureSetStorage(cid, storages.prisontime)
			doCreatureSetStorage(cid, storages.prisoned)
			doTeleportThing(cid, templepos)
		else
			prisonEvent[cid] = addEvent(checkprisoned, 1000, cid)
			doTeleportThing(cid, prisonpos)
		end
	end
	return true
end
 
function onLogout(cid)
	if prisonEvent[cid] then
		stopEvent(prisonEvent[cid])
		prisonEvent[cid] = nil
	end
	if antiBotEvent[cid] then
		stopEvent(antiBotEvent[cid])
		antiBotEvent[cid] = nil
	end
	if checkAnswerEvent[cid] then
		stopEvent(checkAnswerEvent[cid])
		checkAnswerEvent[cid] = nil
	end
	doCreatureSetStorage(cid, storages.first_num)
	doCreatureSetStorage(cid, storages.second_num)
	doCreatureSetStorage(cid, storages.result)
	doCreatureSetStorage(cid, storages.answer)
	doCreatureSetStorage(cid, storages.wrong_answers)
	return true
end
LUA:
<event type="attack" name="Check_Bot" script="bot_check.lua"/>

What I've tried to change:

Removed check at login
Removed prison, added storage for botter + alter column botter in MySQL
Removed check if player is afk
Removed check if player is already a botter
Added check at attack monster (don't check if attack player)

Problems:
Script isn't activating when attack monster
Player can logout with battle (I just realized it now, I think it have something to do with this script, can someone confirm?)

I know you've alredy done way TOO much, but... Any ideas about what might be the problem?
 
Back
Top