[ROZWIĄZANE] Otwieranie menu przez CT
Najlepsza odpowiedź Zabijaka Gryps 22.01.2014 20:09
killer98
22.01.2014
Chcę aby to menu było otwierane przez CT i flagę ADMIN_KICK
/* Autor: grankee * Plugin pisany z myslą o tych, którzy giną przy przenoszeniu do drugiej drużyny przez admina ;) * W przypadku gdy admin przenosi żywego gracza do drugiej drużyny jest on zabijany. * Ten plugin sprawia, że przenoszony gracz pojawia sie na respie drużyny, do której został przeniesiony * (lub zostaje w miejscu w przypadku amx_teammenuspawn=0) * * Robiony na podstawie kodu plmenu.sma * */ #include <amxmodx> #include <amxmisc> #include <fun> /** skip autoloading since it's optional */ //#define AMXMODX_NOAUTOLOAD #include <cstrike> new g_menuPosition[33] new g_menuPlayers[33][32] new g_menuPlayersNum[33] new g_menuOption[33] #define MAX_CLCMDS 24 new g_coloredMenus new g_cstrike = 0 public plugin_natives() { set_module_filter("module_filter") set_native_filter("native_filter") } public plugin_init() { register_plugin("Teammenu nokill v4.0", "v4.0", "grankee") register_dictionary("common.txt") register_dictionary("admincmd.txt") register_dictionary("plmenu.txt") register_clcmd("amx_teammenu", "cmdTeamMenu") register_clcmd("teammenu", "cmdTeamMenu") register_cvar("amx_teammenuspawn", "1") register_menucmd(register_menuid("Team Menu"), 1023, "actionTeamMenu") g_coloredMenus = colored_menus() if (module_exists("cstrike")) g_cstrike = 1 } public module_filter(const module[]) { if (equali(module, "cstrike")) return PLUGIN_HANDLED return PLUGIN_CONTINUE } public native_filter(const name[], index, trap) { if (!trap) return PLUGIN_HANDLED return PLUGIN_CONTINUE } public actionTeamMenu(id, key) { //new teamname[32] switch (key) { case 7: { g_menuOption[id] = 1 - g_menuOption[id] displayTeamMenu(id, g_menuPosition[id]) } case 8: displayTeamMenu(id, ++g_menuPosition[id]) case 9: displayTeamMenu(id, --g_menuPosition[id]) default: { new player = g_menuPlayers[id][g_menuPosition[id] * 7 + key] new authid[32], authid2[32], name[32], name2[32] get_user_name(player, name2, 31) get_user_authid(id, authid, 31) get_user_authid(player, authid2, 31) get_user_name(id, name, 31) log_amx("Cmd: ^"%s<%d><%s><>^" transfer ^"%s<%d><%s><>^" (team ^"%s^")", name, get_user_userid(id), authid, name2, get_user_userid(player), authid2, g_menuOption[id] ? "TERRORIST" : "CT") if (get_cvar_num("amx_hideactivity")==1) { for (new a=1;a<=32;a++) { if (is_user_connected(a)) { if (get_user_flags(a) & ADMIN_RESERVATION) { client_print(a, print_chat, "%L", id, "ADMIN_TRANSF_2", name, name2, g_menuOption[id] ? "TERRORIST" : "CT") } } } } else { switch (get_cvar_num("amx_show_activity")) { case 2: client_print(0, print_chat, "%L", id, "ADMIN_TRANSF_2", name, name2, g_menuOption[id] ? "TERRORIST" : "CT") case 1: client_print(0, print_chat, "%L", id, "ADMIN_TRANSF_1", name2, g_menuOption[id] ? "TERRORIST" : "CT") } } if (g_cstrike) { if (is_user_alive(player)) { if(g_menuOption[id]==1) { cs_set_user_team(player, CS_TEAM_T) if (get_cvar_num("amx_teammenuspawn") > 0) spawn(player) } else { cs_set_user_team(player, CS_TEAM_CT) if (get_cvar_num("amx_teammenuspawn") > 0) spawn(player) } } else { if(g_menuOption[id]==1) { cs_set_user_team(player, CS_TEAM_T) cs_reset_user_model(player) } else { cs_set_user_team(player, CS_TEAM_CT) cs_reset_user_model(player) } } } displayTeamMenu(id, g_menuPosition[id]) } } return PLUGIN_HANDLED } displayTeamMenu(id, pos) { if (pos < 0) return get_players(g_menuPlayers[id], g_menuPlayersNum[id]) new menuBody[512] new b = 0 new i, iteam new name[32], team[4] new start = pos * 7 new ja[32] get_user_name (id, ja, 31) if (start >= g_menuPlayersNum[id]) start = pos = g_menuPosition[id] = 0 new len = format(menuBody, 511, g_coloredMenus ? "\y%L\R%d/%d^n\w^n" : "%L %d/%d^n^n", id, "TEAM_MENU", pos + 1, (g_menuPlayersNum[id] / 7 + ((g_menuPlayersNum[id] % 7) ? 1 : 0))) new end = start + 7 new keys = MENU_KEY_0|MENU_KEY_8 if (end > g_menuPlayersNum[id]) end = g_menuPlayersNum[id] for (new a = start; a < end; ++a) { i = g_menuPlayers[id][a] get_user_name(i, name, 31) if (g_cstrike) { iteam = _:cs_get_user_team(i) if (iteam == 1) { copy(team, 3, "TE") } else if (iteam == 2) { copy(team, 3, "CT") } else { get_user_team(i, team, 3) } } else { iteam = get_user_team(i, team, 3) } if ((iteam == (g_menuOption[id] ? 1 : 2)) || (access(i, ADMIN_IMMUNITY)&&(i!=id))) { ++b if (g_coloredMenus) len += format(menuBody[len], 511-len, "\d%d. %s\R%s^n\w", b, name, team) else len += format(menuBody[len], 511-len, "#. %s %s^n", name, team) } else { keys |= (1<<b) if (is_user_admin(i)) len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s \r*\y\R%s^n\w" : "%d. %s * %s^n", ++b, name, team) else len += format(menuBody[len], 511-len, g_coloredMenus ? "%d. %s\y\R%s^n\w" : "%d. %s %s^n", ++b, name, team) } } len += format(menuBody[len], 511-len, "^n8. %L^n", id, "TRANSF_TO", g_menuOption[id] ? "TERRORIST" : "CT") if (end != g_menuPlayersNum[id]) { format(menuBody[len], 511-len, "^n9. %L...^n0. %L", id, "MORE", id, pos ? "BACK" : "EXIT") keys |= MENU_KEY_9 } else format(menuBody[len], 511-len, "^n0. %L", id, pos ? "BACK" : "EXIT") show_menu(id, keys, menuBody, -1, "Team Menu") } public cmdTeamMenu(id, level, cid) { if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED g_menuOption[id] = 0 displayTeamMenu(id, g_menuPosition[id] = 0) return PLUGIN_HANDLED }
Użytkownik killer98 edytował ten post 22.01.2014 19:16
MAGNET
22.01.2014
Chodzi tobie o to, że menu może być otwierane tylko przez CT? Jeśli tak, to przy tworzeniu menu warunek:
if(cs_get_user_team(index) == CS_TEAM_CT).....
+ moduł cstrike
killer98
22.01.2014
Chodzi tobie o to, że menu może być otwierane tylko przez CT? Jeśli tak, to przy tworzeniu menu warunek:
if(cs_get_user_team(index) == CS_TEAM_CT).....+ moduł cstrike
No ale gdzie to dodać bo to nie jest normalne menu ...
Użytkownik killer98 edytował ten post 22.01.2014 19:21
Zabijaka Gryps
22.01.2014
warunek przy otwieraniu menu
if(cs_get_user_team(id) == CS_TEAM_CT && ADMIN_KICK && is_user_connected(id))
Przecież napisał że nie wie jak dodać to po kiego grzyba mu taki warunek dajesz (wcześniej już magnet podał podobny). + jaki jest sens sprawdzenia podłączenia osoby wywołującej na samym końcu?
Już wogóle pominę fakt że Twój warunek nawet się nie skompiluje, co to jest za warunek ADMIN_KICK?
@topic
Autorze, powiedz dokładnie co i jak ma być - komu ma się odpalać menu. Tylko osobie będącej w ct (każdej)? Czy może tylko osobie w ct mającej jakąś flagę? Czy może i osobie w ct (każdej, bez flagi) jak i osobie mającej flagę obojętnie w jakim jest teamie?
killer98
22.01.2014
Każdemu w ct, oraz adminowi z flagą kick, dobrze by było aby to było dla prowadzącego. Próbowałem dodać do menu Cypisa ale wywala error. Więc dla CT i Admin_KICK I fajnie by było żeby zamiast korzystać z plmenu.txt były napisy "Strażnik nick przeniósł nick do TT"
Użytkownik killer98 edytował ten post 22.01.2014 19:33
Zabijaka Gryps
22.01.2014
//edit
Łap w załączniku, bo w forumowych tagach [sma] coś się tabulacja rozwala.
Załączone pliki
killer98
22.01.2014
<220> undefinied symbol "B"
keys |= (1<< B)
@edit poprzedni się nie kompilował
@edit2 Wszystko miodzio. Mam prośbę, chcę żeby dla ct była inna komenda, bo amx_teammenu zna każdy.
@edit3 ten co dałeś w <code> się lokalnie nie kompilował, pewnie przez tabulację.
Użytkownik killer98 edytował ten post 22.01.2014 19:48
Zabijaka Gryps
22.01.2014
Coś może źle skopiowałeś, kliknij na plug.amxx (pod sma) to automatycznie się skompiluje (i wszystko działa, normalnie idzie).<220> undefinied symbol "B"
keys |= (1<< B)@edit poprzedni się nie kompilował
Zabijaka Gryps
22.01.2014
To teraz tak, podaj, na jaką chcesz komendę, oraz powiedz o co Ci chodziło z prowadzącym. Zamienić, aby nie każdy ct lub admin tylko prowadzący lub admin?@edit2 Wszystko miodzio. Mam prośbę, chcę żeby dla ct była inna komenda, bo amx_teammenu zna każdy.
Musiałeś coś za mało lub za dużo skopiować, przez niepoprawną tabulację wyskakują tylko warningi (ostrzeżenia), ale kompiluje się poprawnie.@edit3 ten co dałeś w się lokalnie nie kompilował, pewnie przez tabulację.
killer98
22.01.2014
Komenda:
teammenu_ct
Chciałem żeby tylko prowadzący (zwykły gracz) miał dostęp do menu. Oczywiście admin ma dostęp do zwykłego amx_teammenu
killer98
22.01.2014
Ok. dziala.A zrobisz tak, że wyświetla się "Straznik nick przeniosl nick do TT" ?
KillerBee 22.01.2014
public cmdTeamMenu(id, level, cid) { if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED g_menuOption[id] = 0 displayTeamMenu(id, g_menuPosition[id] = 0) return PLUGIN_HANDLED }
zamien na
public cmdTeamMenu(id) { if (get_user_flags(id) & ADMIN_KICK || get_user_team(id) == 2) { g_menuOption[id] = 0 displayTeamMenu(id, g_menuPosition[id] = 0) } return PLUGIN_HANDLED }
Użytkownik KillerBee edytował ten post 22.01.2014 20:54
Engi
22.01.2014
public cmdTeamMenu(id, level, cid) { if (!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED g_menuOption[id] = 0 displayTeamMenu(id, g_menuPosition[id] = 0) return PLUGIN_HANDLED }zamien na
public cmdTeamMenu(id) { if (get_user_flags(id) & ADMIN_KICK || get_user_team(id) == 2) { g_menuOption[id] = 0 displayTeamMenu(id, g_menuPosition[id] = 0) } return PLUGIN_HANDLED }
Dlaczego?
killer98
22.01.2014
get_user_team(id) == 2 -> CT
get_user_flags(id) & ADMIN_KICK -> ADMIN_KICK
Kolega nie zauważył, że Zabijaka mi pomógł + za chęci