Advertisement
Guest User

Untitled

a guest
Jul 12th, 2017
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.54 KB | None | 0 0
  1. init start
  2. -- remember to input your accounts here, caps are considered
  3. local myAccounts = {
  4. ['Charactername'] = {name = 'accname', pass = 'password'},
  5. }
  6.  
  7. -- local SCRIPT_VERSION = "2.3.2"
  8. -- If ReopenBps is set to true then it'll try to reopen the visible backpacks on the main backpack
  9. -- setting it to false will just ignore your bps after you are logged in
  10.  
  11. local ReopenBps = true
  12.  
  13. -- If IgnoreServerSave is set to false it'll wait to relog if server save is occurring
  14. -- setting it to true will try to relog even on server saving time
  15.  
  16. local IgnoreServerSave = false
  17.  
  18. -- [[ ONLY EDIT SPECIAL CHECKS IF YOU KNOW WHAT YOU'RE DOING ]]--
  19.  
  20. -- special checks are the checks it'll do after you login
  21. -- for example: if you are skulled, inside temple, etc ...
  22.  
  23. local SpecialChecks = {
  24. {
  25. function()
  26. return isontemple()
  27. end,
  28. function()
  29. printerrorf("Safe Reconnect: [%q] Client closed. Reason: Character was inside a temple.", $name)
  30. closeclient(true)
  31. end
  32. },
  33. {
  34. function()
  35. return ($self.skull == SKULL_RED or $self.skull == SKULL_BLACK) and $pzone
  36. end,
  37. function()
  38. printerrorf("Safe Reconnect: [%q] Client closed. Reason: Character was red/black skulled inside a protection zone.", $name)
  39. closeclient(true)
  40. end
  41. },
  42. {
  43. function()
  44. return $stamina <= 14*60 and $pzone
  45. end,
  46. function()
  47. printerrorf("Safe Reconnect: [%q] Client closed. Reason: Character had less/equal than 14 hours of stamina and inside a protection zone.", $name)
  48. closeclient(true)
  49. end
  50. },
  51. }
  52.  
  53. -- DO NOT EDIT BELOW --
  54. local reconState = 1
  55.  
  56. if $curscript.type ~= 'persistent' then
  57. reconState = -1
  58. printerror('Reconnect should be placed at Scripter/Persistents.\nChange this setting to run it properly.')
  59. end
  60.  
  61. local openFunc = function()
  62. local lifeTime = $timems
  63. local reopenLogin = get('Looting/OpenBPsAtLogin')
  64.  
  65. set('Looting/OpenBPsAtLogin', 'no')
  66. reopenwindows('small')
  67.  
  68. while $openingbps do
  69. wait(100)
  70.  
  71. if $timems - lifeTime >= 10000 and not $pzone then
  72.  
  73. set('Looting/OpenBPsAtLogin', reopenLogin)
  74. return false
  75. end
  76. end
  77.  
  78. set('Looting/OpenBPsAtLogin', reopenLogin)
  79. return true
  80. end
  81.  
  82. local randTimeSS = math.random(100, 700)
  83.  
  84. init end
  85.  
  86. auto(1000)
  87.  
  88. if (not $connected) and (IgnoreServerSave or (sstime() >= 600 + randTimeSS and sstime() <= 85800 - randTimeSS)) and reconState == 1 then
  89. set('Targeting/Enabled', 'no')
  90. set('Cavebot/Enabled', 'no')
  91.  
  92. local changeSettings = false
  93.  
  94. if $worldvisible then
  95. changeSettings = get('Settings/OpenMenuPolicy')
  96. set('Settings/OpenMenuPolicy', 'Do nothing')
  97. end
  98.  
  99. --reconnect($worldvisible)
  100. connect(myAccounts[$name].name, myAccounts[$name].pass, $name)
  101.  
  102. randTimeSS = math.random(100, 700)
  103.  
  104. if changeSettings then
  105. set('Settings/OpenMenuPolicy', changeSettings)
  106. end
  107.  
  108. if $connected then
  109. pausewalking(10000)
  110. else
  111. return
  112. end
  113.  
  114. if ReopenBps then
  115. local clientMin = $minimized
  116.  
  117. if clientMin and not $addons.enabled then
  118. -- if windaddons is enabled then we don't need to restore the window
  119. -- but if it's not, the bp opener will get stuck and alert you anytime
  120. -- se we restore the window to make sure it'll open and you won't die
  121. restoreclient() waitping()
  122. end
  123.  
  124. local reopenSuccess = openFunc()
  125.  
  126. if not reopenSuccess then
  127. -- this will only happen if you took more than 10 seconds to open bps
  128. -- if this happened probably you have another script trying to open it
  129. -- or any other thing blocking it from opening, if so we should start
  130. -- cavebot and targeting again to make sure you won't die, because after
  131. -- 10 seconds the monsters will surround you and start attacking
  132. printerrorf("Safe Reconnect: [%q] It took too long to open the backpacks, they could be already opened but for safety reasons you were alerted.", $name)
  133. pausewalking(0)
  134. set('Targeting/Enabled', 'yes')
  135. set('Cavebot/Enabled', 'yes')
  136.  
  137. -- alert in this case
  138. for _ = 1, 10 do
  139. beep()
  140. wait(1000)
  141. end
  142. end
  143.  
  144. if clientMin and not $minimized then
  145. minimizeclient()
  146. end
  147. end
  148.  
  149. for _, callback in ipairs(SpecialChecks) do
  150. -- here we check for the given special checks like
  151. -- is on temple, low stamina, skulled, and logout
  152. -- if something happened
  153. if callback[1]() then
  154. reconState = 0
  155.  
  156. return (callback[2] ~= nil and stopattack() and callback[2]()) or false
  157. end
  158. end
  159.  
  160. if not ($targeting and $cavebot) then
  161. set('Targeting/Enabled', 'yes')
  162. set('Cavebot/Enabled', 'yes')
  163. pausewalking(0)
  164. end
  165. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement