|
楼主 |
发表于 2005-1-16 20:48:00
|
显示全部楼层
来自 中国–福建–三明
我把原文件贴出来,在AMXX官方论坛找的地址:http://www.amxmodx.org/forums/vi ... 29&highlight=tk:
/***********************************************************************
* ftk.sma - AmxModX (AMXX) forgivetk plugin
*
* Detects team kills and bans when VAR_TKLIMIT is reached
*
* Visit http://www.amxmodx.org/ for more information
*
* VAR_TKLIMIT - sets the tk limit
* VAR_BANTIME - sets the bantime
* VAR_TKADMIN - sets admin immunity so admins aren't punished
* var_debug - turns debug messages on/off
*/
/***********************************************************************
* Build information
*
* Version Date Info
*-------------------------------------------------
* v1.0 10 Aug 2004 Initial Release
* v1.01 11 Aug 2004 Fixed Death Messages being squashed
* v1.02 19 Aug 2004 Fixed problem with map crashes
* v1.03 22 Aug 2004 Fixed problem with TK'er not always being kicked
* v1.04 29 Aug 2004 Fixed problem with admin access.
*/
/***********************************************************************
* Contact Info
* ICQ# - 2713748
* AIM - WhoTHCares
* Yahoo - WhoTHCares@yahoo.com
*
* NOTE - Server side 'mp_tkpenalty -1' MUST be set for this to work
* properly. The cvar is checked and forced to -1 if it's not set.
*/
/* Built and tested around amxmodx-v0.16 */
/* Requires modules: Fun & Engine */
#include <amxmodx>
#include <amxmisc>
#include <engine>
#define MAX_PLAYERS 32 + 1
#define MAX_CHAR 200
#define MAX_NAME 33
#define VAR_TKLIMIT 4
#define VAR_TKADMIN 1
#define VAR_BANTIME 10
/* Global Variables */
new g_typeHelp[MAX_CHAR] = "Type 'ftk_help' in the console to see !forgivetk commands"
new g_ftkVersion[MAX_CHAR] = "1.04"
new g_ftkBuildDate[MAX_CHAR] = "August 29, 2004"
new tkCount[MAX_PLAYERS] = {0,...}
new LastTker = 0
new LastTked = 0
new WasLastTker = 0
new WasLastTked = 0
new var_debug = 0
public plugin_init()
{
register_plugin("AMXX !forgivetk", g_ftkVersion, "WhoCares?")
register_event("DeathMsg", "tkCheck", "a", "1>0")
register_concmd("amx_ftk", "amx_ftk", ADMIN_IMMUNITY, " <new|old> : forgives most or least recent TK (only usable by admins)")
register_concmd("amx_ftkv", "amx_ftkv", ADMIN_IMMUNITY, "")
/* General User commands */
register_concmd("ftk_help","ftkHelp",0,"- displays this help")
register_clcmd("say /tks","display_tks")
register_clcmd("say_team /tks","display_tks")
register_clcmd("say !forgivetk","forgive_tk")
register_clcmd("say_team !forgivetk","forgive_tk")
log_message("AMXX ftk plugin loaded, Version: %s, Build Date: %s", g_ftkVersion, g_ftkBuildDate)
setftkHelp(0)
}
public Announce(id, iRed, iGreen, iBlue, Msg[MAX_CHAR], channel)
{
/* Announce is used to pass messages to players */
/* Announce is equivalent to admin/amx_tsay */
if (var_debug) log_message("AMXX ftk - Inside Announce")
set_hudmessage(iRed, iGreen, iBlue, 0.025, 0.625, 0, 4.0, 4.0, 1.0, 1.0, channel)
show_hudmessage(id, Msg)
if (var_debug) log_message("AMXX ftk - Leaving Announce")
}
public amx_ftkv(id, level, cid)
{
if (!cmd_access(id,level,cid,1)) return PLUGIN_HANDLED
console_print(id, "AMXX ftk version: %s, Build Date: %s", g_ftkVersion, g_ftkBuildDate )
server_print("AMXX ftk version: %s, Build Date: %s", g_ftkVersion, g_ftkBuildDate )
return PLUGIN_CONTINUE
}
public dispHelp(id)
{
if (var_debug) log_message("AMXX ftk - Inside dispHelp")
if (id) client_print(id, print_chat, g_typeHelp)
else server_print (g_typeHelp)
if (var_debug) log_message("AMXX ftk - Leaving dispHelp")
}
public setftkHelp(id)
{
if (var_debug) log_message("AMXX ftk - Inside setftkHelp")
set_task(90.0,"dispHelp",id,"",0,"b")
if (var_debug) log_message("AMXX ftk - Leaving setftkHelp")
}
public ftkHelp(id,level,cid) /* Function to print usage */
{
if (var_debug) log_message("AMXX ftk - Inside ftkHelp")
new is_admin = (get_user_flags(id)&ADMIN_IMMUNITY)
console_print(id, "----- AMXX ftk plugin Help -----")
console_print(id, "1:say !forgivetk - forgive the last TK")
console_print(id, "2:say /tks - list how many tk's you have.")
if (is_admin)
{
console_print(id, "3:amx_ftk <new|old> - forgives most or least recent TK (only usable by admins)")
console_print(id, "4:amx_ftkv - prints version and build information")
}
if (var_debug) log_message("AMXX ftk - Leaving ftkHelp")
return PLUGIN_HANDLED
}
public display_tks(id)
{
if (var_debug) log_message("AMXX ftk - Inside display_tks")
new Killer_Name[MAX_NAME]
get_user_name(id, Killer_Name, MAX_NAME)
client_print(id, print_center, "TK's: %d",tkCount[id])
if (var_debug) log_message("AMXX ftk - Leaving display_tks")
return PLUGIN_CONTINUE
}
public tkPunish(kindex,vindex)
{
if (var_debug) log_message("AMXX ftk - Inside tkPunish")
new kname[MAX_NAME],vname[MAX_NAME],Msg[MAX_CHAR]
get_user_name( vindex, vname, MAX_NAME)
if ( !get_user_name( kindex, kname, MAX_NAME ))
{
log_message("AMXX ftk - tkPunish -> attacker not found on server")
return PLUGIN_HANDLED_MAIN
}
tkCount[kindex]++
if (tkCount[kindex] < 0)
{
tkCount[kindex] = 0 /* reset to 0 to avoid negative count */
log_message("AMXX ftk - Error: tkPunish -> tkCount less than 0, reset.")
return PLUGIN_HANDLED_MAIN
}
if ( tkCount[kindex] < VAR_TKLIMIT )
{
format(Msg, MAX_CHAR, "TK'ing isn't nice! You should ask %s for forgiveness.", vname)
Announce(kindex, 61, 61, 61, Msg, 1)
format(Msg, MAX_CHAR, "Team killers can be forgiven by saying !forgivetk.")
Announce(vindex, 61, 61, 61, Msg, 2)
return PLUGIN_HANDLED_MAIN
}
if ( (tkCount[kindex] == VAR_TKLIMIT) && VAR_BANTIME == 0 )
{
format( Msg, MAX_CHAR, "%s has been perma-banned for TK'ing.", kname)
client_print(kindex, print_console, Msg)
Announce(kindex, 255, 0, 0, Msg, 4)
if (var_debug) log_message("kindex: %d",kindex)
server_cmd("banid %d #%d kick;wait;writeid",VAR_BANTIME,get_user_userid(kindex))
server_cmd("kick %s ^"You are permabanned for TK'ing^"",kname)
tkCount[kindex] = 0 /* reset to 0 to avoid negative count */
return PLUGIN_HANDLED_MAIN
}
else
{
format( Msg, MAX_CHAR, "AMXX ftk - %s has been banned for %i minutes for TK'ing.", kname, VAR_BANTIME)
client_print(kindex, print_console, Msg)
Announce(0, 255, 0, 0, Msg, 4)
if (var_debug) log_message("kindex: %d",kindex)
server_cmd("banid %d #%d kick;wait;writeid",VAR_BANTIME,get_user_userid(kindex))
server_cmd("kick %s ^"You have been banned for %d minutes for TK'ing^"",kname,VAR_BANTIME)
tkCount[kindex] = 0 /* reset to 0 to avoid negative count */
return PLUGIN_HANDLED_MAIN
}
if (var_debug) log_message("AMXX ftk - kindex = %d", kindex)
/* public statement about forgiving */
format(Msg, MAX_CHAR, "Team Killers can be forgiven by saying !forgivetk.")
Announce(vindex, 61, 61, 61, Msg, 2)
if (var_debug) log_message("AMXX ftk - Leaving tkPunish")
return PLUGIN_CONTINUE
}
public tkCheck(msgid)
{
if (var_debug) log_message("AMXX ftk - Inside tkCheck")
new kindex = read_data(1)
new kteam = entity_get_int(kindex, EV_INT_team)
new kname[MAX_NAME]
get_user_name(kindex, kname, MAX_NAME)
new vindex = read_data(2)
new vteam = entity_get_int(vindex, EV_INT_team)
new Msg[MAX_CHAR]
new is_admin = (get_user_flags(kindex)&ADMIN_IMMUNITY)
log_message("AMXX ftk - Killer Flags=%d", is_admin)
if (var_debug) log_message("AMXX ftk - Killer Flags=%d", is_admin)
if (var_debug) log_message("AMXX ftk - Check teams")
/* if killer is alive, not himself, and on same team */
if (kindex && (kindex != vindex) && (kteam == vteam))
{
if (var_debug) log_message("AMXX ftk - Check immunity")
if ((VAR_TKADMIN == 1) && (is_admin))
{
log_message("AMXX ftk - immunity found, Name: %s, immunity=%d", kname, is_admin)
format(Msg,MAX_CHAR,"Alright %s, even though you're an admin,^ntry to keep the TK'ing to a minimum.",kname)
client_print(kindex, print_console, Msg)
Announce(kindex, 61, 61, 61, Msg, 1)
return PLUGIN_HANDLED_MAIN
}
if (var_debug) log_message("AMXX ftk - Calling tkPunish")
tkPunish(kindex,vindex)
WasLastTker = LastTker
WasLastTked = LastTked
LastTker = kindex
LastTked = vindex
}
if (var_debug) log_message("AMXX ftk - Leaving tkCheck")
return PLUGIN_CONTINUE
}
forgive_new()
{
if (var_debug) log_message("AMXX ftk - Inside forgive_new")
new kname[MAX_NAME],vname[MAX_NAME]
/* player doesn't exist or this tk was already forgiven */
if (LastTked == 0 || LastTker == 0) return PLUGIN_HANDLED
if (!get_user_name(LastTker,kname,MAX_NAME) || \
!get_user_name(LastTked,vname,MAX_NAME)) return PLUGIN_HANDLED
/* if a tk count does't exist, don't do anything */
if (tkCount[LastTker] == 0) return PLUGIN_HANDLED
tkCount[LastTker]--
client_print(0,print_chat,"%s forgives %s",vname,kname)
LastTked = WasLastTked
LastTker = WasLastTker
WasLastTked = 0
WasLastTker = 0
if (var_debug) log_message("AMXX ftk - Leaving forgive_new")
return PLUGIN_CONTINUE
}
forgive_old()
{
if (var_debug) log_message("AMXX ftk - Inside forgive_old")
new kname[MAX_NAME],vname[MAX_NAME]
/* player doesn't exist or this tk was already forgiven */
if (WasLastTked == 0 || WasLastTker == 0) return PLUGIN_HANDLED
if (!get_user_name(WasLastTker,kname,MAX_NAME) || \
!get_user_name(WasLastTked,vname,MAX_NAME)) return PLUGIN_HANDLED
/* if a tk count does't exist, don't do anything */
if (tkCount[WasLastTker] == 0) return PLUGIN_HANDLED
tkCount[WasLastTker]--
client_print(0,print_chat,"%s forgives %s",vname,kname)
WasLastTked = 0
WasLastTker = 0
if (var_debug) log_message("AMXX ftk - Leaving forgive_old")
return PLUGIN_CONTINUE
}
public amx_ftk(id, level, cid)
{
if (var_debug) log_message("AMXX ftk - Inside amx_ftk")
if (!cmd_access(id,level,cid,2)) return PLUGIN_HANDLED
new Data[4]
read_argv(1, Data, 3)
if ( equali( Data, "new" ) == 1 ) forgive_new()
if ( equali( Data, "old" ) == 1 ) forgive_old()
return PLUGIN_CONTINUE
}
public forgive_tk(id)
{
if (var_debug) log_message("AMXX ftk - Inside forgive_tk")
if (id == LastTked) forgive_new()
if (id == WasLastTked) forgive_old()
if (var_debug) log_message("AMXX ftk - Leaving forgive_tk")
return PLUGIN_CONTINUE
}
public client_connect(id)
{
tkCount[id] = 0
}
public client_disconnect(id)
{
tkCount[id] = 0
}
public client_putinserver(id)
{
if (var_debug) log_message("AMXX ftk - Inside client_putinserver")
setftkHelp(id)
if (var_debug) log_message("AMXX ftk - Leaving client_putinserver")
}
下面是我试着汉化的data文本,不知道对不对,请指点谢谢
[cn]
Type 'ftk_help' in the console to see !forgivetk commands = 在控制台输入"ftk_help"查看!forgivetk命令
ftkHelp = ftk帮助
display_tks = TK次数
AMXX ftk plugin loaded, Version: %s, Build Date: %s =AMXX TK插件已加载,版本:%s,Build Date:%s
AMXX ftk - Inside Announce
AMXX ftk - Leaving Announce
----- AMXX ftk plugin Help ----- =AMXX ftk 插件帮助
1:say !forgivetk - forgive the last TK =1.按“Y”输入 !forgivetk 原谅队友TK。
2:say /tks - list how many tk's you have. = 2. 按“Y”输入 /tks 显示自己TK次数。
3:amx_ftk <new|old> - forgives most or least recent TK (only usable by admins) = 3. 管理员输入amx_ftk <new|old>可清除新或旧TK记录
4:amx_ftkv - prints version and build information = 4.输入amx_ftkv查看插件版本信息
TK'ing isn't nice! You should ask %s for forgiveness. = TK是不好D!向 %s 说sorry,请他输入 !forgivetk 原谅你~
Team killers can be forgiven by saying !forgivetk. = 按“Y”输入 !forgivetk 可以原谅队友TK。
%s has been perma-banned for TK'ing. = %s 因为TK被 BAN 掉鸟~~
AMXX ftk - %s has been banned for %i minutes for TK'ing. = 提示 - %s因为TK被 BAN %i 分钟
AMXX ftk - Killer Flags=%d = 提示:TKer=%d
%s forgives %s = %s 原谅了 %s TK |
|