Skip to content

Instantly share code, notes, and snippets.

@metasta
Last active March 1, 2017 19:55
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save metasta/2939342 to your computer and use it in GitHub Desktop.
Save metasta/2939342 to your computer and use it in GitHub Desktop.
A plugin for Counter-Strike 1.6 with AMXModX

Clan Match Basic

CS1.6 の自動クラン戦プラグイン (要 AMXModX).

クラン戦プラグインは他にもあるけど, HUD とか派手なのが多い. AMXX プラグインづくりの練習も兼ねてこのさい地味なのをひとつ自作してみた.

Features 特長

自動でクラン戦ができます.

  • ナイフラウンド (火器使用不可、勝利側に T/CT 選択投票メニュー表示)
  • lo3.cfg などのクラン戦用 cfg ファイルの自動読み込み
  • 自動チーム交替 (開始時、前後半交替時)
  • 延長戦
  • クラン戦全体を通してスコアボードのラウンド数表示を保持 など

CVAR 利用可能な変数と既定値

autoload-config

  • knifecfgfile knife.cfg ナイフ開始時
  • matchcfgfile lo3.cfg 試合開始時
  • overtimecfgfile ot.cfg 延長戦開始時
  • restcfgfile practice.cfg ナイフ前+前後半の交替時

rules

  • mp_halfrounds 15 前後半それぞれのラウンド数
  • mp_overtime 1 延長戦の有無. 0 で無, 非 0 で有
  • mp_halfrounds_overtime 3 延長戦での前後半それぞれのラウンド数

other variables

  • mp_preparetime 15 サーバに二人以上プレイヤーが入ってからナイフ開始までの秒数
  • mp_readytime 15 ナイフ後から前半開始までの秒数と, 前半終了から後半開始までの秒数

Where is '.amxx'? プラグインはどこ

ソースコードのみ配布しますので, お手数ですが各自コンパイルして御利用ください.

最近は AMX Mod X Web Compiler など便利なものがあるみたいです.

Changelog 変更履歴

v0.11 - 2012.06.16

  • プラグイン名変更, ドキュメント作成

v0.1 - 2011.11.21

  • 公開
