const sACTION_DELIM = "~**~" const sFIELD_DELIM = "~*~" '***************************************************************************************************** ' DO NOT USE '***************************************************************************************************** function parseStatus( ByVal sStatus ) end function ' parseStatus '***************************************************************************************************** ' parseUsers ' Description: Primary parser for loading users into the Players object for tracking ' Called By: ofMain.RequestServerUsers '***************************************************************************************************** function parseUsers( ByVal sUsers, ByVal bForceConsistency ) dim vLines dim vFields dim sTemp dim iLoop dim sID, sWONID, sName dim oPlayer dim vActive dim iActive On Error Resume Next If sUsers = "" Then Exit Function vLines = Split(sUsers, vbLf) Redim vActive( UBound( vLines ) ) For iLoop = 2 To UBound(vLines) sTemp = vLines(iLoop) If sTemp <> "" Then vFields = Split(vLines(iLoop), ":") If UBound(vFields) = 2 Then 'Get id, wonid, and name sID = Trim(vFields(0)) sWONID = Trim(vFields(1)) sName = Trim(Replace(vFields(2), vbCRLF, "" )) 'Save em If sWONID <> "" Then 'Check whether they are already on file If goServer.Players.HasElement(sWONID) Then Set oPlayer = goServer.Players(sWONID) Else Set oPlayer = goServer.Players.Add(sWONID) End If 'Update info oPlayer.iID = sID oPlayer.sName = sName oPlayer.bActive = true oPlayer.dtLastActive = Now iActive = iActive + 1 vActive( iLoop ) = oPlayer.iWONID End If 'sWONID <> "" End If 'UBound(vFields) End If 'sTemp <> "" Next 'iLoop 'Consistency Check - go through player, mark non-matches inactive ' This is in case we missed them on disconnect if bForceConsistency then for each oPlayer in goServer.Players if oPlayer.bActive then bOK = false for iLoop = 2 to UBound(vActive) if vActive( iLoop ) = oPlayer.iWONID then bOK = true exit for end if ' vActive( iLoop ) = oPlayer.iWONID next 'iLoop oPlayer.bActive = bOK end if next 'oPlayer end if 'Update player status goServer.Players.iActive = iActive 'Uncomment MsgBox to see errors on screen, helps you debug if Err.number <> 0 then 'msgbox "Err #" & Err.number & ": " & Err.Description end if end function ' parseUsers '***************************************************************************************************** ' parseLog ' Description: Primary parser for log messages from server. You can extend this function ' Called: Whenever CSCop recieves a message '***************************************************************************************************** Function parseLog(ByVal sLog) Dim vLines Dim vFields Dim sTemp, sTemp2, sTemp3 Dim iLoop Dim sID, sWONID, sName Dim oPlayer Dim oReg Dim oMatches Dim sActions On Error Resume Next If sLog = "" Then Exit Function 'Ignore multi line logs for now vLines = Split(sLog, vbLf) 'If UBound(vLines) > 2 Then Exit Function Set oReg = CreateObject("VBScript.RegExp") 'Check object if oReg Is Nothing then MsgBox "ERROR: Could not init RegExp object, VBScript 5.5 required." parseLog = "" exit function end if oReg.Global = True sActions = "" For iLoop = 0 To UBound(vLines) If vLines(iLoop) <> "" Then sTemp = "" 'Strip Date/Time If Len(vLines(iLoop)) > 29 Then sTemp = Right(vLines(iLoop), Len(vLines(iLoop)) - 29 - InStr( vLines( iLoop ), "log" ) + 1) 'Kill (KILLER WONID) (VICTIM WONID) (KILLER TEAM) (VICTIM TEAM) oReg.Pattern = """.+<([0-9]+)><([0-9]+)><(.*)>"" killed "".+<([0-9]+)><([0-9]+)><(.+)>""" If oReg.Test(sTemp) Then 'Get IDs Set oMatches = oReg.Execute(sTemp) sActions = sActions & sACTION_DELIM & "KILL" & sFIELD_DELIM & oMatches(0).SubMatches(1) & _ sFIELD_DELIM & oMatches(0).SubMatches(4) & _ sFIELD_DELIM & oMatches(0).SubMatches(2) & _ sFIELD_DELIM & oMatches(0).SubMatches(5) End If 'Self-kill - (WONID) oReg.Pattern = """.+<([0-9]+)><([0-9]+)><(.*)>"" committed suicide with " If oReg.Test(sTemp) Then 'Get IDs Set oMatches = oReg.Execute(sTemp) sActions = sActions & sACTION_DELIM & "SELFKILL" & sFIELD_DELIM & oMatches(0).Submatches(1) End If 'Attack - (ATTACKER WONID) (VICTIM WONID) (ATTACKER TEAM) (VICTIM TEAM) (WEAPON) (DAMAGE HEALTH) (DAMAGE ARMOR) (HEALTH) (ARMOR) oReg.Pattern = """.+<([0-9]+)><([0-9]+)><(.*)>"" attacked "".+<([0-9]+)><([0-9]+)><(.+)>"" with ""(.+)"" \(damage ""health:([0-9]+)""\) \(damage ""armor:([0-9]+)""\) \(health ""([0-9]+)""\) \(armor ""([0-9]+)""\)" If oReg.Test(sTemp) Then 'Get IDs Set oMatches = oReg.Execute(sTemp) sActions = sActions & sACTION_DELIM & "ATTACK" & sFIELD_DELIM & oMatches(0).Submatches(1) & _ sFIELD_DELIM & oMatches(0).SubMatches(4) & _ sFIELD_DELIM & oMatches(0).SubMatches(2) & _ sFIELD_DELIM & oMatches(0).SubMatches(5) & _ sFIELD_DELIM & oMatches(0).SubMatches(6) & _ sFIELD_DELIM & oMatches(0).SubMatches(7) & _ sFIELD_DELIM & oMatches(0).SubMatches(8) & _ sFIELD_DELIM & oMatches(0).SubMatches(9) & _ sFIELD_DELIM & oMatches(0).SubMatches(10) End If 'Changed name - (WONID) (NEWNAME) oReg.Pattern = """.+<([0-9]+)><([0-9]+)><(.*)>"" changed name to ""(.+)""" If oReg.Test(sTemp) Then 'Get IDs Set oMatches = oReg.Execute(sTemp) sActions = sActions & sACTION_DELIM & "NAMECHANGE" & sFIELD_DELIM & oMatches(0).Submatches(1) & sFIELD_DELIM & oMatches(0).Submatches(3) End If 'Disconnect - (WONID) oReg.Pattern = """.+<([0-9]+)><([0-9]+)><(.*)>"" disconnected" If oReg.Test(sTemp) Then 'Get IDs Set oMatches = oReg.Execute(sTemp) sActions = sActions & sACTION_DELIM & "DISCONNECT" & sFIELD_DELIM & oMatches(0).Submatches(1) End If 'Connect (NAME) (ID) (WONID) oReg.Pattern = """(.+)<([0-9]+)><([0-9]+)><>"" connected," If oReg.Test(sTemp) Then 'Get IDs Set oMatches = oReg.Execute(sTemp) sActions = sActions & sACTION_DELIM & "CONNECT" & sFIELD_DELIM & oMatches(0).Submatches(0) & sFIELD_DELIM & oMatches(0).Submatches(1) & sFIELD_DELIM & oMatches(0).Submatches(2) End If 'Enter game - (WONID) oReg.Pattern = """.+<([0-9]+)><([0-9]+)><(.*)>"" entered the game" If oReg.Test(sTemp) Then 'Get IDs Set oMatches = oReg.Execute(sTemp) sActions = sActions & sACTION_DELIM & "ENTERGAME" & sFIELD_DELIM & oMatches(0).Submatches(1) End If 'New Level - (LEVELNAME) oReg.Pattern = "Loading map ""(.+)""" If oReg.Test(sTemp) Then 'Get IDs oReg.Pattern = """(.+)""" Set oMatches = oReg.Execute(sTemp) sActions = sActions & sACTION_DELIM & "NEWLEVEL" & sFIELD_DELIM & oMatches(0).Submatches(0) End If 'New Level oReg.Pattern = "Server shutdown." If oReg.Test(sTemp) Then sActions = sActions & sACTION_DELIM & "SHUTDOWN" End If 'Join team - (WONID) (TEAM) oReg.Pattern = """.+<([0-9]+)><([0-9]+)><(.*)>"" joined team ""(.+)""" If oReg.Test(sTemp) Then 'Get IDs Set oMatches = oReg.Execute( sTemp ) sActions = sActions & sACTION_DELIM & "JOINTEAM" & sFIELD_DELIM & oMatches(0).Submatches(1) & sFIELD_DELIM & oMatches(0).Submatches(3) End If 'Log file started oReg.Pattern = "Log file started " If oReg.Test(sTemp) Then sActions = sActions & sACTION_DELIM & "LOGSTARTED" End If 'Log file closed 'oReg.Pattern = "Log file closed" 'If oReg.Test(sTemp) Then ' sActions = sActions & sACTION_DELIM & "LOGSTOPPED" 'End If 'Server name - (SERVERNAME) oReg.Pattern = "Server name is ""(.+)""" If oReg.Test(sTemp) Then Set oMatches = oReg.Execute( sTemp ) sActions = sActions & sACTION_DELIM & "SERVERNAME" & sFIELD_DELIM & oMatches(0).Submatches(0) End If 'Rcon command - (GOOD|BAD) (COMMAND) (IP) (PASSWORD) (CHALLENGE) 'oReg.Pattern = "(Bad )?Rcon: ""(.+)"" from ""(.+)""" 'If oReg.Test(sTemp) Then ' Set oMatches = oReg.Execute( sTemp ) ' if oMatches(0).Submatches(0) = "Bad " then ' sTemp2 = "BAD" ' else ' sTemp2 = "GOOD" ' end if ' sActions = sActions & sACTION_DELIM & "RCON" & sFIELD_DELIM & sTemp2 ' sTemp2 = oMatches(0).Submatches(1) ' sTemp3 = oMatches(0).Submatches(2) 'IP ' oReg.Pattern = "rcon ([0-9]*) ""(.*)"" (.+)" ' set oMatches = oReg.Execute( sTemp2 ) ' sActions = sActions & sFIELD_DELIM & Trim( oMatches(0).Submatches(2) ) & _ ' sFIELD_DELIM & sTemp3 & _ ' sFIELD_DELIM & oMatches(0).Submatches(1) & _ ' sFIELD_DELIM & oMatches(0).Submatches(0) 'End If 'Forgive TK - (WONID) oReg.Pattern = """.+<([0-9]+)><([0-9]+)><(.*)>"" say ""(?: *)(?:[fF][oO][rR][gG][iI][vV][eE] [tT][kK])(?: *)""" If oReg.Test(sTemp) Then Set oMatches = oReg.Execute( sTemp ) sActions = sActions & sACTION_DELIM & "FORGIVETK" & sFIELD_DELIM & oMatches(0).Submatches(1) End If 'RoundStart oReg.Pattern = """Round_Start""" If oReg.Test(sTemp) Then sActions = sActions & sACTION_DELIM & "ROUNDSTART" End If 'RoundEnd oReg.Pattern = """Round_End""" If oReg.Test(sTemp) Then sActions = sActions & sACTION_DELIM & "ROUNDEND" End If '***************************************************************************************************** ' Add Extensions Here '***************************************************************************************************** '***************************************************************************************************** ' End Extensions Here '***************************************************************************************************** End If 'vlines(iLoop) Next 'iLoop 'Trim first ACTION_DELIM sActions = Right( sActions, Len( sActions ) - Len( sACTION_DELIM ) ) Set oMatches = Nothing Set oReg = Nothing parseLog = sActions 'Uncomment MsgBox to see errors on screen, helps you debug If Err.Number <> 0 Then 'MsgBox "Err #" & Err.Number & ": " & Err.Description End If End Function ' parseLog '***************************************************************************************************** ' processCustomCommands ' Description: Processes custom "actions". Add handlers for your custon "actions" here ' Called: Whenever CSCop does not recognize an "action" '***************************************************************************************************** Sub processCustomCommands( ByVal sAction ) Const iCMD = 0 Const iARG1 = 1 Const iARG2 = 2 dim loPlayer on error resume next Dim vFields vFields = Split( sAction, sFIELD_DELIM ) select case vFields( iCMD ) '***************************** ' Add handlers here '***************************** case "ROUNDSTART" 'Get player object using the name 'if goServer.Players.iActive > 0 then ' ofMain.RCONSay ofMain.FillInTextVars( "FF is ON! Watch your fire." ) 'end if case else ofMain.DisplayRCONData "Unknown Command: " & sAction, 1 end select 'Uncomment MsgBox to see errors on screen, helps you debug If Err.Number <> 0 Then 'MsgBox "Err #" & Err.Number & ": " & Err.Description End If End Sub ' processCustomCommands '***************************************************************************************************** ' processTimedCommands ' Description: This sub is called every minute, you can add server messages and info here. ' Called: This sub is called every minute ' Use: Create a global for each item you want to time, then compare and save '***************************************************************************************************** 'GLOBAL TIMERS Dim dtLastWelcome dtLastWelcome = Now() Dim dtExampleTimer dtExampleTimer = Now() Sub processTimedCommands( ) On Error Resume Next 'This displays the welcome message every 4 minutes 'Another option is to move the Welcome Message to the RoundStart in processCustomCommands if DateDiff( "n", dtLastWelcome, Now ) >= 4 then if goServer.Players.iActive > 0 then ofMain.RCONSay ofMain.FillInTextVars(goServer.sWelcomeMessage) end if dtLastWelcome = Now() end if 'This is an example timer 'Displays maps message every 4 minutes 'if DateDiff( "n", dtExampleTimer, Now ) >= 4 then 'Only display if players are on server ' if goServer.Players.iActive > 0 then ' ofMain.RCONSay ofMain.FillInTextVars("Download maps at http://cs.rocks.com") ' end if ' dtExampleTimer = Now() 'end if 'Uncomment MsgBox to see errors on screen, helps you debug If Err.Number <> 0 Then 'MsgBox "Err #" & Err.Number & ": " & Err.Description End If End Sub 'processTimedCommands '***************************************************************************************************** ' processAttackEvent ' Description: Allows extra actions to be taken when attacks are logged ' Called: This sub is called every time an attack is logged against a friendly or an enemy ' Use: mp_logdetail must be set in the server config for this function to ever be called ' Use this function to take extra actions when an attack occurs. Use the WONID to access ' information about the attacker and victim. '***************************************************************************************************** Sub processAttackEvent( ByVal sAttackerWONID, _ ByVal sAttackerTeam, _ ByVal sVictimWONID, _ ByVal sVictimTeam, _ ByVal sWeapon, _ ByVal iHealthDamage, _ ByVal iArmorDamage, _ ByVal iVictimHealth, _ ByVal iVictimArmor ) On Error Resume Next Dim oAttacker Dim oVictim Dim bTW 'Team Wound 'Example bTW = ( sAttackerTeam = sVictimTeam ) 'Set oAttacker = ofMain.getPlayerByWON( sAttackerWONID ) 'if oAttacker Is Nothing then Exit Sub 'Set oVictim = ofMain.getPlayerByWON( sVictimWONID ) 'if oVictim Is Nothing then Exit Sub 'if bTW then ' ofMain.RCONSay( oAttacker.sName & " attacked teammate " & oVictim.sName ) 'else ' ofMain.RCONSay( oAttacker.sName & " hit " & oVictim.sName & " doing " & ( iArmorDamage + iHealthDamage ) & " damage." ) 'end if 'Set oAttacker = Nothing 'Set oVictim = Nothing If Err.Number <> 0 Then 'MsgBox "Err #" & Err.Number & ": " & Err.Description End If End Sub 'processAttackEvent '******************************************************** ' SUPPORT FUNCTIONS - Do Not Edit '******************************************************** Function FillInTextVars(ByVal sMsg, ByRef oPlayer) Dim sOut If sMsg = "" Then Exit Function If IsObject( oPlayer ) then If Not oPlayer Is Nothing Then 'Replace special vars with player info sOut = Replace(sMsg, "%PLAYER%", oPlayer.sName ) sOut = Replace(sOut, "%PLAYERID%", oPlayer.iID ) sOut = Replace(sOut, "%PLAYERWONID%", oPlayer.iWONID ) sOut = Replace(sOut, "%TKSLEFT%", goServer.TKCop.iMaxTKs - oPlayer.TK.iTKs) sOut = Replace(sOut, "%TKS%", oPlayer.TK.iTKs) sOut = Replace(sOut, "%KILLS%", oPlayer.iKills) sOut = Replace(sOut, "%DEATHS%", oPlayer.iDeaths) sOut = Replace(sOut, "%CONSECUTIVE%", oPlayer.iKillsSinceDeath) End If ' Not oPlayer Is Nothing Else sOut = sMsg End If sOut = Replace(sOut, "%MAXTKS%", goServer.TKCop.iMaxTKs) sOut = Replace(sOut, "%BANLENGTH%", goServer.TKCop.iBanLength) FillInTextVars = sOut End Function