• 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!

Anti anti-afk system

ntmr

hi!
Senator
Joined
Jul 7, 2007
Messages
1,835
Reaction score
15
Location
Santa Catarina, Brazil
Hello :D

I was trying to create a system that I've seen on some servers, but not had success :(

The system works like this:

When the player step on a tile with a certain actionid, every 16 minutes he will receive a message like 'ANTI-BOT: 5+3=?' and he must respond in no more than 1 minute with something like '!antibot "8' or he will be kicked.

The it will kick the players that use "anti-afk" tools, to still training afk for more than 15 minutes.

I don't know if it can be done in Lua :wub:
 
ok here is a not tested version for TFS.

just change the movement file for this one.

Code:
local answer_storage = 15923 --
local answered = 15924 --
local status_storage = 15925 --
local afk_time = 15 -- afk time in minutes.
local time_to_answer = 30 --time to answer in seconds.
function onStepIn(cid, item, position, fromPosition)
local status = getPlayerStorageValue(cid, status_storage)
local x = {cid=cid, pos=position}
--if status == -1 then
addEvent(doQuestion, afk_time * 60 * 1000, x)
setPlayerStorageValue(cid, status_storage, 1)
--end
end
--function onStepOut(cid, item, pos)
--stopEvent(doQuestion)
--end
function doQuestion(x)
value1 = math.random(1,15)
value2 = math.random(1,15)
answer = value1 + value2
doPlayerSendTextMessage(x.cid,22,"" .. value1 .. " + " .. value2 .. " = ??")
setPlayerStorageValue(x.cid, answer_storage, answer)
addEvent(checkAnswer, time_to_answer * 1000, x)
end
function checkAnswer(x)
local answer_status = getPlayerStorageValue(x.cid, answered)
if answer_status == 1 then
setPlayerStorageValue(x.cid, answer_storage, -1)
setPlayerStorageValue(x.cid, status_storage, -1)
setPlayerStorageValue(x.cid, answered, -1)
doPlayerSendTextMessage(x.cid,22,"Starting time again")
doTeleportThing(x.cid, {x = x.pos.x, y = x.pos.y+1, z = x.pos.z}, FALSE)
addEvent(doTeleportBack, 2 * 1000, x)
else
setPlayerStorageValue(x.cid, answer_storage, -1)
setPlayerStorageValue(x.cid, status_storage, -1)
setPlayerStorageValue(x.cid, answered, -1)
addEvent(doKick, 5 * 1000, x)
end
end
function doTeleportBack(x)
doTeleportThing(x.cid, x.pos, FALSE)
doSendMagicEffect(x.pos, 2)
end
function doKick(x)
doRemoveCreature(x.cid)
end

i dint tested it (the TFS Version), so please someone tellme if it works.
 
when i try to step in to the tile i get this msg and i cant pass :S
The tile seems to be protected against unwanted intruders.
 
Already scripted before. Credits to Pening (The Poster) Credits to Yunie (The scripts) i bet.

creaturescripts.xml add:
Code:
<event type="login" name="AntiBotLogin" script="antibot.lua"/>
<event type="logout" name="AntiBotLogout" script="antibot.lua"/>
data/creaturescripts/scripts/antibot.lua
Lua:
-- configs
local mintoanswer = 2 -- minutes to answer anti bot system
local delayAntiBot = 30 -- minutes of delay of delayAntiBot
local maxgroupid = 1 -- groupid higher than this don't have antiBotSystem Activated
local prisionpos = {x=83,y=122,z=7} -- if don't answer, go to this pos
local prisionminutes = 10 -- time inside the prision
local templepos = {x=95, y=117, z=7} -- after the prisionminutes, back to this position (temple is recommended)
-- end configs

-- 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 onLogin(cid)
local prisioned = getPlayerStorageValue(cid,storages.prisioned)
if (prisioned == 1) then
local prisiontime = getPlayerStorageValue(cid,storages.prisiontime)
local timenow = os.time()
if (timenow >= prisiontime) then
setPlayerStorageValue(cid,storages.prisiontime,0)
setPlayerStorageValue(cid,storages.prisioned,0)
doTeleportThing(cid, templepos)
else
prisionEvent = addEvent(checkprisioned,1000,{cid=cid})
doTeleportThing(cid, prisionpos)
end
end


if (delayAntiBot <= mintoanswer) then
debugPrint("Error! Anti Bot System debugs: variable delayAntiBot need to be higher than mintoanswer.")
else
if (getPlayerGroupId(cid) <= maxgroupid) then
antiBotEvent = addEvent(antiBot,1000,{cid=cid})
else
doPlayerSendTextMessage(cid, 20, "People with group ID higher than ".. maxgroupid .." don't have this system.")
end
end
return TRUE
end

function onLogout(cid)
stopEvent(prisionEvent)
stopEvent(antiBotEvent)
stopEvent(checkAnswerEvent)


setPlayerStorageValue(cid,storages.first_num,0)
setPlayerStorageValue(cid,storages.second_num,0)
setPlayerStorageValue(cid,storages.result,0)
setPlayerStorageValue(cid,storages.answer,0)
setPlayerStorageValue(cid,storages.wrong_answers,0)
return TRUE
end

