Raised This Month: $ Target: $400
 0% 

adding menu to plugin


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 10-14-2006 , 19:12   adding menu to plugin
Reply With Quote #1

if i wanted to add a menu in my plugin script how would i do it?

Here is my script:

Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <cstrike>
 
#define PLUGIN "health_model"
#define VERSION "1.0"
#define AUTHOR "HeadxShot"
 
 // Add your code here...
public plugin_init()
{
     register_plugin(PLUGIN, VERSION, AUTHOR)
     register_concmd("amx_hp", "cmd_hp", ADMIN_SLAY, "<target> <hp>")
}
 
public cmd_hp(id, level, cid)
{
     if (!cmd_access(id, level, cid, 3))
        return PLUGIN_HANDLED
 
     new Arg1[24]
     new Arg2[4]
 
     //Get the command arguments from the console
     read_argv(1, Arg1, 23)
     read_argv(2, Arg2, 3)
 
     //Convert the health from a string to a number
     new Health = str_to_num(Arg2)
     if(Health < 1)
     {
          // Print a message saying health has to be greater than 0.
          // If they get their health set to less than 1.
          // It will kill the player automatically.
          return PLUGIN_HANDLED;
     }
 
     //Is the first character the @ symbol?
     if (Arg1[0] == '@')
     {
          new Team = 0
          if (equali(Arg1[1], "CT"))
          {
               Team = 2
          } else if (equali(Arg1[1], "T")) {
               Team = 1
          }
          new players[32], num
          get_players(players, num)
          new i
          for (i=0; i<num; i++)
          {
               if (!Team)
               {
                    set_user_health(players[i], Health)
                    cs_set_user_model(players[i], "clone")
               } else {
                    if (get_user_team(players[i]) == Team)
                    {
                         set_user_health(players[i], Health)
                         cs_set_user_model(players[i], "clone")
                    }
               }
          }
     } else {
          new player = cmd_target(id, Arg1, 1)
          if (!player)
          {
               console_print(id, "Sorry, player %s could not be found or targetted!", Arg1)
               return PLUGIN_HANDLED
          } else {
               set_user_health(player, Health)
               cs_set_user_model(player, "clone")
          }
     }
 
     return PLUGIN_HANDLED
     
   }
public plugin_precache()
{
     precache_model("models/player/clone/clone.mdl")
}
Thnx in advance.
__________________
i stop around here and there.
Da_sk8rboy is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 10-14-2006 , 19:41   Re: adding menu to plugin
Reply With Quote #2

look at other plugins
[ --<-@ ] Black Rose is offline
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 10-14-2006 , 21:22   Re: adding menu to plugin
Reply With Quote #3

ok thats not what i asked. i asked how to add a menu to my plugin.
__________________
i stop around here and there.
Da_sk8rboy is offline
TheNewt
Donor
Join Date: Jun 2006
Location: Where I live.
Old 10-15-2006 , 00:11   Re: adding menu to plugin
Reply With Quote #4

no, Black Rose was right. Look at other plugins.
If you can't understand what he means by that, don't ever join an open source community again. It's that simple ^.^
__________________
Quote:
toe3_ left the chat room. (G-lined (AUTO Excessive connections from a single host.))
TheNewt is offline
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 10-15-2006 , 11:06   Re: adding menu to plugin
Reply With Quote #5

Oh okay, i understand what hes talking about. would this work?

Code:
#include <amxmodx>
 
 
public plugin_init()
{
   register_clcmd( "say /menu","ShowMenu", -1, "Shows The menu" )
 
   register_menucmd(register_menuid("\yFirst Menu:"), 1023, "MenuCommand" )
 
   return PLUGIN_CONTINUE
}
 
public ShowMenu( id )
{
   new szMenuBody[256]
   new keys
 
   new nLen = format( szMenuBody, 255, "\yFirst Menu:^n" )
 
   nLen += format( szMenuBody[nLen], 255-nLen, "^n\w1. First Option" )
   nLen += format( szMenuBody[nLen], 255-nLen, "^n\w2. Second Option" )
   nLen += format( szMenuBody[nLen], 255-nLen, "^n\w3. Third Option" )
   nLen += format( szMenuBody[nLen], 255-nLen, "^n\w4. Fourth Option" )
   nLen += format( szMenuBody[nLen], 255-nLen, "^n\w5. Fifth Option" )
   nLen += format( szMenuBody[nLen], 255-nLen, "^n\w6. Sixth Option" )
   nLen += format( szMenuBody[nLen], 255-nLen, "^n\w7. Seventh Option" )
   nLen += format( szMenuBody[nLen], 255-nLen, "^n\w8. Eighth Option" )
   nLen += format( szMenuBody[nLen], 255-nLen, "^n\w9. Ninth Option" )
   nLen += format( szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit" )
 
   keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)
 
   show_menu( id, keys, szMenuBody, -1 )
 
   return PLUGIN_CONTINUE
}
 
