I have a little problem changing line, I dont know why but it seems it's not working.
[QUOTE]
hook.Add( "PlayerButtonDown", "Example", function( _, key, ply)
if ( key == KEY_F7 ) then
print( "Shit ran" )
file.Write("listofusers.txt", "The file was edited.\n") -- I tried \r\n & \n
end
end )
[/QUOTE]
there are 2 arguments in playerbuttondown, you are excluding the first one by doing '_', remove the '_' and it will work.
[QUOTE=Invule;52732056]there are 2 arguments in playerbuttondown, you are excluding the first one by doing '_', remove the '_' and it will work.[/QUOTE]
Still not working. I tried what you said:
[QUOTE]
hook.Add( "PlayerButtonDown", "Example", function( ply, key)
if ( key == KEY_F7 ) then
print( "Shit ran" )
file.Write("listofusers.txt", "The file was edited.\r\n")
-- do your stuff here
end
end )
[/QUOTE]
What exactly do you want? "It's not working" doesn't give us much to go on considering we don't even know what you're trying to do.
[QUOTE=txike;52732080]What exactly do you want? "It's not working" doesn't give us much to go on considering we don't even know what you're trying to do.[/QUOTE]
[QUOTE]I have a little problem changing line, I dont know why but it seems it's not working.
[/QUOTE]
I want to add a line with text everytime I press F7.
I don't see any issues with the code above, make sure its serverside and the file is being ran.
[QUOTE=Invule;52732093]I don't see any issues with the code above, make sure its serverside and the file is being ran.[/QUOTE]
I delete the file, Press F7, the file is recreated and the text is in it, but it seems everytime I press F7 it simply replace the complete file.
Check if the file exists using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/file/Exists]file.Exists[/url]. If it doesn't then create it, otherwise use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/file/Append]file.Append[/url].
[QUOTE=txike;52732235]Check if the file exists using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/file/Exists]file.Exists[/url]. If it doesn't then create it, otherwise use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/file/Append]file.Append[/url].[/QUOTE]
It actually worked ! Thank you for helping me out . :cat:
Sorry, you need to Log In to post a reply to this thread.