#include <amxmodx>
#include <cstrike>
#include <amxmisc>
new const version[] = "0.11"
enum GameStatus {
REST,
KNIFE,
MATCH_F,
MATCH_L
}
new GameStatus:status = REST
new score[2] = {0,0}
new sidevote[2] = {0,0}
new overtime = 0
new maxrounds = 0
public plugin_init ()
{
register_plugin ("Clan Match Basic", version, "meta")
register_cvar ("knifecfgfile", "knife.cfg")
register_cvar ("matchcfgfile", "lo3.cfg")
register_cvar ("overtimecfgfile", "ot.cfg")
register_cvar ("restcfgfile", "practice.cfg")
register_cvar ("mp_halfrounds", "15", FCVAR_SERVER)
register_cvar ("mp_overtime", "1", FCVAR_SERVER)
register_cvar ("mp_halfrounds_overtime", "3", FCVAR_SERVER)
register_cvar ("mp_preparetime", "15", FCVAR_SERVER)
register_cvar ("mp_readytime", "15", FCVAR_SERVER)
register_event ("TextMsg", "event_gamecommencing", "a", "2&#Game_C")
register_event ("CurWeapon", "event_curweapon", "be", "1=1", "2!29")
register_event ("SendAudio", "event_terwin", "a", "2=%!MRAD_terwin")
register_event ("SendAudio", "event_ctwin", "a", "2=%!MRAD_ctwin")
register_event ("HLTV", "update_scoreboard", "a", "2=90")
register_event ("TeamScore", "update_scoreboard", "a")
register_menu ("Select your side", MENU_KEY_1|MENU_KEY_2, "count_sidevote")
}
public count_sidevote (i, key)
{
sidevote[key] += 1
new name[32], team[32]
get_user_name (i, name, 31)
team = (key) ? "Counter-Terrorist Force" : "Terrorist Force"
client_print (0, print_chat, "%s chose %s", name, team)
}
public update_scoreboard ()
{
new scoreid = get_user_msgid ("TeamScore")
message_begin (MSG_ALL, scoreid)
write_string ("TERRORIST")
write_short (score[0])
message_end ()
message_begin (MSG_ALL, scoreid)
write_string ("CT")
write_short (score[1])
message_end ()
}
exec_cfg (cfgfile[128])
{
new config[128]
get_cvar_string (cfgfile, config, 127)
if (file_exists (config)) server_cmd ("exec %s", config)
}
public restartround ()
{
server_cmd ("sv_restartround 1")
}
exec_lo3cfg (cfgfile[128])
{
new config[128]
get_cvar_string (cfgfile, config, 127)
if (file_exists (config)) server_cmd ("exec %s", config)
else {
restartround ()
set_task (1.1, "restartround")
set_task (2.2, "restartround")
}
}
public countdown_knife (n)
{
client_print (0, print_center, "The Knife Round will start in %d SECOND%s", n, (n > 1) ? "S" : "")
}
public countdown_sidevote (n)
{
client_print (0, print_center, "Team select will finish in %d SECOND%s", n, (n > 1) ? "S" : "")
}
public countdown_firsthalf (n)
{
client_print (0, print_center, "The First Half will start in %d SECOND%s", n, (n > 1) ? "S" : "")
}
public countdown_latterhalf (n)
{
client_print (0, print_center, "The Latter Half will start in %d SECOND%s", n, (n > 1) ? "S" : "")
}
public countdown_overtime (n)
{
client_print (0, print_center, "The Overtime will start in %d SECOND%s", n, (n > 1) ? "S" : "")
}
show_countdown (n, func[64])
{
for (new i = 1; i < n; i++) set_task (i - 0.0, func, n - i)
}
public change_side ()
{
new players[32], num
get_players (players, num)
for (new index = 0; index < num; index++){
new i = players[index]
new CsTeams:side = cs_get_user_team (i)
switch (side){
case CS_TEAM_T: cs_set_user_team (i, CS_TEAM_CT, CS_CT_SAS)
case CS_TEAM_CT: {
cs_set_user_team (i, CS_TEAM_T, CS_T_LEET)
cs_set_user_defuse (i, 0)
}
default: {}
}
}
new tmp = score[1]
score[1] = score[0]
score[0] = tmp
}
public event_curweapon (i)
{
if (status == KNIFE && read_data (2) != 6) engclient_cmd (i, "weapon_knife")
return PLUGIN_CONTINUE
}
round_win (CsTeams:win)
{
new b = (win == CS_TEAM_T) ? 0 : 1
if (status != REST) score[b] += 1
new r = get_cvar_num ("mp_halfrounds")
new o = get_cvar_num ("mp_halfrounds_overtime")
new h = (overtime) ? o : r
new s = r + overtime * o
switch (status){
case REST: return PLUGIN_CONTINUE
case KNIFE: end_knife (win)
case MATCH_F: if (score[b] + score[1-b] == 2 * s - h) end_firsthalf ()
case MATCH_L: {
if (score[b] == s + 1) end_latterhalf (win)
else if (score[b] + score[1-b] == 2 * s) end_latterhalf (CS_TEAM_UNASSIGNED)
}
default: {}
}
return PLUGIN_CONTINUE
}
public event_terwin ()
{
round_win (CS_TEAM_T)
return PLUGIN_CONTINUE
}
public event_ctwin ()
{
round_win (CS_TEAM_CT)
return PLUGIN_CONTINUE
}
public event_gamecommencing ()
{
status = REST
exec_cfg ("restcfgfile")
new t = get_cvar_num ("mp_preparetime")
set_task (t + 1.0, "start_knife")
show_countdown (t + 1, "countdown_knife")
return PLUGIN_CONTINUE
}
public start_knife ()
{
status = KNIFE
score[0] = score[1] = 0
exec_lo3cfg ("knifecfgfile")
}
public end_knife (CsTeams:win)
{
status = REST
exec_cfg ("restcfgfile")
start_sidevote (win)
}
public start_sidevote (CsTeams:win)
{
new menu[128]
format (menu, 127, "\ySelect your side^n^n\w1. Terrorist Force^n2. Counter-Terrorist Force")
for (new i = 1; i < 33; i++){
if (is_user_connected (i) && cs_get_user_team (i) == win)
show_menu (i, MENU_KEY_1|MENU_KEY_2, menu, 10)
}
set_task (11.0, "end_sidevote")
show_countdown (11, "countdown_sidevote")
}
public end_sidevote ()
{
new win = (score[0] > score[1]) ? 0 : 1
client_print (0, print_chat, "Result: Terrorist(%d) CT(%d)", sidevote[0], sidevote[1])
if (sidevote[win] < sidevote[1 - win] || (sidevote[0] == sidevote[1] && random (2))) {
change_side ()
restartround ()
}
score[0] = score[1] = 0
set_task (3.0, "ready_for_match")
}
public ready_for_match ()
{
new t = get_cvar_num ("mp_readytime")
set_task (t + 1.0, "start_firsthalf")
show_countdown (t + 1, overtime ? "countdown_overtime" : "countdown_firsthalf")
}
public start_firsthalf ()
{
status = MATCH_F
exec_lo3cfg (overtime ? "overtimecfgfile" : "matchcfgfile")
}
public end_firsthalf ()
{
status = REST
exec_cfg ("restcfgfile")
set_task (2.5, "change_side")
set_task (3.0, "intermission")
}
public intermission ()
{
new t = get_cvar_num ("mp_readytime")
set_task (t + 1.0, "start_latterhalf")
show_countdown (t + 1, "countdown_latterhalf")
}
public start_latterhalf ()
{
status = MATCH_L
exec_lo3cfg (overtime ? "overtimecfgfile" : "matchcfgfile")
}
public end_latterhalf (CsTeams:win)
{
status = REST
if (win == CS_TEAM_UNASSIGNED && get_cvar_num ("mp_overtime")){
overtime += 1
exec_cfg ("restcfgfile")
set_task (3.0, "ready_for_match")
} else {
set_task (5.0, "end_match")
}
}
public end_match ()
{
maxrounds = get_cvar_num ("mp_maxrounds")
set_cvar_num ("mp_maxrounds", 1)
}
public plugin_end ()
{
set_cvar_num ("mp_maxrounds", maxrounds)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment