Nice However I don't like way you done it (Some tips: 1: from what I saw, all answer*.lua files are the same, just some values changed so maybe merge it to 1 file. 2: storages currently aren't configurable because in talkactions you are overriding them (dofile). 3: in answer10.lua there is sending message to channel with '15', but I don't see it declared anywhere. 4: globaevents would be faster instead starting events for every single player. 5: maybe make stamina configurable? Why it should break compatiblity
Reeepp+++ [;
local config = {
mintoanswer = 15, -- minutes to answer anti bot system....needs to be lower than delayAntiBot
delayAntiBot = 60, -- minutes of delay of delayAntiBot....needs to be higher than mintoanswer
channel = 6, -- what channel is BotShield on in channels.xml (make sure Answers.lua is on same channel)
toomany = "NOTICE: Failed! Too many attempts.", --failed too many attempts message
timedout = "NOTICE: Failed! Time limit has been reached.", --failed time limit message
failedmsg = " BotShield Alert!\n You received a notation for suspicious behavior.\n If you have complaints please report on our forum."
}
if(channelId == 6) then
if(channelId == config.channel) then
o must have missed that, thanks
<globalevent interval="60" event="script"><![CDATA[
function onThink(interval, lastExecution, thinkInterval)
for _, pid in ipairs(getPlayersOnline()) do
if(getPlayerStorageValue(cid, #STORAGE#) >= 0) then
-- something
end
end
return TRUE
end
]]></globalevent>
<?xml version="1.0" encoding="UTF-8"?>
<mod name="BotShield Pro" version="2.1" author="Syntax" contact="[email protected]" enabled="yes">
<description>
This mod will enable mid-level bot prevention in your server.
</description>
<talkaction words="2" script="Answers.lua" log="no"/>
<talkaction words="3" script="Answers.lua" log="no"/>
<talkaction words="4" script="Answers.lua" log="no"/>
<talkaction words="5" script="Answers.lua" log="no"/>
<talkaction words="6" script="Answers.lua" log="no"/>
<talkaction words="7" script="Answers.lua" log="no"/>
<talkaction words="8" script="Answers.lua" log="no"/>
<talkaction words="9" script="Answers.lua" log="no"/>
<talkaction words="10" script="Answers.lua" log="no"/>
<event type="joinchannel" name="AntiBotLogin" script="BotShield.lua"/>
<channel id="CHANNEL#" active="no" name="BotShield"/>
</mod>
local mintoanswer = 1 -- minutes to answer anti bot system....needs to be lower than delayAntiBot
local delayAntiBot = 3 -- minutes of delay of delayAntiBot....needs to be higher than mintoanswer
local storages = {first_num = 20123, second_num = 20124, result = 20125, answer = 20126, wrong_answers = 20129}
function onLogin(cid)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "BotShield = ON")
antiBotEvent = addEvent(antiBot,1000,{cid=cid})
return TRUE
end
function onLogout(cid)
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 playername = getPlayerName(cid)
if (getTilePzInfo(playerpos) == FALSE) and (getCreatureCondition(cid, CONDITION_INFIGHT) == TRUE) then
local first_num = math.random(1,5)
local second_num = math.random(1,5)
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, MESSAGE_INFO_DESCR,"NOTICE: ".. first_num .." + ".. second_num .."= ? You have ".. mintoanswer .." minute(s).")
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 = getPlayerStorageValue(cid,storages.first_num), getPlayerStorageValue(cid,storages.second_num), getPlayerStorageValue(cid,storages.result), getPlayerStorageValue(cid,storages.answer)
local wrong_answers = getPlayerStorageValue(cid,storages.wrong_answers)
if (wrong_answers > 3) then
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)
doAddNotation(getPlayerAccountId(cid), 3, 4, BotShield, auto)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"NOTICE: Failed! Too many attempts.")
doPlayerPopupFYI(cid, "You faild")
elseif (answer ~= 1 and result > 0) then
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)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "NOTICE: Failed! Time limit has been reached.")
doAddNotation(getPlayerAccountId(cid), 3, 4, "BotShield", auto)
doPlayerPopupFYI(cid, "You faild")
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.wrong_answers,0)
end
end
function onSay(cid, words, param, channel)
local storages = {first_num = 20123, second_num = 20124, result = 20125, answer = 20126, wrong_answers = 20129}
local first_num = getPlayerStorageValue(cid,storages.first_num)
local second_num = getPlayerStorageValue(cid,storages.second_num)
local result = getPlayerStorageValue(cid,storages.result)
local answer = getPlayerStorageValue(cid,storages.answer)
doCreatureSay(cid, words, 1)
if (answer ~= 1 and result > 0) then
if (words == result) then
if (getPlayerStorageValue(cid,storages.wrong_answers) <= 3) then
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Accepted.")
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, MESSAGE_INFO_DESCR,"Correct, too many attempts though, you may relog to prevent punishment if you aren't AFK.")
end
else
wrong_answers_now = getPlayerStorageValue(cid,storages.wrong_answers)
setPlayerStorageValue(cid,storages.wrong_answers,wrong_answers_now+1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR,"Incorrect. ".. getPlayerStorageValue(cid,storages.wrong_answers).."/3 failed attempts.")
end
end
end
ok i think i understand what your saying with globalevent, and could you pm me some mods of urs as an example, take out the important parts if you want, i just need to know how they all work and what all i can do with them
EDIT:
Ok few more questions, do I have to modify login.lua or how would i register it? and also this is correct right
<event type="login" name="AntiBotLogin" event="buffer/><![CDATA[
registerCreatureEvent(cid, "AntiBotJoinChannel")
_result = true
]]></event>