AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Giving ammo packs ZP4.3 (https://forums.alliedmods.net/showthread.php?t=312948)

Vellety 12-22-2018 04:58

Giving ammo packs ZP4.3
 
Could someone tell me why this does not work?
If I don't provide an argument it'll just say "Player not found" right, but if I do provide args nothing happens at all.

PHP Code:

public plugin_init()
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
    
// cmds
    
register_clcmd("say /giveap""hCMD"ADMIN_BAN"Usage: /giveap <name> <amount>")
    
register_clcmd("say_team /giveap""hCMD"ADMIN_BAN"Usage: /giveap <name> <amount>")
}

public 
hCMD(id)
{
    new 
szName[32], iAmount[256];
    
read_argv(1szNamecharsmax (szName));
    
read_argv(2iAmountcharsmax (iAmount));
    
    new 
iTarget cmd_target(idszName2);
    if (!
iTarget)
    {
        
ColorChat(idRED"[ZM]^1 Player not found!!");
        return 
PLUGIN_HANDLED;
    }
    
    
zp_add_user_ammo_packs(iTargetmax(1str_to_num(iAmount)));
    return 
PLUGIN_HANDLED;



OciXCrom 12-22-2018 08:38

Re: Giving ammo packs ZP4.3
 
You can't use arguments with chat commands like that. You need to hook the "say" command and use "read_args" + "parse" to get the arguments.

Vellety 12-22-2018 11:00

Re: Giving ammo packs ZP4.3
 
Quote:

Originally Posted by OciXCrom (Post 2630508)
You can't use arguments with chat commands like that. You need to hook the "say" command and use "read_args" + "parse" to get the arguments.

Yea, thanks. Solved it :)


All times are GMT -4. The time now is 07:32.

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