
Стаж: 11 лет
Сообщений: 457
Благодарностей: 115
Полезность: 456
|
Цитата(romana @ 25.12.2015, 0:23)  Помогите пожалуйста отсюда убрать префикс *Мертвый*! Код:
#include <amxmodx> #define TAGS //#define GREEN_MSG // #define AES #define DEF_ENG #define GL_ADMIN ADMIN_RCON #define ADMIN ADMIN_BAN #define VIP ADMIN_LEVEL_H // #define LOG_MESSAGE // #define FIX_CRASH
#if defined AES #include <aes_main> #endif #define get_bit(%1,%2) (%1 & (1 << (%2 & 31))) #define set_bit(%1,%2) %1 |= (1 << (%2 & 31)) #define clr_bit(%1,%2) %1 &= ~(1 << (%2 & 31))
new iPlayerRus[33] new iIgnorePlayer
new const eng[][] = { "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","}",":",'"',"<",">","~","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","[","]",";","'",",",".","`","?","/","@","$","^^","&" }; new const rus[][] = { "Ф","И","С","В","У","А","П","Р","Ш","О","Л","Д","Ь","Т","Щ","З","Й","К","Ы","Е","Г","М","Ц","Ч","Н","Я","Х","Ъ","ж","Э","Б","Ю","Ё","ф","и","с","в","у","а","п","р","ш","о","л","д","ь","т","щ","з","й","к","ы","е","г","м","ц","ч","н","я","х","ъ","ж","э","б","ю","ё",",",".","'",";", ":","?" };
public plugin_init() { #define VERSION "2.5.7b" register_plugin("Lite Translit", VERSION, "neygomon") register_cvar("lt_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY) register_clcmd("say /rus", "LangRus") register_clcmd("say /eng", "LangEng") register_clcmd("say", "Say_Handler") register_clcmd("say_team", "SayTeam_Handler") }
public client_putinserver(id) { if(is_user_hltv(id) || is_user_bot(id)) { set_bit(iIgnorePlayer, id) return } #if defined DEF_RUS iPlayerRus[id] = true #endif } public client_disconnect(id) clr_bit(iIgnorePlayer, id)
public LangRus(id) { if(!iPlayerRus[id]) { iPlayerRus[id] = true client_print(id, print_center, "Русский чат активирован!") } else client_print(id, print_center, "Русский чат УЖЕ активирован!") } public LangEng(id) { if(iPlayerRus[id]) { iPlayerRus[id] = false client_print(id, print_center, "Английский чат активирован!") } else client_print(id, print_center, "Английский чат УЖЕ активирован!") }
public Say_Handler(id) return FormatMsg(id, false)
public SayTeam_Handler(id) return FormatMsg(id, true)
public FormatMsg(id, bool:is_say_team) { if(get_bit(iIgnorePlayer, id)) return PLUGIN_CONTINUE static szMessage[128] read_args(szMessage, charsmax(szMessage)) remove_quotes(szMessage) if(!szMessage[0] || szMessage[0] == '/') return PLUGIN_HANDLED_MAIN
if(iPlayerRus[id]) { for(new i; i < sizeof eng; i++) replace_all2(szMessage, charsmax(szMessage), eng[i], rus[i]) } static iLen, szFormatTags[96], iAlive, iTeam; iAlive = is_user_alive(id), iTeam = get_user_team(id) if(is_say_team) { switch(iTeam) { case 1: iLen = formatex(szFormatTags, charsmax(szFormatTags), "^1%s(Террорист) ", iAlive ? "" : "*Мертвый* ") case 2: iLen = formatex(szFormatTags, charsmax(szFormatTags), "^1%s(Мент) ", iAlive ? "" : "*Мертвый* ") case 3: iLen = formatex(szFormatTags, charsmax(szFormatTags), "^1(Наблюдатель) ") } } else { if(iTeam == 3) iLen = formatex(szFormatTags, charsmax(szFormatTags), "^1(Наблюдатель) ") else iLen = formatex(szFormatTags, charsmax(szFormatTags), "%s", iAlive ? "^1" : "^1*Мертвый* ") } #if defined AES static AESLvl[33][64], aStats[AES_ST_END] aes_get_player_stats(id, aStats) aes_get_level_name(aStats[AES_ST_LEVEL], AESLvl[id], 63, LANG_SERVER) iLen += formatex(szFormatTags[iLen], charsmax(szFormatTags) - iLen, "^4[%s] ", AESLvl[id]) #endif #if defined TAGS static const szAdminPrefix[][] = { "", "^4[Гл. Админ] ", "^4[Админ] ", "^4[VIP] " } iLen += formatex(szFormatTags[iLen], charsmax(szFormatTags) - iLen, "%s", szAdminPrefix[CheckFlags(id)]) #endif #if defined GREEN_MSG if(CheckFlags(id)) iLen += formatex(szFormatTags[iLen], charsmax(szFormatTags) - iLen, "^3%%s1^1 :^4") else iLen += formatex(szFormatTags[iLen], charsmax(szFormatTags) - iLen, "^3%%s1^1 :") #else iLen += formatex(szFormatTags[iLen], charsmax(szFormatTags) - iLen, "^3%%s1^1 :") #endif #if defined FIX_CRASH /* Костыль :D || "Fix" crash on 192 bytes */ if(strlen(szFormatTags) + strlen(szMessage) >= 190) { client_print(id, print_center, "Сообщение слишком длинное;)"); return PLUGIN_HANDLED; } /* End fix */ #endif static players[32], pcount; get_players(players, pcount, "c") if(is_say_team) { for(new i; i < pcount; i++) if(get_user_flags(id) & ADMIN || (iTeam == get_user_team(players[i]) && iAlive == is_user_alive(players[i]))) PrintChat(players[i], id, szFormatTags, szMessage) } else { for(new i; i < pcount; i++) PrintChat(players[i], id, szFormatTags, szMessage) } #if defined LOG_MESSAGE static authid[32], userteam[16], username[32] get_user_name(id, username, 31) get_user_authid(id, authid, 31) get_user_team(id, userteam, 15) log_message("^"%s<%d><%s><%s>^" %s ^"%s^"", username, get_user_userid(id), authid, userteam, is_say_team ? "say_team" : "say" , szMessage) #endif return PLUGIN_HANDLED } stock PrintChat(const iReceiver, const iSender, const szTags[], const szMessage[]) { static StrSend[191]; formatex(StrSend, charsmax(StrSend), "%s %%s2", szTags) message_begin(MSG_ONE_UNRELIABLE, 76, _, iReceiver) write_byte(iSender) write_string(StrSend) write_string("") write_string(szMessage) message_end() } stock CheckFlags(id) { static iFlags iFlags = get_user_flags(id) if(iFlags & GL_ADMIN) return 1 else if(iFlags & ADMIN) return 2 else if(iFlags & VIP) return 3 return 0 }
stock replace_all2(string[], len, const what[], const with[]) { new pos if((pos = contain(string, what)) == -1) return 0 new total, with_len = strlen(with), diff = strlen(what) - with_len, total_len = strlen(string), temp_pos while(total_len + with_len < len && replace(string[pos], len - pos, what, with) != 0) { total++ pos += with_len total_len -= diff if (pos >= total_len) break temp_pos = contain(string[pos], what) if (temp_pos == -1) break pos += temp_pos } return total } Вроде так: Код:
#include <amxmodx> #define TAGS //#define GREEN_MSG // #define AES #define DEF_ENG #define GL_ADMIN ADMIN_RCON #define ADMIN ADMIN_BAN #define VIP ADMIN_LEVEL_H // #define LOG_MESSAGE // #define FIX_CRASH #if defined AES #include <aes_main> #endif #define get_bit(%1,%2) (%1 & (1 << (%2 & 31))) #define set_bit(%1,%2) %1 |= (1 << (%2 & 31)) #define clr_bit(%1,%2) %1 &= ~(1 << (%2 & 31)) new iPlayerRus[33] new iIgnorePlayer new const eng[][] = { "A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z","{","}",":",'"',"<",">","~","a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","[","]",";","'",",",".","`","?","/","@","$","^^","&" }; new const rus[][] = { "Ф","И","С","В","У","А","П","Р","Ш","О","Л","Д","Ь","Т","Щ","З","Й","К","Ы","Е","Г","М","Ц","Ч","Н","Я","Х","Ъ","ж","Э","Б","Ю","Ё","ф","и","с","в","у","а","п","р","ш","о","л","д","ь","т","щ","з","й","к","ы","е","г","м","ц","ч","н","я","х","ъ","ж","э","б","ю","ё",",",".","'",";", ":","?" }; public plugin_init() { #define VERSION "2.5.7b" register_plugin("Lite Translit", VERSION, "neygomon") register_cvar("lt_version", VERSION, FCVAR_SERVER | FCVAR_SPONLY) register_clcmd("say /rus", "LangRus") register_clcmd("say /eng", "LangEng") register_clcmd("say", "Say_Handler") register_clcmd("say_team", "SayTeam_Handler") } public client_putinserver(id) { if(is_user_hltv(id) || is_user_bot(id)) { set_bit(iIgnorePlayer, id) return } #if defined DEF_RUS iPlayerRus[id] = true #endif } public client_disconnect(id) clr_bit(iIgnorePlayer, id) public LangRus(id) { if(!iPlayerRus[id]) { iPlayerRus[id] = true client_print(id, print_center, "Русский чат активирован!") } else client_print(id, print_center, "Русский чат УЖЕ активирован!") } public LangEng(id) { if(iPlayerRus[id]) { iPlayerRus[id] = false client_print(id, print_center, "Английский чат активирован!") } else client_print(id, print_center, "Английский чат УЖЕ активирован!") } public Say_Handler(id) return FormatMsg(id, false) public SayTeam_Handler(id) return FormatMsg(id, true) public FormatMsg(id, bool:is_say_team) { if(get_bit(iIgnorePlayer, id)) return PLUGIN_CONTINUE static szMessage[128] read_args(szMessage, charsmax(szMessage)) remove_quotes(szMessage) if(!szMessage[0] || szMessage[0] == '/') return PLUGIN_HANDLED_MAIN if(iPlayerRus[id]) { for(new i; i < sizeof eng; i++) replace_all2(szMessage, charsmax(szMessage), eng[i], rus[i]) } static iLen, szFormatTags[96], iAlive, iTeam; iAlive = is_user_alive(id), iTeam = get_user_team(id) if(is_say_team) { switch(iTeam) { case 1: iLen = formatex(szFormatTags, charsmax(szFormatTags), "^1%s(Террорист) ", " : ") case 2: iLen = formatex(szFormatTags, charsmax(szFormatTags), "^1%s(Мент) ", " : ") case 3: iLen = formatex(szFormatTags, charsmax(szFormatTags), "^1(Наблюдатель) ") } } else { if(iTeam == 3) iLen = formatex(szFormatTags, charsmax(szFormatTags), "^1(Наблюдатель) ") else iLen = formatex(szFormatTags, charsmax(szFormatTags), "^1%s", " : ") } #if defined AES static AESLvl[33][64], aStats[AES_ST_END] aes_get_player_stats(id, aStats) aes_get_level_name(aStats[AES_ST_LEVEL], AESLvl[id], 63, LANG_SERVER) iLen += formatex(szFormatTags[iLen], charsmax(szFormatTags) - iLen, "^4[%s] ", AESLvl[id]) #endif #if defined TAGS static const szAdminPrefix[][] = { "", "^4[Гл. Админ] ", "^4[Админ] ", "^4[VIP] " } iLen += formatex(szFormatTags[iLen], charsmax(szFormatTags) - iLen, "%s", szAdminPrefix[CheckFlags(id)]) #endif #if defined GREEN_MSG if(CheckFlags(id)) iLen += formatex(szFormatTags[iLen], charsmax(szFormatTags) - iLen, "^3%%s1^1 :^4") else iLen += formatex(szFormatTags[iLen], charsmax(szFormatTags) - iLen, "^3%%s1^1 :") #else iLen += formatex(szFormatTags[iLen], charsmax(szFormatTags) - iLen, "^3%%s1^1 :") #endif #if defined FIX_CRASH /* Костыль :D || "Fix" crash on 192 bytes */ if(strlen(szFormatTags) + strlen(szMessage) >= 190) { client_print(id, print_center, "Сообщение слишком длинное;)"); return PLUGIN_HANDLED; } /* End fix */ #endif static players[32], pcount; get_players(players, pcount, "c") if(is_say_team) { for(new i; i < pcount; i++) if(get_user_flags(id) & ADMIN || (iTeam == get_user_team(players[i]) && iAlive == is_user_alive(players[i]))) PrintChat(players[i], id, szFormatTags, szMessage) } else { for(new i; i < pcount; i++) PrintChat(players[i], id, szFormatTags, szMessage) } #if defined LOG_MESSAGE static authid[32], userteam[16], username[32] get_user_name(id, username, 31) get_user_authid(id, authid, 31) get_user_team(id, userteam, 15) log_message("^"%s<%d><%s><%s>^" %s ^"%s^"", username, get_user_userid(id), authid, userteam, is_say_team ? "say_team" : "say" , szMessage) #endif return PLUGIN_HANDLED } stock PrintChat(const iReceiver, const iSender, const szTags[], const szMessage[]) { static StrSend[191]; formatex(StrSend, charsmax(StrSend), "%s %%s2", szTags) message_begin(MSG_ONE_UNRELIABLE, 76, _, iReceiver) write_byte(iSender) write_string(StrSend) write_string("") write_string(szMessage) message_end() } stock CheckFlags(id) { static iFlags iFlags = get_user_flags(id) if(iFlags & GL_ADMIN) return 1 else if(iFlags & ADMIN) return 2 else if(iFlags & VIP) return 3 return 0 } stock replace_all2(string[], len, const what[], const with[]) { new pos if((pos = contain(string, what)) == -1) return 0 new total, with_len = strlen(with), diff = strlen(what) - with_len, total_len = strlen(string), temp_pos while(total_len + with_len < len && replace(string[pos], len - pos, what, with) != 0) { total++ pos += with_len total_len -= diff if (pos >= total_len) break temp_pos = contain(string[pos], what) if (temp_pos == -1) break pos += temp_pos } return total }
Отредактировал: Villlenka, - 25.12.2015, 9:07

|