|
本帖最后由 css 于 2013-1-19 22:49 编辑
- /* AMX Mod X
- * Custom Team Select Menu
- * Code By baby
- * Credits:
- * VEN(Borrowed some code from his Auto Join on Connect :D)
- *
- */
- #include <amxmodx>
- #define PLUGIN_NAME "custom team select menu"
- #define PLUGIN_VERSION "0.10"
- #define PLUGIN_AUTHOR "baby"
- #define IMMUNITY_ACCESS_LEVEL ADMIN_IMMUNITY
- #define TEAM_SELECT_VGUI_MENU_ID 2
- new bool:g_unassigned[33]
- new bool:g_changed[33]
- new g_msgid[33]
- new p_allow_spectators
- new p_teambalance
- new p_limitteams
- new bool:g_allow_t
- new bool:g_allow_ct
- new bool:g_allow_spec
- new g_num_t, g_num_ct
- #define Keysmenu_1 (1<<0)|(1<<1)|(1<<4)|(1<<5)|(1<<9) // Keys: 12560
- #define Keysmenu_2 (1<<0)|(1<<1)|(1<<4)|(1<<5)|(1<<9) // Keys: 1250
- public plugin_init() {
- register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
-
- register_message(get_user_msgid("ShowMenu"), "message_show_menu")
- register_message(get_user_msgid("VGUIMenu"), "message_vgui_menu")
-
- register_menucmd(register_menuid("mainmenu"), Keysmenu_1, "_menu_chooseteam")
-
- register_logevent("hook_roundstart",2,"1=Round_Start")
-
- p_allow_spectators = get_cvar_pointer("allow_spectators")
- p_teambalance = get_cvar_pointer( "mp_autoteambalance" )
- p_limitteams = get_cvar_pointer( "mp_limitteams" )
- register_clcmd("chooseteam", "hook_chooseteam")
-
- }
- public hook_roundstart()
- {
- for (new i = 1; i < 33; i++)
- {
- g_changed[i] = false
- }
- }
- public client_connect(id)
- {
- g_changed[id] = false
- g_unassigned[id] = true
-
- }
- public client_disconnect(id)
- {
- g_changed[id] = false
- g_unassigned[id] = true
-
- }
- public hook_chooseteam(id)
- {
- menu_chooseteam(id)
- return PLUGIN_HANDLED
- }
- stock team_join(id, team[] = "5")
- {
- new menu_msgid = g_msgid[id]
- new msg_block = get_msg_block(menu_msgid)
- set_msg_block(menu_msgid, BLOCK_SET)
- engclient_cmd(id, "jointeam", team)
- set_msg_block(menu_msgid, msg_block)
- }
- public menu_choosemodel_t(id)
- {
- new menu = menu_create("\y夏威夷\r@\yT人物模型菜单^n^n\r>>默认T人物模型::", "_menu_choosemodel_t")
-
- menu_additem(menu, "\w凤凰战士", "1", 0);
- menu_additem(menu, "\w杀手精英", "2", 0);
- menu_additem(menu, "\w复仇勇者", "3", 0);
- menu_additem(menu, "\w圣战英雄", "4", 0);
-
- menu_setprop(menu, MPROP_EXIT, MEXIT_NEVER);
- menu_display(id, menu, 0);
- }
- public _menu_choosemodel_t(id, menu, item)
- {
- new data[6], iName[64];
- new access, callback;
- menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
-
- new menu_msgid = g_msgid[id]
- new msg_block = get_msg_block(menu_msgid)
- set_msg_block(menu_msgid, BLOCK_SET)
- engclient_cmd(id, "joinclass", data)
- set_msg_block(menu_msgid, msg_block)
-
- g_changed[id] = true
- g_unassigned[id] = false
- menu_destroy(menu);
-
-
- return PLUGIN_HANDLED;
- }
- public menu_choosemodel_ct(id)
- {
- new menu = menu_create("\y夏威夷\r@\yCT人物模型菜单^n^n\r>>默认CT人物模型::", "_menu_choosemodel_ct")
-
- menu_additem(menu, "\w美军陆站队", "1", 0);
- menu_additem(menu, "\w德国GSG-9", "2", 0);
- menu_additem(menu, "\w英国SAS", "3", 0);
- menu_additem(menu, "\w法国GIGN", "4", 0);
-
- menu_setprop(menu, MPROP_EXIT, MEXIT_NEVER);
- menu_display(id, menu, 0);
- }
- public _menu_choosemodel_ct(id, menu, item)
- {
-
- new data[6], iName[64];
- new access, callback;
- menu_item_getinfo(menu, item, access, data,5, iName, 63, callback);
-
- new menu_msgid = g_msgid[id]
- new msg_block = get_msg_block(menu_msgid)
- set_msg_block(menu_msgid, BLOCK_SET)
- engclient_cmd(id, "joinclass", data)
- set_msg_block(menu_msgid, msg_block)
-
- g_changed[id] = true
- g_unassigned[id] = false
- menu_destroy(menu);
-
- return PLUGIN_HANDLED;
- }
- public menu_chooseteam(id)
- {
- if (is_user_connected(id) && !is_user_bot(id) && !is_user_hltv(id))
- {
-
- check_teams(id)
-
- new text[512], len
-
- len = format(text, 511,"\y夏威夷\r@\y多功能菜单^n^n")
-
- if (g_changed[id])
- {
- len += format(text[len], 511 - len, "\w>>只能更换一次队伍::^n")
- len += format(text[len], 511 - len, "\d1. 恐怖分子^n")
- len += format(text[len], 511 - len, "\d2. 反恐精英^n")
- len += format(text[len], 511 - len, "\d5. 自动选择^n")
- len += format(text[len], 511 - len, "\d6. 观看一族^n^n")
- }
- else
- {
- len += format(text[len], 511 - len, "\r>>选择你要加入的队伍::^n")
- len += format(text[len], 511 - len, "\r1. \w恐怖分子^n")
- len += format(text[len], 511 - len, "\r2. \w反恐精英^n")
- len += format(text[len], 511 - len, "\r5. \w自动选择^n")
- }
-
- if ((g_allow_spec && !g_changed[id]))
- {
- len += format(text[len], 511 - len, "\r6. \w观看一族^n^n")
- len += format(text[len], 511 - len, "^n\r0. 取消^n")
- show_menu(id, Keysmenu_1, text, -1, "mainmenu")
- }
- else
- {
- len += format(text[len], 511 - len, "^n\r0. 取消^n")
- show_menu(id, Keysmenu_2, text, -1, "mainmenu")
- }
-
- }
- }
- public _menu_chooseteam(id, key)
- {
- check_teams(id)
- switch(key)
- {
- case 0:
- {
- if (g_allow_t && !g_changed[id])
- {
- team_join(id, "1")
-
- menu_choosemodel_t(id)
- }
- //set_force_team_join_task(id, g_msgid[id])
-
- }
- case 1:
- {
- if (g_allow_ct && !g_changed[id])
- {
- team_join(id, "2")
-
- menu_choosemodel_ct(id)
- }
- //Send them to the submenu
-
- }
- case 4:
- {
- if (!g_changed[id])
- {
- if (g_allow_t && g_allow_ct)
- {
- if (get_systime() % 2)
- {
- team_join(id, "1")
- menu_choosemodel_t(id)
- }
- else
- {
- team_join(id, "2")
- menu_choosemodel_ct(id)
- }
- }
- else if (g_allow_t)
- {
- team_join(id, "1")
- menu_choosemodel_t(id)
- //Send them to the submenu
- }
- else if (g_allow_ct)
- {
- team_join(id, "2")
- menu_choosemodel_ct(id)
- }
- }
- }
- case 5:
- {
- if (!g_changed[id])
- {
- force_team_join(id, g_msgid[id], "6", _)
- }
- //Send them to the submenu
-
- }
- case 9:
- {
- return PLUGIN_HANDLED;
- }
- }
-
- return PLUGIN_HANDLED;
- }
- public message_show_menu(msgid, dest, id) {
-
-
- static team_select[] = "#Team_Select"
- static menu_text_code[sizeof team_select]
- get_msg_arg_string(4, menu_text_code, sizeof menu_text_code - 1)
-
- //
- //server_print("Graphic menu");
-
- if (!equal(menu_text_code, team_select))
- return PLUGIN_CONTINUE
-
-
- g_msgid[id] = msgid
- menu_chooseteam(id)
-
-
- return PLUGIN_HANDLED
- }
- public message_vgui_menu(msgid, dest, id) {
- if (get_msg_arg_int(1) != TEAM_SELECT_VGUI_MENU_ID)
- return PLUGIN_CONTINUE
- //
- //server_print("VGUI menu");
-
- g_msgid[id] = msgid
- menu_chooseteam(id)
-
-
- return PLUGIN_HANDLED
- }
- public check_teams(id)
- {
- g_allow_t= true
- g_allow_ct = true
-
-
- new playerst[32], playersct[32]
- get_players(playerst, g_num_t, "eh", "TERRORIST")
- get_players(playersct, g_num_ct, "eh", "CT")
-
- if (get_pcvar_num(p_allow_spectators) && (g_num_t + g_num_ct > 1 || g_unassigned[id]))
- {
- g_allow_spec = true
- }
- else
- {
- g_allow_spec = false
- }
-
-
- if (get_user_team(id) == 2)//ct
- {
- g_num_ct--
- }
- else if (get_user_team(id) == 1)//t
- {
- g_num_t--
- }
-
- if (get_pcvar_num(p_teambalance))
- {
- new limit = get_pcvar_num(p_limitteams)
- if (g_num_t - g_num_ct >= limit)
- {
- g_allow_t = false
- }
- else if (g_num_ct - g_num_t >= limit)
- {
- g_allow_ct = false
- }
- }
- }
- stock force_team_join(id, menu_msgid, team[] = "5", class[] = "0") {
- static jointeam[] = "jointeam"
- if (class[0] == '0') {
- engclient_cmd(id, jointeam, team)
- g_changed[id] = true
- g_unassigned[id] = false
- return
- }
-
- static msg_block, joinclass[] = "joinclass"
- msg_block = get_msg_block(menu_msgid)
- set_msg_block(menu_msgid, BLOCK_SET)
- engclient_cmd(id, jointeam, team)
- engclient_cmd(id, joinclass, class)
- set_msg_block(menu_msgid, msg_block)
-
- g_changed[id] = true
- g_unassigned[id] = false
- }
复制代码 改成那种 可以让玩家自由选择自定义人物模型的
效果图如下
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注个册吧
×
|