w9s66v09c8x5o1fl3p0

Rifbot Anti-Idle

Jan 11th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.09 KB | None | 0 0
  1. --[[
  2.     Script Name:        Anti-Idle
  3.     Description:        Turn your character with random direction to avoid logout.
  4.     Author:             Ascer - example
  5. ]]
  6.  
  7. local MAIN_DELAY = {7, 13}          -- mintues between run antiidle function.
  8. local TURN_DELAY = {200, 450}       -- miliseconds between turn action.
  9. local TURN_TRIES = {1, 5}           -- amount of times to turn.
  10.  
  11.  
  12. -- DONT'T EDIT BELOW THIS LINE
  13.  
  14. local mainTime, turnTime, mainDelay, turnDelay, tries, turnTries, dir = 0, 0, 0, 0, 0, 0
  15.  
  16. Module.New("Anti-Idle", function ()
  17.     if (os.clock() - mainTime) >= mainDelay then -- check main time
  18.         if turnTries <= 0 then
  19.             turnTries = math.random(TURN_TRIES[1], TURN_TRIES[2]) + 1  -- set random tries
  20.             dir = Self.Direction() -- save start direction
  21.         else
  22.             if (os.clock() - turnTime) >= turnDelay and Self.isConnected() then -- check connection and time
  23.                 local dirs = {}
  24.                 local direction = Self.Direction()
  25.                 for i = 0, 3 do
  26.                     if (tries + 1) < turnTries then -- insert dirs that different than your current
  27.                         if (3 - i) ~= direction then
  28.                             table.insert(dirs, (3 - i))
  29.                         end
  30.                     else
  31.                         table.insert(dirs, dir) -- on last tries insert your start dir
  32.                     end      
  33.                 end
  34.                 Self.Turn(dirs[math.random(1, 3)]) -- turn
  35.                 turnTime = os.clock()
  36.                 turnDelay = math.random(TURN_DELAY[1], TURN_DELAY[2])/1000 -- set a new delay for turn /1000 cuz clock return time in seconds
  37.                 tries = tries + 1
  38.                 if tries >= turnTries then -- rest variables
  39.                     tries = 0
  40.                     turnTries = 0
  41.                     mainTime = os.clock()
  42.                     mainDelay = math.random(MAIN_DELAY[1] * 60, MAIN_DELAY[2] * 60)
  43.                 end
  44.             end
  45.         end
  46.     end                    
  47.     -- when no mod:Delay(a, b) then run module every 200ms
  48. end)
Add Comment
Please, Sign In to add comment