lm1 Posted November 8, 2006 Posted November 8, 2006 im working at an internet cafe and this script if for our counterstrike game, the script is supposed to dole out dummy licence files to set the log in on that computer from our server, it is supposed to mark a dummy file as read only before it starts to stop any other computers from running at the same time so they dont copy files. now it is dealing out the same license multiple times the code is as such expandcollapse popup; ---------------------------------------------------------------------------- ; <AUT2EXE INCLUDE-END: C:\Program Files\AutoIt3\Include\GUIConstants.au3> ; ---------------------------------------------------------------------------- ;Run random picture from z:\pics directory Break(0) ;user cannot close script Dim $var1 ;creates $var1 variable $var1 =Random(1, 5, 1) $gui1 = GUICreate("The Liquid Matrix",1040,840,-1,-1,$WS_SIZEBOX+$WS_SYSMENU) ;creates Guipicture with the var $gui1 GUISetBkColor (0x000000) GUICtrlCreatePic("z:\Pics\"& $var1 & ".jpg",60,108, 900,500) GUISetState(@SW_SHOW) Dim $user $user = RegRead("HKCU\Environment", "asc_user") ;grabs user variable from registry (SL issues this) $search1 = FileFindFirstFile("D:\Valve\Steam\lmsteamclient??");Searches for dummy license file locally If $search1=0 Then $steamclient = FileFindNextFile($search1) ;if search successful, $steamclient set to Local client file FileCopy("D:\Valve\"& $steamclient &"","z:\valve\licensesmoved\") EndIf If $search1 = -1 Then ;if local search fails, search z:\valve\licenses directory Do ;Checks dummy.txt for file attribute - Waits until not read only (Otherwise, someone launching steam at the same time may end up with the same license $attrib = FileGetAttrib("z:\valve\licenses\dummy.txt") sleep(200) Until Not StringInStr($attrib, "R") FileSetAttrib("z:\valve\licenses\dummy.txt", "+R") $search2 = FileFindFirstFile("z:\Valve\licenses\lmsteamclient??") ; Check if network search also unsuccessful, no licenses found, program exits If $search2 = -1 Then MsgBox(0, "Notice", "No License Found: Manual login needed- Please Ask Staff for Assistance.") FileSetAttrib("z:\valve\licenses\dummy.txt", "-R") Exit EndIf ; Apply steamclient variable to search results $steamclient = FileFindNextFile($search2) FileClose($search2) EndIf ; Move dummy license file out to used license directory If FileExists("z:\valve\licenses\"& $steamclient &"") then Filemove("z:\Valve\licenses\"& $steamclient &"","z:\valve\licensesmoved",1) EndIf FileSetAttrib("z:\valve\licenses\dummy.txt", "-R") ; waits till steamclient var set, and license moved, then takes read only off of dummy.txt (allows next user to launch steam) Run("D:\Valve\Steam\Steam.exe -login "& $steamclient &" 59122494"); run Steam w/ user and passy ; Copy user files to current steam directory FileCopy("Y:\"& $user &"\Steam\config.cfg", "D:\Valve\Steam\SteamApps\"& $steamclient &"\counter-strike source\cstrike\cfg\config.cfg", 1) DirCopy("Y:\"& $user &"\Steam\SAVE", "D:\Valve\Steam\SteamApps\"& $steamclient &"\half-life 2\hl2\SAVE", 1) ; wait for hl2.exe to exist, Timeout after 2 minutes dim $count $count=1 Dim $exec Do If not ProcessExists("steam.exe") then ExitLoop If ProcessExists("hl2.exe") then $exec="hl2.exe" ExitLoop EndIf If ProcessExists("hl.exe") then $exec="hl.exe" ExitLoop Endif If ProcessExists("se4.exe") then $exec="se4.exe" ExitLoop EndIf If ProcessExists("darwinia.exe") then $exec="darwinia.exe" ExitLoop EndIf If ProcessExists("Rag_Doll_Kung_Fu_Steam.exe") then $exec="Rag_Doll_Kung_Fu_Steam.exe" ExitLoop EndIf If ProcessExists("sin.exe") then $exec="sin.exe" ExitLoop EndIf If ProcessExists("RedOrchestra.exe") then $exec="RedOrchestra.exe" ExitLoop EndIf If ProcessExists("Shadowgrounds.exe") then $exec="Shadowgrounds.exe" ExitLoop EndIf If ProcessExists("dangerouswaters.exe") then $exec="dangerouswaters.exe" ExitLoop EndIf Sleep(1000) $count = $count + 1 Until $count=25000 If IsDeclared("exec") then ProcessWaitClose(""& $exec &"") Filemove("z:\valve\licensesmoved\"& $steamclient &"","z:\Valve\licenses\",1) ;move the dummy license file back to usable license directory GUICreate("The Liquid Matrix",1040,840,-1,-1,$WS_SIZEBOX+$WS_SYSMENU) GUISetBkColor (0x000000) GUICtrlCreatePic("z:\Pics\closegame.jpg",60,108, 900,500) GUISetState(@SW_SHOW) GUIDelete($gui1) WinSetOnTop("The Liquid Matrix","",1) WinSetState("STEAM -","",@SW_MINIMIZE) ;delete local file FileDelete("D:valve\"& $steamclient &"") ;once hl2.exe closes, steam.exe is terminated Processclose("steam.exe") $begin = TimerInit() ;copy user cfgs and saves to user directory FileCopy("D:\Valve\Steam\SteamApps\"& $steamclient &"\counter-strike source\cstrike\cfg\config.cfg","Y:\"& $user &"\Steam\config.cfg", 1) DirCopy("D:\Valve\Steam\SteamApps\"& $steamclient &"\half-life 2\hl2\SAVE", "Y:\"& $user &"\Steam\SAVE", 1) TimerDiff($begin) $dif = TimerDiff($begin) If $dif< 2000 then Sleep (2000) If $dif> 5000 then MsgBox(0,"Liquid Matrix","Sorry about the wait "& $user &". Your game files are now saved!") if anyone has any idea as to why it is doing this any help would be nice and i will be working on this a lot because this is one of our major games that we have running at this business
tresa Posted November 9, 2006 Posted November 9, 2006 what means your test $search1 = FileFindFirstFile("D:\Valve\Steam\lmsteamclient??");Searches for dummy license file locally If $search1=0 Then .... if the search is succesfull $search1 is a handle<>0 And the other kind of test after filefindfirstfile is @error=1 (in the help file)
tresa Posted November 9, 2006 Posted November 9, 2006 Without knowing if this is the issue, I found that your waiting loop is dangerous : ... Do ;Checks dummy.txt for file attribute - Waits until not read only (Otherwise, someone launching steam at the same time may end up with the same license $attrib = FileGetAttrib("z:\valve\licenses\dummy.txt") sleep(200) Until Not StringInStr($attrib, "R") ...
lm1 Posted November 11, 2006 Author Posted November 11, 2006 well i just started to redo the entire script, so how it goes is we have a folder that holds dummy license files that depending on what one it grabs sets the login name and the pass. we have a file called dummy.txt and the script cannot continue untill that file is not read only. then the next person can grab a license this is what i have so far any help would be good. expandcollapse popup;Run random picture from z:\pics directory Break(0) ;user cannot close script Dim $var1 ;creates $var1 variable $var1 =Random(1, 5, 1) $gui1 = GUICreate("The Liquid Matrix",1040,840,-1,-1,$WS_SIZEBOX+$WS_SYSMENU) ;creates Guipicture with the var $gui1 GUISetBkColor (0x000000) GUICtrlCreatePic("z:\Pics\"& $var1 & ".jpg",60,108, 900,500) GUISetState(@SW_SHOW) Dim $user $user = RegRead("HKCU\Environment", "asc_user") ;grabs user variable from registry (SL issues this) Do sleep(200) ;Checks dummy.txt for file attribute - Waits until not read only (Otherwise, someone launching steam at the same time may end up with the same license $attrib = FileGetAttrib("z:\valve\licenses\dummy.txt") Until Not StringInStr($attrib, "R") FileSetAttrib("z:\valve\licenses\dummy.txt", "+R") $search1 = FileFindFirstFile("z:\Valve\licenses\lmsteamclient??") ; Check if network search also unsuccessful, no licenses found, program exits If $search1 = -1 Then MsgBox(0, "Notice", "No License Found: Manual login needed- Please Ask Staff for Assistance.") FileSetAttrib("z:\valve\licenses\dummy.txt", "-R") endIf ; Apply steamclient variable to search results $steamclient = FileFindNextFile($search1) FileClose($search1) ; Move dummy license file out to used license directory If FileExists("z:\valve\licenses\"& $steamclient &"") then Filemove("z:\Valve\licenses\"& $steamclient &"","z:\valve\licensesmoved",1) EndIf sleep(100) FileSetAttrib("z:\valve\licenses\dummy.txt", "-R") ; waits till steamclient var set, and license moved, then takes read only off of dummy.txt (allows next user to launch steam) Run("D:\Valve\Steam\Steam.exe -login "& $steamclient &" 59122494"); run Steam w/ user and passy ; Copy user files to current steam directory FileCopy("Y:\"& $user &"\Steam\config.cfg", "D:\Valve\Steam\SteamApps\"& $steamclient &"\counter-strike source\cstrike\cfg\config.cfg", 1) DirCopy("Y:\"& $user &"\Steam\SAVE", "D:\Valve\Steam\SteamApps\"& $steamclient &"\half-life 2\hl2\SAVE", 1) dim $count $count=1 Dim $exec Do If not ProcessExists("steam.exe") then ExitLoop If ProcessExists("hl2.exe") then $exec="hl2.exe" ExitLoop EndIf If ProcessExists("hl.exe") then $exec="hl.exe" ExitLoop Endif If ProcessExists("se4.exe") then $exec="se4.exe" ExitLoop EndIf If ProcessExists("darwinia.exe") then $exec="darwinia.exe" ExitLoop EndIf If ProcessExists("Rag_Doll_Kung_Fu_Steam.exe") then $exec="Rag_Doll_Kung_Fu_Steam.exe" ExitLoop EndIf If ProcessExists("sin.exe") then $exec="sin.exe" ExitLoop EndIf If ProcessExists("RedOrchestra.exe") then $exec="RedOrchestra.exe" ExitLoop EndIf If ProcessExists("Shadowgrounds.exe") then $exec="Shadowgrounds.exe" ExitLoop EndIf If ProcessExists("dangerouswaters.exe") then $exec="dangerouswaters.exe" ExitLoop EndIf Sleep(1000) $count = $count + 1 Until $count=25000 If IsDeclared("exec") then ProcessWaitClose(""& $exec &"") Filemove("z:\valve\licensesmoved\"& $steamclient &"","z:\Valve\licenses\",1) ;move the dummy license file back to usable license directory GUICreate("The Liquid Matrix",1040,840,-1,-1,$WS_SIZEBOX+$WS_SYSMENU) GUISetBkColor (0x000000) GUICtrlCreatePic("z:\Pics\closegame.jpg",60,108, 900,500) GUISetState(@SW_SHOW) GUIDelete($gui1) WinSetOnTop("The Liquid Matrix","",1) WinSetState("STEAM -","",@SW_MINIMIZE) ;delete local file FileDelete("D:valve\"& $steamclient &"") ;once hl2.exe closes, steam.exe is terminated Processclose("steam.exe") $begin = TimerInit() ;copy user cfgs and saves to user directory FileCopy("D:\Valve\Steam\SteamApps\"& $steamclient &"\counter-strike source\cstrike\cfg\config.cfg","Y:\"& $user &"\Steam\config.cfg", 1) DirCopy("D:\Valve\Steam\SteamApps\"& $steamclient &"\half-life 2\hl2\SAVE", "Y:\"& $user &"\Steam\SAVE", 1) TimerDiff($begin) $dif = TimerDiff($begin) If $dif< 2000 then Sleep (2000) If $dif> 5000 then MsgBox(0,"Liquid Matrix","Sorry about the wait "& $user &". Your game files are now saved!")
tresa Posted November 11, 2006 Posted November 11, 2006 well i just started to redo the entire script, so how it goes is we have a folder that holds dummy license files that depending on what one it grabs sets the login name and the pass. we have a file called dummy.txt and the script cannot continue untill that file is not read only. then the next person can grab a license this is what i have so far any help would be good. ; Check if network search also unsuccessful, no licenses found, program exits If $search1 = -1 Then MsgBox(0, "Notice", "No License Found: Manual login needed- Please Ask Staff for Assistance.") FileSetAttrib("z:\valve\licenses\dummy.txt", "-R") endIf oÝ÷ Ûú®¢×¢»a˧²çz˺[j·!Ê¢¸(¶Ø^{²Özg§µ«¢+Ø(ì ¡¬¥¹ÑݽɬÍÉ ±Í¼Õ¹ÍÕÍÍÕ°°¹¼±¥¹Í̽չ°Áɽɴá¥ÑÌ(%ÀÌØíÍÉ Äô´ÄQ¡¸(5Í ½à À°ÅÕ½Ðí9½Ñ¥ÅÕ½Ðì°ÅÕ½Ðí9¼1¥¹Í½Õ¹è5¹Õ°±½¥¸¹´A±ÍͬMѽÈÍÍ¥Íѹ¸ÅÕ½Ðì¤(¥±MÑÑÑÉ¥ ÅÕ½ÐíèèÀäÈíÙ±ÙÀäÈí±¥¹ÍÌÀäÈíÕµµä¹ÑáÐÅÕ½Ðì°ÅÕ½ÐìµHÅÕ½Ðì¤(á¥Ð(¹%(
tresa Posted November 11, 2006 Posted November 11, 2006 (edited) well i just started to redo the entire script, so how it goes is we have a folder that holds dummy license files that depending on what one it grabs sets the login name and the pass. we have a file called dummy.txt and the script cannot continue untill that file is not read only. then the next person can grab a license this is what i have so far any help would be good. expandcollapse popupdim $count $count=1 Dim $exec Do If not ProcessExists("steam.exe") then ExitLoop If ProcessExists("hl2.exe") then $exec="hl2.exe" ExitLoop EndIf If ProcessExists("hl.exe") then $exec="hl.exe" ExitLoop Endif If ProcessExists("se4.exe") then $exec="se4.exe" ExitLoop EndIf If ProcessExists("darwinia.exe") then $exec="darwinia.exe" ExitLoop EndIf If ProcessExists("Rag_Doll_Kung_Fu_Steam.exe") then $exec="Rag_Doll_Kung_Fu_Steam.exe" ExitLoop EndIf If ProcessExists("sin.exe") then $exec="sin.exe" ExitLoop EndIf If ProcessExists("RedOrchestra.exe") then $exec="RedOrchestra.exe" ExitLoop EndIf If ProcessExists("Shadowgrounds.exe") then $exec="Shadowgrounds.exe" ExitLoop EndIf If ProcessExists("dangerouswaters.exe") then $exec="dangerouswaters.exe" ExitLoop EndIf Sleep(1000) $count = $count + 1 Until $count=25000 If IsDeclared("exec") then ProcessWaitClose(""& $exec &"") Edited November 12, 2006 by tresa
tresa Posted November 11, 2006 Posted November 11, 2006 well i just started to redo the entire script, so how it goes is we have a folder that holds dummy license files that depending on what one it grabs sets the login name and the pass. we have a file called dummy.txt and the script cannot continue untill that file is not read only. then the next person can grab a license this is what i have so far any help would be good. TimerDiff($begin) $dif = TimerDiff($begin) If $dif< 2000 then Sleep (2000) If $dif> 5000 then MsgBox(0,"Liquid Matrix","Sorry about the wait "& $user &". Your game files are now saved!") oÝ÷ Ûú®¢×jvÞÞ²)©æ®¶s`¤bFÖW$Ffbb33c¶&VvâfwC²3FVâ×6t&÷ÂgV÷C´ÆVBÖG&gV÷C²ÂgV÷Cµ6÷''&÷WBFRvBgV÷C²fײb33c·W6W"fײgV÷C²â÷W"vÖRfÆW2&Ræ÷r6fVBb333²gV÷C² You may also include a timeout so that the msgbox atomatically close after a certain amount of time
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now