meta_api:
PHP Code:
int MSGID_ShowMenu = 0;
void MessageBegin(int msg_dest, int msg_type, const float *pOrigin, edict_t *ed)
{
static bool LoadedMSGS = false;
if(!LoadedMSGS)
{
MSGID_ShowMenu = GET_USER_MSG_ID(PLID, "ShowMenu", NULL);
LoadedMSGS = true;
}
RETURN_META(MRES_IGNORED);
}
void ClientCommand(edict_t *pEntity)
{
const char *szArg;
szArg = CMD_ARGV(0);
if (FStrEq(szArg, "jointeam") || FStrEq(szArg, "chooseteam"))
{
fw_JoinTeam( pEntity );
RETURN_META(MRES_SUPERCEDE);
}
RETURN_META(MRES_IGNORED);
}
main_menu.cpp:
PHP Code:
#define KEY_1 (1<<0)
extern void fw_JoinTeam( edict_t *pEntity );
extern int MSGID_ShowMenu;
void UTIL_ShowMenu(edict_t* pEdict, int slots, int time, char *menu, int mlen);
void fw_JoinTeam( edict_t *pPlayer )
{
int keys = KEY_1;
char menu[512];
int len = sprintf(menu, "\\yMain Menu\n\n\
\\r1.\\w Menu");
UTIL_ShowMenu( pPlayer, keys, -1, menu, len);
}
void UTIL_ShowMenu(edict_t* pEdict, int slots, int time, char *menu, int mlen)
{
char *n = menu;
char c = 0;
int a;
if (!MSGID_ShowMenu)
return; // some games don't support ShowMenu (Firearms)
while (*n)
{
a = mlen;
if (a > 175) a = 175;
mlen -= a;
c = *(n+=a);
*n = 0;
MESSAGE_BEGIN(MSG_ONE, MSGID_ShowMenu, NULL, pEdict);
WRITE_SHORT(slots);
WRITE_CHAR(time);
WRITE_BYTE(c ? TRUE : FALSE);
WRITE_STRING(menu);
MESSAGE_END();
*n = c;
menu = n;
}
}
All functions are called,but menu,doesn't show.
__________________