请各位高手帮我看看菜单那里出问题了
本帖最后由 702033080 于 2009-9-11 00:52 编辑http://i3.6.cn/cvbnm/40/12/95/c43b0269d1874e4e99506b8847f65fe9.jpghttp://i3.6.cn/cvbnm/40/9b/1b/1761f1735aa6b620cd1468f28a81fba3.jpg
为何菜单显示不足8个..第一页才4个..第二页1个..到底哪里出问题了?
看了下修改的源码 ..貌似只加了这条东西: if(!equal(szUserName,"",10)) continue
一下是源码
#include <amxmodx>
#include <amxmisc>#define MENU_SIZE 512
#define MENU_PLAYERS 8new g_nMenuPosition
new g_nMenuPlayers
new g_votekick={0,0,...}public plugin_init()
{
register_plugin( "Vote Menu", "1.0", "skywalker" )
register_dictionary("common.txt")
register_dictionary("menufront.txt")
register_clcmd( "amx_votekickmenu", "ShowVKMenu", ADMIN_VOTE, "Shows Vote Kick Player Menu" )
register_clcmd( "amx_votebanmenu", "ShowVKMenu", ADMIN_VOTE, "Shows Vote Ban Player Menu" )
register_menucmd( register_menuid("Vote Kick"), 1023, "MenuAction" )
register_menucmd( register_menuid("Vote Ban"), 1023, "MenuAction" )
}public ShowVKMenu( id, lvl, cid )
{
if( cmd_access( id, lvl, cid, 1 ) )
{
new cmd
read_argv(0,cmd,31)
g_votekick = equali(cmd,"amx_votekickmenu")
ShowPlayerMenu( id, g_nMenuPosition = 0 )
} return PLUGIN_HANDLED
}public MenuAction( id, key )
{
switch( key )
{
case 8: ShowPlayerMenu( id, ++g_nMenuPosition )
case 9: ShowPlayerMenu( id, --g_nMenuPosition )
default:
{
new vID = g_nMenuPlayers * MENU_PLAYERS + key]
new userid = get_user_userid( vID )
client_cmd(id,g_votekick?"amx_votekick #%d":"amx_voteban #%d", userid )
}
}
return PLUGIN_HANDLED
}public ShowPlayerMenu( id, pos )
{
if( pos < 0 ) return new i, j
new szMenuBody
new nCurrKey = 0
new szUserName
new nStart = pos * MENU_PLAYERS
new nNum get_players( g_nMenuPlayers, nNum ) if( nStart >= nNum )
nStart = pos = g_nMenuPosition = 0
new nLen = format( szMenuBody, MENU_SIZE-1, g_votekick ? "\y%L\R%d/%d^n\w^n" : "\y%L\R%d/%d^n\w^n", id, (g_votekick?"VOTE_KICK":"VOTE_BAN"), pos+1, (nNum / MENU_PLAYERS + ((nNum % MENU_PLAYERS) ? 1 : 0 )) )
new nEnd = nStart + MENU_PLAYERS
new nKeys = MENU_KEY_0 if( nEnd > nNum )
nEnd = nNum for( i = nStart; i < nEnd; i++ )
{
j = g_nMenuPlayers
get_user_name( j, szUserName, 31 )
if(!equal(szUserName,"",10)) continue ;
if( get_user_flags(j) & ADMIN_IMMUNITY )
{
nCurrKey++
nLen += format( szMenuBody, (MENU_SIZE-1-nLen), "\d%d. %s (%L)^n\w", nCurrKey, szUserName, id, "IMMU" )
}else{
nKeys |= (1<<nCurrKey++)
if(is_user_admin(j))
nLen += format( szMenuBody, (MENU_SIZE-1-nLen), "%d. %s \r*\w^n", nCurrKey, szUserName )
else
nLen += format( szMenuBody, (MENU_SIZE-1-nLen), "%d. %s^n", nCurrKey, szUserName )
}
} if( nEnd != nNum )
{
format( szMenuBody, (MENU_SIZE-1-nLen), "^n9. %L...^n0. %L", id , "MORE", id, (pos ? "BACK" : "EXIT" ))
nKeys |= MENU_KEY_9
}
else
format( szMenuBody, (MENU_SIZE-1-nLen), "^n0. %L", id, (pos ? "BACK" : "EXIT" ))
show_menu( id, nKeys, szMenuBody, -1 , g_votekick? "Vote Kick":"Vote Ban") return
} 本帖最后由 702033080 于 2009-9-11 11:44 编辑
我自己估计大概是那条函数把菜单的sxe菜单玩家的名字给隐藏了..把no sxe i的玩家给显示在菜单上..难道要重新编写votemenu菜单?还是怎么样..我想不出办法 if(!equal(szUserName,"",10)) continue,这一条不要加,而是要修改前面的 get_players 调用,改成这样:get_players( g_nMenuPlayers, nNum, "f", "")不过这样判断相对不是那么准确,因为它是判断名字包含“”,而不是以“”开头。
如果想判断更准确,可以自己写个函数,如stock get_nosxei_players(players)
{
new num = 0;
new maxplayers = get_maxplayers();
new name
for(new i=1;i<=maxplayers;i++)
{
if(!is_user_connected(i)&&!is_user_connecting(i)) continue;
get_user_name(i, name, 31);
if(equal(name, "", 10))
players = i;
}
return num;
}然后把调用 get_players 的那个语句改成这样:
nNum = get_nosxei_players( g_nMenuPlayers ) 本帖最后由 702033080 于 2009-9-11 13:45 编辑
谢谢R版主的提示..现在菜单弄好了.衷心感谢R版主为各位op服务 会满意.................
页:
[1]