Jump to content

writing .cfg's


layer
 Share

Recommended Posts

hello... i thought i saw this a while ago... but how would i write a .cfg? ive searched the help file... ive looked in file.au3... but heres my code that doest write any .cfg files...

Func n0r3c0i1 ()
   $path= "C:\Program Files\Steam\SteamApps\mynamehere**\counter-strike\cstrike\autoexec.cfg"
FileWriteLine ($path, "cl_pitchspeed 2.5")
FileWriteLine ($path, "alias w wait")
FileWriteLine ($path, "alias +ab ab1; ab2")
FileWriteLine ($path, "alias -ab ab3; ab4")
FileWriteLine ($path, "alias ab1 +lookdown; w; +attack")
FileWriteLine ($path, "alias ab2 +lookdown; w; +attack")
FileWriteLine ($path, "alias ab3 -lookdown; w; -attack")
FileWriteLine ($path, "alias ab4 -lookdown; w; -attack")
FileWriteLine ($path, "bind mouse1 +ab")
EndFunc

While 1
Sleep(10)
$get= GUIGetMsg ()
Select
Case $get= $b1
   n0r3c0i1 ()
   EndSelect
WEnd

lets say $1 and others are already defined though... what am i doing wrong?

Edited by layer
FootbaG
Link to comment
Share on other sites

While 1
   
   Sleep(10)
   $get= GUIGetMsg ()
   
   Select
   Case 1=1;$get= $b1
      n0r3c0i1 ()
      Exit; for testing purposes
   EndSelect
   
WEnd

Func n0r3c0i1 ()
   Local $sFile = "output.cfg"; for testing purposes
  ;"C:\Program Files\Steam\SteamApps\MYNAMEHERE\counter-strike\cstrike\autoexec.cfg"
   
   FileWriteLine ($sFile, "cl_pitchspeed 2.5")
   FileWriteLine ($sFile, "alias w wait")
   FileWriteLine ($sFile, "alias +ab ab1; ab2")
   FileWriteLine ($sFile, "alias -ab ab3; ab4")
   FileWriteLine ($sFile, "alias ab1 +lookdown; w; +attack")
   FileWriteLine ($sFile, "alias ab2 +lookdown; w; +attack")
   FileWriteLine ($sFile, "alias ab3 -lookdown; w; -attack")
   FileWriteLine ($sFile, "alias ab4 -lookdown; w; -attack")
   FileWriteLine ($sFile, "bind mouse1 +ab")
EndFunc

Yeah...as Valik said. :idiot:

Link to comment
Share on other sites

hmmm, i updated the code up there ^^ still doesn't work... :D

EDIT: i even tried josbe's code, that doesnt work either :lol::idiot:

EDIT2: nevermind, i got it, thanks guys

EDIT3: sometimes i think my brain is as small as homers... ;)

Edited by layer
FootbaG
Link to comment
Share on other sites

One possible revision. See the FileWriteLine remarks for why this is better...

Func n0r3c0i1 ()
   Local $path = "C:\Program Files\Steam\SteamApps\MYNAMEHERE\counter-strike\cstrike\autoexec.cfg"
   Local $handle = FileOpen($path, 1);append mode
   If $handle = -1 Then
      Return MsgBox(4096,"Error","Could not open file for writing...")
   EndIf
   
   FileWriteLine($handle, "cl_pitchspeed 2.5")
   FileWriteLine($handle, "alias w wait"
   FileWriteLine($handle, "alias +ab ab1; ab2"
   FileWriteLine($handle, "alias -ab ab3; ab4"
   FileWriteLine($handle, "alias ab1 +lookdown; w; +attack"
   FileWriteLine($handle, "alias ab2 +lookdown; w; +attack"
   FileWriteLine($handle, "alias ab3 -lookdown; w; -attack"
   FileWriteLine($handle, "alias ab4 -lookdown; w; -attack"
   FileWriteLine($handle, "bind mouse1 +ab"
EndFunc

In fact, why do you even need to FileWriteLine text that doesn't change? Couldn't you overwrite autoexec.cfg with a premade file?

If you wanted to merge a premade file with autoexec.cfg you could try the following on Windows XP (assuming you used the correct full file paths):

Run('cmd /c type "yourAdditionalLines.cfg" >> "autoexec.cfg"', "", @SW_HIDE)

Use Mozilla | Take a look at My Disorganized AutoIt stuff | Very very old: AutoBuilder 11 Jan 2005 prototype I need to update my sig!
Link to comment
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
 Share

  • Recently Browsing   0 members

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