Advertisement
Guest User

Untitled

a guest
May 29th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Script("Name")        = "Tournament Tracker"
  2. Script("Author")      = "Camaro"
  3. Script("Major")       = 1
  4. Script("Minor")       = 7
  5. Script("Revision")    = 31
  6. Script("Description") = "Basic tournament script made out of neccessity."
  7.  
  8.   iniFolder = "CS Configs"
  9.   tFolder   = "Tournaments"
  10.   iniFile   = Script("Name") & ".ini"
  11.   sFile  = "tsettings.ini"
  12.  
  13. ' Feature List
  14.  ' [x] Stand Alone Configuration system
  15.  ' [x] Tournament Folder
  16.  ' [x] Command Creator
  17.  ' [ ] Separate Tournament Configurations
  18.  ' [ ] Separate Tournament Lists
  19.  
  20.  
  21. Sub Event_Load()
  22.   Set fso = CreateObject("Scripting.FileSystemObject")
  23.  
  24.   If Not FSO.FolderExists(SSC.BotPath() & iniFolder) Then
  25.     Set objFolder = FSO.GetFolder(SSC.BotPath())
  26.     objFolder.SubFolders.Add(iniFolder)
  27.     AddChat Color.RoyalBlue, "{TT}", Color.Green, " The folder '" & iniFolder & "' was created successfully."
  28.   End If
  29.  
  30.   If Not FSO.FolderExists(SSC.BotPath() & tFolder) Then
  31.     Set objFolder = FSO.GetFolder(SSC.BotPath())
  32.     objFolder.SubFolders.Add(tFolder)
  33.     AddChat Color.RoyalBlue, "{TT}", Color.Green, " The folder '" & tFolder & "' was created successfully."
  34.   End If
  35.  
  36.   If Not FSO.FileExists(SSC.BotPath() & iniFolder & "\" & iniFile) Then
  37.     Set objFile = FSO.OpenTextFile(SSC.BotPath() & iniFolder & "\" & iniFile, 2, True, 0)
  38.     with objFile
  39.       .writeLine "[Main]"
  40.       .writeLine "TournamentAdmin=" & BotVars.Username
  41.       .writeLine "TournamentModerator=" & BotVars.Username
  42.       .writeLine "TournamentOperator=" & BotVars.Username
  43.       .close
  44.     End With
  45.     AddChat Color.RoyalBlue, "{TT}", Color.Green, " The file '" & Script("Name") & ".ini' was created successfully."
  46.   End If
  47.  
  48.   If Not FSO.FileExists(SSC.BotPath() & iniFolder & "\" & sFile) Then
  49.     Set objFile = FSO.OpenTextFile(SSC.BotPath() & iniFolder & "\" & sFile, 2, True, 0)
  50.     with objFile
  51.       .writeLine "[Example]"
  52.       .writeLine "Host=" & BotVars.Username
  53.       .writeLine "Type=1"
  54.       .writeLine "Time=" & Hour(Time)+1 & ":00"
  55.       If day(date) >= 28 Then Month(date) = Month(date)+1 AND day(date) = 1
  56.       If month(date) >= 12 AND day(date) >= 28 Then Month(date) = Month(date)+1 AND day(date) = 1
  57.       .writeLine "Date=" & month(date) & "-" & day(date)+1 & "-" & year(date)
  58.       .writeLine "[Example2]"
  59.       .writeLine "Host=" & BotVars.Username
  60.       .writeLine "Type=1"
  61.       .writeLine "Time=" & Hour(Time)+1 & ":00"
  62.       If day(date) >= 28 Then Month(date) = Month(date)+1 AND day(date) = 1
  63.       If month(date) >= 12 AND day(date) >= 28 Then Month(date) = Month(date)+1 AND day(date) = 1
  64.       .writeLine "Date=" & month(date) & "-" & day(date)+1 & "-" & year(date)
  65.       .close
  66.     End With
  67.     AddChat Color.RoyalBlue, "{TT}", Color.Green, " The file '" & sFile & ".ini' was created successfully."
  68.   End If
  69.  
  70.     Call CreateCommands()
  71. End Sub
  72.  
  73. Sub Event_Command(Command)
  74.     If NOT(Command.Docs.Owner = Script("Name")) Then Exit Sub
  75.     If NOT Command.HasAccess Then Exit Sub
  76.  
  77.     Dim usage
  78.     usage = "Proper usage: " & BotVars.Trigger & Command.Name & " <command>"
  79.  
  80.     Select Case LCase(Command.Name)
  81.     Case "joint", "jt", "jointourny"
  82.         If Command.IsValid Then
  83.  
  84.       Set fso = CreateObject("Scripting.FileSystemObject")
  85.  
  86.       tFile = SSC.BotPath() & tFolder & "\" & Command.Argument("Tournament") & ".txt"
  87.       If Not fso.FileExists(tfile) Then
  88.         Command.Respond "Invalid Tournament selected. Please select a tournament that has not ended or has been made."
  89.       Else
  90.         Set objStream = fso.OpenTextFile(tFile, 1, false, 0)
  91.         Do While Not objStream.AtEndOfStream
  92.           strLine = objStream.ReadLine
  93.           If strLine = LCase(Command.Username) Then
  94.             objStream.Close
  95.             Exit Do
  96.           End If
  97.           strLine = ""
  98.         Loop
  99.  
  100.         Set objStream = fso.OpenTextFile(tFile, 8, false, 0)
  101.         If strLine = "" Then
  102.           With objStream
  103.             .WriteLine Lcase(Command.Username)
  104.             .Close
  105.             Command.Respond Command.Username & " joined the upcoming tournament."
  106.           End With
  107.         Else
  108.           Command.Respond Command.Username & " is already in the tournament!"
  109.         End If
  110.  
  111.       End If
  112.  
  113.     Else
  114.             Command.Respond usage
  115.         End If
  116.     Case "createt", "ct", "createtourny"
  117.         If Command.IsValid Then
  118.  
  119.       Set fso = CreateObject("Scripting.FileSystemObject")
  120.  
  121.       tFile = SSC.BotPath() & tFolder & "\" & Command.Argument("Name") & ".txt"
  122.       If Not fso.FileExists(tfile) Then
  123.         Set objStream = fso.CreateTextFile(tFile, false, False)
  124.         Command.Respond "The Tournament " & Command.Argument("Name") & " was created successfully."
  125.       Else
  126.         Command.Respond "The Tournament " & Command.Argument("Name") & " already exists."
  127.       End If
  128.  
  129.     Else
  130.             Command.Respond usage
  131.         End If
  132.     Case "leavet", "lt", "leavetourny"
  133.         If Command.IsValid Then
  134.         Command.Respond "You have left the tournament " & Command.Argument("Name") & "."
  135.     Else
  136.             Command.Respond usage
  137.         End If
  138.     End Select
  139. End Sub
  140.  
  141. Private Sub CreateCommands()
  142.     Dim Command, Parameter
  143.  
  144.     Set Command = OpenCommand("joint")
  145.     If Command Is Nothing Then
  146.         Set Command = CreateCommand("joint")
  147.         With Command
  148.             Set Parameter = .NewParameter("Tournament", False, "String")
  149.             Parameter.Description = "The tournament you want to join."
  150.             .Parameters.Add Parameter
  151.  
  152.             .Aliases.Add "jt"
  153.             .Aliases.Add "jointourny"
  154.             .RequiredRank = 1
  155.             .Description = "Adds the command's user to the tournament database."
  156.             .Save
  157.         End With
  158.         AddChat color.RoyalBlue, "{TS}", color.Pink, " Successfully created command (Join Tournament)"
  159.     End If
  160.  
  161.     Set Command = OpenCommand("leavet")
  162.     If Command Is Nothing Then
  163.         Set Command = CreateCommand("leavet")
  164.         With Command
  165.             Set Parameter = .NewParameter("Name", False, "String")
  166.             Parameter.Description = "The tournament you want to join."
  167.             .Parameters.Add Parameter
  168.  
  169.             .Aliases.Add "lt"
  170.             .Aliases.Add "leavetourny"
  171.             .RequiredRank = 1
  172.             .Description = "Lists all participants in the named tournament."
  173.             .Save
  174.         End With
  175.         AddChat color.RoyalBlue, "{TS}", color.Pink, " Successfully created command (Leave Tournament)"
  176.     End If
  177.  
  178.     Set Command = OpenCommand("list")
  179.     If Command Is Nothing Then
  180.         Set Command = CreateCommand("list")
  181.         With Command
  182.             Set Parameter = .NewParameter("Name", False, "String")
  183.             Parameter.Description = "The tournament you want to join."
  184.             .Parameters.Add Parameter
  185.  
  186.             .RequiredRank = 1
  187.             .Description = "Removes the command's user to the tournament database."
  188.             .Save
  189.         End With
  190.         AddChat color.RoyalBlue, "{TS}", color.Pink, " Successfully created command (List Tournament)"
  191.     End If
  192.  
  193.     Set Command = OpenCommand("ct")
  194.     If Command Is Nothing Then
  195.         Set Command = CreateCommand("ct")
  196.         With Command
  197.             Set Parameter = .NewParameter("Type", False, "Word")
  198.             Parameter.Description = "The command you want to set access for."
  199.             .Parameters.Add Parameter
  200.  
  201.             Set Parameter = .NewParameter("Name", False, "String")
  202.             Parameter.Description = "The command you want to set access for."
  203.             .Parameters.Add Parameter
  204.  
  205.             .Aliases.Add "createt"
  206.             .Aliases.Add "createtourny"
  207.             .RequiredRank = 5
  208.             .Description = "Creates a tournament."
  209.             .Save
  210.         End With
  211.         AddChat color.RoyalBlue, "{TS}", color.Pink, " Successfully created command (Create Tournament)"
  212.     End If
  213.  
  214.     Set Command = OpenCommand("endt")
  215.     If Command Is Nothing Then
  216.         Set Command = CreateCommand("endt")
  217.         With Command
  218.             Set Parameter = .NewParameter("Tournament", False, "String")
  219.             Parameter.Description = "The tournament you want to join."
  220.             .Parameters.Add Parameter
  221.  
  222.             .Aliases.Add "et"
  223.             .Aliases.Add "endtourny"
  224.             .RequiredRank = 5
  225.             .Description = "Closes and deletes the Tournament from the Tournament folder."
  226.             .Save
  227.         End With
  228.         AddChat color.RoyalBlue, "{TS}", color.Pink, " Successfully created command (End Tournament)"
  229.     End If
  230.  
  231.     Set Command = Nothing
  232.     Set Parameter = Nothing
  233. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement