Offline |
|
Csatlakozott:2013.01.21. 10:10 Hozzászólások:138 Megköszönt másnak: 20 alkalommal Megköszönték neki: 6 alkalommal
|
Tomos írta: Ebbe bele lehetne írni hogy akinek nincs ban joga ne [.] igy írja ki a nevét hanem [Kisadmin]-t írjon és még hogy az admin nevét zöldel írja ki és az üzenetet zölddel írja. #include <amxmodx> #include <amxmisc> #define PLUGIN "Admin Chat Colors" #define VERSION "2.0" #define AUTHOR "Arion" #define ACCESS_LEVEL ADMIN_IMMUNITY #define ADMIN_LISTEN ADMIN_LEVEL_C new message[192] new sayText new teamInfo new maxPlayers new g_AdminListen new strName[191] new alive[11] new const g_szTag[][] = { "", "[Tulaj]", "[Admin]", "[.]" } public plugin_init() { register_plugin(PLUGIN, VERSION, AUTHOR) g_AdminListen = register_cvar("amx_listen", "1") // Set whether admins see or not all messages(Alive, dead and team-only) sayText = get_user_msgid("SayText") teamInfo = get_user_msgid("TeamInfo") maxPlayers = get_maxplayers() register_clcmd("say", "hook_say") register_clcmd("say_team", "hook_teamsay") } public hook_say(id) { read_args(message, 191) remove_quotes(message) // Gungame commands and empty messages if(message[0] == '@' || message[0] == '/' || message[0] == '!' || equal(message, "")) // Ignores Admin Hud Messages, Admin Slash commands, return PLUGIN_CONTINUE new name[32] get_user_name(id, name, 31) new admin = 0, iFlags = get_user_flags(id) if(iFlags & ADMIN_IMMUNITY) admin = 1 else if(iFlags & ADMIN_BAN) admin = 2 else if(iFlags & ADMIN_RESERVATION) admin = 3 new isAlive if(is_user_alive(id)) { isAlive = 1 alive = "^x01" } else { isAlive = 0 alive = "^x01*DEAD* " } static color[10] if(admin) { get_user_team(id, color, 9) format(strName, 191, "^x04%s %s^x03%s", g_szTag[admin], alive, name) format(message, 191, "%s ^x01:^x04 %s", strName, message) } else // Player is not admin. Team-color name : Yellow message { get_user_team(id, color, 9) format(strName, 191, "%s^x03%s", alive, name) format(message, 191, "^%s^x01 : %s", strName, message) } sendMessage(color, isAlive) // Sends the colored message return PLUGIN_HANDLED } public hook_teamsay(id) { new playerTeam = get_user_team(id) new playerTeamName[19] switch(playerTeam) // Team names which appear on team-only messages { case 1: copy(playerTeamName, 11, "Terrorists") case 2: copy(playerTeamName, 18, "Counter-Terrorists") default: copy(playerTeamName, 9, "Spectator") } read_args(message, 191) remove_quotes(message) // Gungame commands and empty messages if(message[0] == '@' || message[0] == '/' || message[0] == '!' || equal(message, "")) // Ignores Admin Hud Messages, Admin Slash commands, return PLUGIN_CONTINUE new name[32] get_user_name(id, name, 31) new admin = 0, iFlags = get_user_flags(id) if(iFlags & ADMIN_IMMUNITY) admin = 1 else if(iFlags & ADMIN_KICK) admin = 2 else if(iFlags & ADMIN_RESERVATION) admin = 3 new isAlive if(is_user_alive(id)) { isAlive = 1 alive = "^x01" } else { isAlive = 0 alive = "^x01*DEAD* " } static color[10] if(admin) { get_user_team(id, color, 9) format(strName, 191, "%s(%s)^x04%s ^x03%s", alive, playerTeamName, g_szTag[admin], name) format(message, 191, "%s ^x01: ^x04%s", strName, message) } else // Player is not admin. Team-color name : Yellow message { get_user_team(id, color, 9) format(strName, 191, "%s(%s) ^x03%s", alive, playerTeamName, name) format(message, 191, "%s ^x01: %s", strName, message) } sendTeamMessage(color, isAlive, playerTeam) // Sends the colored message return PLUGIN_HANDLED } public sendMessage(color[], alive) { new teamName[10] for(new player = 1; player < maxPlayers; player++) { if(!is_user_connected(player)) continue if(alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN) { get_user_team(player, teamName, 9) // Stores user's team name to change back after sending the message changeTeamInfo(player, color) // Changes user's team according to color choosen writeMessage(player, message) // Writes the message on player's chat changeTeamInfo(player, teamName) // Changes user's team back to original } } } public sendTeamMessage(color[], alive, playerTeam) { new teamName[10] for(new player = 1; player < maxPlayers; player++) { if(!is_user_connected(player)) continue if(get_user_team(player) == playerTeam || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN) { if(alive && is_user_alive(player) || !alive && !is_user_alive(player) || get_pcvar_num(g_AdminListen) && get_user_flags(player) & ADMIN_LISTEN) { get_user_team(player, teamName, 9) // Stores user's team name to change back after sending the message changeTeamInfo(player, color) // Changes user's team according to color choosen writeMessage(player, message) // Writes the message on player's chat changeTeamInfo(player, teamName) // Changes user's team back to original } } } } public changeTeamInfo(player, team[]) { message_begin(MSG_ONE, teamInfo, _, player) // Tells to to modify teamInfo(Which is responsable for which time player is) write_byte(player) // Write byte needed write_string(team) // Changes player's team message_end() // Also Needed } public writeMessage(player, message[]) { message_begin(MSG_ONE, sayText, {0, 0, 0}, player) // Tells to modify sayText(Which is responsable for writing colored messages) write_byte(player) // Write byte needed write_string(message) // Effectively write the message, finally, afterall message_end() // Needed as always }
Helló! erre van egy egyszerűbb plugin: new g_bad_prefix, g_listen, g_listen_flag, g_custom_current, g_custom_current_flag, g_custom_others, g_custom_others_flag, g_say_characters, g_prefix_characters; new pre_ips_count = 0, pre_names_count = 0, pre_flags_count = 0, bad_prefix_count = 0, i, temp_cvar[2]; new configs_dir[64], file[128], text[128], prefix[32], type[2], acc_type[32], length, line = 0, error[256]; new g_saytxt, g_maxplayers, g_nvault, g_team; new g_typed[192], g_message[192], g_name[32], typed_prefix[33]; new pre_ips_collect[MAX_PREFIXES][33], ips_collect[MAX_PREFIXES][32], pre_names_collect[MAX_PREFIXES][33], names_collect[MAX_PREFIXES][33], pre_flags_collect[MAX_PREFIXES][33], flags_collect[MAX_PREFIXES][2], bad_prefixes_collect[MAX_BAD_PREFIXES][33], client_prefix[33][33]; new const forbidden_say_symbols[] = { "/", "!", "%", "$" } new const forbidden_prefixes_symbols[] = { "/", "\", "%", "$", ".", ":", "?", "!", "@", "#", "%" } new const separator[] = "************************************************" new const in_prefix[] = "[AdminPrefixes]" public plugin_init() { register_plugin("Admin Prefixes", "2.2", "m0skVi4a ;]") g_bad_prefix = register_cvar("ap_bad_prefixes", "1") g_listen = register_cvar("ap_listen", "1") g_listen_flag = register_cvar("ap_listen_flag", "a") g_custom_current = register_cvar("ap_custom_current", "1") g_custom_current_flag = register_cvar("ap_custom_current_flag", "b") g_custom_others = register_cvar("ap_custom_others", "1") g_custom_others_flag = register_cvar("ap_custom_others_flag", "c") g_say_characters = register_cvar("ap_say_characters", "1") g_prefix_characters = register_cvar("ap_prefix_characters", "1") g_saytxt = get_user_msgid ("SayText") g_maxplayers = get_maxplayers() g_nvault = nvault_open("CustomAdminPrefixes") register_concmd("ap_reload_prefixes", "LoadPrefixes") register_concmd("ap_reload_badprefixes", "LoadBadPrefixes") register_concmd("ap_put", "SetPrefix") register_concmd("ap_put_player", "SetPlayerPrefix") register_clcmd("say", "HookSay") register_clcmd("say_team", "HookSayTeam") register_dictionary("admin_prefixes.txt") get_configsdir(configs_dir, charsmax(configs_dir)) LoadPrefixes(0) LoadBadPrefixes(0) } public LoadPrefixes(id) { if(!(get_user_flags(id) & FLAG_LOAD)) { console_print(id, "%L", LANG_SERVER, "PREFIX_PERMISSION", in_prefix) return PLUGIN_HANDLED } line = 0, pre_flags_count = 0, pre_ips_count = 0, pre_names_count = 0; formatex(file, charsmax(file), "%s/ap_prefixes.ini", configs_dir) if(!file_exists(file)) { formatex(error, charsmax(error), "%L", LANG_SERVER, "PREFIX_NOT_FOUND", in_prefix, file) set_fail_state(error) } server_print(separator) while(read_file(file, line++ , text, charsmax(text), length) && pre_flags_count <= MAX_PREFIXES) { if(!text[0] || text[0] == '^n' || text[0] == ';') continue parse(text, type, charsmax(type), prefix, charsmax(prefix), acc_type, charsmax(acc_type)) trim(prefix) if(!type[0] || !prefix[0] || !acc_type[0]) continue replace_all(prefix, charsmax(prefix), "!g", "^x04") replace_all(prefix, charsmax(prefix), "!t", "^x03") replace_all(prefix, charsmax(prefix), "!n", "^x01") switch(type[0]) { case 'i': { pre_ips_count++ pre_ips_collect[pre_ips_count] = prefix ips_collect[pre_ips_count] = acc_type server_print("%L", LANG_SERVER, "PREFIX_LOAD_IP", in_prefix, prefix, acc_type) } case 'n': { pre_names_count++ pre_names_collect[pre_names_count] = prefix names_collect[pre_names_count] = acc_type server_print("%L", LANG_SERVER, "PREFIX_LOAD_NAME", in_prefix, prefix, acc_type) } case 'f': { pre_flags_count++ pre_flags_collect[pre_flags_count] = prefix flags_collect[pre_flags_count][0] = acc_type[0] server_print("%L", LANG_SERVER, "PREFIX_LOAD_FLAG", in_prefix, prefix, acc_type[0]) } default: { continue } } } if(pre_flags_count <= 0 && pre_ips_count <= 0 && pre_names_count <= 0) { server_print("%L", LANG_SERVER, "PREFIX_NO", in_prefix) } get_user_name(id, g_name, charsmax(g_name)) server_print("%L", LANG_SERVER, "PREFIX_LOADED_BY", in_prefix, g_name) console_print(id, "%L", LANG_SERVER, "PREFIX_LOADED", in_prefix) server_print(separator) for(new i = 1; i <= g_maxplayers; i++) { client_prefix[id] = "" CheckNvaultPrefix(i) } return PLUGIN_HANDLED } public LoadBadPrefixes(id) { if(!get_pcvar_num(g_bad_prefix)) { console_print(id, "%L", LANG_SERVER, "BADP_OFF", in_prefix) return PLUGIN_HANDLED } if(!(get_user_flags(id) & FLAG_LOAD)) { console_print(id, "%L", LANG_SERVER, "BADP_PERMISSION", in_prefix) return PLUGIN_HANDLED } line = 0, bad_prefix_count = 0; formatex(file, charsmax(file), "%s/ap_bad_prefixes.ini", configs_dir) if(!file_exists(file)) { console_print(id, "%L", LANG_SERVER, "BADP_NOT_FOUND", in_prefix, file) return PLUGIN_HANDLED } server_print(separator) while(read_file(file, line++ , text, charsmax(text), length) && bad_prefix_count <= MAX_BAD_PREFIXES) { if(!text[0] || text[0] == '^n' || text[0] == ';') continue parse(text, prefix, charsmax(prefix)) if(!prefix[0]) continue bad_prefix_count++ bad_prefixes_collect[bad_prefix_count] = prefix server_print("%L", LANG_SERVER, "BADP_LOAD", in_prefix, prefix) } if(bad_prefix_count <= 0) { server_print("%L", LANG_SERVER, "BADP_LOAD", in_prefix) } get_user_name(id, g_name, charsmax(g_name)) server_print("%L", LANG_SERVER, "BADP_LOADED_BY", in_prefix, g_name) console_print(id, "%L", LANG_SERVER, "BADP_LOADED", in_prefix) server_print(separator) for(new i = 1; i <= g_maxplayers; i++) { CheckNvaultPrefix(i) } return PLUGIN_HANDLED } public client_putinserver(id) { client_prefix[id] = "" CheckNvaultPrefix(id) } public HookSay(id) { read_args(g_typed, charsmax(g_typed)) remove_quotes(g_typed) if(equal(g_typed, "") || !is_user_connected(id)) return PLUGIN_HANDLED_MAIN if((client_prefix[id][0] && get_pcvar_num(g_say_characters) == 1) || (!client_prefix[id][0] && get_pcvar_num(g_say_characters) == 2) || get_pcvar_num(g_say_characters) == 3) { if(check_say_characters(g_typed)) return PLUGIN_HANDLED_MAIN } get_user_name(id, g_name, charsmax(g_name)) g_team = get_user_team(id) new const team_info[2][][] = { {"*SPEC* ", "*DEAD* ", "*DEAD* ", "*SPEC* "}, {"", "", "", ""} } if(client_prefix[id][0]) { formatex(g_message, charsmax(g_message), "^1%s^4%s^3 %s :^4 %s", team_info[is_user_alive(id)][g_team], client_prefix[id], g_name, g_typed) } else { formatex(g_message, charsmax(g_message), "^1%s^3%s :^1 %s", team_info[is_user_alive(id)][g_team], g_name, g_typed) } get_pcvar_string(g_listen_flag, temp_cvar, charsmax(temp_cvar)) for(new i = 1; i <= g_maxplayers; i++) { if(!is_user_connected(i)) continue if(is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i) || get_pcvar_num(g_listen) && get_user_flags(i) & read_flags(temp_cvar)) { send_message(g_message, id, i) } } return PLUGIN_HANDLED_MAIN } public HookSayTeam(id) { read_args(g_typed, charsmax(g_typed)) remove_quotes(g_typed) if(equal(g_typed, "") || !is_user_connected(id)) return PLUGIN_HANDLED_MAIN if((client_prefix[id][0] && get_pcvar_num(g_say_characters) == 1) || (!client_prefix[id][0] && get_pcvar_num(g_say_characters) == 2) || get_pcvar_num(g_say_characters) == 3) { if(check_say_characters(g_typed)) return PLUGIN_HANDLED_MAIN } get_user_name(id, g_name, charsmax(g_name)) g_team = get_user_team(id) new const team_info[2][][] = { {"(Spectator) ", "*DEAD*(Terrorist) ", "*DEAD*(Counter-Terrorist) ", "(Spectator) "}, {"(Spectator) ", "(Terrorist) ", "(Counter-Terrorist) ", "(Spectator) "} } if(client_prefix[id][0]) { formatex(g_message, charsmax(g_message), "^1%s^4%s^3 %s :^4 %s", team_info[is_user_alive(id)][g_team], client_prefix[id], g_name, g_typed) } else { formatex(g_message, charsmax(g_message), "^1%s^3%s :^1 %s", team_info[is_user_alive(id)][g_team], g_name, g_typed) } get_pcvar_string(g_listen_flag, temp_cvar, charsmax(temp_cvar)) for(new i = 1; i <= g_maxplayers; i++) { if(!is_user_connected(i)) continue if(get_user_team(id) == get_user_team(i) || get_pcvar_num(g_listen) && get_user_flags(i) & read_flags(temp_cvar)) { if(is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i) || get_pcvar_num(g_listen) && get_user_flags(i) & read_flags(temp_cvar)) { send_message(g_message, id, i) } } } return PLUGIN_HANDLED_MAIN } public SetPrefix(id) { if(!get_pcvar_num(g_custom_current) || !get_pcvar_string(g_custom_current_flag, temp_cvar, charsmax(temp_cvar))) { console_print(id, "%L", LANG_SERVER, "CUSTOM_OFF", in_prefix) return PLUGIN_HANDLED } if(!(get_user_flags(id) & read_flags(temp_cvar))) { console_print(id, "%L", LANG_SERVER, "CUSTOM_PERMISSION", in_prefix) return PLUGIN_HANDLED } read_args(typed_prefix, charsmax(typed_prefix)) remove_quotes(typed_prefix) trim(typed_prefix) if(get_pcvar_num(g_bad_prefix) && is_bad_prefix(typed_prefix)) { console_print(id, "%L", LANG_SERVER, "CUSTOM_FORBIDDEN", in_prefix, typed_prefix) return PLUGIN_HANDLED } if(get_pcvar_num(g_prefix_characters) && check_prefix_characters(typed_prefix)) { console_print(id, "%L", LANG_SERVER, "CUSTOM_SYMBOL", in_prefix, typed_prefix, forbidden_prefixes_symbols[i]) return PLUGIN_HANDLED } get_user_name(id, g_name, charsmax(g_name)) if(equal(typed_prefix, "")) { nvault_remove(g_nvault, g_name) console_print(id, "%L", LANG_SERVER, "CUSTOM_REMOVE", in_prefix) server_print("%L", LANG_SERVER, "CUSTOM_REMOVE_INFO", in_prefix, g_name) PutPrefix(id) return PLUGIN_HANDLED } nvault_set(g_nvault, g_name, typed_prefix) client_prefix[id] = typed_prefix console_print(id, "%L", LANG_SERVER, "CUSTOM_CHANGE", in_prefix, typed_prefix) server_print("%L", LANG_SERVER, "CUSTOM_CHANGE_INFO", in_prefix, g_name, typed_prefix) return PLUGIN_HANDLED } public SetPlayerPrefix(id) { if(!get_pcvar_num(g_custom_current) || !get_pcvar_string(g_custom_current_flag, temp_cvar, charsmax(temp_cvar)) || !get_pcvar_num(g_custom_others) || !get_pcvar_string(g_custom_others_flag, temp_cvar, charsmax(temp_cvar))) { console_print(id, "%L", LANG_SERVER, "CO_OFF", in_prefix) return PLUGIN_HANDLED } if(!(get_user_flags(id) & read_flags(temp_cvar))) { console_print(id, "%L", LANG_SERVER, "CO_FORBIDDEN", in_prefix) return PLUGIN_HANDLED } new name_tag[64], typed_name[32]; read_args(name_tag, charsmax(name_tag)) remove_quotes(name_tag) parse(name_tag, typed_name, charsmax(typed_name), typed_prefix, charsmax(typed_prefix)) trim(typed_prefix) if(get_pcvar_num(g_bad_prefix) && is_bad_prefix(typed_prefix)) { console_print(id, "%L", LANG_SERVER, "CUSTOM_FORBIDDEN", in_prefix, typed_prefix) return PLUGIN_HANDLED } if(get_pcvar_num(g_prefix_characters) && check_prefix_characters(typed_prefix)) { console_print(id, "%L", LANG_SERVER, "CUSTOM_SYMBOL", in_prefix, typed_prefix, forbidden_prefixes_symbols[i]) return PLUGIN_HANDLED } get_user_name(id, g_name, charsmax(g_name)) new target = cmd_target(id, typed_name, 1) if(!target) return PLUGIN_HANDLED if(equal(typed_prefix, "")) { nvault_remove(g_nvault, typed_name) console_print(id, "%L", LANG_SERVER, "CO_REMOVE", in_prefix, typed_name) server_print("%L", LANG_SERVER, "CO_REMOVE_INFO", in_prefix, g_name, typed_name) PutPrefix(target) return PLUGIN_HANDLED } nvault_set(g_nvault, typed_name, typed_prefix) client_prefix[id] = typed_prefix console_print(id, "%L", LANG_SERVER, "CO_CHANGE", in_prefix, typed_name, typed_prefix) server_print("%L", LANG_SERVER, "CO_CHANGE_INFO", in_prefix, g_name, typed_name, typed_prefix) return PLUGIN_HANDLED } public client_infochanged(id) { if(!is_user_connected(id)) return PLUGIN_CONTINUE new g_old_name[32]; get_user_info(id, "name", g_name, charsmax(g_name)) get_user_name(id, g_old_name, charsmax(g_old_name)) if(!equal(g_name, g_old_name)) { client_prefix[id] = "" set_task(0.5, "CheckNvaultPrefix", id) return PLUGIN_HANDLED } return PLUGIN_CONTINUE } public CheckNvaultPrefix(const id) { new nvault_prefix[33]; get_user_name(id, g_name, charsmax(g_name)) get_pcvar_string(g_custom_current_flag, temp_cvar, charsmax(temp_cvar)) new data = nvault_get(g_nvault, g_name, nvault_prefix, charsmax(nvault_prefix)) if(data && get_pcvar_num(g_custom_current) && get_user_flags(id) & read_flags(temp_cvar)) { if((get_pcvar_num(g_bad_prefix) && is_bad_prefix(nvault_prefix)) || (get_pcvar_num(g_prefix_characters) && check_prefix_characters(nvault_prefix))) { PutPrefix(id) return PLUGIN_HANDLED } client_prefix[id] = nvault_prefix return PLUGIN_HANDLED } else { PutPrefix(id) return PLUGIN_HANDLED } return PLUGIN_HANDLED } stock PutPrefix(const id) { new temp_ip[16]; get_user_ip(id, temp_ip, charsmax(temp_ip), 1) for(new i = 0; i <= pre_ips_count; i++) { if(equal(temp_ip, ips_collect[i])) { client_prefix[id] = pre_ips_collect[i] return PLUGIN_HANDLED } } get_user_name(id, g_name, charsmax(g_name)) for(new i = 0; i <= pre_names_count; i++) { if(equal(g_name, names_collect[i])) { client_prefix[id] = pre_names_collect[i] return PLUGIN_HANDLED } } for(new i = 0; i <= pre_flags_count; i++) { if(get_user_flags(id) & read_flags(flags_collect[i])) { client_prefix[id] = pre_flags_collect[i] return PLUGIN_HANDLED } } return PLUGIN_HANDLED } stock send_message(const message[], const id, const i) { message_begin(MSG_ONE, g_saytxt, {0, 0, 0}, i) write_byte(id) write_string(message) message_end() } bool:check_say_characters(const check_message[]) { for(new i = 0; i < charsmax(forbidden_say_symbols); i++) { if(check_message[0] == forbidden_say_symbols[i]) { return true } } return false } bool:check_prefix_characters(const check_prefix[]) { for(i = 0; i < charsmax(forbidden_prefixes_symbols); i++) { if(containi(check_prefix, forbidden_prefixes_symbols[i]) != -1) { return true } } return false } bool:is_bad_prefix(const check_prefix[]) { for(new i = 0; i <= bad_prefix_count; i++) { if(equali(check_prefix, bad_prefixes_collect[i])) { return true } } return false }
Leírás: Előtag adás(ap_prefixes.ini-be kell írni): "i" "[IP ELOTAG]" "192.168.1.100" - IP-re adás "n" "[NEV ELOTAG]" "Nandee" - Névre adás "f" "[JOG ELOTAG]" "n" - példa: n jogra adás általánosan: <mód i=ip n=név f=jog> <előtag> <ip/név/jog> A WHITE CHAT -et NE tedd be, mert akkor nem tudsz majd zölden írni!Telepítés a szokásos módon, ZIP-ben könyvtárok szerint van rendezve. A ZIP-et itt tudod letölteni: Admin Prefixes!__________ Megköszönni nem szégyen, ezért tedd azt! _________________ See you next time! :) Ha hasznosnak találtad a hozzászólásomat, köszönd meg a lenyomásával..!! :)
|
|