Advertisement
Cavitt

Untitled

Apr 25th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 8.02 KB | None | 0 0
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <mod name="Anti CaveBot System" version="4.0" author="Syntax" contact="[email protected]" enabled="no">
  3.     <config name="AntiAFK_lib"><![CDATA[
  4.         function checkCaveBotter(player)
  5.             for _,cid in ipairs(getPlayersOnline()) do
  6.                 if getCreatureName(cid) == player or player == "all" then
  7.                     local target = getCreatureTarget(cid)
  8.                     local not_checked, not_qued = getCreatureStorage(cid, "AFK_Check") < 0, getCreatureStorage(cid, "AFK_Que") < 0
  9.                     if(target)then
  10.                         if(isMonster(target) and not_checked and not_qued)then
  11.                             if(getCreatureName(target) ~= "Training Monk")then
  12.                                 addEvent(queCheck, 1000, cid)
  13.                                 doCreatureSetStorage(cid, "AFK_Que", 1)
  14.                             end
  15.                         end
  16.                     end
  17.                 end
  18.             end
  19.         end
  20.         function isInDanger(cid)
  21.             local spec = getSpectators(getThingPosition(cid), 7, 7)
  22.             if(spec)then
  23.                 for _, sid in ipairs(spec) do
  24.                     if(getCreatureTarget(sid) == cid)then              
  25.                         return true
  26.                     end
  27.                 end
  28.             end
  29.             return false
  30.         end
  31.         function queCheck(cid)
  32.             if(isPlayer(cid))then
  33.                 if(getCreatureStorage(cid, "AFK_Que") > 0) and hasClient(cid) then
  34.                     if(not isInDanger(cid))then
  35.                         local createPos = getClosestFreeTile(cid, getThingPosition(cid), true, false)
  36.                         if doSetItemActionId(doCreateItem(8046, 1, createPos), 90000 + getPlayerGUID(cid)) then
  37.                             doCreatureSetStorage(cid, "AFK_Check", 1)
  38.                             doCreatureSetStorage(cid, "AFK_Que", -1)
  39.                             addEvent(doSendBotterWarning, 5 * 60 * 1000, cid, 5)
  40.                             return loopCheck(cid, "Hunting Bonus!", createPos)
  41.                         end
  42.                     else
  43.                         return addEvent(queCheck, 1000, cid)
  44.                     end
  45.                 end
  46.             end
  47.             doCreatureSetStorage(cid, "AFK_Check", -1)
  48.             doCreatureSetStorage(cid, "AFK_Que", -1)
  49.         end
  50.         function enforcePosition(cid, pos)
  51.             if getDistanceBetween(getThingPosition(cid), pos) > 7 then
  52.                 doCreatureSetNoMove(cid, true)
  53.             else
  54.                 doCreatureSetNoMove(cid, false)
  55.             end
  56.         end
  57.         function loopCheck(cid, text, pos)
  58.             local checked = getCreatureStorage(cid, "AFK_Check") > 0
  59.             if(isPlayer(cid) and hasClient(cid) and checked)then
  60.            
  61.                 --remove field
  62.                 local field = getTileItemByType(pos, ITEM_TYPE_MAGICFIELD)
  63.                 if(field.itemid > 0) then
  64.                     doRemoveItem(field.uid)
  65.                 end
  66.                
  67.                 --remove any on the tile
  68.                 local invisItem = getTileItemById(pos, 8046)
  69.                 if (invisItem.uid > 0) then
  70.                     doRemoveItem(invisItem.uid)
  71.                     doSetItemActionId(doCreateItem(8046, 1, pos), 90000 + getPlayerGUID(cid))
  72.                 else
  73.                     doSetItemActionId(doCreateItem(8046, 1, pos), 90000 + getPlayerGUID(cid))
  74.                 end
  75.                
  76.                 doSendMagicEffect(pos, CONST_ME_FIREWORK_YELLOW)
  77.                 addEvent(doSendMagicEffect, 600, pos, CONST_ME_FIREWORK_YELLOW)
  78.                 addEvent(doSendMagicEffect, 1200, pos, CONST_ME_FIREWORK_YELLOW)
  79.                 addEvent(doSendMagicEffect, 1800, pos, CONST_ME_FIREWORK_YELLOW)
  80.                 addEvent(doSendMagicEffect, 2400, pos, CONST_ME_FIREWORK_YELLOW)
  81.                 addEvent(doSendMagicEffect, 3000, pos, CONST_ME_FIREWORK_YELLOW)
  82.                
  83.                 doSteerCreature(cid, pos)
  84.                 addEvent(doSteerCreature, 1600, cid)
  85.                 addEvent(doSteerCreature, 2400, cid)
  86.                 addEvent(enforcePosition, 1200, cid, pos)
  87.                 addEvent(enforcePosition, 2400, cid, pos)
  88.                
  89.                 doCreatureSay(cid, choose(text, "Free Stamina!", "Look here to receive a reward!", "Look Here!"), TALKTYPE_MONSTER_YELL, false, cid, pos)
  90.  
  91.                 addEvent(loopCheck, 3800, cid, text, pos)
  92.             else
  93.                 local id = getTileItemById(pos, 8046)
  94.                 if(id.itemid > 0)then
  95.                     doRemoveItem(id.uid)
  96.                 end
  97.             end
  98.         end
  99.         function doSendBotterWarning(cid, timeToKill)
  100.             if not isPlayer(cid) or not hasClient(cid) then
  101.                 return true
  102.             end
  103.             if getCreatureStorage(cid, "AFK_Check") ~= 1 then
  104.                 return true
  105.             end
  106.             if timeToKill > 0 then
  107.                 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.")
  108.                 addEvent(doSendBotterWarning, 60 * 1000, cid, timeToKill-1)
  109.             elseif (getCreatureSkullType(cid) == SKULL_NONE) then
  110.                 doCreatureSetSkullType(cid, SKULL_WHITE)
  111.                 addEvent(doBroadcastMessage, 3000, getCreatureName(cid) .. " has been white-skulled for botting afk!", MESSAGE_STATUS_WARNING)
  112.                 doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You lose 7 minutes of stamina for botting afk.")
  113.                 doPlayerSetStamina(cid, getPlayerStamina(cid) - 7)
  114.                 addEvent(doSendBotterWarning, 60 * 1000, cid, timeToKill)
  115.             else
  116.                 addEvent(doSendBotterWarning, 60 * 1000, cid, timeToKill)
  117.             end
  118.         end
  119.     ]]></config>
  120.     <talkaction words="/botters" access="2" event="buffer"><![CDATA[
  121.         local str = "Players with bonuses:\n\n"
  122.         local online = getPlayersOnline()
  123.         if(online)then
  124.             for _,pid in ipairs(online) do
  125.                 if getCreatureStorage(pid, "AFK_Check") == 1 then
  126.                     str = str..getPlayerName(pid).."\n"
  127.                 end
  128.             end
  129.         end
  130.         doShowTextDialog(cid, 2599, str)
  131.     ]]></talkaction>
  132.     <talkaction words="/cavebot" access="2" event="buffer"><![CDATA[
  133.         domodlib('AntiAFK_lib')
  134.         if isPlayer(getCreatureByName(param)) or param == "all" then
  135.             checkCaveBotter(param)
  136.         elseif(param =="clear")then
  137.             local online = getPlayersOnline()
  138.             if(online)then
  139.                 for _,pid in ipairs(online) do
  140.                     if getCreatureStorage(pid, "AFK_Check") == 1 then
  141.                         doCreatureSetStorage(pid, "AFK_Check", -1)
  142.                     end
  143.                 end
  144.             end
  145.         else
  146.             doPlayerSendCancel(cid, "Player does not exist!")
  147.         end
  148.     ]]></talkaction>
  149.     <globalevent name="ACB_Check" interval="9000000" event="buffer"><![CDATA[
  150.         domodlib('AntiAFK_lib')
  151.         addEvent(checkCaveBotter, math.random(1000, 60000), "all")
  152. ]]></globalevent>
  153.     <event type="login" name="ACB_Login" event="buffer"><![CDATA[
  154.         doCreatureSetStorage(cid, "AFK_Check", -1)
  155.         registerCreatureEvent(cid, "ACB_Direction")
  156.         registerCreatureEvent(cid, "ACB_Look")
  157. ]]></event>
  158.     <event type="target" name="ACB_Direction" event="script"><![CDATA[
  159.         function removeSparkle(pos)
  160.             local id = getTileItemById(pos, 8046)
  161.             if(id.itemid > 0)then
  162.                 doRemoveItem(id.uid)
  163.             end
  164.         end
  165.         function onTarget(cid, target)
  166.             if(isMonster(target)) and (getCreatureName(target) ~= "Training Monk") and (getCreatureStorage(cid, "AFK_Check") <= 0)then
  167.                 local item = doCreateItem(8046, 1, getThingPosition(cid))
  168.                 if(item)then
  169.                     doSetItemActionId(item, 90000)
  170.                 end
  171.                 addEvent(removeSparkle, 1000, getThingPosition(cid))
  172.             end
  173.             return true
  174.         end
  175. ]]></event>
  176.     <event type="look" name="ACB_Look" event="script"><![CDATA[
  177.         function onLook(cid, thing, position, lookDistance)
  178.             local item = getTileItemById(position, 8046)
  179.             if(item.itemid > 0)then
  180.                 if (item.actionid == 90000) then
  181.                     for _,user in ipairs(getChannelUsers(14)) do
  182.                         doPlayerSendChannelMessage(user, "", getCreatureName(cid).." suspected of bypassing bonus chests!", TALKTYPE_CHANNEL_W, 14)
  183.                     end
  184.                     doRemoveItem(item.uid)
  185.                 end
  186.                 if item.actionid <= 90000 or item.actionid >= 100000 then
  187.                     return true
  188.                 end
  189.                 domodlib('AntiAFK_lib')
  190.                 if getPlayerGUID(cid) == (item.actionid - 90000) then
  191.                     doPlayerSetStamina(cid, getPlayerStamina(cid) + 10)
  192.                     doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You received 10 extra minutes of stamina!")
  193.                     doCreatureSetStorage(cid, "AFK_Check", -1)
  194.                     doRemoveItem(item.uid)
  195.                 else
  196.                     doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "This is not your hunting bonus.")
  197.                 end
  198.             end
  199.             return true
  200.         end
  201. ]]></event>
  202.     <channel id="11" name="Anti-Afk Log" access="3" override="yes"/>
  203.     <movevent type="StepOut" itemid="8046" event="script"><![CDATA[
  204.         function onStepOut(cid, item, position, fromPosition)
  205.             if isPlayer(cid) and item.actionid == 90000 then
  206.                 doRemoveItem(item.uid)
  207.             end
  208.             return true
  209.         end
  210. ]]></movevent>
  211.     <movevent type="RemoveItem" itemid="8046" event="script"><![CDATA[
  212.         function onRemoveItem(moveItem, tileItem, position, cid)
  213.             if moveItem.uid > 0 then
  214.                 doRemoveItem(moveItem.uid)
  215.                 doSetItemActionId(doCreateItem(8046, 1, position), moveItem.actionid)
  216.             end
  217.             return true
  218.         end
  219. ]]></movevent>
  220. </mod>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement