viktorX Posted September 30, 2018 Share Posted September 30, 2018 hello i need someone to tell me how to make a script like that: log for players cmds i mean when someone type any cmd it's saves to file in ftp I also want to make a script to watch the cmds of a particular player inside the server how to make that? Link to comment
Dimos7 Posted September 30, 2018 Share Posted September 30, 2018 I think you need onPlayerCommand -- event fileCreate fileWrite fileClose Link to comment
viktorX Posted October 2, 2018 Author Share Posted October 2, 2018 need more help pls Link to comment
URBAN Posted October 2, 2018 Share Posted October 2, 2018 (edited) addEventHandler("onResourceStart",root, function() if fileExists("log.txt") then log = fileOpen("log.txt") else log = fileCreate("log.txt") end end) addEventHandler("onPlayerCommand",root, function(command) fileWrite(file,getPlayerName(source).." used "..command.." command.".."\n" ) end) Edited October 2, 2018 by URBAN Link to comment
#[K]iLLeR<3 Posted October 2, 2018 Share Posted October 2, 2018 your server will get lag if have many players .. Link to comment
N3xT Posted October 3, 2018 Share Posted October 3, 2018 15 hours ago, URBAN said: addEventHandler("onResourceStart",root, function() if fileExists("log.txt") then log = fileOpen("log.txt") else log = fileCreate("log.txt") end end) addEventHandler("onPlayerCommand",root, function(command) fileWrite(file,getPlayerName(source).." used "..command.." command.".."\n" ) end) You need to close the file after you finish editing. Link to comment
Gordon_G Posted October 3, 2018 Share Posted October 3, 2018 So now MTA's forum directly gives scripts Link to comment
sanyisasha Posted October 3, 2018 Share Posted October 3, 2018 3 hours ago, Gordon_G said: So now MTA's forum directly gives scripts Yeah, dunno why. Maybe road to +reps. 10 hours ago, N3xT said: You need to close the file after you finish editing. And use log isntead of file variable. Btw i think this keep open the file to optimize more memory. Bcs open/close file every command not better than keep the file open (i think fileWrite don't require fileClose to work) Link to comment
N3xT Posted October 4, 2018 Share Posted October 4, 2018 4 hours ago, sanyisasha said: Yeah, dunno why. Maybe road to +reps. And use log isntead of file variable. Btw i think this keep open the file to optimize more memory. Bcs open/close file every command not better than keep the file open (i think fileWrite don't require fileClose to work) Wiki: It is also important to remember to close a file after you've finished all your operations on it, especially if you've been writing to the file. If you don't close a file and your resource crashes, all changes to the file may be lost. Link to comment
Discord Moderators Pirulax Posted October 9, 2018 Discord Moderators Share Posted October 9, 2018 You can use fileFlush to save the changes made to the file, but it doesn't close the file, which is, obviously good for ya' Link to comment
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