Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Script("Name") = "Tournament Tracker"
- Script("Author") = "Camaro"
- Script("Major") = 1
- Script("Minor") = 7
- Script("Revision") = 31
- Script("Description") = "Basic tournament script made out of neccessity."
- iniFolder = "CS Configs"
- tFolder = "Tournaments"
- iniFile = Script("Name") & ".ini"
- sFile = "tsettings.ini"
- ' Feature List
- ' [x] Stand Alone Configuration system
- ' [x] Tournament Folder
- ' [x] Command Creator
- ' [ ] Separate Tournament Configurations
- ' [ ] Separate Tournament Lists
- Sub Event_Load()
- Set fso = CreateObject("Scripting.FileSystemObject")
- If Not FSO.FolderExists(SSC.BotPath() & iniFolder) Then
- Set objFolder = FSO.GetFolder(SSC.BotPath())
- objFolder.SubFolders.Add(iniFolder)
- AddChat Color.RoyalBlue, "{TT}", Color.Green, " The folder '" & iniFolder & "' was created successfully."
- End If
- If Not FSO.FolderExists(SSC.BotPath() & tFolder) Then
- Set objFolder = FSO.GetFolder(SSC.BotPath())
- objFolder.SubFolders.Add(tFolder)
- AddChat Color.RoyalBlue, "{TT}", Color.Green, " The folder '" & tFolder & "' was created successfully."
- End If
- If Not FSO.FileExists(SSC.BotPath() & iniFolder & "\" & iniFile) Then
- Set objFile = FSO.OpenTextFile(SSC.BotPath() & iniFolder & "\" & iniFile, 2, True, 0)
- with objFile
- .writeLine "[Main]"
- .writeLine "TournamentAdmin=" & BotVars.Username
- .writeLine "TournamentModerator=" & BotVars.Username
- .writeLine "TournamentOperator=" & BotVars.Username
- .close
- End With
- AddChat Color.RoyalBlue, "{TT}", Color.Green, " The file '" & Script("Name") & ".ini' was created successfully."
- End If
- If Not FSO.FileExists(SSC.BotPath() & iniFolder & "\" & sFile) Then
- Set objFile = FSO.OpenTextFile(SSC.BotPath() & iniFolder & "\" & sFile, 2, True, 0)
- with objFile
- .writeLine "[Example]"
- .writeLine "Host=" & BotVars.Username
- .writeLine "Type=1"
- .writeLine "Time=" & Hour(Time)+1 & ":00"
- If day(date) >= 28 Then Month(date) = Month(date)+1 AND day(date) = 1
- If month(date) >= 12 AND day(date) >= 28 Then Month(date) = Month(date)+1 AND day(date) = 1
- .writeLine "Date=" & month(date) & "-" & day(date)+1 & "-" & year(date)
- .writeLine "[Example2]"
- .writeLine "Host=" & BotVars.Username
- .writeLine "Type=1"
- .writeLine "Time=" & Hour(Time)+1 & ":00"
- If day(date) >= 28 Then Month(date) = Month(date)+1 AND day(date) = 1
- If month(date) >= 12 AND day(date) >= 28 Then Month(date) = Month(date)+1 AND day(date) = 1
- .writeLine "Date=" & month(date) & "-" & day(date)+1 & "-" & year(date)
- .close
- End With
- AddChat Color.RoyalBlue, "{TT}", Color.Green, " The file '" & sFile & ".ini' was created successfully."
- End If
- Call CreateCommands()
- End Sub
- Sub Event_Command(Command)
- If NOT(Command.Docs.Owner = Script("Name")) Then Exit Sub
- If NOT Command.HasAccess Then Exit Sub
- Dim usage
- usage = "Proper usage: " & BotVars.Trigger & Command.Name & " <command>"
- Select Case LCase(Command.Name)
- Case "joint", "jt", "jointourny"
- If Command.IsValid Then
- Set fso = CreateObject("Scripting.FileSystemObject")
- tFile = SSC.BotPath() & tFolder & "\" & Command.Argument("Tournament") & ".txt"
- If Not fso.FileExists(tfile) Then
- Command.Respond "Invalid Tournament selected. Please select a tournament that has not ended or has been made."
- Else
- Set objStream = fso.OpenTextFile(tFile, 1, false, 0)
- Do While Not objStream.AtEndOfStream
- strLine = objStream.ReadLine
- If strLine = LCase(Command.Username) Then
- objStream.Close
- Exit Do
- End If
- strLine = ""
- Loop
- Set objStream = fso.OpenTextFile(tFile, 8, false, 0)
- If strLine = "" Then
- With objStream
- .WriteLine Lcase(Command.Username)
- .Close
- Command.Respond Command.Username & " joined the upcoming tournament."
- End With
- Else
- Command.Respond Command.Username & " is already in the tournament!"
- End If
- End If
- Else
- Command.Respond usage
- End If
- Case "createt", "ct", "createtourny"
- If Command.IsValid Then
- Set fso = CreateObject("Scripting.FileSystemObject")
- tFile = SSC.BotPath() & tFolder & "\" & Command.Argument("Name") & ".txt"
- If Not fso.FileExists(tfile) Then
- Set objStream = fso.CreateTextFile(tFile, false, False)
- Command.Respond "The Tournament " & Command.Argument("Name") & " was created successfully."
- Else
- Command.Respond "The Tournament " & Command.Argument("Name") & " already exists."
- End If
- Else
- Command.Respond usage
- End If
- Case "leavet", "lt", "leavetourny"
- If Command.IsValid Then
- Command.Respond "You have left the tournament " & Command.Argument("Name") & "."
- Else
- Command.Respond usage
- End If
- End Select
- End Sub
- Private Sub CreateCommands()
- Dim Command, Parameter
- Set Command = OpenCommand("joint")
- If Command Is Nothing Then
- Set Command = CreateCommand("joint")
- With Command
- Set Parameter = .NewParameter("Tournament", False, "String")
- Parameter.Description = "The tournament you want to join."
- .Parameters.Add Parameter
- .Aliases.Add "jt"
- .Aliases.Add "jointourny"
- .RequiredRank = 1
- .Description = "Adds the command's user to the tournament database."
- .Save
- End With
- AddChat color.RoyalBlue, "{TS}", color.Pink, " Successfully created command (Join Tournament)"
- End If
- Set Command = OpenCommand("leavet")
- If Command Is Nothing Then
- Set Command = CreateCommand("leavet")
- With Command
- Set Parameter = .NewParameter("Name", False, "String")
- Parameter.Description = "The tournament you want to join."
- .Parameters.Add Parameter
- .Aliases.Add "lt"
- .Aliases.Add "leavetourny"
- .RequiredRank = 1
- .Description = "Lists all participants in the named tournament."
- .Save
- End With
- AddChat color.RoyalBlue, "{TS}", color.Pink, " Successfully created command (Leave Tournament)"
- End If
- Set Command = OpenCommand("list")
- If Command Is Nothing Then
- Set Command = CreateCommand("list")
- With Command
- Set Parameter = .NewParameter("Name", False, "String")
- Parameter.Description = "The tournament you want to join."
- .Parameters.Add Parameter
- .RequiredRank = 1
- .Description = "Removes the command's user to the tournament database."
- .Save
- End With
- AddChat color.RoyalBlue, "{TS}", color.Pink, " Successfully created command (List Tournament)"
- End If
- Set Command = OpenCommand("ct")
- If Command Is Nothing Then
- Set Command = CreateCommand("ct")
- With Command
- Set Parameter = .NewParameter("Type", False, "Word")
- Parameter.Description = "The command you want to set access for."
- .Parameters.Add Parameter
- Set Parameter = .NewParameter("Name", False, "String")
- Parameter.Description = "The command you want to set access for."
- .Parameters.Add Parameter
- .Aliases.Add "createt"
- .Aliases.Add "createtourny"
- .RequiredRank = 5
- .Description = "Creates a tournament."
- .Save
- End With
- AddChat color.RoyalBlue, "{TS}", color.Pink, " Successfully created command (Create Tournament)"
- End If
- Set Command = OpenCommand("endt")
- If Command Is Nothing Then
- Set Command = CreateCommand("endt")
- With Command
- Set Parameter = .NewParameter("Tournament", False, "String")
- Parameter.Description = "The tournament you want to join."
- .Parameters.Add Parameter
- .Aliases.Add "et"
- .Aliases.Add "endtourny"
- .RequiredRank = 5
- .Description = "Closes and deletes the Tournament from the Tournament folder."
- .Save
- End With
- AddChat color.RoyalBlue, "{TS}", color.Pink, " Successfully created command (End Tournament)"
- End If
- Set Command = Nothing
- Set Parameter = Nothing
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement