Advertisement
Guest User

Untitled

a guest
Jan 4th, 2010
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.30 KB | None | 0 0
  1. #include <a_samp>
  2.  
  3. #define MAX_COMMANDS        (500)
  4.  
  5. new g_str_CommandsNames[MAX_COMMANDS][25];
  6.  
  7. stock strtok(str[], str2[], &idx, separator = ',')
  8. {
  9.     new i;
  10.  
  11.     while(str[idx] != separator && idx < 25)
  12.     {
  13.         if(str[idx] != '/')
  14.         {
  15.             str2[i] = str[idx];
  16.             i++;
  17.         }
  18.  
  19.         idx++;
  20.     }
  21.  
  22.     str2[i] = EOS;
  23.    
  24.     idx++;
  25. }
  26.  
  27. stock ReadFile()
  28. {
  29.     new
  30.         File: File,
  31.         str_FileText[256],
  32.         i;
  33.  
  34.     File = fopen("bcommands.ini", io_read);
  35.  
  36.     while(fread(File, str_FileText, sizeof(str_FileText)))
  37.     {
  38.         if(strfind(str_FileText, "Type here the commands", true) != -1)
  39.             continue;
  40.  
  41.         new idx;
  42.  
  43.         strtok(str_FileText,g_str_CommandsNames[i], idx);
  44.         i++;
  45.  
  46.     }
  47.  
  48.     fclose(File);
  49. }
  50.  
  51. public OnFilterScriptInit()
  52. {
  53.     print("\n--------------------------------------\n Commands blocker \
  54.      script\n        Loaded\n   By Conan/Destrojer \n--------------------------\
  55.     ------------");
  56.  
  57.     if(!fexist("bcommands.ini"))
  58.     {
  59.         new File: File;
  60.        
  61.         File = fopen("bcommands.ini", io_append);
  62.        
  63.         fwrite(File, "Type here the commands that are to be blocked. \
  64.          Separate theme with ','\r\n");
  65.         fwrite(File, "command1,\r\n");
  66.         fwrite(File, "command2,\r\n");
  67.         fwrite(File, "command3,\r\n");
  68.         fwrite(File, "etc,\r\n");
  69.         fclose(File);
  70.        
  71.         return 1;
  72.     }
  73.    
  74.     ReadFile();
  75.    
  76.     return 1;
  77. }
  78.  
  79. public OnFilterScriptExit()
  80. {
  81.     print("\n--------------------------------------\n Commands blocker \
  82.      script\n        Unloaded\n   By Conan/Destrojer \n------------------------\
  83.     --------------");
  84.     return 1;
  85. }
  86.  
  87. public OnPlayerCommandText(playerid, cmdtext[])
  88. {
  89.     if(strcmp(cmdtext[1], "reload", true) == 0)
  90.     {
  91.         if(!IsPlayerAdmin(playerid))
  92.             return 0;
  93.  
  94.         ReadFile();
  95.         SendClientMessage(playerid, 0xDDAD66FF,  "****Reload compited***");
  96.        
  97.         return 1;
  98.     }
  99.    
  100.     for(new i; i < MAX_COMMANDS; i++)
  101.         if(strcmp(cmdtext[1], g_str_CommandsNames[i], true,
  102.          strlen(g_str_CommandsNames[i])) == 0 &&
  103.          strlen(g_str_CommandsNames[i]) > 0)
  104.             return SendClientMessage(playerid, 0xDDAD66FF,
  105.              "Sorry. This command is blocked");
  106.  
  107.     return 0;
  108. }
  109.  
  110. /*------------------------------------------------------------------------------
  111.     You are the only one who read that. JOKE.
  112. ------------------------------------------------------------------------------*/
  113.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement