Sign in to follow this  
Followers 0
Skrip

Any reason why this won't write to file?

5 posts in this topic

$Input7 = GUICtrlCreateInput("shared.lua", 160, 216, 121, 21)
$Input32 = GUICtrlCreateInput("Garry's Mod", 160, 192, 433, 21)
$Input33 = GUICtrlCreateInput("", 160, 224, 433, 21)
;PreVars
$path = RegRead("HKEY_CURRENT_USER\Software\Valve\Steam", "SteamPath")
GUICtrlSetData($Input32, $path)

While 1
    $nMsg = GUIGetMsg()
    Switch $nMsg
        Case $GUI_EVENT_CLOSE
            Exit
        Case $Button1
            $path = GUICtrlRead($Input32)
            $name = GUICtrlRead($Input33)
            $file = FileOpen($path & "\" & $name & ".lua", 2)
            Sleep(100)
            FileWrite($file, "if (SERVER) then" & @CRLF)
            FileWrite($file, "AddCSLuaFile(""" & $input7 & """)")
            FileWrite($file, "SWEP.Weight = " & $input7)
    EndSwitch
WEnd

I think that's all you need to figure it out. If you need the whole code. PM me.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites



Case $Button1
$Button1 is missing on the GUI.

Share this post


Link to post
Share on other sites

Well, I do not know if that's the problem.

It creates the file. It just doesn't write the lines.


[left][sub]We're trapped in the belly of this horrible machine.[/sub][sup]And the machine is bleeding to death...[/sup][sup][/sup][/left]

Share this post


Link to post
Share on other sites

OK, it works for me fine when creating files. The lines are written OK too, here is the code in case I have the concept wrong:

$Input7 = "shared.lua"
;PreVars
$path = RegRead("HKEY_CURRENT_USER\Software\Valve\Steam", "SteamPath")

$name = "Hello"
MsgBox(0,"",$path & "\" & $name & ".lua")
$file = FileOpen($path & "\" & $name & ".lua", 2)
Sleep(100)
FileWrite($file, "if (SERVER) then" & @CRLF)
FileWrite($file, "AddCSLuaFile(""" & $input7 & """)")
FileWrite($file, "SWEP.Weight = " & $input7)
FileClose($file)

And the file looks like:

if (SERVER) then
AddCSLuaFile("shared.lua")SWEP.Weight = shared.lua

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