AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Menu + HUD message problems (https://forums.alliedmods.net/showthread.php?t=11715)

Prelithe 03-26-2005 21:34

Menu + HUD message problems
 
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
}


KyleD 03-26-2005 21:58

Try using "format".

XxAvalanchexX 03-26-2005 23:36

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.

Prelithe 03-27-2005 00:58

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


All times are GMT -4. The time now is 09:49.

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