Raised This Month: $ Target: $400
 0% 

Menu + HUD message problems


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Prelithe
Junior Member
Join Date: Mar 2005
Old 03-26-2005 , 21:34   Menu + HUD message problems
Reply With Quote #1

hi,

got this code basically to show up a menu, and when you press a specific key it displays hud_showmessage(whatever string). Since i lost my old code, and had to work with my other crap code (omg the errors ) i looked around this forum and got another set of menu code but it still doesn't work...my problem...whenever i select a key, it doesn't display any text....anyone can fix my problem?

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

public plugin_init()
{
    register_plugin("Menu Demo", "1.0", "BAILOPAN")
    new keys = 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|
    register_menucmd(register_menuid("Which Weapon?"), keys, "giveWeapon")
    register_clcmd("giveme", "showWeaponMenu")
    return PLUGIN_CONTINUE
}

public showWeaponMenu(id)
{
    new menu[192]
    new keys = 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|

    format(menu, 191, "Which Weapon?^n^n1. AK47^n2. M4A1^n3. AWP")
    show_menu(id, keys, menu)
    return PLUGIN_CONTINUE
}


//Our menu function will get the player id and the key they pressed
public giveWeapon(id, key)
{
  switch(key)
  {
    case 0:
    {
      new plist[32],pnum,uName[64]
      get_players(plist,pnum)
      for(new i=0; i<pnum; i++)
      {
        get_user_name(plist[i],uName,63)
        set_hudmessage(200,100,0,0.0,0.0,0,6.0,12.0,0.1,0.2,4)
        show_hudmessage(plist[i],"test 1", uName)
      }
    }
    case 1:
    {
      new plist[32],pnum,uName[64]
      get_players(plist,pnum)
      for(new i=0; i<pnum; i++)
      {
        get_user_name(plist[i],uName,63)
        set_hudmessage(200,100,0,0.0,0.0,0,6.0,12.0,0.1,0.2,4)
        show_hudmessage(plist[i],"test 2", uName)
      }
    }
    case 2:
    {
      new plist[32],pnum,uName[64]
      get_players(plist,pnum)
      for(new i=0; i<pnum; i++)
      {
        get_user_name(plist[i],uName,63)
        set_hudmessage(200,100,0,0.0,0.0,0,6.0,12.0,0.1,0.2,4)
        show_hudmessage(plist[i],"test 3", uName)
      }
    }
    case 3:
    {
      new plist[32],pnum,uName[64]
      get_players(plist,pnum)
      for(new i=0; i<pnum; i++)
      {
        get_user_name(plist[i],uName,63)
        set_hudmessage(200,100,0,0.0,0.0,0,6.0,12.0,0.1,0.2,4)
        show_hudmessage(plist[i],"test 4", uName)
      }
    }
    case 4:
    {
      new plist[32],pnum,uName[64]
      get_players(plist,pnum)
      for(new i=0; i<pnum; i++)
      {
        get_user_name(plist[i],uName,63)
        set_hudmessage(200,100,0,0.0,0.0,0,6.0,12.0,0.1,0.2,4)
        show_hudmessage(plist[i],"test 5", uName)
      }
    }
    case 5:
    {
      new plist[32],pnum,uName[64]
      get_players(plist,pnum)
      for(new i=0; i<pnum; i++)
      {
        get_user_name(plist[i],uName,63)
        set_hudmessage(200,100,0,0.0,0.0,0,6.0,12.0,0.1,0.2,4)
        show_hudmessage(plist[i],"test 6", uName)
      }
    }
    case 6:
    {
      new plist[32],pnum,uName[64]
      get_players(plist,pnum)
      for(new i=0; i<pnum; i++)
      {
        get_user_name(plist[i],uName,63)
        set_hudmessage(200,100,0,0.0,0.0,0,6.0,12.0,0.1,0.2,4)
        show_hudmessage(plist[i],"test 7", uName)
      }
    }
    case 7:
    {
      new plist[32],pnum,uName[64]
      get_players(plist,pnum)
      for(new i=0; i<pnum; i++)
      {
        get_user_name(plist[i],uName,63)
        set_hudmessage(200,100,0,0.0,0.0,0,6.0,12.0,0.1,0.2,4)
        show_hudmessage(plist[i],"test8", uName)
      }
    }
    case 8:
    {
      new plist[32],pnum,uName[64]
      get_players(plist,pnum)
      for(new i=0; i<pnum; i++)
      {
        get_user_name(plist[i],uName,63)
        set_hudmessage(200,100,0,0.0,0.0,0,6.0,12.0,0.1,0.2,4)
        show_hudmessage(plist[i],"test 9", uName)
      }
    }
  }
    return PLUGIN_CONTINUE
}
Prelithe is offline
KyleD
Member
Join Date: Mar 2005
Location: Anchorage, AK
Old 03-26-2005 , 21:58  
Reply With Quote #2

Try using "format".
__________________
KyleD is offline
Send a message via MSN to KyleD
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 03-26-2005 , 23:36  
Reply With Quote #3

Code:
    new keys = 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|

This appears several times in your code. What is that extra | on the end for?

Code:
        show_hudmessage(plist[i],"test 1", uName)

What is uName there for? No %s's. Could be generating a string formatted incorrectly error in-game.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Prelithe
Junior Member
Join Date: Mar 2005
Old 03-27-2005 , 00:58  
Reply With Quote #4

thanks so much Avalanche for your help....im such an idiot for not even noticing that!
Prelithe is offline
Reply


Thread Tools
Display Modes

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 09:49.


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