Advertisement
Hyuna

Vips [BROKEN]

May 31st, 2013 (edited)
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 4.82 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3.  
  4. #define set_vip_flags(%1,%2)      (g_vipflags[%1] |= (1<<(%2&31)))
  5. #define remove_vip_flags(%1,%2)    (g_vipflags[%1] &= ~(1 <<(%2&31)))
  6. #define get_vip_flags(%1,%2)    (g_vipflags[%1] & (1<<(%2&31)))
  7.  
  8. #define vipcfgfile "vipcfg.ini"
  9.  
  10. new g_vipflags[33];
  11.  
  12. new Trie:g_vips;
  13.  
  14. new logfile[128];
  15. new szFile[64];
  16.  
  17. enum ( <<=1 )
  18. {
  19.     VIP_FLAG_A = 1, // Flag "a"
  20.     VIP_FLAG_B, // Flag "b"
  21.     VIP_FLAG_C, // Flag "c"
  22.     VIP_FLAG_D, // Flag "d"
  23.     VIP_FLAG_E, // Flag "e"
  24.     VIP_FLAG_F, // Flag "f"
  25.     VIP_FLAG_G, // Flag "g"
  26.     VIP_FLAG_H // Flag "h"
  27. }
  28.  
  29. public plugin_init(){
  30.     register_plugin("VIP Plugin","1.0","Hyuna & xControl");
  31.  
  32.     register_concmd("amx_addvip","cmd_addvip",ADMIN_RCON,"<name or steamid> <flags>",1);
  33.     register_concmd("amx_reloadvips","cmd_reloadvips",ADMIN_RCON,"- Reload VIPs",1);
  34.    
  35.     register_clcmd("say /vip","check_vip");
  36. }
  37.  
  38. public plugin_cfg(){
  39.     get_time("vip_log_%d-%m-%Y.log",logfile,128);
  40.    
  41.     g_vips = TrieCreate();
  42.    
  43.     get_configsdir(szFile,63);
  44.     format(szFile,63,"%s/%s",szFile,vipcfgfile);
  45.    
  46.     if (!file_exists(szFile))
  47.     {
  48.         write_file(szFile,"; Vip Config");
  49.         write_file(szFile,"");
  50.         write_file(szFile,"");
  51.         write_file(szFile,"; Flags:");
  52.         write_file(szFile,"; a - bla bla bla");
  53.         write_file(szFile,"; b - bla bla bla");
  54.         write_file(szFile,"; c - bla bla bla");
  55.         write_file(szFile,"; d - bla bla bla");
  56.         write_file(szFile,"; e - bla bla bla");
  57.         write_file(szFile,"; f - bla bla bla");
  58.         write_file(szFile,"; g - bla bla bla");
  59.         write_file(szFile,"; h - bla bla bla");
  60.         write_file(szFile,"");
  61.         write_file(szFile,"");
  62.         write_file(szFile,"; How to add vips?");
  63.         write_file(szFile,"; ^"STEAMID^" ^"FLAGS^"");
  64.         write_file(szFile,"");
  65.         write_file(szFile,"; Example:");
  66.         write_file(szFile,"; ^"STEAM_0:0:50958313^" ^"abcdefgh^"");
  67.     }
  68.    
  69.     ReadVips(szFile);
  70. }
  71.  
  72. public plugin_natives(){
  73.     register_library("vips");
  74.    
  75.     register_native("get_vip_flags","_get_vip_flags");
  76. }
  77.  
  78. public _get_vip_flags(plugin,params){
  79.     new client = get_param(1);
  80.    
  81.     if (client < 1 || client > 32 || !is_user_connected(client))
  82.     {
  83.         log_error(AMX_ERR_NATIVE,"[Vips] Invaild player id %d",client);
  84.         return -1;
  85.     }
  86.    
  87.     return g_vipflags[client];
  88. }
  89.  
  90. public client_authorized(client){
  91.     static szID[35];
  92.     get_user_authid(client,szID,charsmax(szID));
  93.    
  94.     if (TrieKeyExists(g_vips,szID))
  95.     {
  96.         new szKey[32];
  97.         TrieGetString(g_vips,szID,szKey,31);
  98.         set_vip_flags(client,read_flags(szKey));
  99.     }
  100.    
  101.     else
  102.         g_vipflags[client] = 0;
  103. }
  104.  
  105. public check_vip(client){
  106.     client_print(client,print_chat,"[AMXX] You are%s vip!",(g_vipflags[client] ? "":"n't"));
  107.    
  108.     if (g_vipflags[client])
  109.     {
  110.         new szFlags[16];
  111.         get_flags(g_vipflags[client],szFlags,15);
  112.         client_print(client,print_chat,"[AMXX] You'r flags: %s",szFlags);
  113.     }
  114. }
  115.  
  116. public cmd_addvip(client,level,cid){
  117.     if(!cmd_access(client,level,cid,3))
  118.         return 1;
  119.        
  120.     new szFlags[16],szID[35];
  121.        
  122.     read_argv(1,szID,34);
  123.     read_argv(2,szFlags,15);
  124.    
  125.     remove_quotes(szID);
  126.     remove_quotes(szFlags);
  127.    
  128.     if ((contain(szID,"STEAM_") == -1))
  129.     {
  130.         new player = cmd_target(client,szID,CMDTARGET_NO_BOTS | CMDTARGET_ALLOW_SELF);
  131.        
  132.         if (!player)
  133.             return 1;
  134.            
  135.         if (!g_vipflags[client])
  136.             return 1;
  137.            
  138.         get_user_authid(player,szID,34);
  139.        
  140.         set_vip_flags(player,read_flags(szFlags));
  141.     }
  142.    
  143.     else if (contain(szID,"_ID_LAN") != -1 || contain(szID,"STEAM_0:4") != -1 || contain(szID,"VALVE") != -1 || equali(szID,"STEAM_666:88:666"))
  144.     {
  145.         console_print(client,"Error: Invaild SteamID!");
  146.         return 1;
  147.     }
  148.    
  149.     static some[128];
  150.    
  151.     formatex(some,127,"^"%s^" ^"%s^"",szID,szFlags);
  152.     write_file(szFile,some);
  153.        
  154.     ReadVips(szFile);
  155.    
  156.     return 1;
  157. }
  158.  
  159. public cmd_reloadvips(client,level,cid){
  160.     if(!cmd_access(client,level,cid,1))
  161.         return 1;
  162.    
  163.     ReadVips(szFile);
  164.    
  165.     return 1;
  166. }
  167.  
  168. stock ReadVips(szFile[]){
  169.     new cfg = fopen(szFile,"rt");
  170.    
  171.     if (!cfg)
  172.     {
  173.         new some[128];
  174.         formatex(some,127,"Error openning config file (%s)",szFile);
  175.         set_fail_state(some);
  176.     }
  177.    
  178.     static szText[128],szID[35],szFlags[16];
  179.  
  180.     new totalvips;
  181.    
  182.     while(!feof(cfg))
  183.     {
  184.         fgets(cfg,szText,charsmax(szText));
  185.        
  186.         if (equali(szText,"") || szText[0] == ';' || szText[0] == '#' || (szText[0] == '/' && szText[1] == '/'))
  187.             continue;
  188.        
  189.         remove_quotes(szText);
  190.        
  191.         parse(szText,szID,charsmax(szID),szFlags,charsmax(szFlags));
  192.        
  193.         if((contain(szID,"STEAM_") == -1) || contain(szID,"_ID_LAN") != -1 || contain(szID,"STEAM_0:4") != -1 || contain(szID,"VALVE") != -1 || equali(szID,"STEAM_666:88:666"))
  194.         {
  195.             log_to_file(logfile,"ERROR: Failed to load VIP: %s isn't an vaild steamid!",szID);
  196.             continue;
  197.         }
  198.        
  199.         TrieSetString(g_vips,szID,szFlags);
  200.        
  201.         log_to_file(logfile,"VIP Loaded: SteamID: %s | Flags: %s",szID,szFlags);
  202.        
  203.         totalvips++;
  204.     }
  205.    
  206.     log_to_file(logfile,"Total vips loaded: %d",totalvips);
  207.    
  208.     fclose(cfg);
  209. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement