• 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:
 
A system like this would indeed be awesome and handy for my server!
 
maybe use an addevent function with a storage value the problem would be making it say 5+3=? or you can be like anitbot:say three?
 
Hi guys :p, i think this idea is very useful, so i decided to try script it in Lua, here is my version.

-Give an action id to every tile that you cant be afk too mouch time (where the botters stand).
-Put this scripts in your data.

in movements/scripts

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, pos)
local status = getPlayerStorageValue(cid, status_storage)
local x = {cid=cid, pos=pos}
--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})
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)
doSendMagicEffect(x.pos, 2)
end
function doKick(x)
doRemoveCreature(x.cid)
end

in movements.xml add

Code:
<movevent event="StepIn" actionid="2525" script="antiafk.lua" />

set the action id and the script name.

in talkations/scripts create this file.

Code:
local answer_storage = 15923 --
local answered = 15924 --
local status_storage = 15925 --
function onSay(cid, words, param)
local question_done = getPlayerStorageValue(cid, status_storage)
local answer = getPlayerStorageValue(cid, answer_storage)
if question_done == 1 then
if param == "" .. answer .. "" then
setPlayerStorageValue(cid, answered, 1)
doPlayerSendTextMessage(cid,22,"Correct")
else
doPlayerSendCancel(cid, "Wrong.")
end
else
doPlayerSendCancel(cid, "No question done.")
end
end

and in talkations.xml add

Code:
<talkaction words="answer" script="antiafk.lua" />

ok, how does it work.
when the afk time have passed the player will get a msg with a ramdom operation, if he no answer correct he will be kicked.

note: i ve done it in a short time, there are some things that ill let other to fix em, temporally disable some parts of the code, wasnt done in TFS, so you should change some function names and parameters.

hope it help you.
 
+++ REP to Nahruto! Your still my favourite scripter :D

Edit: my SQL works fine again, so I can help you testing scripts for TFS again. :) So would be great if you could help me on msn or something to make it work perfectly for TFS :)
 
Last edited:

Similar threads

Back
Top