AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   adding menu to plugin (https://forums.alliedmods.net/showthread.php?t=45938)

Da_sk8rboy 10-14-2006 19:12

adding menu to plugin
 
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.

[ --<-@ ] Black Rose 10-14-2006 19:41

Re: adding menu to plugin
 
look at other plugins

Da_sk8rboy 10-14-2006 21:22

Re: adding menu to plugin
 
ok thats not what i asked. i asked how to add a menu to my plugin.

TheNewt 10-15-2006 00:11

Re: adding menu to plugin
 
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 ^.^

Da_sk8rboy 10-15-2006 11:06

Re: adding menu to plugin
 
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
}




Da_sk8rboy 10-15-2006 11:09

Re: adding menu to plugin
 
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")

TheNewt 10-15-2006 12:52

Re: adding menu to plugin
 
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.     } }

Zenith77 10-15-2006 14:39

Re: adding menu to plugin
 
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;

Da_sk8rboy 10-15-2006 16:40

Re: adding menu to plugin
 
so would i add that in with my script or make another plugin with it?

[ --<-@ ] Black Rose 10-15-2006 17:02

Re: adding menu to plugin
 
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?


All times are GMT -4. The time now is 04:51.

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