Try this. I just deleted the bot block and added an extra conditional before it displays the menu.
Code:
public menuSuperPowers(id, menuOffset)
{
// Don't show menu if mod off or they're not connected
if ( !shModActive() || !is_user_connected(id) || gReadXPNextRound[id] ) return PLUGIN_HANDLED
inMenu[id] = false
gPlayerMenuOffset[id] = 0
// show menu super power
new message[1801]
new temp[128]
new keys = 0
new heroIndex, heroLevel, playerpowercount
// check for cheat death
if ( !passCheatDeathCheck(id) ) {
client_print(id, print_center, "Get C/D From www.unitedadmins.com")
return PLUGIN_HANDLED // Just don't show the gui menu
}
if ( isPowerBanned[id] ) {
client_print(id, print_center, "You are not allowed to have powers")
return PLUGIN_HANDLED // Just don't show the gui menu
}
// Don't show menu if they already have enough powers
playerpowercount = getPowerCount(id)
if ( playerpowercount >= gPlayerLevel[id] || playerpowercount >= gMaxPowers ) return PLUGIN_HANDLED
// Figure out how many powers a person should be able to have
// Example: At level 10 a person can pick a max of 1 lvl 10 hero
// and a max of 2 lvl 9 heroes, and a max of 3 lvl 8 heors, etc...
new LvlLimit = get_cvar_num("sh_lvllimit")
if (LvlLimit == 0) LvlLimit = SH_MAXLEVELS
for ( new x = 0; x <= gNumLevels; x++) {
if ( gPlayerLevel[id] >= x ) {
maxPowersLeft[id][x] = gPlayerLevel[id] - x + LvlLimit
}
else maxPowersLeft[id][x] = 0
}
// Now decrement the level powers that they've picked
for ( new x = 1; x <= getPowerCount(id) && x <= SH_MAXLEVELS; x++ ) {
heroIndex = gPlayerPowers[id][x]
if ( heroIndex < 0 || heroIndex > gSuperHeroCount) continue
heroLevel = getHeroLevel(heroIndex)
// Decrement all maxPowersLeft by 1 for the level hero they have and below
for ( new y = heroLevel; y >= 0; y-- ) {
if (--maxPowersLeft[id][y] < 0) maxPowersLeft[id][y] = 0
//If none left on this level, there should be none left on any higher levels
if (maxPowersLeft[id][y] <= 0 && y < SH_MAXLEVELS) {
if (maxPowersLeft[id][y+1] != 0) {
for ( new z = y; z <= gNumLevels; z++ ) {
maxPowersLeft[id][z] = 0
}
}
}
}
}
// OK BUILD A LIST OF HEROES THIS PERSON CAN PICK FROM
gPlayerMenuChoices[id][0] = 0 // <- 0 choices so far
new count = 0, enabled = 0
new MaxBinds = min(get_cvar_num("sh_maxbinds"), SH_MAXBINDPOWERS)
new menuMode = get_cvar_num("sh_menumode")
new bool:thisEnabled
for ( new x = 0; x < gSuperHeroCount; x++ ) {
heroIndex = x
heroLevel = getHeroLevel(heroIndex)
thisEnabled = false
if ( gPlayerLevel[id] >= heroLevel ) {
if (maxPowersLeft[id][heroLevel] > 0 && !(gPlayerBinds[id][0] >= MaxBinds && gSuperHeros[heroIndex][requiresKeys])) {
thisEnabled = true
}
// Don't want to present this power if the player already has it!
if ( !playerHasPower(id, heroIndex) && (thisEnabled || menuMode > 0)) {
count++
gPlayerMenuChoices[id][0] = count
gPlayerMenuChoices[id][count] = heroIndex
if (thisEnabled) enabled++
}
}
}
//menuOffset Stuff
if (menuOffset <= 0 || menuOffset > gPlayerMenuChoices[id][0]) menuOffset = 1
gPlayerMenuOffset[id] = menuOffset
new total = min ( gMaxPowers, gPlayerLevel[id] )
format(message,180, "\ySelect Super Power:%-16s\r(You've Selected %d/%d)^n^n", " ", playerpowercount, total )
// OK Display the Menu
for ( new x = menuOffset; x < menuOffset + 8; x++ ) {
// Only allow a selection from powers the player doesn't have
if (x > gPlayerMenuChoices[id][0]) {
add(message, 1800, "^n")
continue
}
heroIndex = gPlayerMenuChoices[id][x]
heroLevel = getHeroLevel(heroIndex)
if (maxPowersLeft[id][heroLevel] <= 0 || (gPlayerBinds[id][0] >= MaxBinds && gSuperHeros[heroIndex][requiresKeys])) {
add(message,1800,"\d")
}
else {
add(message,1800,"\w")
}
keys |= (1<<x-menuOffset) // enable this option
format(temp, 127, "%s (%d%s)",gSuperHeros[heroIndex][hero],heroLevel,gSuperHeros[heroIndex][requiresKeys] ? "b" : "")
format(temp, 127, "%d. %-20s- %s^n", x - menuOffset + 1, temp, gSuperHeros[heroIndex][superpower] )
add(message, 1800, temp)
}
if ( gPlayerMenuChoices[id][0] > 8 ) {
// Can only Display 8 heroes at a time
add(message, 1800, "\w^n9. More Heroes")
keys |= (1<<8)
}
else {
add(message, 1800, "^n")
}
// Cancel
add(message, 1800, "\w^n0. Cancel")
keys |= (1<<9)
if ((count > 0 && enabled > 0) || inMenu[id]) {
if (is_user_bot(id)) {
selectedSuperPower(id, random_num(0, 8));
}
else {
format(debugt, 127, "Displaying Menu - offset: %d - count: %d - enabled: %d", menuOffset, count, enabled)
debugMessage(debugt, id, 8)
inMenu[id] = true
show_menu(id, keys, message)
}
}
return PLUGIN_HANDLED
}
Actually, I made a slight oversight. There's the case where the menu is shorter than 8 elements so it might not select anything. In that case, it may cause a runtime error. I'd like to fix it but I can't at the moment. Will see if I can do so later so remind me if I forget.