Raised This Month: $51 Target: $400
 12% 

+Health menu


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   ALL        Category:   Admin Commands       
made.tn
BANNED
Join Date: Nov 2011
Old 11-27-2011 , 05:28   +Health menu
Reply With Quote #1

PHP Code:
#include <amxmodx> 
#include <fun> 

public plugin_init() 

    
register_concmd("hp_menu""menu"


public 
menu(id

    new 
menu menu_create("Menu Name""menu_handler"
     
    
menu_additem(menu"Give 100 hp ""1"
    
menu_additem(menu"Give 500 hp ""2"
    
menu_additem(menu"Give 1000 hp ""3"
     
    
menu_display(idmenu0


public 
menu_handler(idmenuitem

    new 
maxdata[64], maxnames[64], accesscallback 
     
    menu_item_getinfo
(menuitemaccessmaxdatasizeof maxdata 1maxnamessizeof maxnames 1callback
     
    new 
key str_to_num(maxdata
    new 
health get_user_health(id
     
    switch (
key
    { 
        case 
1
        { 
            
set_user_health(idhealth 100
        }case 
2
        { 
            
set_user_health(idhealth 500
        }case 
3
        { 
            
set_user_health(idhealth 1000
        } 
    } 
    
menu_destroy(menu
    return 
PLUGIN_HANDLED 

Attached Files
File Type: sma Get Plugin or Get Source (hpmenu.sma - 697 views - 1.2 KB)
made.tn is offline
ConnorMcLeod
Veteran Member
Join Date: Jul 2006
Location: France (95)
Old 11-27-2011 , 05:55   Re: +Health menu
Reply With Quote #2

Redundant, limited (self health), useless, no description : Unapproved.

I think it's your first plugin, usually coders don't release their 1st plugin, they keep become better untill they make an original plugin and then they release it ;)

About the code, you could use item directly in the switch, from 0 to 2 instead of key from 1 to 3, then you wouldn't need to add extra info in menu_additem, and you wouldn't need to retrieve item info in the handler.

Also, the menu is not dynamic, so you could build it in plugin_init and then open the same one instead of create it each time and destroy it each time.
__________________
- tired and retired -

- my plugins -
ConnorMcLeod 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 07:20.


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