static cell_t SendPanelToClient(IPluginContext *pContext, const cell_t *params) { Handle_t hndl = (Handle_t)params[1]; HandleError err; IMenuPanel *panel; if ((err=ReadPanelHandle(hndl, &panel)) != HandleError_None) { return pContext->ThrowNativeError("Menu handle %x is invalid (error %d)", hndl, err); } IPluginFunction *pFunction; if ((pFunction=pContext->GetFunctionById(params[3])) == NULL) { return pContext->ThrowNativeError("Function id %x is invalid", params[3]); } CPanelHandler *handler = g_MenuHelpers.GetPanelHandler(pFunction); if (!panel->SendDisplay(params[2], handler, params[4])) { g_MenuHelpers.FreePanelHandler(handler); } return 1; }
void CRPGPlayer::ShowChar() { IMenuStyle *style = menus->GetDefaultStyle(); IBaseMenu *menu = style->CreateMenu(&g_RPGPlugin, myself->GetIdentity()); IMenuPanel *panel = menu->CreatePanel(); menu->SetDefaultTitle(MENU_CHAR_TITLE); panel->DrawTitle(MENU_CHAR_TITLE); char text[255]; sprintf(text, "Player ID: %d", GetSQLIndex()); panel->DrawItem(ItemDrawInfo(text)); int classnum = GetCurrentClass(); if (classnum > RPG_CLASS_NONE) { int team = GetCachedTeam(); if ( team == TEAM_SURVIVORS) { sprintf(text, "Class: %s", HumanClasses[classnum]); } else if (team == TEAM_UNDEAD) { sprintf(text, "Class: %s", ZombieClasses[classnum]); } else { sprintf(text, "Class: None"); } panel->DrawItem(ItemDrawInfo(text)); // item 1 sprintf(text, "Level: %d", GetLevel()); panel->DrawItem(ItemDrawInfo(text)); // item 2 sprintf(text, "Experience: %d", GetExperience()); panel->DrawItem(ItemDrawInfo(text)); // item 3 for (int i = 0; i < MAX_SKILLS; i++) // item 4-7 { sprintf(text, "%s - (Level %d)", SkillNames[skills[i].iIndex], skills[i].iLevel); panel->DrawItem(ItemDrawInfo(text)); } } panel->SendDisplay(GetIndex(), &g_RPGPlugin, MENU_TIME_FOREVER ); }
static cell_t InternalShowMenu(IPluginContext *pContext, const cell_t *params) { int client = params[1]; CPlayer *pPlayer = g_Players.GetPlayerByIndex(client); if (pPlayer == NULL) { return pContext->ThrowNativeError("Invalid client index %d", client); } else if (!pPlayer->IsInGame()) { return pContext->ThrowNativeError("Client %d is not in game", client); } if (!g_RadioMenuStyle.IsSupported()) { return pContext->ThrowNativeError("Radio menus are not supported on this mod"); } char *str; pContext->LocalToString(params[2], &str); IMenuPanel *pPanel = g_RadioMenuStyle.MakeRadioDisplay(str, params[4]); if (pPanel == NULL) { return 0; } IMenuHandler *pHandler; CPanelHandler *pActualHandler = NULL; if (params[5] != -1) { IPluginFunction *pFunction = pContext->GetFunctionById(params[5]); if (pFunction == NULL) { return pContext->ThrowNativeError("Invalid function index %x", params[5]); } pActualHandler = g_MenuHelpers.GetPanelHandler(pFunction); } if (pActualHandler == NULL) { pHandler = &s_EmptyMenuHandler; } else { pHandler = pActualHandler; } bool bSuccess = pPanel->SendDisplay(client, pHandler, params[3]); pPanel->DeleteThis(); if (!bSuccess && pActualHandler != NULL) { g_MenuHelpers.FreePanelHandler(pActualHandler); } return bSuccess ? 1 : 0; }