Adventx

Restricted Names

Oct 9th, 2014
734
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 1.59 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5.  
  6. new const PLUGIN[] = "Restricted Names";
  7. new const VERSION[] = "1.0";
  8.  
  9. new file[128];
  10.  
  11. public plugin_init()
  12. {
  13.     register_plugin(PLUGIN, VERSION, "Adventx");
  14.    
  15.     // Add your code here...
  16.     register_cvar("restricted_name_version", VERSION, FCVAR_SERVER|FCVAR_SPONLY);
  17.     set_cvar_string("restricted_name_version", VERSION);
  18. }
  19.  
  20. public plugin_cfg()
  21. {
  22.     // get cfg dir
  23.     new cfgdir[64];
  24.     get_configsdir(cfgdir, sizeof(cfgdir) - 1);
  25.    
  26.     // formatex
  27.     formatex(file, sizeof file - 1, "%s/restricted_names.ini", cfgdir);
  28.    
  29.     // file exists
  30.     if(!file_exists(file))
  31.     {
  32.         write_file(file, "// ----------------", -1);
  33.         write_file(file, "// Restricted Names", -1);
  34.         write_file(file, "// ----------------", -1);
  35.     }
  36. }
  37.  
  38. public client_putinserver(id)
  39. {
  40.     new szName[32];
  41.     get_user_info(id, "name", szName, sizeof szName -1);
  42.    
  43.     if(is_string_in_file(szName))
  44.         set_user_info(id, "name", "unnamed");
  45. }
  46.  
  47. // Thanks to Askhanar (https://forums.alliedmods.net/member.php?u=174947)
  48. stock bool:is_string_in_file(const String[])
  49. {
  50.     static szBuffer[32];
  51.     new iFile = fopen(file, "rt");
  52.    
  53.     if(!iFile)
  54.         return false;
  55.    
  56.     while(!feof(iFile))
  57.     {
  58.         fgets(iFile, szBuffer, sizeof(szBuffer) - 1);
  59.        
  60.         if(!szBuffer[0] || szBuffer[0] == ';')
  61.             continue;
  62.         if(equali(szBuffer, String, strlen(String)))
  63.             return true;
  64.     }
  65.    
  66.     fclose(iFile);
  67.     return false;
  68. }
  69.  
  70. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  71. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
  72. */
Advertisement
Add Comment
Please, Sign In to add comment