PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <colorchat>
#include <zp50_ammopacks>
new g_UserTotalAmmo[33]
new g_CvarAllowDonate
public plugin_init() {
register_plugin ( "[ZP50] Addon: Donate AP" , "1.0" , "H.RED.ZONE" )
g_CvarAllowDonate = register_cvar ( "zp_stats_allow_donate" , "1" )
register_clcmd ( "say" , "handleSay", ADMIN_ADMIN , "Donate Ammo Packs " )
register_clcmd ( "say_team" , "handleSay", ADMIN_ADMIN , "Donate Ammo Packs " )
register_event ( "HLTV" , "RoundStart" , "a" , "1=0" , "2=0" ); }
public RoundStart() {
if ( get_pcvar_num ( g_CvarAllowDonate ) )
set_task ( 2.2 , "MsgOnRoundStart" )
set_task ( 12.2 , "MsgOnRoundStart")
set_task ( 22.2 , "MsgOnRoundStart"); }
public MsgOnRoundStart() {
if ( get_pcvar_num ( g_CvarAllowDonate ) )
ColorChat ( 0 , GREEN , "^1[^4ZP^1]^1To ^4donate^1 others Ammo Packs, type ^4/donate <nick> <amount>" ); }
public handleSay ( id , level , cid ) {
if ( !cmd_access ( id , level , cid , 3 ) )
return PLUGIN_HANDLED
new args [ 64 ]
read_args ( args , charsmax ( args ) )
remove_quotes ( args )
new arg1 [ 16 ]
new arg2 [ 32 ]
strbreak ( args , arg1 , charsmax ( arg1 ) , arg2 , charsmax ( arg2 ) )
if ( get_pcvar_num ( g_CvarAllowDonate ) && equal ( arg1 ,"/donate" , 7 ) )
donate ( id , arg2 )
return PLUGIN_HANDLED; }
public donate ( id, arg[]) {
new to [32], count[10]
strbreak(arg, to, 31, count, 9)
if (!to [ 0 ] || !count [ 0 ] ) {
ColorChat ( id , GREEN, "^1[^4ZP^1]^1To use^4 donate^1: say ^4/donate <name> <amount>")
return; }
new ammo_sender = zp_ammopacks_get ( id )
new ammo
if ( equal ( count , "all" ) )
ammo = ammo_sender
else
ammo = str_to_num ( count )
if ( ammo <= 0 ) {
ColorChat ( id , GREEN, "^1[^4ZP^1]^1Wrong ammo quantity!")
return; }
ammo_sender -= ammo
if (ammo_sender < 0){
ammo+=ammo_sender
ammo_sender = 0; }
new reciever = cmd_target(id, to, (CMDTARGET_ALLOW_SELF))
if (!reciever || reciever == id) {
ColorChat ( id , GREEN, "^1[^4ZP^1]^1Player ^4%s ^1has not been found on the server!", to)
return; }
zp_ammopacks_set(reciever, zp_ammopacks_get(reciever) + ammo)
g_UserTotalAmmo[reciever] += ammo
zp_ammopacks_set(id, ammo_sender)
new aName[32], vName[32]
get_user_name(id, aName, 31)
get_user_name(reciever, vName, 31)
set_hudmessage(255, 0, 0, -1.0, 0.3, 0, 6.0, 6.0)
show_hudmessage(0, "%s donated %d Ammo Packs to %s!", aName, ammo, vName); }