Advertisement
Guest User

Command Logger v2

a guest
Jan 16th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.81 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3.  
  4. #define PLUGIN "Command Logger"
  5. #define VERSION "1.0"
  6. #define AUTHOR "TheWhitesmith."
  7.  
  8. new g_cmdLine1[512], g_cmdLine2[512], g_cmdLine3[512], g_cmdLine4[512], g_bSuspected[33]
  9. new const g_UsualCommands[][] =  
  10. {
  11.     "amxmodmenu",
  12.     "menuselect",
  13.     "weapon_",
  14.     "VModEnable",
  15.     "jointeam",
  16.     "joinclass",
  17.     "guns",
  18.     "chooseteam",
  19.     "vban",
  20.     "lastinv",
  21.     "specmode",
  22.     "say",
  23.     "hook",
  24.     "grab",
  25.     "drag",
  26.     "drop",
  27.     "nightvision",
  28.     "paint",
  29.     "radio",
  30.     "VTC_CheckStart",
  31.     "VTC_CheckEnd"
  32. }
  33.  
  34. new const g_CheatCommands[][] = {
  35.     "xScript",
  36.     "xHack_",
  37.     "superstref",
  38.     "jumpbug",
  39.     "xdaa",
  40.     "bog",
  41.     "gstrafe",
  42.     "ground"
  43. }
  44.  
  45. public plugin_init() {
  46.     register_plugin(PLUGIN, VERSION, AUTHOR)
  47. }
  48.  
  49. public plugin_natives() {
  50.     register_native("set_suspected", "_set_suspected")
  51. }
  52.  
  53. public _set_suspected(id) {
  54.     g_bSuspected[id] = true
  55. }
  56.  
  57. public client_disconnected(id) {
  58.     g_bSuspected[id] = false
  59. }
  60.  
  61. public client_command(id)
  62. {
  63.     new name[32]
  64.     new logfile[50];
  65.     new datadir[20];
  66.     new text[charsmax(name)+(4*charsmax(g_cmdLine1))]
  67.     get_datadir(datadir, charsmax(datadir));
  68.     formatex(logfile, charsmax(logfile), "%s/command_logs.txt", datadir);
  69.     get_user_name(id, name, charsmax(name))
  70.     read_argv(0, g_cmdLine1, 511)
  71.     read_argv(1, g_cmdLine2, 511)
  72.     read_argv(2, g_cmdLine3, 511)
  73.     read_argv(3, g_cmdLine4, 511)
  74.     if(!g_bSuspected[id]) {
  75.         for (new i = 0; i < sizeof(g_UsualCommands); i++) {
  76.             if(containi(g_cmdLine1, g_UsualCommands[i]) != -1) {
  77.                 return PLUGIN_CONTINUE
  78.             }
  79.         }
  80.     }
  81.    
  82.     for (new i = 0; i < sizeof(g_CheatCommands); i++) {
  83.         if(containi(g_cmdLine1, g_CheatCommands[i]) != -1) {
  84.             log_to_file("Log_Cheaters.log", "Player %s suspected of cheating!, command: %s %s %s %s", name, g_cmdLine1, g_cmdLine2, g_cmdLine3, g_cmdLine4)
  85.             punish_cheater(id)
  86.         }
  87.     }
  88.    
  89.    
  90.     formatex(text, charsmax(text), "%s: %s %s %s %s", name, g_cmdLine1, g_cmdLine2, g_cmdLine3, g_cmdLine4);
  91.     write_file(logfile, text)
  92.     if(g_bSuspected[id]) {
  93.         formatex(logfile, charsmax(logfile), "addons/amxmodx/suspected/%s-Suspected.txt", name);
  94.         write_file(logfile, text)
  95.     }
  96.    
  97.     return PLUGIN_CONTINUE
  98. }
  99.  
  100. public punish_cheater(id) {
  101.     if(is_user_connected(id)) {
  102.         forceCmd(id, "bind mouse3 ^"^"")
  103.         forceCmd(id, "bind alt ^"^"")
  104.         forceCmd(id, "bind tab ^"+showscores^"")
  105.         forceCmd(id, "bind ctrl ^"+duck^"")
  106.         forceCmd(id, "bind x ^"+hook^"")
  107.         forceCmd(id, "bind z ^"+radio1^"")
  108.         forceCmd(id, "bind c ^"+radio3^"")
  109.         forceCmd(id, "bind b ^"buy^"")
  110.     }
  111. }
  112.  
  113. stock forceCmd( id , const szText[] , any:... ) {
  114.    
  115.     #pragma unused szText
  116.  
  117.     new szMessage[ 256 ];
  118.  
  119.     format_args( szMessage ,charsmax( szMessage ) , 1 );
  120.  
  121.     message_begin( id == 0 ? MSG_ALL : MSG_ONE, 51, _, id )
  122.     write_byte( strlen( szMessage ) + 2 )
  123.     write_byte( 10 )
  124.     write_string( szMessage )
  125.     message_end()
  126. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement