Jump to content

  • Log in with Facebook Log in with Twitter Log In with Google Log In with Steam Sign In
  • Create Account
Photo

Recording in logs

- - - - -

  • Please log in to reply
7 replies to this topic

#1
OFFLINE   Geo

Geo

    Regular Member

  • Members
  • PipPipPip
  • 70 posts
12
A step in the right direction
  • LocationUnited Kingdom

If I was getting player guids like this:

 

function GetPlayerGUID(client)
local player_guid = et.Info_ValueForKey(et.trap_GetUserinfo(client), "sil_guid" )
if player_guid == "NO_GUID" or player_guid == "unknown" then 
return true
end
return player_guid
end

 

and checking if clients use a certain cmd (let's say i'm looking for people trying to access rcon for example) something like this

 

function et_ClientCommand(clientNum, command)
   if et.trap_Argv(0) == "rcon" then
      if et.trap_Argc() == 2 then
      et.trap_SendServerCommand(clientNum, "print blablabla")
 
      et.G_Logprint(????) -- WHAT GOES HERE? SOMETHING TO PRINT GUID INTO LOG. PLAYER_GUID FROM ABOVE?
    else
      return
  end
 return 1
end
end

I want a msg to print to the client, but I want to record their silent GUID in the console log for further notice. How can I do this? Thanks

Could be totally in wrong direction here but i'm just experimenting



#2
OFFLINE   gaoesa

gaoesa

    Advanced Member

  • Management
  • PipPipPipPip
  • 4391 posts
341
Will become famous
  • LocationFinland

The rcon command is not an actual client command. If you want to log them, unfortunately, it must be done in the server engine or in the firewall. Luckily, the rcon command is sent as plain text inside the packets. I don't know what kind of options current server engine modifications can offer for this type of security.



#3
OFFLINE   Geo

Geo

    Regular Member

  • Members
  • PipPipPip
  • 70 posts
12
A step in the right direction
  • LocationUnited Kingdom

Ah okay thanks for the clarification. About the g_logprint, would there be a way to print the GUID of player that uses a console command (say if they did /players for a random example) to the log?


Edited by Arcane, 31 March 2013 - 03:55 PM.


#4
OFFLINE   gaoesa

gaoesa

    Advanced Member

  • Management
  • PipPipPipPip
  • 4391 posts
341
Will become famous
  • LocationFinland

Yes. You can intercept the "players" command with et_ClientCommand Lua hook.

 

For example:

function et_ClientCommand(clientNum, command)
	command = command:lower()
	if command == "players" then
		local name = et.gentity_get(clientNum, "pers.netname")
		local guid = et.gentity_get(clientNum, "sess.guid")
		local logLine = "Player "..name.." silEnT GUID "..guid.." executed command: "..command.."\n"
     
		-- log to the server log
		et.G_LogPrint(logLine)
		-- log to a separate file
		fd, len = et.trap_FS_FOpenFile("clientcommands.log", et.FS_APPEND)
		et.trap_FS_Write(logLine, string.len(logLine), fd)
		et.trap_FS_FCloseFile(fd)
	end

	return 0
end


#5
OFFLINE   Geo

Geo

    Regular Member

  • Members
  • PipPipPip
  • 70 posts
12
A step in the right direction
  • LocationUnited Kingdom

Thankyou, I managed to get my original script to work but your example is much simpler and a lot easier to understand! Much appreciated.



#6
OFFLINE   Geo

Geo

    Regular Member

  • Members
  • PipPipPip
  • 70 posts
12
A step in the right direction
  • LocationUnited Kingdom

There's one more question I have about this - can I add the date and time of when a client executes a command. E.G in the log 2013-04-05: 01:13:00 so I can check the log and see what time the specific command was executed. I tried to do this but I couldn't get it to work.



#7
OFFLINE   gaoesa

gaoesa

    Advanced Member

  • Management
  • PipPipPipPip
  • 4391 posts
341
Will become famous
  • LocationFinland

Using the older example as base

 

local timestamp = os.date("%Y-%m-%d %H:%M:%S")
local logLine = timestamp.." Player "..name.." silEnT GUID "..guid.." executed command: "..command.."\n"

  • Geo likes this

#8
OFFLINE   Geo

Geo

    Regular Member

  • Members
  • PipPipPip
  • 70 posts
12
A step in the right direction
  • LocationUnited Kingdom

Thanks, this worked perfectly!






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users