Strange errors on this script

Last post 10-15-2008 12:56 PM by Juba_PornBorn. 0 replies.

Sort Posts:

  • Strange errors on this script

    10-15-2008, 12:56 PM
    • Member
      point Member
    • Juba_PornBorn
    • Member since 05-06-2008, 11:48 PM
    • Posts 2
    Hello, Im doing my first IP script and I'm getting really weird mistake I don't understand how to solve. Here's the code and the errors I get: 1> 2 form windows and system tray icons show up 2> Button does not work and sometimes it shows this message on press: startcheck[] has 2 arguments, none given I haven't defined arguments for startcheck. 3> Can't get values from the variables inside the class in the script Here's the script: ''' Script by Juba_PornBorn, Open Source Cod4 Tool Project, To donate or any kind of support: server_help@hotmail.co.uk Oficial web Page: uadminsdevenezuela.co.nr''' import os import os.path import socket import cPickle from threading import Timer import clr clr.AddReference('System') clr.AddReference('System.Windows.Forms') clr.AddReference('System.Drawing') from System import * from System.Windows.Forms import * from System.Drawing import * name_saver = {} username = 'none' martyrdom = 'frag_grenade_short_mp' noob_tube = 'gl_weapon_mp' host = 'localhost' #value to check if new line is written checkline = 0 #tray icon on logcheck loop on else turn of tray_on = 0 class MyForm(Form): def __init__(self): self.MaximizeBox = 0 self.MinimizeBox = 1 self.ShowInTakbar = 0 self.GetStayOnTop = 0 self.FormBorderStyle = FormBorderStyle.Sizable self.Size = Size(546, 381) self.Text = "COD4 Warning System" image = Bitmap(Application.StartupPath + '\picturebox3img.jpg') self.BackgroundImage = image self.button1 = Button(Text='Start Check', Location=Point(448,320), Size=Size(75, 23)) self.button1.BackColor = Color.FromArgb(167, 166, 170) self.button1.Font = Font('Microsoft Sans Serif', 8) self.button1.Cursor = Cursors.Default self.Controls.Add(self.button1) self.checkbox1 = CheckBox(Text='Noob Tube (Granade Launcher)', Location=Point(24,24), Size=Size(184, 19)) self.checkbox1.Checked = True self.checkbox1.BackColor = Color.FromArgb(255, 255, 255) self.checkbox1.Font = Font('Microsoft Sans Serif', 8) self.checkbox1.Cursor = Cursors.Default self.checkbox1.BackColor = Color.Transparent self.Controls.Add(self.checkbox1) self.checkbox2 = CheckBox(Text='Martyrdom', Location=Point(24,56), Size=Size(168, 22)) self.checkbox2.Checked = True self.checkbox2.BackColor = Color.FromArgb(255, 255, 255) self.checkbox2.Font = Font('Microsoft Sans Serif', 8) self.checkbox2.Cursor = Cursors.Default self.checkbox2.BackColor = Color.Transparent self.Controls.Add(self.checkbox2) self.textbox5 = TextBox(Text='Insert game_mp.log direction here...', Location=Point(224,24), Size=Size(288, 20)) self.textbox5.BackColor = Color.FromArgb(255, 255, 255) self.textbox5.Font = Font('Microsoft Sans Serif', 8) self.textbox5.Cursor = Cursors.Default self.Controls.Add(self.textbox5) self.textbox2 = TextBox(Text='1', Location=Point(10,104), Size=Size(20, 20)) self.textbox2.BackColor = Color.FromArgb(255, 255, 255) self.textbox2.Font = Font('Microsoft Sans Serif', 8) self.textbox2.Cursor = Cursors.Default self.Controls.Add(self.textbox2) self.textbox3 = TextBox(Text='1', Location=Point(10,144), Size=Size(20, 20)) self.textbox3.BackColor = Color.FromArgb(255, 255, 255) self.textbox3.Font = Font('Microsoft Sans Serif', 8) self.textbox3.Cursor = Cursors.Default self.Controls.Add(self.textbox3) self.label1 = Label(Text='Max Warnings on Martydom before kick', Location=Point(40,144), Size=Size(238, 17)) self.label1.Font = Font('Microsoft Sans Serif', 8) self.label1.Cursor = Cursors.Default self.label1.BackColor = Color.Transparent self.Controls.Add(self.label1) self.label2 = Label(Text='Max Warnings on Noob Tube before kick', Location=Point(40,104), Size=Size(238, 17)) self.label2.Font = Font('Microsoft Sans Serif', 8) self.label2.Cursor = Cursors.Default self.label2.BackColor = Color.Transparent self.Controls.Add(self.label2) self.textbox4 = TextBox(Text='20', Location=Point(314,104), Size=Size(25, 20)) self.textbox4.BackColor = Color.FromArgb(255, 255, 255) self.textbox4.Font = Font('Microsoft Sans Serif', 8) self.textbox4.Cursor = Cursors.Default self.Controls.Add(self.textbox4) self.label3 = Label(Text='Time in minutes to save to Database', Location=Point(344,96), Size=Size(140, 34)) self.label3.Font = Font('Microsoft Sans Serif', 9) self.label3.Cursor = Cursors.Default self.label3.BackColor = Color.Transparent self.Controls.Add(self.label3) self.textbox10 = TextBox(Text='20', Location=Point(314,144), Size=Size(25, 20)) self.textbox10.BackColor = Color.FromArgb(255, 255, 255) self.textbox10.Font = Font('Microsoft Sans Serif', 8) self.textbox10.Cursor = Cursors.Default self.Controls.Add(self.textbox10) self.label4 = Label(Text='PunkBuster Temp Ban time in minutes', Location=Point(344,136), Size=Size(100, 31)) self.label4.Font = Font('Microsoft Sans Serif', 9) self.label4.Cursor = Cursors.Default self.label4.BackColor = Color.Transparent self.Controls.Add(self.label4) self.textbox6 = TextBox(Text='password', Location=Point(16,208), Size=Size(100, 20)) self.textbox6.BackColor = Color.FromArgb(255, 255, 255) self.textbox6.Font = Font('Microsoft Sans Serif', 8) self.textbox6.Cursor = Cursors.Default self.Controls.Add(self.textbox6) self.label5 = Label(Text='Rcon Password', Location=Point(16,192), Size=Size(100, 23)) self.label5.Font = Font('Microsoft Sans Serif', 8) self.label5.Cursor = Cursors.Default self.label5.BackColor = Color.Transparent self.Controls.Add(self.label5) self.textbox7 = TextBox(Text='28960', Location=Point(136,208), Size=Size(100, 20)) self.textbox7.BackColor = Color.FromArgb(255, 255, 255) self.textbox7.Font = Font('Microsoft Sans Serif', 8) self.textbox7.Cursor = Cursors.Default self.Controls.Add(self.textbox7) self.label6 = Label(Text='Server Port', Location=Point(136,192), Size=Size(134, 17)) self.label6.Font = Font('Microsoft Sans Serif', 8) self.label6.Cursor = Cursors.Default self.label6.BackColor = Color.Transparent self.Controls.Add(self.label6) self.textbox8 = TextBox(Text='%s is going to get kicked if noob tube is used again...'%username, Location=Point(16,264), Size=Size(340, 20)) self.textbox8.BackColor = Color.FromArgb(255, 255, 255) self.textbox8.Font = Font('Microsoft Sans Serif', 8) self.textbox8.Cursor = Cursors.Default self.Controls.Add(self.textbox8) self.label7 = Label(Text='Warning message for noob tube', Location=Point(16,248), Size=Size(298, 17)) self.label7.Font = Font('Microsoft Sans Serif', 8) self.label7.Cursor = Cursors.Default self.label7.BackColor = Color.Transparent self.Controls.Add(self.label7) self.textbox9 = TextBox(Text='%s is going to get kicked if Martyrdom is used again...'%username, Location=Point(16,320), Size=Size(340, 20)) self.textbox9.BackColor = Color.FromArgb(255, 255, 255) self.textbox9.Font = Font('Microsoft Sans Serif', 8) self.textbox9.Cursor = Cursors.Default self.Controls.Add(self.textbox9) self.label11 = Label(Text='Warning message for Martyrdom', Location=Point(16,304), Size=Size(298, 17)) self.label11.Font = Font('Microsoft Sans Serif', 8) self.label11.Cursor = Cursors.Default self.label11.BackColor = Color.Transparent self.Controls.Add(self.label11) self.initNotifyIcon() self.Resize += self.ResizeForm def initNotifyIcon(self): self.notifyIcon = NotifyIcon() self.notifyIcon.Icon = Icon(Application.StartupPath + '\cod4.ico') self.notifyIcon.Visible = True self.notifyIcon.MouseDoubleClick += self.DoubleClickOnTrayIcon def ResizeForm(self, s, e): if self.WindowState == FormWindowState.Minimized: self.notifyIcon.Visible = True self.Visible = False def DoubleClickOnTrayIcon(self, s, e): if e.Button == MouseButtons.Left: self.Visible = True if self.WindowState == FormWindowState.Minimized: self.WindowState = FormWindowState.Normal self.notifyIcon.Visible = False def StartCheckButton(sender, eventArgs): sender += eventArgs def startcheck(): global savedb, rcon_password, server_port, active_noobtube, active_martyrdom, minutes_kick_variable, warning_counter_tube, warning_counter_marty, game_or_mod_path, save_database, noob_text, marty_text # timer of saving database savedb = Timer(save_database * 60, savedatabase) savedb.start() #check form variables rcon_password = values.textbox6.Text server_port = values.textbox7.Text active_noobtube = values.checkbox1.Checked active_martyrdom = values.checkbox2.Checked minutes_kick_variable = values.textbox10.Text #In the form corresponds to the 20 minute Punkbuster variable warning_counter_tube = values.textbox2.Text # Number of times player is warned before kick in the form corresponds to Max warnings Tube warning_counter_marty = values.textbox3.Text # Number of times player is warned before kick in the form corresponds to Max warnings Martydom game_or_mod_path = values.textbox5.Text #test path save_database = values.textbox4.Text #time in minutes wich saves cPickle database of users noob_text = values.textbox8.Text marty_text = values.textbox9.Text # start logcheck loop tray_on = 1 #Close form window and open system tray button values.WindowState = FormWindowState.Minimized test_socket() loaddatabase() openlogexists() def socketconnect(cmd): try: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) s.settimeout(5) s.connect((host, server_port)) packet = 'ÿÿÿÿrcon "%s" %s ' %(rcon_password, cmd) while len(packet) > 0: c = s.send(packet) packet = packet[c:] sleep(1) message = s.recv(2048) s.close() return message except ArgumentException: MessageBox.Show("Could not connect to Server", "",MessageBoxButtons.OK, MessageBoxIcon.Exclamation) def test_socket(): socketconnect('status') def openlogexists(): #complete path to games_mp.log global lastline global checkline global size try: logfile = open(game_or_mod_path, 'r') size = os.path.getsize(game_or_mod_path) lineList = logfile.readlines() lastline = lineList[-1] logfile.close() except ArgumentException: # to print on an error box MessageBox.Show("Log %s not found" %game_or_mod_path , "",MessageBoxButtons.OK, MessageBoxIcon.Exclamation) # check if line is still the same if lastline: if checkline != lastline: checkline = lastline checkcounters() logcheck() #start loop here on log check or wait until the logcheck function ends and wait a second or 2 and start it again def logcheck(): global size global lastline logfile = open(game_or_mod_path, 'r') logfile.seek(size) lineList = logfile.readlines() lastline = lineList[-1] if lastline: if checkline != lastline: checkline = lastline size = os.path.getsize(game_or_mod_path) newlenght = len(lineList) - 1 x = -1 while x < newlenght: x += 1 lastline = lineList[x] lastline checkcounters() sleep(5) # give a 5 second space between each check if tray_on == 1: logcheck() #perform a loop on logcheck def getname(lastline): #get username from lastline all_sentence = lastline.split(";") if 'allies' in all_sentence: all_sentence.remove('allies') if 'axis' in all_sentence: all_sentence.remove('axis') username = all_sentence[8] return username def loaddatabase(): # warning database with names and number of times warned loaded on startcheck global db global name_saver try: db = open(Application.StartupPath + '\warningdatabase.db', 'r') name_saver = cPickle.load(db) db.close() except ArgumentException: MessageBox.Show(" Error Loading Database: Check or Create warningdatabase.db in Aplication Folder" , "",MessageBoxButtons.OK, MessageBoxIcon.Exclamation) def savedatabase(): # saved in time defined in save_database global db global name_saver db = open(Application.StartupPath + '\warningdatabase.db', 'w') cPickle.dump(name_saver, db) db.close() def checkcounters(): global lastline global username global name_saver if active_noobtube == "True": #debug print "testcounters" if noob_tube in lastline: #get username from lastline getname(lastline) # check if player is in warning list if name_saver.has_key(str(username)): name_saver[str(username)]["kick_tube"] += 1 else: name_saver["name"] = str(username) name_saver[str(username)] ={'kick_tube':0, 'kick_marty':0} if name_saver[str(username)]["kick_tube"] <= warning_counter_tube: # sockets messages here and preferably sentences are loaded from a ini supporting multiple language print "%s is about to be kicked for using noobtube!!!" %username socketconnect(noob_text) else: #here goes the sockets connection to send the pb_kick command socketconnect(cmd = 'PB_SV_Kick %s %s "Kicked due to use of noob tube" | "No noob tube in the server ever!"'%(username, minutes_kick_variable)) if active_martyrdom == "True": if martyrdom in lastline: #get username from lastline getname(lastline) # check if player is in warning list if name_saver.has_key(str(username)): name_saver[str(username)]["kick_marty"] += 1 else: name_saver["name"] = str(username) name_saver[str(username)] = {'kick_tube':0, 'kick_marty':0} if name_saver[str(username)]["kick_marty"] <= warning_counter_marty: print "%s is about to be kicked for using martyrdom!!!" %username # sockets messages here socketconnect(marty_text) else: #here goes the sockets connection to send the pb_kick command socketconnect(cmd = 'PB_SV_Kick %s %s "Kicked due to use of Martyrdom" | "No Martyrdom in the server ever!"'%(username, minutes_kick_variable)) StartCheckButton(MyForm().button1.Click, startcheck) values = MyForm() Application.EnableVisualStyles() Application.Run(values)
    Filed under:
Page 1 of 1 (1 items)