Thread: [Suggestion / Subplugin Request] REQ ZP5 Admin ammo donate
View Single Post
H.RED.ZONE
Veteran Member
Join Date: Sep 2011
Location: Serbia, Belgrade
Old 04-28-2012 , 15:29   Re: REQ ZP5 Admin ammo donate
Reply With Quote #4

Change ADMIN_ADMIN to what ever you want --> http://www.amxmodx.org/funcwiki.php?go=module&id=1

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 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 ) )
    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" ) )
    
donate id arg2 
    return 
PLUGIN_HANDLED; }

public 
donate idarg[]) {
    new 
to [32], count[10]
    
strbreak(argto31count9)
    
    if (!
to ] || !count ] ) {
        
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 <= ) {
        
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(idto, (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(recieverzp_ammopacks_get(reciever) + ammo)
    
g_UserTotalAmmo[reciever] += ammo
    zp_ammopacks_set
(idammo_sender)
    new 
aName[32], vName[32]
    
    
get_user_name(idaName31)
    
get_user_name(recievervName31)
    
    
set_hudmessage(25500, -1.00.306.06.0)
    
show_hudmessage(0"%s donated %d Ammo Packs to %s!"aNameammovName); } 
__________________
H.RED.ZONE is offline