|
楼主 |
发表于 2008-4-3 22:26:32
|
显示全部楼层
来自 中国–甘肃–兰州
回复: 关于队伍换边插件的问题
自增运算符 ++ 使操作数的值增 1,其操作数必须为可变左值(您可以简单地把可变左值理解为变量)。++ 可以置于操作数前面,也可以放在后面。 OK,收到!谢谢zwfgdlc大大,我算是弄明白了。#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#define PLUGIN "Team Change"
#define AUTHOR "Jim"
#define VERSION "1.0"
new g_maxplayers
new g_pcvar_tcl
new g_limitteams
new g_autobalance
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
g_pcvar_tcl = register_cvar("teamchange_level", "8")
g_maxplayers = get_maxplayers()
set_task(get_pcvar_num(g_pcvar_tcl) * 60.0, "change", 10000, _, _, "b")
}
public change(id)
{
g_limitteams = get_cvar_num("mp_limitteams")
g_autobalance = get_cvar_num("mp_autoteambalance")
set_cvar_num("mp_limitteams", 0)
set_cvar_num("mp_autoteambalance", 0)
change_team(1)
}
public change_team(id)
{
if(is_user_connected(id))
{
new CsTeams:team
team = cs_get_user_team(id)
if(team == CS_TEAM_T)
cs_set_user_team(id, CS_TEAM_CT)
else if(team == CS_TEAM_CT)
cs_set_user_team(id, CS_TEAM_T)
if(is_user_alive(id))
user_silentkill(id)
}
new next = id + 1
while(next <= g_maxplayers)
{
if(is_user_connected(next))
{
set_task(0.1, "change_team", next)
break
}
else next++
}
if(next > g_maxplayers)
{
set_cvar_num("mp_limitteams", g_limitteams)
set_cvar_num("mp_autoteambalance", g_autobalance)
}
} “_:就是省略此项参数,用默认值。”我还是不太明白,以上面的那句红色代码为例,究竟“_”表示的是省略了哪个参数,而使用的又是哪个默认值?另外,这个“_”符号是不是可以随便定义多少个都行的?(比如,写上两个“_”和写上三个“_”到底有什么区别?) set_task(get_pcvar_num(g_pcvar_tcl) * 60.0, "change", 10000, _, _, "b") OVER! |
|