Advertisement
Hyuna

JailBreak Simple Box v1.0 by Hyuna

May 1st, 2016
319
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 3.00 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <ColorChat>
  4. #include <cstrike>
  5. #include <fun>
  6. #include <hamsandwich>
  7.  
  8. #define PREFIX "[ ^4AMXX^1 ]"
  9.  
  10. #define VERSION "v1.0"
  11.  
  12. new g_pCvar;
  13. new bool:g_isEnabled;
  14. new bool:g_bResetHP;
  15.  
  16. public plugin_init() {
  17.     register_plugin("JailBreak Simple Box",VERSION,"Hyuna");
  18.    
  19.     register_cvar("jbsbox_version",VERSION,FCVAR_SERVER);
  20.  
  21.     register_clcmd("say /box","cmdBox");
  22.     register_clcmd("say_team /box","cmdBox");
  23.    
  24.     RegisterHam(Ham_TakeDamage,"player","fwdHamTakeDamagePre",0);
  25.    
  26.     g_pCvar = get_cvar_pointer("mp_friendlyfire");
  27.    
  28.     if (!g_pCvar)
  29.         set_fail_state("Failed to find cvar mp_friendlyfire");
  30.    
  31. }
  32.  
  33. public plugin_cfg() {
  34.     set_pcvar_num(g_pCvar,0);
  35. }
  36.  
  37. public cmdBox(client) {
  38.     static some[256], iMenu, iCallBack;
  39.    
  40.     if (!isClientVaild(client))
  41.     {
  42.         ColorChat(client, NORMAL, "%s You must be ^3alive ^4Guard/Admin^1 to use the box system!",PREFIX);
  43.         return PLUGIN_HANDLED;
  44.     }
  45.    
  46.     iMenu = menu_create("[AMXX] Box Menu","mHandler");
  47.     iCallBack = menu_makecallback("mCallback");
  48.    
  49.     formatex(some,charsmax(some),"Box Status: \d[ \r%sabled \d]",(g_isEnabled ? "En":"Dis"));
  50.     menu_additem(iMenu,some);
  51.    
  52.     formatex(some,charsmax(some),"Reset HP to Terrorists: \d[ \r%sabled \d]",(g_bResetHP ? "En":"Dis"));
  53.     menu_additem(iMenu,some,"",0,iCallBack);
  54.    
  55.     return PLUGIN_HANDLED;
  56. }
  57.  
  58. public mCallback(client,menu,item) {
  59.     return (g_isEnabled ? ITEM_DISABLED:ITEM_ENABLED);
  60. }
  61.  
  62. public mHandler(client,menu,item) {
  63.     static szName[32],players[32],pnum,i;
  64.    
  65.     if (item != MENU_EXIT)
  66.     {
  67.         switch(item)
  68.         {
  69.             case 0:
  70.             {
  71.                 g_isEnabled = !g_isEnabled;
  72.                
  73.                 get_user_name(client,szName,charsmax(szName));
  74.                
  75.                 set_pcvar_num(g_pCvar,(g_isEnabled ? 1:0));
  76.                
  77.                 if (g_isEnabled && g_bResetHP)
  78.                 {
  79.                     get_players(players,pnum,"aceh","TERRORIST");
  80.                    
  81.                     for (i = 0; i < pnum; i++)
  82.                         set_user_health(players[i],100);
  83.                 }
  84.                
  85.                 ColorChat(client, NORMAL, "%s ^3%s^1 has ^4%sabled^1 the Box System!",PREFIX,szName,(g_isEnabled ? "en":"dis"));
  86.             }
  87.            
  88.             case 1:
  89.             {
  90.                 g_bResetHP = !g_bResetHP;
  91.                 ColorChat(client, NORMAL, "%s ^3Reset HP^1 is now ^4%sabled^1.",PREFIX,(g_bResetHP ? "en":"dis"));
  92.             }
  93.         }
  94.        
  95.         menu_destroy(menu); // Anti memory-leak
  96.        
  97.         return cmdBox(client);
  98.     }
  99.    
  100.     menu_destroy(menu); // Anti memory-leak
  101.    
  102.     return PLUGIN_HANDLED;
  103. }
  104.  
  105. public fwdHamTakeDamagePre(victim, idinflictor, attacker, Float:damage, damagebits) {
  106.     static CsTeams:t1, CsTeams:t2;
  107.    
  108.     if (!is_user_alive(victim) || !is_user_alive(attacker))
  109.         return HAM_IGNORED;
  110.        
  111.     t1 = cs_get_user_team(victim);
  112.     t2 = cs_get_user_team(attacker);
  113.    
  114.     return ((t1 == CS_TEAM_T && t2 == CS_TEAM_CT) || (t1 == CS_TEAM_CT && t2 == CS_TEAM_CT)) ? HAM_SUPERCEDE:HAM_IGNORED;
  115. }
  116.  
  117. stock bool:isClientVaild(client) {
  118.     static CsTeams:tmp;
  119.    
  120.     if (!is_user_alive(client))
  121.         return false;
  122.        
  123.     if (is_user_admin(client))
  124.         return true;
  125.        
  126.     tmp = cs_get_user_team(client);
  127.    
  128.     if (tmp != CS_TEAM_T)
  129.         return false;
  130.        
  131.     return true;
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement