get_user_frags怎么返回总是零?
我编了一个插件,能通过编译,但运行没效果,发现:for (new i_player = 0; i_player < i_numplayers; i_player++)
{
new i_deaths = get_user_deaths( i_player)
client_print(i_player, print_chat, "*******%d*******!.",i_deaths)
new i_frags = get_user_frags( i_player)
client_print(i_player, print_chat, "*******%d*******!.",i_frags)
是上面出问题了,我把上面的语句放到每局开始时运行,每次屏幕上打印的都是零,怎么看这语句都没错啊,希望达达能帮帮我,万分感谢! 你应该这样!new players, pnum
for (new i = 0; i < pnum; i++)
{
new id = players
new i_deaths = get_user_deaths(id)
new i_frags = get_user_frags(id)
client_print(id, print_chat, "this is a example, your kill %d, and death %d times", i_frags, i_deaths)
写法不对,应该是
for (new i_player = 1; i_player < =32; i_player++)
{
if (!is_user_connected(i)
continue;
new i_deaths = get_user_deaths( i_player)
client_print(i_player, print_chat, "*******%d*******!.",i_deaths)
new i_frags = get_user_frags( i_player)
client_print(i_player, print_chat, "*******%d*******!.",i_frags) 3# lnjkming
有什么不对?哪里不对了!
你能解释一下哪个函数用错了吗? 搞错,是这样,:dizzy:,呵呵
for (new i_player = 1; i_player < =32; i_player++)
{
if (!is_user_connected(i_player)
continue;
new i_deaths = get_user_deaths( i_player)
client_print(i_player, print_chat, "*******%d*******!.",i_deaths)
new i_frags = get_user_frags( i_player)
client_print(i_player, print_chat, "*******%d*******!.",i_frags) 谢谢楼上的两位,我把代码装上去运行一下,回来报告结果! 用了lnjkming 的代码,编译无法通过,用了kk阿朗 ,编译能过,但运行显%D的地方还是0,这就奇怪了,这语句没毛病啊 这样,刚上面的符号有误,:dizzy:
for (new i_player = 1; i_player <=32; i_player++)
{
if (!is_user_connected(i_player))
continue;
new i_deaths = get_user_deaths( i_player)
client_print(i_player, print_chat, "*******%d*******!.",i_deaths)
new i_frags = get_user_frags( i_player)
client_print(i_player, print_chat, "*******%d*******!.",i_frags)
} 遍历玩家使用循环从1开始,到maxplayers结束比较好,效果比较高。另外,最好不要在循环里定义变量。new i_deaths, i_frags
new maxplayers = get_maxplayers();
for (new i_player=1; i_player<=maxplayers; i_player++)
{
if(!is_user_connected(i_player)) continue;
i_deaths = get_user_deaths(i_player)
client_print(i_player, print_chat, "*******%d*******!.", i_deaths)
i_frags = get_user_frags( i_player)
client_print(i_player, print_chat, "*******%d*******!.", i_frags)
}甚至可以定义一个全称变量 g_maxplayers, 在plugin_init中赋值 g_maxplayers = get_maxplayers();
然后在循环中从1至g_maxplayers,这样效率更高一些。 本帖最后由 kk阿朗 于 2009-7-27 22:48 编辑
不好意思,少了个函数!
new players, pnum
get_players(players, pnum)
for (new i = 1; i < pnum; i++)
{
new id = players
new i_deaths = get_user_deaths(id)
new i_frags = get_user_frags(id)
client_print(id, print_chat, "this is a example, your kill %d, and death %d times", i_frags, i_deaths)
}还想顺便请教一下R版
上我这个跟你那究竟哪个会好一点?new i_deaths, i_frags
new maxplayers = get_maxplayers();
for (new i_player=1; i_player<=maxplayers; i_player++)
{
if(!is_user_connected(i_player)) continue;
i_deaths = get_user_deaths(i_player)
client_print(i_player, print_chat, "*******%d*******!.", i_deaths)
i_frags = get_user_frags( i_player)
client_print(i_player, print_chat, "*******%d*******!.", i_frags)
}
页:
[1]
2