Raised This Month: $ Target: $400
 0% 

Admin donate ammopacks


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
satelitegames
Member
Join Date: Nov 2010
Old 06-07-2012 , 22:22   Admin donate ammopacks
Reply With Quote #1

Hello, I would like to ask for help, add a menu for donation of ammopacks.


After I select the player to show a client_cmd (id, "messagemode Amount") for me to enter the amount of ammopacks I'll donate


PHP Code:
#include <amxmodx> 
#include <amxmisc>
#include <zombieplague> 

public plugin_init ()
{
    
register_plugin "ZP: Give Ammo""1.0.0""Arkshine" );
    
register_clcmd "zp_giveap""CmdGiveAP"ADMIN_RCON"- zp_giveap <name> <amount> : Give Ammo Packs" );
    
register_clcmd "amx_giveap""CmdGiveAP"ADMIN_RCON"- amx_giveap <name> <amount> : Give Ammo Packs" );
}

public 
CmdGiveAP idlevelcid )
{
    if ( !
cmd_access idlevelcid) )
    {
        return 
PLUGIN_HANDLED;
    }
    
    new 
s_Name32 ], s_Amount];
    
    
read_argv 1s_Namecharsmax s_Name ) );
    
read_argv 2s_Amountcharsmax s_Amount ) );
    
    new 
i_Target cmd_target ids_Name);
    
    if ( !
i_Target )
    {
        
client_print idprint_console"(!) Player not found" );
        return 
PLUGIN_HANDLED;
    }
    
    
zp_set_user_ammo_packs i_Targetmax 1str_to_num s_Amount ) ) );
    
    return 
PLUGIN_HANDLED;

__________________




satelitegames is offline
Liverwiz
Veteran Member
Join Date: Feb 2010
Location: Maryland
Old 06-07-2012 , 23:49   Re: Admin donate ammopacks
Reply With Quote #2

call this function from your main menu initializer. It will fill out your player list into the menu, including data containing the id of the player. Make sure to check in the functionality that the player is still connected. You'll also have to separate the data accordingly. I use the semi-colon as a delimiter. You can also remove it completely rather easily.

PHP Code:
/*   THIS FUNCTION AUTOMATICALLY SETS THE EXIT (creates a useable menu)
       p_menu is a pointer to the menu that we're going to add the players list to
       source[] is the source menu to keep track of what's going on internally
       itemAccess is the "access" paramater for menu_additem
       getPlayersFlags[] is a string of flags for the get_players command 
       RETURNS: number of players in the list */
mhlp_getPlayerMenu(&p_menusource[]="fal"itemAccess=0getPlayersFlags[]="ch")
{
    new 
players[32], plyrCntplayer
    
new sz_name[32], sz_info[8]
    
get_players(playersplyrCntgetPlayersFlags)
    
    for(new 
i=0i<plyrCnti++)
    {
        
player players[i]
        
get_user_name(playersz_namecharsmax(sz_name) )
        
formatex(sz_infocharsmax(sz_info), "%s;%d"sourceplayer)
        
menu_additem(p_menusz_namesz_infoitemAccess)
    }
    
    
menu_setprop(p_menuMPROP_EXITMEXIT_ALL)
    return 
plyrCnt

Just a little bit to give you some help writing your menu. Good luck!
Here's a tut on how to write a menu using the new menu system (which is what this function is based on)
http://forums.alliedmods.net/showthread.php?t=46364
__________________
What an elegant solution to a problem that doesn't need solving....

Last edited by Liverwiz; 06-08-2012 at 00:04.
Liverwiz is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:55.


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