Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #---------------------------
- # Import Libraries
- #---------------------------
- import socket
- import struct
- #---------------------------
- # [Required] Script Information
- #---------------------------
- ScriptName = "Stream Fighter Alpha"
- Website = "http://twitch.com/vilgefartz"
- Description = "Python client for Stream Fighter Alpha server"
- Creator = "Vilgefartz"
- Version = "1.0.0.0"
- #---------------------------
- # Connect to Game Client
- #---------------------------
- host = socket.gethostbyname(socket.gethostname())
- port = 4555
- s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
- # tuple of host and port
- #---------------------------
- # [Required] Initialize Data (Only called on load)
- #---------------------------
- def Init():
- """Required init function"""
- s.connect((host, port))
- return
- #---------------------------
- # [Required] Tick method (Gets called during every iteration even when there is no incoming data)
- #---------------------------
- def Tick():
- """Required tick function"""
- return
- #---------------------------
- # [Required] Execute Data / Process messages
- #---------------------------
- def Execute(data): #called whenever there is a new chat message
- if data.IsChatMessage():
- senddata(data)
- def senddata(command):
- # old code message = raw_input("-> ")
- message = str(command)
- buffer_type = str(len(message))+"s"
- buffer = struct.pack(buffer_type, message)
- s.send(buffer) # socket.send(message), sends message to server
- print buffer
- print "message sent"
- s.close() # close the socket
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement