SHARE
TWEET

Untitled

a guest Oct 21st, 2019 64 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmodx>
  2.  
  3. #define VIP_FLAG ADMIN_LEVEL_H
  4.  
  5. new const vip_time[] = {22, 08};
  6. new const TAG[] = "[Strike]";
  7.  
  8. new g_msg_saytext, g_sync, cvar_freevip, g_maxplayers;
  9. new vip_free = 0;
  10.  
  11. public plugin_init()
  12. {
  13.     register_plugin("Vip Free", "4.0", "cyby");
  14.    
  15.     set_task(60.0, "check_time", _, _, _, "b");
  16.     set_task(1.0, "hud_mess", _, _, _, "b");
  17.    
  18.     cvar_freevip = register_cvar("vip_free", "0");
  19.    
  20.     g_msg_saytext = get_user_msgid("SayText");
  21.     g_maxplayers = get_maxplayers();
  22.     g_sync = CreateHudSyncObj();
  23.     cached_vars();
  24.     set_task(1.0, "check_time");
  25.     register_clcmd("say /timevip", "time_remain");
  26. }
  27.  
  28. public client_putinserver(id)
  29. {
  30.     if(!vip_free)
  31.         return;
  32.    
  33.     if(!(get_user_flags(id) & VIP_FLAG))
  34.     {
  35.         new flags = get_user_flags(id);
  36.         flags |= VIP_FLAG
  37.         set_user_flags(id, flags);
  38.     }
  39. }
  40.  
  41. public cached_vars()
  42.     vip_free = get_pcvar_num(cvar_freevip);
  43.  
  44. public check_time()
  45. {
  46.     new o;
  47.     time(o, _, _);
  48.    
  49.     if(!vip_free)
  50.     {
  51.         if(o >= vip_time[0] || o < vip_time[1])
  52.         {
  53.             vip_free = 1;
  54.             set_pcvar_num(cvar_freevip, 1);
  55.             color(0, ".v%s.g Eventul.e Free VIP.g a fost activat!", TAG);
  56.         }
  57.     }
  58.     else
  59.     {
  60.         if(o < vip_time[0] && o >= vip_time[1])
  61.         {
  62.             vip_free = 0;
  63.             set_pcvar_num(cvar_freevip, 0);
  64.             color(0, ".v%s.g Eventul.e Free VIP.g a fost dezactivat!", TAG);
  65.             for(new i = 1; i <= g_maxplayers; i++)
  66.             {
  67.                 if(!is_user_connected(i) || get_user_flags(i) & VIP_FLAG)
  68.                     continue;
  69.                    
  70.                 remove_user_flags(i);
  71.             }
  72.             server_cmd("amx_reloadadmins");
  73.         }
  74.     }
  75. }
  76.  
  77. public time_remain(id)
  78. {
  79.     switch(vip_free)
  80.     {
  81.         case 1: color(id, ".v%s.g Timp ramas pana se termina vip-ul free.e %s.g.", TAG, time_left_vip());
  82.         case 0: color(id, ".v%s.g Timp ramas pana incepe vip-ul free.e %s.g.", TAG, time_left_vip());
  83.     }
  84.     return PLUGIN_HANDLED;
  85. }
  86.  
  87. public hud_mess()
  88. {
  89.     if(!vip_free)
  90.         return;
  91.    
  92.     set_hudmessage(random(256), random(256), random(256), 0.00, 0.17, 0, 1.1, 1.0);
  93.     ShowSyncHudMsg(0, g_sync, "VIP Free:22-08");
  94.     // metoda drastica dar n-am cf, sa mearga si la baietii ce au reload admins la 5 secunde sau la cine stie cat.
  95.     new flage;
  96.     for(new i = 1; i <= g_maxplayers; i++)
  97.     {
  98.         if(!is_user_connected(i) || get_user_flags(i) & VIP_FLAG)
  99.             continue;
  100.            
  101.         flage = get_user_flags(i);
  102.         flage |= VIP_FLAG
  103.         set_user_flags(i, flage);
  104.     }
  105. }
  106.  
  107. stock color(const id, const input[], any:...)
  108. {
  109.     new count = 1, players[32]
  110.     static msg[191]
  111.     vformat(msg, 190, input, 3)
  112.  
  113.     replace_all(msg, 190, ".v", "^4")
  114.     replace_all(msg, 190, ".g", "^1")
  115.     replace_all(msg, 190, ".e", "^3")
  116.  
  117.     if(id) players[0] = id; else get_players(players, count, "ch")
  118.     {
  119.         for(new i = 0; i < count; i++)
  120.         {
  121.             if(is_user_connected(players[i]))
  122.             {
  123.                 message_begin(MSG_ONE_UNRELIABLE, g_msg_saytext, _, players[i])
  124.                 write_byte(players[i]);
  125.                 write_string(msg);
  126.                 message_end();
  127.             }
  128.         }
  129.     }
  130. }
  131.  
  132. stock time_left_vip()
  133. {
  134.     new timp_ramas[16], len = 0;
  135.     new h, m, lh, lm;
  136.     time(h, m, _);
  137.     switch(vip_free)
  138.     {
  139.         case 1: lh = vip_time[1] - h;
  140.         case 0: lh = vip_time[0] - h;
  141.     }
  142.     lm = 60 - m;
  143.     if(lm < 60)
  144.         lh--;
  145.    
  146.     if(lh > 0)
  147.         len += formatex(timp_ramas[len], charsmax(timp_ramas) - len, "%d or%s", lh, lh == 1 ? "a" : "e");
  148.        
  149.     if(lm < 60)
  150.         len += formatex(timp_ramas[len], charsmax(timp_ramas) - len, " %d minut%s", lm, lm == 1 ? "" : "e");
  151.        
  152.     return timp_ramas;
  153. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top