function antiBot(parameters)
local cid = parameters.cid

local playerpos = getCreaturePosition(cid)
local playerpz = getTilePzInfo(playerpos)
local playername = getPlayerName(cid)
local prisioned = getPlayerStorageValue(cid,storages.prisioned)
if (playerpz ~= 1 and prisioned ~= 1) then
local first_num = math.random(1,9)
local second_num = math.random(1,9)
local result = first_num+second_num

setPlayerStorageValue(cid,storages.first_num,first_num)
setPlayerStorageValue(cid,storages.second_num,second_num)
setPlayerStorageValue(cid,storages.result,result)
doPlayerSendTextMessage(cid, 20, "Yunie Anti Bot System: Hello, "..playername.."! You have ".. mintoanswer .." minute(s) to answer how much is ".. first_num .." + ".. second_num ..". To answer say: !antibot \"number.")
doPlayerSendTextMessage(cid, 20, "Yunie Anti Bot System: Example: 20+20 = 40, then you would say !antibot \"40.")
checkAnswerEvent = addEvent(checkAnswer,mintoanswer*60*1000,{cid=cid})
end
antiBotEvent = addEvent(antiBot,delayAntiBot*60*1000,{cid=cid})
end

function checkAnswer(parameters)
local cid = parameters.cid
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)
local wrong_answers = getPlayerStorageValue(cid,storages.wrong_answers)
if (wrong_answers > 3) then
doTeleportThing(cid, prisionpos)
setPlayerStorageValue(cid,storages.wrong_answers,0)
setPlayerStorageValue(cid,storages.first_num,0)
setPlayerStorageValue(cid,storages.second_num,0)
setPlayerStorageValue(cid,storages.result,0)
setPlayerStorageValue(cid,storages.answer,0)
setPlayerStorageValue(cid,storages.prisioned,1)
setPlayerStorageValue(cid,storages.prisiontime,os.time()+(prisionminutes*60))
doPlayerSendTextMessage(cid, 20, "Time limit! You had been prisioned for ".. prisionminutes .." minute(s) because answered many wrong times.")
prisionEvent = addEvent(checkprisioned,1000,{cid=cid})
else
if (answer ~= 1 and prisioned ~= 1 and result > 0) then
doTeleportThing(cid, prisionpos)
setPlayerStorageValue(cid,storages.first_num,0)
setPlayerStorageValue(cid,storages.second_num,0)
setPlayerStorageValue(cid,storages.result,0)
setPlayerStorageValue(cid,storages.answer,0)
setPlayerStorageValue(cid,storages.prisioned,1)
setPlayerStorageValue(cid,storages.wrong_answers,0)
setPlayerStorageValue(cid,storages.prisiontime,os.time()+(prisionminutes*60))
doPlayerSendTextMessage(cid, 20, "Time limit! You had been prisioned for ".. prisionminutes .." minute(s).")
prisionEvent = addEvent(checkprisioned,1000,{cid=cid})
else
setPlayerStorageValue(cid,storages.first_num,0)
setPlayerStorageValue(cid,storages.second_num,0)
setPlayerStorageValue(cid,storages.result,0)
setPlayerStorageValue(cid,storages.answer,0)
setPlayerStorageValue(cid,storages.prisioned,0)
setPlayerStorageValue(cid,storages.wrong_answers,0)
doPlayerSendTextMessage(cid, 20, "Yunie Anti Bot System: You are ok, but in some minutes you are going to be asked again.")
end
end
end

function checkprisioned(parameters)
local cid = parameters.cid
local prisioned = getPlayerStorageValue(cid,storages.prisioned)
local prisiontime = getPlayerStorageValue(cid,storages.prisiontime)
local timenow = os.time()
if (prisioned == 1) then
if (timenow >= prisiontime) then
doPlayerSendTextMessage(cid, 20, "You had completed your time here in the prision! You may now relog to go to the city.")
else
prisionEvent = addEvent(checkprisioned,1000,{cid=cid})
end
end
end

Code:
<talkaction words="!antibot" script="antibot.lua"/>

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
 
18:03 Yunie Anti Bot System: Hello, Testslayer! You have 2 minute(s) to answer how much is 3 + 7. To answer say: !antibot "number.
18:03 Yunie Anti Bot System: Example: 20+20 = 40, then you would say !antibot "40.
18:03 Yunie Anti Bot System: Wrong answer!
18:03 Yunie Anti Bot System: You had already got 0 wrong answers! The limit is 3.
18:03 Testslayer [1]: !antibot "10
18:05 Yunie Anti Bot System: Wrong answer!
18:05 Yunie Anti Bot System: You had already got 1 wrong answers! The limit is 3.
18:05 Testslayer [1]: !antibot 10
18:05 Yunie Anti Bot System: Wrong answer!
18:05 Yunie Anti Bot System: You had already got 2 wrong answers! The limit is 3.
18:05 Testslayer [1]: !antibot 1
18:05 Yunie Anti Bot System: Wrong answer!
18:05 Yunie Anti Bot System: You had already got 3 wrong answers! The limit is 3.
18:05 Testslayer [1]: !antibot "10
18:05 Time limit! You had been prisioned for 10 minute(s).

Lmao... my math sux or its not working
 
Back
Top