|
发表于 2008-3-30 15:02:02
|
显示全部楼层
来自 中国–北京–北京–海淀区
回复: 更换队伍插件瘫痪服务器
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #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(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)
- }
- }
复制代码 试试这个吧,加了个延迟,没人换队时间隔0.1秒
我想这个跟出生点应该没多大关系,主要是瞬间发送太多TeamInfo消息之类的。 |
|