New Autobiolog giver

      New Autobiolog giver

      I have made a little bot, it gives to the biologist the items, this works if the server has "Professional Biolog System". Anyway i made the bot check if the system is there, and if it has not, it will tell you!

      Still need to figure out how to make the onupload depend the time_remainig of the biologist, any idea will be welcomed!

      Code:
      Show Spoiler

      Python Source Code

      1. ​import uiprofessionalbiolog, ui, app, chat, net
      2. bioState=0
      3. class VisualPart(ui.ScriptWindow):
      4. def __init__(self):
      5. ui.ScriptWindow.__init__(self)
      6. self.Board = ui.BoardWithTitleBar()
      7. self.Board.SetTitleName('Enzor Auto Biog bot')
      8. self.Board.SetSize(180, 150)
      9. self.Board.SetCenterPosition()
      10. self.Board.SetCloseEvent(self.Cls)
      11. self.Board.AddFlag('movable')
      12. self.Board.Show()
      13. self.comp = Component()
      14. self.BioBtn = self.comp.ToggleButton(self.Board, 'Auto Bio', 'Automatically gives items', 50, 70, self.bioOff, self.bioOn, 'd:/ymir work/ui/public/Large_button_01.sub', 'd:/ymir work/ui/public/Large_button_02.sub','d:/ymir work/ui/public/Large_button_03.sub')
      15. def ShowBack(self):
      16. global IsShowing
      17. IsShowing=1
      18. self.Board.Show()
      19. def Cls(self):
      20. global IsShowing
      21. IsShowing=0
      22. self.Board.Hide()
      23. def bioOn(self):
      24. global bioState
      25. bioState=1
      26. chat.AppendChat(7, 'AutoBiog activated')
      27. def bioOff(self):
      28. global bioState
      29. bioState=0
      30. chat.AppendChat(7, 'AutoBiog desactivated')
      31. class Component:
      32. def Button(self, parent, buttonName, tooltipText, x, y, func, UpVisual, OverVisual, DownVisual):
      33. button = ui.Button()
      34. if parent != None:
      35. button.SetParent(parent)
      36. button.SetPosition(x, y)
      37. button.SetUpVisual(UpVisual)
      38. button.SetOverVisual(OverVisual)
      39. button.SetDownVisual(DownVisual)
      40. button.SetText(buttonName)
      41. button.SetToolTipText(tooltipText)
      42. button.Show()
      43. button.SetEvent(func)
      44. return button
      45. def HideButton(self, parent, buttonName, tooltipText, x, y, func, UpVisual, OverVisual, DownVisual):
      46. button = ui.Button()
      47. if parent != None:
      48. button.SetParent(parent)
      49. button.SetPosition(x, y)
      50. button.SetUpVisual(UpVisual)
      51. button.SetOverVisual(OverVisual)
      52. button.SetDownVisual(DownVisual)
      53. button.SetText(buttonName)
      54. button.SetToolTipText(tooltipText)
      55. button.SetEvent(func)
      56. return button
      57. def ToggleButton(self, parent, buttonName, tooltipText, x, y, funcUp, funcDown, UpVisual, OverVisual, DownVisual):
      58. button = ui.ToggleButton()
      59. if parent != None:
      60. button.SetParent(parent)
      61. button.SetPosition(x, y)
      62. button.SetUpVisual(UpVisual)
      63. button.SetOverVisual(OverVisual)
      64. button.SetDownVisual(DownVisual)
      65. button.SetText(buttonName)
      66. button.SetToolTipText(tooltipText)
      67. button.Show()
      68. button.SetToggleUpEvent(funcUp)
      69. button.SetToggleDownEvent(funcDown)
      70. return button
      71. def F8Func():
      72. global IsShowing
      73. if app.IsPressed(app.DIK_F8) and IsShowing==0:
      74. IsShowing=1
      75. starter.ShowBack()
      76. elif app.IsPressed(app.DIK_F7) and IsShowing==1:
      77. IsShowing=0
      78. starter.Cls()
      79. pass
      80. def OnUpdate(self):
      81. lastTime = max(0, self.endTime - time.clock())
      82. if 0 == lastTime:
      83. self.Close()
      84. self.eventTimeOver()
      85. else:
      86. return
      87. def autoBiog():
      88. global bioState
      89. if bioState==1:
      90. if app.ENABLE_BIOLOG_SYSTEM:
      91. t=int(uiprofessionalbiolog.BIOLOG_BINARY_LOADED["time"][0]) #En segundos
      92. time_remaining = t - app.GetGlobalTimeStamp() #En segundos
      93. if time_remaining <= 0:
      94. net.SendChatPacket("/biolog")
      95. elif time_remaining >0:
      96. pass
      97. else:
      98. pass
      99. hf8 = ui.Window()
      100. hf8.OnUpdate = F8Func
      101. hf8.Show()
      102. ab = ui.Window()
      103. ab.OnUpdate = autoBiog
      104. ab.Show()
      105. starter = VisualPart()
      106. starter.Show()
      107. chat.AppendChat(7,"Press F7 to close and F8 to open the system.")

      Files
      • AutoBio.txt

        (3.7 kB, downloaded 20 times, last: )

      Post was edited 1 time, last by “Marshall” ().

      Yes! Is that simple, I am still reading codes in C++ as my knowledge is not enough to send a packet, but maybe in a future i will try to do it better xD. I just decided to send /biolog command as the new biolog system use that to make the player give the item to the biolog :)