• 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++.
 
Cyk, could you take a look at the script?

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 botter = 15850 -- storageID for botter
 
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?) [SOLVED, I was testing with GM account, I didn't know the battle avoid flag was valid for the whole account]

What I want to do but don't know how:
● When player is tagged as botter, it will be for one month, then it clears
● When player is tagged as botter, it records in sql, just for website purposes, like "Tagged as botter in 23/march/2011 until 23/april/2011"
● Many of the players of my sv are brazilian, so I need an system in portuguese and english, it would be nice if in the first time anti-bot system check player, it ask if he preffers english or portuguese system, then he can change like !antibotlanguage portuguese, or !antibotlanguage english, so it gives player a storage, that script checks and send the correct language message!
 
Last edited:
Hey ho, cyk GOOOOO!!!!

b06f9715facd0cb5bcb739c952452416.gif


Could you just help with the onAttack thing then? So the script enter in action if player attacks a monster... The rest well.. I'll see...
 
Another reason it should be onAttack instead of onLogin

If player logs in at 21:50 and start using bot, system won't check him... With onAttack this will not happen :s
 
Back
Top