Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?xml version="1.0" encoding="UTF-8"?>
- <mod name="Anti CaveBot System" version="4.0" author="Syntax" contact="[email protected]" enabled="no">
- <config name="AntiAFK_lib"><![CDATA[
- function checkCaveBotter(player)
- for _,cid in ipairs(getPlayersOnline()) do
- if getCreatureName(cid) == player or player == "all" then
- local target = getCreatureTarget(cid)
- local not_checked, not_qued = getCreatureStorage(cid, "AFK_Check") < 0, getCreatureStorage(cid, "AFK_Que") < 0
- if(target)then
- if(isMonster(target) and not_checked and not_qued)then
- if(getCreatureName(target) ~= "Training Monk")then
- addEvent(queCheck, 1000, cid)
- doCreatureSetStorage(cid, "AFK_Que", 1)
- end
- end
- end
- end
- end
- end
- function isInDanger(cid)
- local spec = getSpectators(getThingPosition(cid), 7, 7)
- if(spec)then
- for _, sid in ipairs(spec) do
- if(getCreatureTarget(sid) == cid)then
- return true
- end
- end
- end
- return false
- end
- function queCheck(cid)
- if(isPlayer(cid))then
- if(getCreatureStorage(cid, "AFK_Que") > 0) and hasClient(cid) then
- if(not isInDanger(cid))then
- local createPos = getClosestFreeTile(cid, getThingPosition(cid), true, false)
- if doSetItemActionId(doCreateItem(8046, 1, createPos), 90000 + getPlayerGUID(cid)) then
- doCreatureSetStorage(cid, "AFK_Check", 1)
- doCreatureSetStorage(cid, "AFK_Que", -1)
- addEvent(doSendBotterWarning, 5 * 60 * 1000, cid, 5)
- return loopCheck(cid, "Hunting Bonus!", createPos)
- end
- else
- return addEvent(queCheck, 1000, cid)
- end
- end
- end
- doCreatureSetStorage(cid, "AFK_Check", -1)
- doCreatureSetStorage(cid, "AFK_Que", -1)
- end
- function enforcePosition(cid, pos)
- if getDistanceBetween(getThingPosition(cid), pos) > 7 then
- doCreatureSetNoMove(cid, true)
- else
- doCreatureSetNoMove(cid, false)
- end
- end
- function loopCheck(cid, text, pos)
- local checked = getCreatureStorage(cid, "AFK_Check") > 0
- if(isPlayer(cid) and hasClient(cid) and checked)then
- --remove field
- local field = getTileItemByType(pos, ITEM_TYPE_MAGICFIELD)
- if(field.itemid > 0) then
- doRemoveItem(field.uid)
- end
- --remove any on the tile
- local invisItem = getTileItemById(pos, 8046)
- if (invisItem.uid > 0) then
- doRemoveItem(invisItem.uid)
- doSetItemActionId(doCreateItem(8046, 1, pos), 90000 + getPlayerGUID(cid))
- else
- doSetItemActionId(doCreateItem(8046, 1, pos), 90000 + getPlayerGUID(cid))
- end
- doSendMagicEffect(pos, CONST_ME_FIREWORK_YELLOW)
- addEvent(doSendMagicEffect, 600, pos, CONST_ME_FIREWORK_YELLOW)
- addEvent(doSendMagicEffect, 1200, pos, CONST_ME_FIREWORK_YELLOW)
- addEvent(doSendMagicEffect, 1800, pos, CONST_ME_FIREWORK_YELLOW)
- addEvent(doSendMagicEffect, 2400, pos, CONST_ME_FIREWORK_YELLOW)
- addEvent(doSendMagicEffect, 3000, pos, CONST_ME_FIREWORK_YELLOW)
- doSteerCreature(cid, pos)
- addEvent(doSteerCreature, 1600, cid)
- addEvent(doSteerCreature, 2400, cid)
- addEvent(enforcePosition, 1200, cid, pos)
- addEvent(enforcePosition, 2400, cid, pos)
- doCreatureSay(cid, choose(text, "Free Stamina!", "Look here to receive a reward!", "Look Here!"), TALKTYPE_MONSTER_YELL, false, cid, pos)
- addEvent(loopCheck, 3800, cid, text, pos)
- else
- local id = getTileItemById(pos, 8046)
- if(id.itemid > 0)then
- doRemoveItem(id.uid)
- end
- end
- end
- function doSendBotterWarning(cid, timeToKill)
- if not isPlayer(cid) or not hasClient(cid) then
- return true
- end
- if getCreatureStorage(cid, "AFK_Check") ~= 1 then
- return true
- end
- if timeToKill > 0 then
- doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, "You are suspected of botting afk.\nPunishment will occur in "..timeToKill.." minutes.\nUse the bonus near you to avoid punishment.")
- addEvent(doSendBotterWarning, 60 * 1000, cid, timeToKill-1)
- elseif (getCreatureSkullType(cid) == SKULL_NONE) then
- doCreatureSetSkullType(cid, SKULL_WHITE)
- addEvent(doBroadcastMessage, 3000, getCreatureName(cid) .. " has been white-skulled for botting afk!", MESSAGE_STATUS_WARNING)
- doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You lose 7 minutes of stamina for botting afk.")
- doPlayerSetStamina(cid, getPlayerStamina(cid) - 7)
- addEvent(doSendBotterWarning, 60 * 1000, cid, timeToKill)
- else
- addEvent(doSendBotterWarning, 60 * 1000, cid, timeToKill)
- end
- end
- ]]></config>
- <talkaction words="/botters" access="2" event="buffer"><![CDATA[
- local str = "Players with bonuses:\n\n"
- local online = getPlayersOnline()
- if(online)then
- for _,pid in ipairs(online) do
- if getCreatureStorage(pid, "AFK_Check") == 1 then
- str = str..getPlayerName(pid).."\n"
- end
- end
- end
- doShowTextDialog(cid, 2599, str)
- ]]></talkaction>
- <talkaction words="/cavebot" access="2" event="buffer"><![CDATA[
- domodlib('AntiAFK_lib')
- if isPlayer(getCreatureByName(param)) or param == "all" then
- checkCaveBotter(param)
- elseif(param =="clear")then
- local online = getPlayersOnline()
- if(online)then
- for _,pid in ipairs(online) do
- if getCreatureStorage(pid, "AFK_Check") == 1 then
- doCreatureSetStorage(pid, "AFK_Check", -1)
- end
- end
- end
- else
- doPlayerSendCancel(cid, "Player does not exist!")
- end
- ]]></talkaction>
- <globalevent name="ACB_Check" interval="9000000" event="buffer"><![CDATA[
- domodlib('AntiAFK_lib')
- addEvent(checkCaveBotter, math.random(1000, 60000), "all")
- ]]></globalevent>
- <event type="login" name="ACB_Login" event="buffer"><![CDATA[
- doCreatureSetStorage(cid, "AFK_Check", -1)
- registerCreatureEvent(cid, "ACB_Direction")
- registerCreatureEvent(cid, "ACB_Look")
- ]]></event>
- <event type="target" name="ACB_Direction" event="script"><![CDATA[
- function removeSparkle(pos)
- local id = getTileItemById(pos, 8046)
- if(id.itemid > 0)then
- doRemoveItem(id.uid)
- end
- end
- function onTarget(cid, target)
- if(isMonster(target)) and (getCreatureName(target) ~= "Training Monk") and (getCreatureStorage(cid, "AFK_Check") <= 0)then
- local item = doCreateItem(8046, 1, getThingPosition(cid))
- if(item)then
- doSetItemActionId(item, 90000)
- end
- addEvent(removeSparkle, 1000, getThingPosition(cid))
- end
- return true
- end
- ]]></event>
- <event type="look" name="ACB_Look" event="script"><![CDATA[
- function onLook(cid, thing, position, lookDistance)
- local item = getTileItemById(position, 8046)
- if(item.itemid > 0)then
- if (item.actionid == 90000) then
- for _,user in ipairs(getChannelUsers(14)) do
- doPlayerSendChannelMessage(user, "", getCreatureName(cid).." suspected of bypassing bonus chests!", TALKTYPE_CHANNEL_W, 14)
- end
- doRemoveItem(item.uid)
- end
- if item.actionid <= 90000 or item.actionid >= 100000 then
- return true
- end
- domodlib('AntiAFK_lib')
- if getPlayerGUID(cid) == (item.actionid - 90000) then
- doPlayerSetStamina(cid, getPlayerStamina(cid) + 10)
- doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You received 10 extra minutes of stamina!")
- doCreatureSetStorage(cid, "AFK_Check", -1)
- doRemoveItem(item.uid)
- else
- doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "This is not your hunting bonus.")
- end
- end
- return true
- end
- ]]></event>
- <channel id="11" name="Anti-Afk Log" access="3" override="yes"/>
- <movevent type="StepOut" itemid="8046" event="script"><![CDATA[
- function onStepOut(cid, item, position, fromPosition)
- if isPlayer(cid) and item.actionid == 90000 then
- doRemoveItem(item.uid)
- end
- return true
- end
- ]]></movevent>
- <movevent type="RemoveItem" itemid="8046" event="script"><![CDATA[
- function onRemoveItem(moveItem, tileItem, position, cid)
- if moveItem.uid > 0 then
- doRemoveItem(moveItem.uid)
- doSetItemActionId(doCreateItem(8046, 1, position), moveItem.actionid)
- end
- return true
- end
- ]]></movevent>
- </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement