Jump to content

Recommended Posts

Posted

Hi guys, I hope everyone that lives in the US had a happy holiday yesterday, and if you don't live in the US, I still hope you had an amazing day!

Anyways, my little brother(he's 11) will not do his homework. He's always playing computer games, specifically Counter Strike. I needed to do something about this so a buddy of mine from work suggested that I try punishing him by not letting him play Counter Strike. I've tried to make a simple program that will check for his config.ini file and see if it's really him. He always uses the same name(bigmike227), so I figured I can do an IniRead() to check for this, and if it is him, it will write the MAC Address of the computer to another .INI file. Each time he tries to launch the game(from the same account of course), it will deny him. I don't want to do this for any name because this is a family computer, and sometimes my cousins do enjoy playing games on this computer.

So here I am! Unfortunately I think I have done everything right, but that's not the case. When I run the game from my account, it doesn't go to the last Else statement to let me play. It thinks I am 'bigmike227' which I cannot figure out why!

Global $var = IniRead(@MyDocumentsDir&"\Steam\Counter Strike\Config\config.ini", "DefaultPlayer", "Name", "Unnamed")


while 1
    If $var="bigmike227" or "BIGMIKE227" Then
        WinWaitActive("Counter Strike")
        Sleep(5000)
        ControlSend("Counter Strike","","","Hello "&$var&"."&"{ENTER}")
        ControlSend("Counter Strike","","","You are not allowed to play this game!"&"{ENTER}")
        ControlSend("Counter Strike","","","Username: "&$var & " has now been blacklisted. DO YOUR HOMEWORK!!!""{ENTER}")
        
        Sleep(3000)
        $wbemFlagReturnImmediately = 0x10
        $wbemFlagForwardOnly = 0x20
        $colItems = ""
        $strComputer = "localhost"

        Dim $arMAC[1]=[0]
        $objWMIService = ObjGet("winmgmts:\\" & $strComputer & "\root\CIMV2")
        $colItems = $objWMIService.ExecQuery("SELECT * FROM Win32_NetworkAdapter", "WQL", _
                                          $wbemFlagReturnImmediately + $wbemFlagForwardOnly)

            If IsObj($colItems) then
                For $objItem In $colItems
                    If $objItem.MACAddress <> '' Then
                    ReDim $arMAC[UBound($arMAC)+1]
                    $arMAC[UBound($arMAC)-1] = $objItem.MACAddress
                    $arMAC[0] += 1
                    EndIf
                Next
            Endif



        RunWait(@ComSpec & " /c net config workstation > " & @TempDir & "\mac.txt", "", @SW_HIDE)

        If FileExists(@TempDir & "\mac.txt") Then

            $macfile = FileOpen(@TempDir & "\mac.txt", 0)

            While 1
                $macline = FileReadLine($macfile)
                    If @error = -1 Then ExitLoop
                    $macresult = StringInStr($macline, "NetBT_Tcpip_")
                        If $macresult <> "0" Then
                        $macline = StringStripWS($macline, 4)
                        $macarray = StringSplit($macline, "(")
                        $macline = StringStripWS($macarray[2], 8)
                        $macarray = StringSplit($macline, ")")
                        $macaddress = $macarray[1]
                    ExitLoop
                EndIf
            Wend
        IniWrite("C:\name.ini","section","key",$macaddress)
        FileClose($macfile)

        EndIf
    Else
        MsgBox(0,"Text","You are not "&$var)
    ExitLoop
EndIf
ExitLoop
    
WEnd

Also, the mac address function was taken from this forum. Many thanks for that, it saved me a heck of a lot of time!

I would be very pleased if someone could help me or point me in the right direction,

Thank you and take care,

Tater

Posted

That's some funny stuff. I would have probably tried something simpler, like making a password prompt show up when the counterstrike process exists, and if they don't put the password in it closes the game out or something. *shrug* I'd help you with what you've got there but I think it's over my head.

By the way, you may want to hide the tray icon so that he can't just close the script out.

Posted

Sounds like you're trying to get a laugh more than trying to get him to stop, but then again, you are are the sister, not the mother. :P

Posted (edited)

You're right, I may be enjoying myself a little too much with this. :P But on a side note, it's really driving me crazy, haha.

I know this sounds very... dull/first grade programming like, but is there a kind of like.. 'Goto' command in AutoIt? That would make this a ton easier! ;)

Edited by tater
Posted (edited)

Hello tater,

A couple things I notice:

1) $var is assigned to once at the top of the script outside of the while loop. If this script were running in the background, $var would never read the INI file again to see if the default player changed. Try moving the assignment to $var inside the while loop,

2) Failing the above, I would comment out all code concerning "BIGMIKE227". I would then place code in there to reflect who the script THINKS the player is. Then I would test the script by running the game with different players. If you do not have privileges to play as your brother, replace all your MsgBox commands with _FileWriteLog and record the player + time into a log file. Invite your brother to play after you've tested yourself. Once he's done, check the log file and see if the script is capturing the different players.

Maybe you should have your cousin's over more often. They'll definitely accept your invitation to play games and your brother will be "forced" to finish his homework before he can play. No passwords, no scripts. If I had to monitor a younger sibling like myself, that's what I'd do. :P

Zach...

Edited by zfisherdrums

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...