public MenuCommand( id, key )
{
   client_print( id, print_console, "[AMX] Key=%d", key )
   client_print( id, print_chat, "[AMX] Key=%d", key )
 
   switch( key )
   {
       case 0: client_print( id, print_chat, "Menu Option #1" )
       case 1: client_print( id, print_chat, "Menu Option #2" )
       case 2: client_print( id, print_chat, "Menu Option #3" )
       case 3: client_print( id, print_chat, "Menu Option #4" )
       case 4: client_print( id, print_chat, "Menu Option #5" )
       case 5: client_print( id, print_chat, "Menu Option #6" )
       case 6: client_print( id, print_chat, "Menu Option #7" )
       case 7: client_print( id, print_chat, "Menu Option #8" )
       case 8: client_print( id, print_chat, "Menu Option #9" )
       case 9: client_print( id, print_chat, "Menu Option EXIT" )
   } 
 
   return PLUGIN_HANDLED
}


__________________
i stop around here and there.
Da_sk8rboy is offline
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 10-15-2006 , 11:09   Re: adding menu to plugin
Reply With Quote #6

what if i wanted to add like admins with LEVEL_SLAY to be able to use this menu? and where would i put it? and i want tho change the menu into being able to see all the players and being able to change there hp through a menu, thnx if you can help.

Would i just do it like this:

Code:
register_concmd("amx_hpmenu", "cmd_hpmenu", ADMIN_SLAY, "say /hpmenu","ShowMenu", -1, "Shows The menu")
__________________
i stop around here and there.

Last edited by Da_sk8rboy; 10-15-2006 at 11:13.
Da_sk8rboy is offline
TheNewt
Donor
Join Date: Jun 2006
Location: Where I live.
Old 10-15-2006 , 12:52   Re: adding menu to plugin
Reply With Quote #7

lol change this then
Code:
   register_clcmd( "say /menu","ShowMenu", -1, "Shows The menu" )
to like
Code:
 register_clcmd("say /menu", "ShowMenu", ADMIN_SLAY, "Shows the Menu");
and change this
Code:
public ShowMenu( id )
to
Code:
public ShowMenu(id, level, cid)
then add something to check the admin level.

Eh, =P
Code:
#include <amxmodx> #define PLUGIN      "Sample" #define VERSION     "1.0" #define AUTHOR      "Whatev" public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);         register_concmd("say /menu", "MainMenu", ADMIN_SLAY, "Opens the Main Menu");         register_menucmd(register_menuid("menu_MainMenu"),1023,"MenuAction_MainMenu"); } MainMenu(id) {     if (!cmd_access(id, level, cid, 1)) {         client_print(id, print_chat, "[Sample] Access Denied.");         client_print(id, print_console, "[Sample] Access Denied.");         return PLUGIN_HANDLED;     }     new szMenuBody[256]     new key = MENU_KEY_0|MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9         new nLen = format(szMenuBody, 255, "\yMain Menu:^n")         nLen += format(szMenuBody[nLen], 255-nLen, "^n\w1. First Option")     nLen += format(szMenuBody[nLen], 255-nLen, "^n\w2. Second Option")     nLen += format(szMenuBody[nLen], 255-nLen, "^n\w3. Third Option")     nLen += format(szMenuBody[nLen], 255-nLen, "^n\w4. Fourth Option")     nLen += format(szMenuBody[nLen], 255-nLen, "^n\w5. Fifth Option")     nLen += format(szMenuBody[nLen], 255-nLen, "^n\w6. Sixth Option")     nLen += format(szMenuBody[nLen], 255-nLen, "^n\w7. Seventh Option")     nLen += format(szMenuBody[nLen], 255-nLen, "^n\w8. Eighth Option")     nLen += format(szMenuBody[nLen], 255-nLen, "^n\w9. Ninth Option")         nLen += format(szMenuBody[nLen], 255-nLen, "^n^n\w0. Exit")         show_menu(id, key, menu, -1, "menu_MainMenu")         return PLUGIN_HANDLED; } public MenuCommand(id, key) {     switch(key) {         case 0: //Do Option 1         case 1: //Do Option 2         case 2: //Do Option 3         case 3: //Do Option 4         case 4: //Do Option 5         case 5: //Do Option 6         case 6: //Do Option 7         case 7: //Do Option 8         case 8: //Do Option 9         // You don't need case 9, it will exit anyways.     } }
__________________
Quote:
toe3_ left the chat room. (G-lined (AUTO Excessive connections from a single host.))

Last edited by TheNewt; 10-15-2006 at 13:04.
TheNewt is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-15-2006 , 14:39   Re: adding menu to plugin
Reply With Quote #8

Code:
// This checks to make sure a user has proper access // add this to the top of your function if (!cmd_access(id, level, cid, 1))      return PLUGIN_HANDLED;
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Da_sk8rboy
Veteran Member
Join Date: Jul 2006
Old 10-15-2006 , 16:40   Re: adding menu to plugin
Reply With Quote #9

so would i add that in with my script or make another plugin with it?
__________________
i stop around here and there.
Da_sk8rboy is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 10-15-2006 , 17:02   Re: adding menu to plugin
Reply With Quote #10

You add it.
What is the menu supposed to do?

Is it going to list all players and then choose one name and he gets x ammount of hp..?
Or various ammount of hp to one allready selected player?
Or first a playermenu and when you choose a name another menu will appear with hp values?

Last edited by [ --<-@ ] Black Rose; 10-15-2006 at 17:05.
[ --<-@ ] Black Rose 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 04:51.


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