Advertisement
Guest User

Fix

a guest
Jul 17th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.60 KB | None | 0 0
  1. #---------------------------
  2. #   Import Libraries
  3. #---------------------------
  4. import socket
  5. import struct
  6.  
  7. #---------------------------
  8. #   [Required] Script Information
  9. #---------------------------
  10. ScriptName = "Stream Fighter Alpha"
  11. Website = "http://twitch.com/vilgefartz"
  12. Description = "Python client for Stream Fighter Alpha server"
  13. Creator = "Vilgefartz"
  14. Version = "1.0.0.0"
  15.  
  16. #---------------------------
  17. #   Connect to Game Client
  18. #---------------------------
  19. host = socket.gethostbyname(socket.gethostname())
  20. port = 4555
  21. s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  22. # tuple of host and port
  23.  
  24. #---------------------------
  25. #   [Required] Initialize Data (Only called on load)
  26. #---------------------------
  27. def Init():
  28.     """Required init function"""
  29.     s.connect((host, port))
  30.     return
  31.  
  32. #---------------------------
  33. #   [Required] Tick method (Gets called during every iteration even when there is no incoming data)
  34. #---------------------------
  35. def Tick():
  36.     """Required tick function"""
  37.     return
  38.  
  39. #---------------------------
  40. #   [Required] Execute Data / Process messages
  41. #---------------------------
  42. def Execute(data): #called whenever there is a new chat message
  43.     if data.IsChatMessage():
  44.         senddata(data)
  45.  
  46. def senddata(command):
  47.     # old code message = raw_input("-> ")
  48.     message = str(command)
  49.     buffer_type = str(len(message))+"s"
  50.     buffer = struct.pack(buffer_type, message)
  51.     s.send(buffer)              # socket.send(message), sends message to server
  52.     print buffer
  53.     print "message sent"
  54.     s.close()                       # close the socket
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement