- 听众
- 收听
- 积分
- 21
- 主题
- 回帖
- 0
- 精华
注册时间2008-3-16
最后登录1970-1-1
该用户从未签到
|
楼主 |
发表于 2008-3-29 23:59:53
|
显示全部楼层
{
new pcount, i
client_print(0,print_chat,"上半场比赛结束,交换队伍")
pcount = get_playersnum()
for (i = 1; i <= pcount; i++)
{
switch (cs_get_user_team(i))
{
case CS_TEAM_T:
{
cs_set_user_team(i, CS_TEAM_CT)
}
case CS_TEAM_CT:
{
cs_set_user_team(i, CS_TEAM_T)
}
}
}
}
把cs_get_user_team(i)改成get_user_team(i)就会挂服,今天在点通看到代码:#include
#include
#include
#define PLUGIN "Test"
#define AUTHOR "Jim"
#define VERSION "1.0"
new g_maxplayers
new g_round
new g_pcvar_tcl
new g_limitteams
new g_autobalance
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_event("TextMsg", "round_restart", "a", "2=#Game_Commencing", "2=#Game_will_restart_in")
register_logevent("round_end", 2, "1=Round_End")
g_pcvar_tcl = register_cvar("teamchange_level", "3")
g_maxplayers = get_maxplayers()
}
public round_restart()
{
g_round = 0
}
public round_end()
{
g_round++
if(g_round % get_pcvar_num(g_pcvar_tcl))
{
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()
}
}
public change_team()
{
new CsTeams:team
for(new id = 1; id <= g_maxplayers; id++)
{
if(is_user_connected(id))
{
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)
}
}
set_cvar_num("mp_limitteams", g_limitteams)
set_cvar_num("mp_autoteambalance", g_autobalance)
}
多少局换场的,测试时人少一切正常,人数多就挂服,就是上面截图的,是不是处理数据太多CPU负核太大才这样?我有这样个想法,不知行不行得通,如果在10局换场,第九局时死一个玩家就换成对方,这一局不准按M换边,那样新开局的时候应该不会出现挂服了,这段代码一直没找到,希望老大能帮忙,十分谢谢。 |
|