HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. #include <sourcemod>
  2.  
  3. public Plugin:myinfo =
  4. {
  5. name = "Admin loggin",
  6. author = "vIr-Dan",
  7. description = "Logs to admin_STEAMID",
  8. version = "1.0",
  9. url = "http://dansbasement.us"
  10. };
  11.  
  12. public OnPluginStart(){
  13. CreateConVar("sm_al_version","1.0","The version of 'admin logging' running.",FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY);
  14. }
  15.  
  16. public Action:OnLogAction(Handle:source,
  17. Identity:ident,
  18. client,
  19. target,
  20. const String:message[])
  21. {
  22. /* If there is no client or they're not an admin, we don't care. */
  23. if (client < 1 || GetUserAdmin(client) == INVALID_ADMIN_ID)
  24. {
  25. return Plugin_Continue;
  26. }
  27.  
  28. decl String:logtag[64];
  29.  
  30. /* At the moment extensions can't be passed through here yet,
  31. * so we only bother with plugins, and use "SM" for anything else.
  32. */
  33. if (ident == Identity_Plugin)
  34. {
  35. GetPluginFilename(source, logtag, sizeof(logtag));
  36. } else {
  37. strcopy(logtag, sizeof(logtag), "SM");
  38. }
  39.  
  40. /* ':' is not a valid filesystem token on Windows so we replace
  41. * it with '-' to keep the file names readable.
  42. */
  43. decl String:steamid[32];
  44. GetClientAuthString(client, steamid, sizeof(steamid));
  45. ReplaceString(steamid, sizeof(steamid), ":", "-");
  46.  
  47. /* Prefix our file with the word 'admin_' */
  48. decl String:file[PLATFORM_MAX_PATH];
  49. BuildPath(Path_SM, file, sizeof(file), "logs/admin_%s.log", steamid);
  50.  
  51. /* Finally, write to the log file with the log tag we deduced. */
  52. LogToFileEx(file, "[%s] %s", logtag, message);
  53.  
  54. /* Block Core from re-logging this. */
  55. return Plugin_Handled;
  56. }