SHARE
TWEET

viptest

mihay111 Jul 21st, 2019 81 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <nvault>
  4. #include <colorchat>
  5.  
  6. #define PLUGIN "GOLDSRC: VIPTEST"
  7. #define VERSION "1.0"
  8. #define AUTHOR "wannacry"
  9.  
  10. #define Flaga ADMIN_LEVEL_H
  11.  
  12. new use[33] = 0
  13. new czas_gracza[33]
  14. new prefix[33]
  15. new g_vault
  16. new czas
  17. new zapis
  18.  
  19. getFormatedTime(iTime, szTime[], size)
  20. {
  21.     new hours = iTime/3600
  22.     formatex(szTime, size, "%d ore si %d minute", hours, iTime%3600/60)
  23. }
  24. public plugin_init()
  25. {
  26.     register_plugin(PLUGIN, VERSION, AUTHOR)
  27.     g_vault = nvault_open("24h_vip")
  28.     register_clcmd("say /testvip","vip_test")
  29.     register_clcmd("say_team /testvip","vip_test")
  30.     register_clcmd("say /viptest","vip_test")
  31.     register_clcmd("say_team /viptest","vip_test")
  32.    
  33.     register_cvars()
  34. }
  35. public register_cvars()
  36. {
  37.     czas = register_cvar("goldsrc_viptest_ore","24")
  38.     zapis = register_cvar("goldsrc_viptest_save","1")
  39.     register_cvar("goldsrc_viptest_prefix","^1[^4GOLDSRC^1]")
  40. }
  41. public plugin_cfg()
  42. {
  43.     get_cvar_string("amx_viptest_prefix", prefix, 32)
  44. }
  45. public vip_test(id)
  46. {
  47.     if(is_user_connected(id))
  48.     {
  49.         if(get_user_flags(id) & Flaga || use[id] == 1)
  50.         {
  51.             ColorChat(id, NORMAL, "%s Tu esti deja ^3vip^1 sau ai folosit ^3viptest^!!",prefix)
  52.         }
  53.         else
  54.         {
  55.             use[id] = 1
  56.             czas_gracza[id] = get_pcvar_num(czas)*3600
  57.             set_task(1.0,"sprawdz",id,_,_,"b")
  58.             set_task(30.0,"timer",id,_,_,"b")
  59.             set_user_flags(id, get_user_flags(id) | Flaga)
  60.             save(id)
  61.         }
  62.     }
  63. }
  64. public sprawdz(id)
  65. {
  66.     czas_gracza[id]--
  67.     if(czas_gracza[id] <= 0)
  68.     {
  69.         if(task_exists(id))
  70.         {
  71.             remove_task(id)
  72.         }
  73.         remove_user_flags(id, Flaga)
  74.     }
  75. }
  76. public client_disconnect(id)
  77. {
  78.     if(task_exists(id))
  79.     {
  80.         remove_task(id)
  81.     }
  82.     if(use[id] == 1)
  83.     {
  84.         save(id)
  85.     }
  86. }
  87. public client_connect(id)
  88. {
  89.     use[id] = 0
  90.     czas_gracza[id] = 0
  91.     set_task(2.0,"load",id)
  92. }
  93. public save(id)
  94. {
  95.     new name[64]
  96.     switch(get_pcvar_num(zapis))
  97.     {
  98.         case 1:
  99.         {
  100.             get_user_name(id,name,63)
  101.         }
  102.         case 2:
  103.         {
  104.             if(is_user_steam(id))
  105.             {
  106.                 get_user_authid(id, name, 63)
  107.             }
  108.             else
  109.             {
  110.                 get_user_name(id,name,63)
  111.             }
  112.         }
  113.     }
  114.    
  115.     new vaultkey[64],vaultdata[256]
  116.     format(vaultkey,63,"%s-vip",name)
  117.     format(vaultdata,255,"%d#%d",czas_gracza[id],use[id])
  118.     nvault_set(g_vault,vaultkey,vaultdata)
  119. }
  120. public load(id)
  121. {
  122.     new name[64]
  123.     switch(get_pcvar_num(zapis))
  124.     {
  125.         case 1:
  126.         {
  127.             get_user_name(id,name,63)
  128.         }
  129.         case 2:
  130.         {
  131.             if(is_user_steam(id))
  132.             {
  133.                 get_user_authid(id, name, 63)
  134.             }
  135.             else
  136.             {
  137.                 get_user_name(id,name,63)
  138.             }
  139.         }
  140.     }
  141.    
  142.     new vaultkey[64],vaultdata[256]
  143.     get_user_name(id,name,63)
  144.     format(vaultkey,63,"%s-vip",name)
  145.     format(vaultdata,255,"%d#%d",czas_gracza[id], use[id])
  146.     nvault_get(g_vault,vaultkey,vaultdata,255)
  147.     replace_all(vaultdata, 255, "#", " ")
  148.    
  149.     new zmienna[33], zmienna1[33]
  150.     parse(vaultdata, zmienna, 32, zmienna1, 32)
  151.    
  152.     czas_gracza[id] = str_to_num(zmienna)
  153.     use[id] = str_to_num(zmienna1)
  154.    
  155.     if(czas_gracza[id] > 0)
  156.     {
  157.         set_task(30.0,"timer",id,_,_,"b")
  158.         set_task(1.0,"sprawdz",id,_,_,"b")
  159.         set_user_flags(id, get_user_flags(id) | Flaga)
  160.     }
  161.     else
  162.     {
  163.         set_task(30.0,"reclama",id,_,_,"b")
  164.     }
  165. }
  166. public timer(id)
  167. {
  168.     new szTime[32]
  169.     getFormatedTime(czas_gracza[id], szTime, 31)
  170.     ColorChat(id, NORMAL, "%s ^3VIPTEST^1 se expira peste: ^4%s^1!",prefix,szTime)
  171. }
  172. public reclama(id)
  173. {
  174.     ColorChat(id, NORMAL, "%s Vrei sa incerci vip pe ^4%d^1 ore?",prefix, get_pcvar_num(czas))
  175.     ColorChat(id, NORMAL, "%s Scrie ^4/testvip^1 sau ^4/viptest^1",prefix)
  176. }
  177.  
  178. stock bool:is_user_steam(id) {
  179.     new authid[32]; get_user_authid(id, authid, 31);
  180.     return bool:(contain(authid, "STEAM_0:0:") != -1 || contain(authid, "STEAM_0:1:") != -1);
  181. }
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
 
Top