Thread: Grenade Request
View Single Post
floatman
Senior Member
Join Date: Oct 2009
Location: nowhere.
Old 12-02-2009 , 07:22   Re: Grenade Request
Reply With Quote #8

-You must try something like:
PHP Code:
/* 
    
    ------------------------------
    Copyrights 2009© , Shuttle_Wave
    ------------------------------
    
    Grenade Request Menu coded by Shuttle_Wave. Waves Extreme Gaming Network.
    Bugs or issues contact Shuttle_Wave. [email protected] or via PM.
    
    
    
    --------
    CREDITS
    --------
    
    Emp` ; For his new AMXX Menu System.
    Shadow_Wave ; Testing
    
    
    ---------
    Contacts
    ---------
    
    Shuttle_Wave ; [email protected] or via PM

*/


// Includes
#include <amxmodx>
#include <fun>
#include <hamsandwich>

// Defines
#define USE_COLORCHAT

#if defined USE_COLORCHAT
#include <colorchat>
#endif
#define VERSION "2.0"


// Plugins Stuff
public plugin_init() {
    
register_plugin("Grenade Request"VERSION"Shuttle_Wave")
    
    
RegisterHam(Ham_Spawn"player""Player_Spawn_Post"1)
    
    
register_clcmd"say /nade","NadeMenu");
    
register_clcmd"say_team /nade","NadeMenu");
}

public 
NadeMenu(id)
{
    new 
menu menu_create("\rChoose Your Grenade!""menu_handler");
    
    
menu_additem(menu"\wHE Grenade""1"0);
    
menu_additem(menu"\wFlash Bang""2"0);
    
menu_additem(menu"\wSmoke Grenade""3"0);
    
    
menu_setprop(menuMPROP_EXITMEXIT_ALL);
    
    
menu_display(idmenu0);    
}

public 
menu_handler(idmenuitem)
{
    if( 
item == MENU_EXIT )
    {
        
menu_destroy(menu);
        return 
PLUGIN_HANDLED;    
    }
    
    new 
data[6], iName[64];
    new 
accesscallback;
    
    
menu_item_getinfo(menuitemaccessdata,5iName63callback);
    
    new 
key str_to_num(data);
    
    switch(
key)
    {
        case 
1:
        {
            
#if defined USE_COLORCHAT
            
ColorChat(0,NORMAL,"[ ^x04Grenade Request^x01 ] You now have a ^x04HE Grenade^x01");
            
#endif
            
client_print(idprint_chat"[ Grenade Request ] You now have a HE Grenade");
            
give_itemid"weapon_hegrenade" );
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED
        
}
        case 
2:
        {
            
#if defined USE_COLORCHAT
            
ColorChat(0,NORMAL,"[ ^x04Grenade Request^x01 ] You now have a^x04 Flash Bang Grenade^x01");
            
#endif
            
client_print(idprint_chat"[ Grenade Request ] You now have a Flash Bang Grenade");
            
give_itemid"weapon_flashbang" );
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED
        
}
        case 
3:
        {
            
#if defined USE_COLORCHAT
            
ColorChat(0,NORMAL,"[ ^x04Grenade Request^x01 ] You now have a ^x04Smoke Grenade^x01");
            
#endif
            
client_print(idprint_chat"[ Grenade Request ] You now have a Smoke Grenade");
            
give_itemid"weapon_smokegrenade" );
            
menu_destroy(menu);
            return 
PLUGIN_HANDLED
        
}
    }
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED
}

public 
Player_Spawn_Post(id)
{
    
#if defined USE_COLORCHAT
    
ColorChat(0,NORMAL,"[ ^x04Grenade Request^x01 ] To request a grenade type ^x04/nade^x01");
    
#endif
    
client_print(idprint_chat"[ Grenade Request ] To request a grenade type /nade");
    return 
PLUGIN_HANDLED
}
/* Shuttle_Waves-Nots - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1033\\ f0\\ fs16 \n\\ par }
*/ 
For who don't see, i added the part with #if defined USE_COLORCHAT.
If you don't want to use COLORCHAT, add // before #define USE_COLORCHAT.
Is easier than your method.

-At the menu, is useless to destroy every case, destroy when the plugin is end:
PHP Code:
    switch(key)
    {
        case 
1:
        {
            
#if defined USE_COLORCHAT
            
ColorChat(0,NORMAL,"[ ^x04Grenade Request^x01 ] You now have a ^x04HE Grenade^x01");
            
#endif
            
client_print(idprint_chat"[ Grenade Request ] You now have a HE Grenade");
            
give_itemid"weapon_hegrenade" );
    }
        case 
2:
        {
            
#if defined USE_COLORCHAT
            
ColorChat(0,NORMAL,"[ ^x04Grenade Request^x01 ] You now have a^x04 Flash Bang Grenade^x01");
            
#endif
            
client_print(idprint_chat"[ Grenade Request ] You now have a Flash Bang Grenade");
            
give_itemid"weapon_flashbang" );
    }
        case 
3:
        {
            
#if defined USE_COLORCHAT
            
ColorChat(0,NORMAL,"[ ^x04Grenade Request^x01 ] You now have a ^x04Smoke Grenade^x01");
            
#endif
            
client_print(idprint_chat"[ Grenade Request ] You now have a Smoke Grenade");
            
give_itemid"weapon_smokegrenade" );
    }
}
    
menu_destroy(menu);
    return 
PLUGIN_HANDLED

__________________


Last edited by floatman; 12-02-2009 at 07:27.
floatman is offline