Jump to content

Recording in logs


Geo

Recommended Posts

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

Link to comment
Share on other sites

  • Management

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.

Link to comment
Share on other sites

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
Link to comment
Share on other sites

  • Management

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
Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...