AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Problem with zp_giveap plugin command (https://forums.alliedmods.net/showthread.php?t=293856)

GasmoN 02-12-2017 12:50

Problem with zp_giveap plugin command
 
When i tupe zp_giveap SomeName 100, it will give 100 ammo packs to player.
But when i type zp_giveap @ALL 100, command doesn't work. Can someone tell me why?

PHP Code:

public CmdGiveAP idlevelcid )
{
    if(!
cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
    
    
new arg_name[32],arg_ap[10]
    
    
read_argv(1,arg_name,31)
    
read_argv(2,arg_ap,9)
    
    new 
name[32],target_name[32], ip[16],target_ip[16], steamid[32],target_steamid[32],
    
targetnum_ap str_to_num(arg_ap)
    
    if(!
equali(arg_name,"@ALL")) target cmd_target(id,arg_name,0)
    
    
get_user_name(id,name,31)
    
get_user_ip(id,ip,15,1)
    
get_user_authid(id,steamid,31)
    
    
get_user_name(target,target_name,31)
    
get_user_ip(target,target_ip,15,1)
    
get_user_authid(target,target_steamid,31)
    
    if(
num_ap <= 0)
    {
        
console_print(id,"[ZP] You can give only positive ammo packs.")
        return 
PLUGIN_HANDLED
    
}
    
    if(!
target)
    return 
PLUGIN_HANDLED;
    
    if(
equali(arg_name,"@ALL"))
    {
        for(new 
i=1;i<33;i++) if(is_user_connected(i)) zp_ammopacks_set(izp_ammopacks_get(i) + num_ap)
        
client_printc(id"!g%s %L"PREFIXLANG_PLAYER"AP_AMMOTOALL"namenum_ap)
    } 
    else 
    {
        
zp_ammopacks_set(targetzp_ammopacks_get(target) + num_ap)
        
client_printc(target"!g%s !n%L"PREFIXLANG_PLAYER"AP_GIVEAP"namenum_ap)
    }
    
    return 
PLUGIN_HANDLED
    



Natsheh 02-12-2017 13:33

Re: Problem with zp_giveap plugin command
 
You need to check the cmd_access
PHP Code:

if(!cmd_access(id,level,cid,2)) // the 4th parameter is the number of argc (number of blanks) 

And ....

 if(!
equali(arg_name,"@ALL")) target cmd_target(id,arg_name,0
else 
target 1
     

And...

  if(
equali(arg_name,"@ALL")) 
    { 
        for(new 
i=1;i<=get_maxplayers();i++) if(is_user_connected(i)) zp_ammopacks_set(izp_ammopacks_get(i) + num_ap
        
client_printc(0"!g%s %L"PREFIXLANG_PLAYER"AP_AMMOTOALL"namenum_ap)
    } 


GasmoN 02-12-2017 14:14

Re: Problem with zp_giveap plugin command
 
Quote:

Originally Posted by Natsheh (Post 2494942)
You need to check the cmd_access
PHP Code:

if(!cmd_access(id,level,cid,2)) // the 4th parameter is the number of argc (number of blanks) 

And ....

 if(!
equali(arg_name,"@ALL")) target cmd_target(id,arg_name,0
else 
target 1
     

And...

  if(
equali(arg_name,"@ALL")) 
    { 
        for(new 
i=1;i<=get_maxplayers();i++) if(is_user_connected(i)) zp_ammopacks_set(izp_ammopacks_get(i) + num_ap
        
client_printc(0"!g%s %L"PREFIXLANG_PLAYER"AP_AMMOTOALL"namenum_ap)
    } 


This fixed my problem, thanks!

georgik57 02-12-2017 16:15

Re: Problem with zp_giveap plugin command
 
https://www.dropbox.com/sh/tn9j72d52...ampks.sma?dl=0

https://www.dropbox.com/sh/tn9j72d52...ampks.txt?dl=0


All times are GMT -4. The time now is 20:27.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.