Jump to content

[HELP] Getting cmd and arguments from onPlayerCommand


..:D&G:..

Recommended Posts

Hello guys, I am trying to monitor what commands players use the most and the least, and record the command itself and the arguments used, like (/cmdname arg1 arg2) and store them in an txt file. The thing is I don't know how to get what command and arguments the player typed...

Any ideas?

Thanks.

Link to comment

I managed to do this, but it messes up at the first command, and sometimes it messes up on the second.

function logPlayerCommands(cmd) 
    local theFile = fileOpen("cmdslogs.txt") 
    fileSetPos(theFile, 200) 
    fileWrite(theFile, "CMD: /"..cmd.."\n") 
    fileClose(theFile)                             
end 
addEventHandler("onPlayerCommand", root, logPlayerCommands) 

I just want it to continue a new line for each command. something like:

"

CMD: /command1

CMD: /command2

"

And so on...

Link to comment

I made a script describing what you said but i couldnt find it else i would have sent it to you :D.

I made it so that when you did /commandlog playername a gui would popup and show you what commands they used, the time and date they used them. It would create a folder for each player with their account name and playername,

I think this should work i dont quite remember it was so long ago :lol:

function logPlayerCommands(cmd) 
    local theFile = fileOpen("cmdslogs.txt") 
    fileSetPos(theFile, fileGetSize(theFile) -- to go to the end of the file) 
    fileWrite(theFile, "CMD: /"..cmd.."\r\n") 
    fileClose(theFile)                             
end 
addEventHandler("onPlayerCommand", root, logPlayerCommands) 

Link to comment

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
  • Recently Browsing   0 members

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