Can you please send me the file threw pm as the page isn't working.
Cheers
Cheers
#####################################################
## First things first.
##
## 17.12.2010 THy
##
## This program is not copyrighted.
## In stead I will merely eat your heart if you steal it.
## - Timo Hynninen 2010 timo.hynninen at&t lut.fi
##
##Lets import stuff and define ports
import pyinsim
import urllib
import threading
import codecs
end = False
teamlist = []
track = "Fern Bay Black"
weather = "Clear Day, No Wind"
print("Input target IP please: ")
ip = raw_input()
print("Input target port. Use 32300 unless you hae a different on for TV director!: ")
port = raw_input()
print("Input commentator man's name:")
commentatorman = raw_input()
##print("Input URL for position data (can be txt, xml, html etc):")
##url = raw_input()
print
print("There is an admin password field too but I can't think of any use for it \nI was probably drunk whilst making this program")
##print("Anyway, please input your name. If you're not the commentator, don't type \nyour name but the commentators.\nBecause we don't care about your name you half wit:")
##commentator = raw_input()
print
########################################
def insim_multiplayer(insim, rst):
global track
global weather
global wind
trackcode = rst.Track
if trackcode == "AS6R":
track = "Aston GT Rev"
elif trackcode == "AS6":
track = "Aston GT"
elif trackcode == "SO4R":
track = "South City Long Rev"
elif trackcode == "KY3":
track = "Kyoto GP Long"
elif trackcode == "BL1":
track = "Blackwood GP"
else:
track = trackcode
weathercode = rst.Weather
if weathercode == 0:
weather = "Clear Day"
elif weathercode == 1:
weather = "Cloudy Afternoon"
elif weathercode == 2:
weather = "Cloudy Sunset"
else:
weather = "Lovely"
windcode = rst.Wind
if windcode == 0:
wind = "No wind"
elif windcode == 1:
wind = "Weak wind"
elif windcode == 2:
wind = "Strong wind"
#########################################
class team:
number = 0
name = ""
drivers = ""
#############################################
def run_classification():
print_classification()
if not end:
threading.Timer(5.0, run_classification).start()
#####################################
## lets define the button generator
def kirjota():
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=68,
BStyle=pyinsim.ISB_DARK | 5,
T=175,
L=68,
W=130,
H=10,
Text=teksti)
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=69,
BStyle=pyinsim.ISB_DARK | 5,
T=175,
L=48,
W=20,
H=10,
Text="Race Control:")
print
def commentary():
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=71,
BStyle=pyinsim.ISB_LIGHT | 2,
T=5,
L=140,
W=45,
H=10,
Text=teksti)
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=70,
BStyle=pyinsim.ISB_LIGHT | 3,
T=5,
L=110,
W=30,
H=10,
Text="Commentary box:")
def commentator():
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=70,
BStyle=pyinsim.ISB_LIGHT | 3,
T=5,
L=110,
W=30,
H=10,
Text="Your commentator:")
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=71,
BStyle=pyinsim.ISB_LIGHT | 2,
T=5,
L=140,
W=45,
H=10,
Text=teksti)
print
def trackinfo():
global track
global weather
global wind
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=61,
BStyle=pyinsim.ISB_LIGHT | 3,
T=17,
L=128,
W=12,
H=9,
Text="Track")
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=62,
BStyle=pyinsim.ISB_LIGHT | 4,
T=17,
L=140,
W=45,
H=9,
Text=track)
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=63,
BStyle=pyinsim.ISB_LIGHT | 4,
T=26,
L=140,
W=45,
H=9,
Text=weather)
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=64,
BStyle=pyinsim.ISB_LIGHT | 4,
T=35,
L=140,
W=45,
H=9,
Text=wind)
print
#######################################
##### This is how we get rid of stuff!
def clear():
insim.send(pyinsim.ISP_BFN, ClickID=61)
insim.send(pyinsim.ISP_BFN, ClickID=62)
insim.send(pyinsim.ISP_BFN, ClickID=63)
insim.send(pyinsim.ISP_BFN, ClickID=64)
insim.send(pyinsim.ISP_BFN, ClickID=65)
insim.send(pyinsim.ISP_BFN, ClickID=66)
insim.send(pyinsim.ISP_BFN, ClickID=67)
insim.send(pyinsim.ISP_BFN, ClickID=68)
insim.send(pyinsim.ISP_BFN, ClickID=69)
insim.send(pyinsim.ISP_BFN, ClickID=70)
insim.send(pyinsim.ISP_BFN, ClickID=71)
def clear_classification():
for i in range(1, 61):
insim.send(pyinsim.ISP_BFN, ClickID=i)
print
##################################
## Classification print code ##
def print_classification():
try:
classification(29)
except IndexError:
print("BTW:")
print("Boothy is an arse and changed the tracker. Yell at him for that")
try:
tiedosto = urllib.urlopen("http://tracker.newdimensionracing.com", "r")
x = tiedosto.read().split("</dd>")
y = x[3].split("<dd>")
remaining = y[1]
tiedosto.close()
except IndexError:
remaining = "00:00:00 "
## aika
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=60,
BStyle=pyinsim.ISB_DARK | 0,
T=175,
L=1,
W=47,
H=8,
Text=remaining+"remaining")
def classification(number):
apu = 5
tiedosto = urllib.urlopen("http://tracker.newdimensionracing.com/", "r")
x = tiedosto.read().split("<td class='teamName'>")
for i in range (1, number):
p = x[i].split("</td>")
p = p[0]
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=i,
BStyle=pyinsim.ISB_LIGHT | 1,
T=apu,
L=1,
W=6,
H=6,
Text=str(i))
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=30+i,
BStyle=pyinsim.ISB_LIGHT | 2,
T=apu,
L=7,
W=33,
H=6,
Text=p)
apu = apu+6
tiedosto.close()
###############################
# Team info
def print_team_info():
for entry in teamlist:
print entry.number, entry.name, ";",
print
print "Which team do you want (input number)? Non-existant number to exit:"
valinta = raw_input()
try:
valinta = int(valinta)
for entry in teamlist:
if valinta == entry.number:
teksti1 = str(entry.number)
teksti2 = str(entry.name)
teksti3 = str(entry.drivers)
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=65,
BStyle=pyinsim.ISB_LIGHT | 6,
T=155,
L=68,
W=12,
H=10,
Text=teksti1)
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=66,
BStyle=pyinsim.ISB_DARK | 5,
T=155,
L=68,
W=80,
H=10,
Text=teksti2)
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=67,
BStyle=pyinsim.ISB_DARK | 5,
T=165,
L=68,
W=130,
H=10,
Text=teksti3)
break
except:
print "something went wrong again :|"
################################
## Team info handler here:
teamlist = []
tiedosto = codecs.open("nimet.timofile", "r", "utf-8")
tiedosto.readline()
while True:
rivi = tiedosto.readline()
if len(rivi) == 0:
break
else:
x = rivi.split(';')
y = team()
y.number = int(x[0][0:2])
y.name = x[0][2:]
y.drivers = x[1][:-1]
teamlist.append(y)
#################################
insim = pyinsim.insim(ip, int(port), Admin='', IName='TheMasterbator', Flags=pyinsim.ISF_LOCAL)
insim.bind(pyinsim.ISP_RST, insim_multiplayer)
insim.send(pyinsim.ISP_TINY, ReqI=1, SubT=pyinsim.TINY_RST)
pyinsim.run(background=True)
##Now the menu.
while True:
print("\nChoose what ya wanna do mother****er!")
print("1) Race control message")
print('2) Print "Voice of [commentators name]".')
print('3) Print "Voice of [someone else]".')
print("4) Clear everything but classification")
print("5) Print classification.")
print("6) Clear classification.")
print("7) Print track info.")
print("8) Print team info")
print("0) QUIT. Don't choose this one. SRSLY!")
print
print("Choose what you want to do: ")
valinta = raw_input()
try:
valinta = int(valinta)
except:
print("You've typed text instead of a number you halfwitted babboon!")
if valinta == 2:
teksti = commentatorman
commentator()
elif valinta == 5:
end = False
threading.Timer(0.1, run_classification).start()
elif valinta == 1:
print "Race control message:"
teksti = raw_input()
kirjota()
elif valinta == 4:
clear()
elif valinta == 6:
end = True
threading.Timer(5.0, clear_classification).start()
threading.Timer(11.0, clear_classification).start()
elif valinta == 7:
trackinfo()
elif valinta == 8:
print_team_info()
elif valinta == 3:
print "Write co-commentator's / interviewee's name:"
teksti = raw_input()
commentary()
elif valinta == 0:
break
## elif valinta == 11:
## threading.Timer(2.0, run_aika).start()
## elif valinta >4:
## print("No, you don't get to do that.")
## print
elif valinta < 0:
print("No, you don't get to do that.")
print
else:
print
################################
## Apparently this doesn't work. No matter, I'll do it anyway :)
insim.close()
print("You're a faggot. And you've just closed this program")
######################################
## EOF
[COLOR="Red"]import pyinsim[/COLOR]
print("Input target IP please: ")
ip = raw_input()
print("Input target port. Use 32300 unless you have a different on for TV director!: ")
port = raw_input()
## Team info handler here:
teamlist = []
tiedosto = codecs.open("nimet.timofile", "r", "utf-8")
tiedosto.readline()
while True:
rivi = tiedosto.readline()
if len(rivi) == 0:
break
else:
x = rivi.split(';')
y = team()
y.number = int(x[0][0:2])
y.name = x[0][2:]
y.drivers = x[1][:-1]
teamlist.append(y)
def classification(number):
bookmark = 5
tracker_website = urllib.urlopen("http://tracker.newdimensionracing.com/", "r")
tracker_data = tracker_website.read().split("<td class='teamName'>") # split the whole string into an array
for i in range (1, number):
p = tracker_data[i].split("</td>") # split each member of the array again to get rid of unnecessary html code
p = p[0] # this is now the actual team name
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=i,
BStyle=pyinsim.ISB_LIGHT | 1,
T=bookmark,
L=1,
W=6,
H=6,
Text=str(i))
insim.send(pyinsim.ISP_BTN,
ReqI=255,
ClickID=30+i,
BStyle=pyinsim.ISB_LIGHT | 2,
T=bookmark,
L=7,
W=33,
H=6,
Text=p)
bookmark = bookmark+6
tracker_website.close()