raizo21

Slot

Dec 5th, 2019
175
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 2.58 KB | None | 0 0
  1. /* Plugin generated by AMXX-Studio */
  2.  
  3. #include <amxmodx>
  4. #include <amxmisc>
  5.  
  6. #define PLUGIN "Steam Slot"
  7. #define VERSION "1.0"
  8. #define AUTHOR "raizo"
  9.  
  10. #pragma tabsize 0
  11. #pragma compress 1
  12.  
  13. new slot_flags;
  14. new configsDir[64]
  15. new SlotName[] = "Slot Steam"
  16.  
  17. public plugin_init()
  18. {
  19.     register_plugin(PLUGIN, VERSION, AUTHOR)
  20.  
  21.     slot_flags = register_cvar("flag_for_slot", "b")
  22.    
  23.         get_configsdir(configsDir, 63)
  24.         formatex(configsDir, 63, "%s/users.ini", configsDir)
  25. }
  26.  
  27. public client_connect(id)
  28. {
  29.     new auth[32], Comment[33];
  30.  
  31.     if(is_user_steam(id))
  32.     {
  33.         get_user_name(id, Comment, sizeof(Comment)-1)
  34.         get_user_authid(id, auth, 31)
  35.    
  36.         Addslot(id, auth, Comment)
  37.     }
  38. }
  39.  
  40. Addslot(id, auth[], comment[]="")
  41. {
  42.     new configsDir[64],string_steam[20]
  43.     get_pcvar_string(slot_flags,string_steam,19)
  44.        
  45.     get_configsdir(configsDir, 63)
  46.     format(configsDir, 63, "%s/users.ini", configsDir)
  47.  
  48.     if (!file_exists(configsDir))
  49.     {
  50.         console_print(id, "[%s] File ^"%s^" doesn't exist.", SlotName, configsDir)
  51.         return
  52.     }
  53.  
  54.     new line = 0, textline[256], len
  55.     const SIZE = 63
  56.     new line_steamid[SIZE + 1], line_password[SIZE + 1], line_accessflags[SIZE + 1], line_flags[SIZE + 1], parsedParams
  57.                
  58.  
  59.     while ((line = read_file(configsDir, line, textline, 255, len)))
  60.     {
  61.         if (len == 0 || equal(textline, ";", 1))
  62.             continue
  63.  
  64.         parsedParams = parse(textline, line_steamid, SIZE, line_password, SIZE, line_accessflags, SIZE, line_flags, SIZE)
  65.                        
  66.         if (parsedParams != 4)
  67.             continue    
  68.                        
  69.         if (equal(line_steamid, auth))
  70.         {
  71.             server_print("[%s] Steam %s already exists!", SlotName, auth)
  72.             return
  73.         }
  74.     }
  75.  
  76.     new linetoadd[512]
  77.                
  78.     if (comment[0]==0)
  79.     {
  80.         formatex(linetoadd, 511, "^r^"%s^" ^"^" ^"%s^" ^"ce^"", auth, string_steam)
  81.     }
  82.     else
  83.     {
  84.         formatex(linetoadd, 511,  "^r^"%s^" ^"^" ^"%s^" ^"ce^" ;^%s", auth, string_steam, comment)
  85.     }
  86.         console_print(id, "Adding:^n%s", linetoadd)
  87.  
  88.     if (!write_file(configsDir, linetoadd))
  89.         console_print(id, "[%s] Failed writing to %s!", SlotName, configsDir)  
  90. }
  91.  
  92. stock bool:is_user_steam(id)
  93. {
  94.    static dp_pointer
  95.    if(dp_pointer || (dp_pointer = get_cvar_pointer("dp_r_id_provider")))
  96.    {
  97.       server_cmd("dp_clientinfo %d", id)
  98.       server_exec()
  99.       return (get_pcvar_num(dp_pointer) == 2) ? true : false
  100.    }
  101.    return false
  102. }
Add Comment
Please, Sign In to add comment