Advertisement
Guest User

Untitled

a guest
Feb 17th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 6.11 KB | None | 0 0
  1. #include <amxmodx>
  2.  
  3. #include <amxmisc>
  4.  
  5.  
  6.  
  7. native zp_get_user_ammo_packs(id)
  8.  
  9. native zp_set_user_ammo_packs(id, amount)
  10.  
  11.  
  12.  
  13. #define LOG_FILE    "a_giveap_.log"
  14.  
  15. #define LOG_FILE2 "a_removeap.log"
  16.  
  17.  
  18.  
  19. public plugin_init()
  20.  
  21. {
  22.  
  23.     register_plugin("GiveAP", "1.0", "X3")
  24.  
  25.     register_concmd ( "zp_giveap", "AddAmmo", ADMIN_RCON, "<nick, #userid, authid | @all / @ct / @t> <ap>" )
  26.  
  27.     register_concmd ( "zp_removeap", "RemoveAmmo", ADMIN_RCON, "<nick, #userid, authid | @all / @ct / @t> <ap>" )
  28.  
  29. }
  30.  
  31.  
  32.  
  33.  
  34.  
  35. public AddAmmo(iPlayer, level, cid)
  36.  
  37. {
  38.  
  39.     if(!cmd_access(iPlayer, level, cid, 3)) return PLUGIN_HANDLED;
  40.  
  41.    
  42.  
  43.     new arg [32]
  44.  
  45.     read_argv (1, arg, 31)
  46.  
  47.    
  48.  
  49.     new Ammo [32]
  50.  
  51.     read_argv (2, Ammo, charsmax (Ammo))
  52.  
  53.    
  54.  
  55.     new ammo = str_to_num (Ammo)
  56.  
  57.    
  58.  
  59.     new admin [32]
  60.  
  61.     new player [32]
  62.  
  63.     get_user_name (iPlayer, admin, charsmax (admin))
  64.  
  65.    
  66.  
  67.     if(arg[0]=='@')
  68.  
  69.     {
  70.  
  71.         if(equali(arg[1],"All") || equali(arg[1],"ALL"))
  72.  
  73.         {
  74.  
  75.             new players[32], totalplayers, All
  76.  
  77.             get_players(players, totalplayers)
  78.  
  79.            
  80.  
  81.             for (new i = 0; i < totalplayers; i++)
  82.  
  83.             {
  84.  
  85.                 All = players[i]
  86.  
  87.                
  88.  
  89.                 zp_set_user_ammo_packs(All,zp_get_user_ammo_packs(All)+ ammo)
  90.  
  91.             }
  92.  
  93.             client_print_color(0,"^1[ADMIN] ^4%s: ^1give ^4%i ^1AmmoPacks to ^4All Players!", admin, ammo )
  94.  
  95.         }
  96.  
  97.         else if(equali(arg[1],"T") || equali(arg[1],"t"))
  98.  
  99.         {
  100.  
  101.             new players[32], totalplayers, T
  102.  
  103.             get_players(players, totalplayers)
  104.  
  105.            
  106.  
  107.             for (new i = 0; i < totalplayers; i++)
  108.  
  109.             {
  110.  
  111.                 if (get_user_team(players[i]) == 1)
  112.  
  113.                 {
  114.  
  115.                     T = players[i]
  116.  
  117.                     zp_set_user_ammo_packs(T,zp_get_user_ammo_packs(T)+ ammo)
  118.  
  119.                 }
  120.  
  121.             }
  122.  
  123.             client_print_color(0,"^1[ADMIN] ^4%s: ^1give ^4%i ^1AmmoPacks to ^3All Zombies", admin, ammo)
  124.  
  125.             log_to_file( LOG_FILE, "[ADMIN] %s: give %i AmmoPacks to All Zombies", admin,ammo)
  126.  
  127.         }
  128.  
  129.         else if(equali(arg[1],"CT") || equali(arg[1],"ct"))
  130.  
  131.         {
  132.  
  133.             new players[32], totalplayers, CT
  134.  
  135.             get_players(players, totalplayers)
  136.  
  137.            
  138.  
  139.             for(new i = 0; i < totalplayers; i++)
  140.  
  141.             {
  142.  
  143.                 if(get_user_team(players[ i ] ) == 2)
  144.  
  145.                 {
  146.  
  147.                     CT = players[i]
  148.  
  149.                    
  150.  
  151.                     zp_set_user_ammo_packs(CT,zp_get_user_ammo_packs(CT) + ammo)
  152.  
  153.                 }
  154.  
  155.             }
  156.  
  157.             client_print_color(0,"^1[ADMIN] ^4%s: ^1give ^4%i ^1AmmoPacks to ^3All Humans!", admin, ammo)
  158.  
  159.             log_to_file( LOG_FILE, "[ADMIN] %s: give %i AmmoPacks to  All Humans!", admin,ammo)
  160.  
  161.  
  162.  
  163.         }
  164.  
  165.     }
  166.  
  167.     else
  168.  
  169.     {
  170.  
  171.         new Target = cmd_target(iPlayer, arg, 3)
  172.  
  173.         get_user_name (Target, player, charsmax (player))
  174.  
  175.        
  176.  
  177.         if(Target)
  178.  
  179.         {
  180.  
  181.             zp_set_user_ammo_packs(Target,zp_get_user_ammo_packs(Target)+ ammo)
  182.  
  183.            
  184.  
  185.             client_print_color(0,"^1[ADMIN] ^4%s: ^1give ^4%i ^1AmmoPacks to ^4%s", admin, ammo, player)
  186.  
  187.             log_to_file( LOG_FILE, "[ADMIN] %s: give %i AmmoPacks to %s", admin,ammo,player)
  188.  
  189.         }
  190.  
  191.     }
  192.  
  193.     return PLUGIN_HANDLED
  194.  
  195. }
  196.  
  197.  
  198.  
  199. public RemoveAmmo (iPlayer, level, cid)
  200.  
  201. {
  202.  
  203.     if(!cmd_access(iPlayer, level, cid, 3)) return PLUGIN_HANDLED;
  204.  
  205.    
  206.  
  207.     new arg [32]
  208.  
  209.     read_argv (1, arg, 31)
  210.  
  211.    
  212.  
  213.     new RemoveAP [32]
  214.  
  215.     read_argv (2, RemoveAP, charsmax (RemoveAP))
  216.  
  217.    
  218.  
  219.     new ra = str_to_num (RemoveAP)
  220.  
  221.    
  222.  
  223.     new admin [32]
  224.  
  225.     new player [32]
  226.  
  227.     get_user_name (iPlayer, admin, charsmax (admin))
  228.  
  229.    
  230.  
  231.     if(arg[0]=='@')
  232.  
  233.     {
  234.  
  235.         if(equali(arg[1],"All") || equali(arg[1],"ALL"))
  236.  
  237.         {
  238.  
  239.             new players[32], totalplayers, All
  240.  
  241.             get_players(players, totalplayers)
  242.  
  243.            
  244.  
  245.             for (new i = 0; i < totalplayers; i++)
  246.  
  247.             {
  248.  
  249.                 All = players[i]
  250.  
  251.                
  252.  
  253.                 zp_set_user_ammo_packs(All,zp_get_user_ammo_packs(All) - ra)
  254.  
  255.             }
  256.  
  257.             client_print_color(0,"^1[ADMIN] ^4%s: ^1removed ^4%i ^1AmmoPacks from ^4All Players!", admin, ra)
  258.  
  259.             log_to_file( LOG_FILE, "[ADMIN] %s: removed %i AmmoPacks from All Players!", admin,ra)
  260.  
  261.         }
  262.  
  263.         else if(equali(arg[1],"T") || equali(arg[1],"t"))
  264.  
  265.         {
  266.  
  267.             new players[32], totalplayers, T
  268.  
  269.             get_players(players, totalplayers)
  270.  
  271.            
  272.  
  273.             for (new i = 0; i < totalplayers; i++)
  274.  
  275.             {
  276.  
  277.                 if (get_user_team(players[i]) == 1)
  278.  
  279.                 {
  280.  
  281.                     T = players[i]
  282.  
  283.                    
  284.  
  285.                     zp_set_user_ammo_packs(T,zp_get_user_ammo_packs(T) - ra)
  286.  
  287.                 }
  288.  
  289.             }
  290.  
  291.             client_print_color( 0,"^1[ADMIN] ^4%s: ^1removed ^4%i ^1AmmoPacks from ^3All Zombies", admin, ra)
  292.  
  293.             log_to_file( LOG_FILE, "[ADMIN] %s: removed %i AmmoPacks from All Zombies", admin,ra)
  294.  
  295.         }
  296.  
  297.         else if(equali(arg[1],"CT") || equali(arg[1],"ct"))
  298.  
  299.         {
  300.  
  301.             new players[32], totalplayers, CT
  302.  
  303.             get_players(players, totalplayers)
  304.  
  305.            
  306.  
  307.             for(new i = 0; i < totalplayers; i++)
  308.  
  309.             {
  310.  
  311.                 if(get_user_team(players[ i ] ) == 2)
  312.  
  313.                 {
  314.  
  315.                     CT = players[i]
  316.  
  317.                    
  318.  
  319.                     zp_set_user_ammo_packs(CT,zp_get_user_ammo_packs(CT) - ra)
  320.  
  321.                 }
  322.  
  323.             }
  324.  
  325.             client_print_color(0,"^1[ADMIN] ^4%s: ^1removed ^4%i ^1AmmoPacks from ^3 All Humans", admin, ra)
  326.  
  327.             log_to_file( LOG_FILE, "ADMIN %s removed %i ammo packs from all humans", admin,ra)
  328.  
  329.         }
  330.  
  331.     }
  332.  
  333.     else
  334.  
  335.     {
  336.  
  337.         new iTarget = cmd_target(iPlayer, arg, 3)
  338.  
  339.         get_user_name (iTarget, player, charsmax (player))
  340.  
  341.        
  342.  
  343.         if(!iTarget)
  344.  
  345.             return PLUGIN_HANDLED
  346.  
  347.        
  348.  
  349.         zp_set_user_ammo_packs(iTarget,zp_get_user_ammo_packs(iTarget) - ra)
  350.  
  351.        
  352.  
  353.         client_print_color(0,"^1[ADMIN] ^4%s: ^1removed ^4%i ^1AmmoPacks from ^4%s!", admin, ra, player)
  354.  
  355.         log_to_file( LOG_FILE, "[ADMIN] %s: removed %i AmmoPacks from %s!", admin,ra,player)
  356.  
  357.     }
  358.  
  359.    
  360.  
  361.     return PLUGIN_HANDLED;
  362.  
  363. }
  364.  
  365. stock client_print_color(const id, const input[], any:...)
  366.  
  367. {
  368.  
  369.     new count = 1, players[32], i, player
  370.  
  371.     static msg[191]
  372.  
  373.  
  374.  
  375.     if(numargs() == 2)
  376.  
  377.         copy(msg, 190, input)
  378.  
  379.     else
  380.  
  381.         vformat(msg, 190, input, 3)
  382.  
  383.  
  384.  
  385.     replace_all(msg, 190, "!g", "^4")
  386.  
  387.     replace_all(msg, 190, "!y", "^1")
  388.  
  389.     replace_all(msg, 190, "!t", "^3")
  390.  
  391.    
  392.  
  393.     if(id) {
  394.  
  395.         if(!is_user_connected(id)) return
  396.  
  397.         players[0] = id
  398.  
  399.     }
  400.  
  401.     else get_players(players, count, "ch")
  402.  
  403.  
  404.  
  405.     for(i = 0; i < count; i++)
  406.  
  407.     {
  408.  
  409.         player = players[i]
  410.  
  411.        
  412.  
  413.         message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, player)
  414.  
  415.         write_byte(player)
  416.  
  417.         write_string(msg)
  418.  
  419.         message_end()
  420.  
  421.     }
  422.  
  423. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement