Jump to content
Sign in to follow this  

TS2 Script

Recommended Posts


This is something like an alpha version of my TS2 script. Everything it does is to create a little tray tip on someone leaving or joining the channel. I'm sure this programm is much more complicated than needed and uses a lot of cpu performance so I'm glad for every improvement you can suggest. This script actually only works on "join", "Left" and "quit" it does not get something like switched member and doesen't announce their leaving since it doesn't register them.

#include <array.au3>
AutoItSetOption("WinDetectHiddenText", 1)
Dim  $oldchannelmember[1], $person, $channelmember[1]
While 1
    Dim $Memberlist[1], $Logarray[1], $Events[1], $Member[1], $Memberstatus[1][3]
    $text = WinGetText("TeamSpeak 2")
         ;Get the text from the TeamSpeak window
    $log = StringTrimLeft($text, StringInStr($text, "[") - 1)
         ;Remove channelinfo and other stuff
    Do;Make an array from the extracted log
        _ArrayAdd($Logarray, StringLeft($log, StringInStr($log, @CR) - 1))  
        $log = StringTrimLeft($log, StringInStr($log, @CR) + 1)
    Until $log = ""
    $i = 0
         ;check if it is a message about a player joining or leaving or just system messages
    While $i < UBound($Logarray)
        If not (StringInStr($Logarray[$i], "joined") or StringInStr($Logarray[$i], "quit") or StringInStr($Logarray[$i], "Left")) Then
            _ArrayDelete($Logarray, $i)
            $i = 0
            $i += 1 
         ;get the names of the members that left or joined
    For $i = 0 to UBound($Logarray) - 1
            Case StringInStr($Logarray[$i], " joined")
                _ArrayAdd($Memberlist, StringMid($Logarray[$i], StringInStr($Logarray[$i], "]") + 2, StringInStr($Logarray[$i], " joined" , 0, -1) - StringInStr($Logarray[$i], "]") - 2))
            Case StringInStr($Logarray[$i], " quit")
                _ArrayAdd($Memberlist, StringMid($Logarray[$i], StringInStr($Logarray[$i], "]") + 2, StringInStr($Logarray[$i], " quit" , 0, -1) - StringInStr($Logarray[$i], "]") - 2))
            Case StringInStr($Logarray[$i], " Left")
                _ArrayAdd($Memberlist, StringMid($Logarray[$i], StringInStr($Logarray[$i], "]") + 2, StringInStr($Logarray[$i], " Left" , 0, -1) - StringInStr($Logarray[$i], "]") - 2))
    _ArrayDelete($Memberlist, 0)
         ;get the actions that the player did
    For $i = 0 to UBound($Memberlist) - 1
            Case StringInStr($Logarray[$i], "joined")
                _ArrayAdd($Events, "joined")
            Case StringInStr($Logarray[$i], "quit")
                _ArrayAdd($Events, "quit")
            Case StringInStr($Logarray[$i], "Left")
                _ArrayAdd($Events, "Left")
    _ArrayDelete($Events, 0)
         ;filter out double member so you have only the total summalry of all members   
    For $i = 0 to UBound($Memberlist) - 1
        If _ArraySearch($Member, $MemberList[$i]) = -1 Then _ArrayAdd($Member, $MemberList[$i])
    _ArrayDelete($Member, 0)
    ReDim $Memberstatus[UBound($Member)][3]
         ;copy the members from $Member to the first column of $Memberstatus    
    For $i = 0 to UBound($Memberstatus) - 1
        $Memberstatus[$i][0] = $Member[$i]
         ;for each join add one to the second column of $Memberstatus an create an string containing the history
         ;of leaves and joins in the third
    For $i = 0 to UBound($Memberlist) - 1
        For $j = 0 to UBound($Member) - 1
            If  $Member[$j] = $Memberlist[$i] Then
                If $Events[$i] = "joined" Then 
                    $Memberstatus[$j][1] += 1
                    $Memberstatus[$j][2] &= "joined"
                ElseIf  $Events[$i] = "quit" Or $Events[$i] = "Left" Then
                    $Memberstatus[$j][1] -= 1
                    $Memberstatus[$j][2] &= "left"
         ;this is to register changes
    $oldchannelmember = $channelmember
    Dim $channelmember[1]
         ;the number in the second col of $Memberstatus is the summary of all leaves and joins, if it is positive the member
         ;joined more than he left so he might be in the channel, to be sure check if he joined
         ; after he quittet the last time, this creates the array $channelmember, containig the people that are really in the chan
    For $i = 0 to UBound($Member) - 1
        If $Memberstatus[$i][1] > 0 and StringInStr($Memberstatus[$i][2], "joined", 0, -1) > StringInStr($Memberstatus[$i][2], "left", 0, -1) Then
            _ArrayAdd($channelmember, $Memberstatus[$i][0])
    _ArrayDelete($channelmember, 0)
         ;check if the members in the channel changed since last check
         ;if the number decreased
         ;find the missing element in the new one
         ;if the number increased
         ;find the missing element in the old one
    If UBound($oldchannelmember) <> UBound($channelmember) Then
        If UBound($oldchannelmember) > UBound($channelmember) Then
            For $i = 0 to UBound($oldchannelmember) - 1
                If _ArraySearch($channelmember, $oldchannelmember[$i]) = -1 Then TrayTip("", $oldchannelmember[$i] & " left", 10)
        ElseIf  UBound($oldchannelmember) < UBound($channelmember) Then
            For $i = 0 to UBound($channelmember) - 1
                If _ArraySearch($oldchannelmember, $channelmember[$i]) = -1 Then TrayTip("", $channelmember[$i] & " joined", 10)
    $Memberlist = 0
    $Logarray = 0
    $Events = 0
    $Memberstatus = 0
Edited by CHronologist

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this