Sign in to follow this  
Followers 0
layer

writing .cfg's

7 posts in this topic

#1 ·  Posted (edited)

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

Share this post


Link to post
Share on other sites

Quite obviously (Given that you've specified the full path 329538259 times which is dumb...), you're missing a \ after the drive letter.

Share this post


Link to post
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:

Share this post


Link to post
Share on other sites

#4 ·  Posted (edited)

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

Share this post


Link to post
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!

Share this post


Link to post
Share on other sites

thanks cyberslug! that looks awesome :D thanks for helping me :idiot:


FootbaG

Share this post


Link to post
Share on other sites

Now that you got it don't forget "exec autoexec.cfg"

And you better not forget -console

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  
Followers 0