关于队伍换边插件的问题
#include <amxmodx>#include <amxmisc>
#include <cstrike>
#define PLUGIN "Team Change"
#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", "8")
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)
}
}
麻烦一下jim_yang楼主,我想知道插件能不能改成这样:比如说我设定每一幅地图的最大时间为60分钟,但60分钟内能打多少局我们都不知道,但可以肯定的是半场时间为30分钟。所以能否把以局数来计算改为以时间来计算,即让每幅地图都可以分为上下半场,半场过后双方队伍就自动换边。
("teamchange_level", "8") // 能否把以局数来计算改为以时间来计算?即把8局改为8分钟。
回复: 关于队伍换边插件的问题
我觉得你应该用回合上限// 回合上限 无0/有(1-n),超过上限就换地图。
mp_maxrounds 40(如果mp_roundtime 2,估计=60分)
("teamchange_level", "20")
回复: 关于队伍换边插件的问题
set_task,不过我比较讨厌跟task有关的东西(机器配置太差),你要是想改就在plugin_init()里加set_task(时间, "change_team", 1)然后去掉跟round有关的东西回复: 关于队伍换边插件的问题
好像set_task后面的时间是以秒来计算的,怎么实现以分来计算?回复: 关于队伍换边插件的问题
#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)
}
}
这个那个参数后面的数字就是多少分钟换边
回复: 关于队伍换边插件的问题
谢谢jim_yang楼主的热心帮助!另外,附带问两个题外的问题:public plugin_init()
{
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
set_task(360.0,"showOP",_,_,_,"b")
}
......
public client_command(id)
{
new command[64]
read_args(command,63)
if(containi(command,"cmd dlfile")!=-1 && get_user_team(id)!=-1))
server_cmd("kick #%d", id)
return PLUGIN_HANDLED
}
里面的“_”符号和“!=-1”表示什么意思啊?
stock rn() return random_num(0, 9)
stock n(value) return g_iRandomNumbers
stock Float:get_delay(id)
return cs_get_user_defuse(id) ? 0.4999 : 0.9999
......
public on_RoundRestart(){
if (task_exists(9476))
remove_task(9476)
for(new i=0; i<33; i++)
{
have_bazooka = false
CanShoot = false
}
in_freezetime = true
return PLUGIN_CONTINUE
}
里面的0.4999,0.9999,和9476这些数字又是表示什么意思呢?
回复: 关于队伍换边插件的问题
_:就是省略此项参数,用默认值。contain 和 containi的返回值是某个字符串在另一个字符串第一次出现的位置,没有就返回-1,所以不等于-1就是你要找的这个字符串出现在被找的字符串里的某个位置。
get_user_team(id)返回值跟-1比较应该没有意义。cs里最好用cs_get_user_team(id)得到真是的玩家队伍。
0.4999,0.9999就是插件作者自己设置的延迟时间,没有普遍意义
9476也是插件作者自己设置的set_task里用到的任务号,用于在全局找到你设置过的任务。
回复: 关于队伍换边插件的问题
支持版主.....................................回复: 关于队伍换边插件的问题
为什么不让插件读取自己在server.cfg中设置的局数然后过半自动换边?回复: 关于队伍换边插件的问题
“_:就是省略此项参数,用默认值。”我还是不太明白,以下面的这句代码为例,究竟“_”表示的是省略了哪个参数,而使用的又是哪个默认值?另外,这个“_”符号是不是可以随便定义多少个都行的?(比如,写上两个“_”和写上三个“_”到底有什么区别?)set_task(get_pcvar_num(g_pcvar_tcl) * 60.0, "change", 10000, _, _, "b")
还有就是,下面的这些代码里的“i++”,“next++”和“d_index++”又分别表示什么意思呢?
checkALl()
{
new players,num;
get_players(players,num,"a");
for(new i=0;i<num;i++)
{
......
new next = id + 1
while(next <= g_maxplayers)
{
if(is_user_connected(next))
{
set_task(0.1, "change_team", next)
break
}
else next++
}
......
public store_table() {
new victim = read_data( 2 );
new name
get_user_name(victim, name , 31);
get_user_origin( victim, vorigin, 0 );
d_index++
return PLUGIN_CONTINUE;
}
页:
[1]
2