#include <amxmodx>
#include <cstrike>
#include <zombieplague>
#include <dhudmessage>

#define    PLUGIN    "ammo donate/dhud"
#define    VERSION    "1.5"
#define    AUTHOR    "user/zobie-dead bug fix/phantom fix"

new players_menu, players[32], num, i
new accessmenu, iName[64], callback
public plugin_init()
{    
register_plugin(PLUGIN, VERSION, AUTHOR) 
register_clcmd("say /donate", "transfer_menu", ADMIN_ALL, "")    //  команды для вызова меню


register_clcmd("transfer", "transfer_ammo", ADMIN_ALL, "")
}
public transfer_menu(id)
{   
get_players(players, num, "h")       
if (num <= 1)  
{       
set_dhudmessage(0, 155, 0, -1.0, 0.4, 0, 0.0, 5.0, 1.0, 1.0, false)                 
show_dhudmessage(id,"Некому передать аммо")       
return PLUGIN_HANDLED    
}   
    
new tempname[32], info[10]  
  
players_menu = menu_create("Игроки", "players_menu_handler")  
 
for(i = 0; i < num; i++) 
{       
if(players[i] == id)           
continue  
             
get_user_name(players[i], tempname, 31)       
num_to_str(players[i], info, 9)       
menu_additem(players_menu, tempname, info, 0)    
}       
menu_setprop(players_menu, MPROP_EXIT, MEXIT_ALL)  

menu_display(id, players_menu, 0)   
return PLUGIN_CONTINUE
}

public players_menu_handler(id, players_menu, item)
{ 
if(item == MENU_EXIT)   
{       
menu_destroy(players_menu)       
return PLUGIN_HANDLED   
}    
   
new data[6]  
 
menu_item_getinfo(players_menu, item, accessmenu, data, charsmax(data), iName, charsmax(iName), callback) 

new player = str_to_num(data)  
      
client_cmd(id, "messagemode ^"transfer %i^"", player)  

return PLUGIN_CONTINUE
}

public transfer_ammo(id)
{    
new param[6]    
read_argv(2, param, charsmax(param))

for (new x; x < strlen(param); x++)    
{       
if(!isdigit(param[x]))       
 {            
set_dhudmessage(255, 0, 0, -1.0, 0.4, 0, 0.0, 5.0, 1.0, 1.0, false)            
show_dhudmessage(id,"Параметр должен быть числом")            
return 0        
}    
}    
   
new amount = str_to_num(param)   
    
new ammo = zp_get_user_ammo_packs(id) 

if (ammo < amount)    
{             
set_dhudmessage(255, 0, 0, -1.0, 0.4, 0, 0.0, 5.0, 1.0, 1.0, false)             
show_dhudmessage(id,"У  вас не хватает аммо")        
return 0    
} 
      
read_argv(1, param, charsmax(param))   
new player = str_to_num(param) 
      
new player_ammo = zp_get_user_ammo_packs(player)

zp_set_user_ammo_packs(id, ammo - amount)    
zp_set_user_ammo_packs(player, player_ammo + amount)    
   
new names[2][32]        

get_user_name(id, names[0], 31)    
get_user_name(player, names[1], 31)        

set_dhudmessage(0, 125, 200, -1.0, 0.4, 0, 0.0, 5.0, 1.0, 1.0, false)    
show_dhudmessage(0,"Игрок %s передал %i аммо %s", names[0], amount, names[1])        
return 0
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }*/ 