SCRIPT:

'cwar
'1.2
'&Clan War:The-Black-Ninja
'&cwar <clan> <date>=add a war request:win <clan>=add +1 win to a clan:lose <tag>=add +1 loss to a clan:total=displays clan war result:clanwar <on/off>=enables/disables commands
'&40238
'&Be sure to change your username where the Private Const lines are at the top of this plugin!


Private Const cwar_request = "cwar" '// Add a war request
Private Const cwar_addWin = "win" '// Add win to a clan
Private Const cwar_addlose = "lose" '// Add lose to a clan
Private Const cwar_total = "total" '// Displays all clan results
Private Const cwar_on = "clanwar" '// Command to enable/disable the system - followed by on or off
Private Const cwar_myClan = "cw" '// Your clantag
Private Const cwar_access = 200 '// Access to use win and lose commands
Private Const cwar_myUsername = "nofear_gr" '// Username the bot will whisper clan war requests to upon entering channel

Private cwPath, cwFSO


Sub cwar_Event_Load()

cwPath = BotPath & "plugins\cwar_data.ini"
Set cwFSO = CreateObject("Scripting.FileSystemObject")
If NOT cwFSO.FileExists(cwPath) Then
Set File = cwFSO.OpenTextFile(cwPath, 8, True)
File.WriteLine "[Results]"
File.Close
End If
End Sub


Sub cwar_Event_Usertalk(Username, Flags, Message, Ping)

If Not Left(Message, 1) = BotVars.Trigger Then Exit Sub
If Len(Message) < 2 Then Exit Sub
cmd = Split(Mid(LCase(Trim(Message)), 2), " ")

clanTag = GetInternalDataByUsername(Username, 0)

GetDBEntry Username, Access, Flags

Select Case cmd(0)
Case cwar_request
If GetEnabled = 0 Then Exit Sub
If clanTag <> vbNullString Then
If GetConfigEntry("Results", clanTag & "_req", cwPath) = vbNullString Then
If UBound(cmd) = 2 Then
If IsDate(cmd(2)) Then
WriteConfigEntry "Results", clanTag & "_req", cmd(2), cwPath
Dsp 3, "Thank you. Your request has been logged.", Username, vbGreen
Else
Call cwar_sendError(Username, 1)
End If
Else
Call cwar_sendError(Username, 2)
End If
Else
Call cwar_sendError(Username, 3)
End If
End If

Case cwar_addWin
If GetEnabled = 0 Then Exit Sub
If Access < cwar_access Then Exit Sub
If UBound(cmd) <> 1 Then Exit Sub
If GetConfigEntry("Results", cmd(1) & "_result", cwPath) = vbNullString Then
WriteConfigEntry "Results", cmd(1) & "_result", 1 & "-" & 0, cwPath
Dsp 3, "Thank you. +1 wins has been logged for clan " & cmd(1) & ".", Username, vbGreen
Else
wins = Split(GetConfigEntry("Results", cmd(1) & "_result", cwPath), "-")(0)
loss = Split(GetConfigEntry("Results", cmd(1) & "_result", cwPath), "-")(1)
WriteConfigEntry "Results", cmd(1) & "_result", CInt(wins)+1 & "-" & loss, cwPath
Dsp 3, "Thank you. +1 wins has been logged for clan " & cmd(1) & ".", Username, vbGreen
End If

Case cwar_addlose
If GetEnabled = 0 Then Exit Sub
If Access < cwar_access Then Exit Sub
If UBound(cmd) <> 1 Then Exit Sub
If GetConfigEntry("Results", cmd(1) & "_result", cwPath) = vbNullString Then
WriteConfigEntry "Results", cmd(1) & "_result", 0 & "-" & 1, cwPath
Dsp 3, "Thank you. +1 loss has been logged for clan " & cmd(1) & ".", Username, vbGreen
Else
wins = Split(GetConfigEntry("Results", cmd(1) & "_result", cwPath), "-")(0)
loss = Split(GetConfigEntry("Results", cmd(1) & "_result", cwPath), "-")(1)
WriteConfigEntry "Results", cmd(1) & "_result", wins & "-" & CInt(loss)+1, cwPath
Dsp 3, "Thank you. +1 loss has been logged for clan " & cmd(1) & ".", Username, vbGreen
End If

Case cwar_total
If GetEnabled = 0 Then Exit Sub
Set File = cwFSO.OpenTextFile(cwPath, 1, False)
content = Split(File.ReadAll, vbNewLine)
File.Close
For i = 1 To Ubound(content) -1
If InStr(content(i), "_result") Then
sClan = Split(content(i), "_result=")(0)
sResult = Split(content(i), "_result=")(1)
output = output & sClan & ": " & sResult & ", "
End If
Next

If output = vbNullString Then
Dsp 3, "No clan war results have been entered.", Username, vbGreen
Else
Dsp 3, "Clan wins/losses from wars: " & Left(output, Len(output) -2), Username, vbGreen
End If

Case cwar_on
If Access < cwar_access Then Exit Sub
If cmd(1) = "on" OR cmd(1) = "off" Then
Select Case cmd(1)
Case "on"
WriteConfigEntry "Enabled", "cwarEnable", "True", cwPath
Dsp 3, "Clan War plugin is enabled.", Username, vbGreen
Case "off"
WriteConfigEntry "Enabled", "cwarEnable", "False", cwPath
Dsp 3, "Clan War plugin is disabled.", Username, vbGreen
End Select
End If
End Select
End Sub


Sub cwar_Event_Userjoins(Username, Flags, Message, Ping, Product, Level, OriginalStatString)

If LCase(Username) = Lcase(cwar_myUsername) Then
Set File = cwFSO.OpenTextFile(cwPath, 1, False)
content = Split(File.ReadAll, vbNewLine)
File.Close

If UBound(content) =< 2 Then Exit Sub

For i = 1 To Ubound(content) -1
If InStr(content(i), "_req") Then
sClan = Split(content(i), "_req=")(0)
sResult = Split(content(i), "=")(1)
txt = txt & sClan & ": " & sResult & ", "
End If
Next

If txt <> vbNullString Then Dsp 3, "Clans that have requested wars: " & Left(txt, Len(txt) -2), Username, vbGreen
End If
End Sub


Sub cwar_sendError(user, num)

Select Case num
Case 1
Dsp 3, "Error: your date must be in the following format: dd/mm/yyyy", Username, vbGreen
Case 2
Dsp 3, "Error: your request must be in the following format: <clan> <date>", Username, vbGreen
Case 3
Dsp 3, "Error: your clan has already requested a war.", Username, vbGreen
End Select
End Sub


Private Function GetEnabled

If GetConfigEntry("Enabled", "cwarEnable", cwPath) <> vbNullString Then
If GetConfigEntry("Enabled", "cwarEnable", cwPath) = "False" Then
GetEnabled = 0
Else
GetEnabled = 1
End If
Else
GetEnabled = 1
End If
End Function


Commands would be

.cwr<clan><date> \\Clan war request

.win <clanname> \\Add win



.lose<clanname> \\Add lose



.total \\Show all statistics



.clanwar on \\turn on the plugin



.clanwar off \\turn off the plugin

Thanks


I Got it from Stealtbot.net