#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <nvault>
#define MAX_WORDS 192
new const PLUGIN[] = "Hook system final"
new const VERSION[] = "3.5"
new const AUTHOR[] = "WS.Chu:)"
static const VAULTNAME[] = "signature"
new const SYS_PLUGIN_NAME[] = "\y插件名稱^n\r"
new const SYS_PLUGIN_AUTHOR[] = "\y插件作者^n\r"
new const SYS_PLUGIN_VERSION[] = "\y插件版本^n\r"
new const SYS_PLUGIN_DB[] = "\y資料庫^n\r"
new iMessages[256];
new iUserName[40], iTag[256], iPlayerTag[256] = "[一般玩家]";
new iUserAlive, iUserTeam;
new tUserTeam[16], tUserAlive[10];
new gSayText, gMaxplayers;
new szVault, szName[33][35];
new cmdType;
new iHideTag;
new CHARS_MIN = 0, CHARS_MAX = 256;
new SwearsNames[MAX_WORDS][32];
new gSwearsNum;
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_clcmd("say", "cmdHookSay");
register_clcmd("say_team", "cmdHookSayTeam");
cmdType = register_cvar("amx_hook_sysf_type", "1");
register_cvar(SYS_PLUGIN_NAME, PLUGIN, FCVAR_SERVER|FCVAR_SPONLY);
register_cvar(SYS_PLUGIN_AUTHOR, AUTHOR, FCVAR_SERVER|FCVAR_SPONLY);
register_cvar(SYS_PLUGIN_VERSION, VERSION, FCVAR_SERVER|FCVAR_SPONLY);
register_cvar(SYS_PLUGIN_DB, VAULTNAME, FCVAR_SERVER|FCVAR_SPONLY);
szVault = nvault_open(VAULTNAME)
gSayText = get_user_msgid("SayText");
gMaxplayers = get_maxplayers();
if(get_pcvar_num(cmdType) >= 3)
{
server_cmd("amxx pause hook_sys.amxx");
server_print("[ERROR] Cvar ^"hook_sys_type^" effective value are ^"0^" and ^"1^".");
server_print("[ERROR] Plugin info: %s %s %s, auto pause plugin.", PLUGIN, VERSION, AUTHOR);
}
readList()
}
readList()
{
// file to read words from
new szConfigdir[64];
new szFileName[64];
get_configsdir(szConfigdir, 63);
formatex(szFileName, 63, "%s/swear/swearwords.ini", szConfigdir);
if(!file_exists(szFileName))
{
server_print("[ERROR] Swear Filter: file %s not found.", szFileName);
return;
}
new iLen
while(gSwearsNum < MAX_WORDS && read_file(szFileName, gSwearsNum ,SwearsNames[gSwearsNum][1], 30, iLen))
{
if(SwearsNames[gSwearsNum][0] == ';') continue;
SwearsNames[gSwearsNum][0] = iLen;
++gSwearsNum;
}
server_print("[AMXX] Swear Filter: loaded %d words", gSwearsNum);
}
public client_authorized(id)
{
get_user_name(id , szName[id] , charsmax(szName[]));
}
public plugin_end()
{
nvault_close(szVault);
}
public cmdHookSay(id)
{
read_args(iMessages, 255);
remove_quotes(iMessages);
get_user_name(id, iUserName, 31);
if(!is_valid_msg(iMessages))
return PLUGIN_HANDLED;
CheckSwears(id);
if(get_user_flags(id) & ADMIN_IMMUNITY)
iTag = "[OP]";
else if(get_user_flags(id) & ADMIN_KICK)
iTag = "[Administrator]";
else if(get_user_flags(id) & ADMIN_RESERVATION)
iTag = "[VIP]";
else
iTag = iPlayerTag;
iUserAlive = is_user_alive(id);
new szKey[32], szSingature[256], iSignature[256];
formatex(szKey, 31, "%s-Signature", szName[id]);
formatex(szSingature, charsmax(szSingature), "%s", iMessages[10]);
if(iMessages[0] == '/' && iMessages[1] == 'f' && iMessages[2] == 'u' && iMessages[3] == 'n' && iMessages[4] == '_' && iMessages[5] == 'n' && iMessages[6] == 'a' && iMessages[7] == 'm' && iMessages[8] == 'e' && iMessages[9] == ' '
{
new iMsg = strlen(iMessages);
if(iMsg < CHARS_MIN)
{
client_color(id, id, "[香港伺服器溫馨小提示] 您所鍵入的個性簽名太短了。(下限: %d 個英文字或中文字)", CHARS_MIN - 5);
}
else if(iMsg > CHARS_MAX)
{
client_color(id, id, "[香港伺服器溫馨小提示] 您所鍵入的個性簽名太長了。(上限: %d 個英文字或 %d 個中文字)", CHARS_MAX - 5, (CHARS_MAX - 5) / 3);
}
else
{
client_color(id, id, "[香港伺服器溫馨小提示] 您現在的個性簽名:^"%s^"。", iMessages[5]);
nvault_set(szVault, szKey, szSingature);
}
return PLUGIN_HANDLED;
}
if(equal(iMessages, "/delmsg"))
{
formatex(szSingature, charsmax(szSingature), "沒有設定稱號");
nvault_set(szVault, szKey, szSingature);
client_color(id, id, "[香港伺服器溫馨小提示] 您現在的個性簽名已經刪除。");
return PLUGIN_HANDLED;
}
formatex(szKey, 31, "%s-Signature", szName[id]);
if(nvault_get(szVault, szKey, szSingature, charsmax(szSingature)))
formatex(iSignature, charsmax(iSignature), "%s", szSingature);
else
formatex(iSignature, charsmax(iSignature), "沒有設定稱號");
if(get_pcvar_num(cmdType) == 0)
{
client_color(0, id, "^x01%s^x04[^x01%s^x04] ^x03%s ^x01: %s", is_UserAlive(), iSignature, iUserName, iMessages);
client_print(0, print_console, "%s[%s] %s : %s", is_UserAlive(), iSignature, iUserName, iMessages);
}
else if(get_pcvar_num(cmdType) == 1)
{ if(is_user_admin(id))
{
if(equal(iMessages, "/hide"))
{
iHideTag = 1;
client_color(id, id, "[提示] 您的管理員標籤將由 %s 變成 %s。", iTag, iPlayerTag);
return PLUGIN_HANDLED;
}
if(equal(iMessages, "/show"))
{
iHideTag = 0;
client_color(id, id, "[提示] 您的管理員標籤將由 %s 還原成 %s。", iPlayerTag, iTag);
return PLUGIN_HANDLED;
}
}
else if(!is_user_admin(id))
{
iHideTag = 0;
}
if(iHideTag == 1)
{
client_color(0, id, "^x01%s^x04%s ^x04[^x01%s^x04] ^x03%s ^x01: %s", is_UserAlive(), iPlayerTag, iSignature, iUserName, iMessages);
client_print(0, print_console, "%s%s [%s] %s : %s", is_UserAlive(), iPlayerTag, iSignature, iUserName, iMessages);
}
else if(iHideTag == 0)
{
client_color(0, id, "^x01%s^x04%s ^x04[^x01%s^x04] ^x03%s ^x01: %s", is_UserAlive(), iTag, iSignature, iUserName, iMessages);
client_print(0, print_console, "%s%s [%s] %s : %s", is_UserAlive(), iTag, iSignature, iUserName, iMessages);
}
}
return PLUGIN_HANDLED;
}
public cmdHookSayTeam(id)
{
read_args(iMessages, 255);
remove_quotes(iMessages);
get_user_name(id, iUserName, 31);
if(!is_valid_msg(iMessages))
return PLUGIN_HANDLED;
CheckSwears(id);
iUserAlive = is_user_alive(id);
iUserTeam = get_user_team(id);
if(iMessages[0] != '@')
{
static player;
for(player = 1; player <= gMaxplayers; player++)
{
if(get_user_team(player) == iUserTeam)
client_color(player, id, "^x01%s^x03%s %s ^x01: %s", is_UserAlive(), i_UserTeam(), iUserName, iMessages);
}
}
else
{
if(get_user_flags(id) & ADMIN_ADMIN)
iTag = "(ADMIN)"
else
iTag = "(PLAYER)"
new iPlayers[32], iNum;
get_players(iPlayers, iNum, "ch");
// for(new i = 0; i < iNum; i++)
// {
// if(get_user_flags(iPlayers[i]) & ADMIN_CHAT)
// {
// client_color(iPlayers[i], id, "^x04%s ^x03%s ^x01: %s", iTag, iUserName, iMessages[1]);
// }
// else if(!is_user_admin(iPlayers[i]))
// {
// client_color(iPlayers[i], id, "^x04%s ^x03%s ^x01: %s", iTag, iUserName, iMessages[1]);
// }
// }
for(new i = 0; i < iNum; i++)
{
if(get_user_flags(iPlayers[i]) & ADMIN_CHAT && id != iPlayers[i])
{
client_color(iPlayers[i], id, "^x04%s ^x03%s ^x01: %s", iTag, iUserName, iMessages[1]);
}
}
client_color(id, id, "^x04%s ^x03%s ^x01: %s", iTag, iUserName, iMessages[1]);
}
return PLUGIN_HANDLED;
}
public CheckSwears(id)
{
new pos, i = 0;
while (i < gSwearsNum)
{
if((pos = containi(iMessages, SwearsNames[i][1])) != -1 )
{
new len = SwearsNames[i][0]
while(len--)
iMessages[pos++] = '*';
continue;
}
++i
}
return PLUGIN_HANDLED;
}
bool:is_valid_msg(const iMessages[])
{
if(iMessages[0] == '%' || !strlen(iMessages) || equal(iMessages, "") || equal(iMessages, " "))
{
return false;
}
return true;
}
public i_UserTeam()
{
switch(iUserTeam)
{
case 0: copy(tUserTeam, sizeof(tUserTeam) - 1,"( SPEC )");
case 1: copy(tUserTeam, sizeof(tUserTeam) - 1,"( TS )");
case 2: copy(tUserTeam, sizeof(tUserTeam) - 1,"( CT )");
case 3: copy(tUserTeam, sizeof(tUserTeam) - 1,"( SPEC )");
}
return tUserTeam;
}
public is_UserAlive()
{
if(!iUserAlive && 0 < iUserTeam < 3)
copy(tUserAlive, sizeof(tUserAlive) - 1,"*死亡* ");
else
copy(tUserAlive, sizeof(tUserAlive) - 1,"");
return tUserAlive;
}
stock client_color(index, color, const msg[], any:...)
{
static szMessage[192]
szMessage[0] = 0x04
vformat(szMessage[1], charsmax(szMessage)-1, msg, 4)
static iSayText
if (iSayText || (iSayText = gSayText))
{
message_begin(index ? MSG_ONE_UNRELIABLE : MSG_BROADCAST, iSayText, _, index)
{
write_byte(color)
write_string(szMessage)
}
message_end()
}
}