[求助]求TK插件
用在DOD(胜利之日Day of Defeat),因为服务器开了团队伤害,有时候并不是恶意TK,被TK的可以选择忘记TK。服务器是Linux,
插件为AMX v0.16, MetaMod v1.17.2 不知道合不合用
/* AMX Mod script.
*
* (c) Copyright 2002-2003, OLO
* This file is provided as is (no warranties).
*
*/
#include <amxmod>
new gMenu
new gKillers
new gPunishMe
public menu_option1(id,keys){
if (gPunishMe]) {
gPunishMe] = 0
new name1, name2
get_user_name(id,name1,31)
get_user_name(gKillers,name2,31)
client_print(0,print_chat,"* %s 被 %s 惩罚",name2,name1)
user_kill(gKillers)
}
else
client_print(id,print_chat,"* 你的选择超时了")
return PLUGIN_HANDLED
}
public menu_option2(id,keys){
if (gPunishMe]) {
gPunishMe] = 0
new name1, name2
get_user_name(id,name1,31)
get_user_name(gKillers,name2,31)
user_slap(gKillers,50)
client_print(0,print_chat,"* %s 惩罚 %s 掉 50 点血 因为谋杀了队友",name1,name2)
}
else
client_print(id,print_chat,"* 你的选择超时了")
return PLUGIN_HANDLED
}
public menu_option3(id,keys){
if (gPunishMe]) {
gPunishMe]=0
new name1, name2
get_user_name(id,name1,31)
get_user_name(gKillers,name2,31)
client_print(0,print_chat,"* %s 原谅了 %s",name1,name2)
}
else
client_print(id,print_chat,"* 你的选择超时了")
return PLUGIN_HANDLED
}
public menu_option4(id,keys){
if (gPunishMe]){
new name
get_user_name(gKillers,name,31)
client_print(0,print_chat,"* %s 下一轮将受到惩罚 ",name)
}
else
client_print(id,print_chat,"* 你的选择超时了")
return PLUGIN_HANDLED
}
public show_tkmenu(param[]){
new szmenu, name
get_user_name(param,name,31)
format(szmenu,255,"\yTK Revenge on %s^n^n\w1. Kill now!^n2. Slap with 50hp^n3. Forgive TK^n^n4. Punish on nextround",name)
show_menu(param,((1<<0)|(1<<1)|(1<<2)|(1<<3)),szmenu)
}
public death_msg(id){
new killer = read_data(1)
new victim = read_data(2)
if ( killer && (killer!=victim) && (get_user_team(killer)==get_user_team(victim)) ) {
gKillers = killer
gPunishMe = 1
new param
param = victim
param = killer
set_task(0.25,"show_tkmenu",0,param,2)
}
return PLUGIN_CONTINUE
}
public delayed_kill(param[]){
client_print(param,print_chat,"* 你因为谋杀了队友而被惩罚")
user_kill(param)
return PLUGIN_CONTINUE
}
public reset_hud(id){
if (gPunishMe){
gPunishMe = 0
new param
param = id
set_task(0.25,"delayed_kill",0,param,2)
}
return PLUGIN_CONTINUE
}
public client_connect(id){
gPunishMe = 0
return PLUGIN_CONTINUE
}
public client_disconnect(id){
gPunishMe = 0
return PLUGIN_CONTINUE
}
public reset_punishment(){
new imax = get_maxplayers()
for(new a = 1; a<=imax; ++a)
gPunishMe = 0
return PLUGIN_CONTINUE
}
public plugin_init(){
register_plugin("TK Revenge","0.9","default")
gMenu = register_menuid("\yTK Revenge on")
register_menucmd(gMenu,(1<<0),"menu_option1")
register_menucmd(gMenu,(1<<1),"menu_option2")
register_menucmd(gMenu,(1<<2),"menu_option3")
register_menucmd(gMenu,(1<<3),"menu_option4")
register_event("TextMsg","reset_punishment","a","2&#Game_C","2&#Game_w")
register_event("ResetHUD","reset_hud","b")
register_event("DeathMsg","death_msg","a")
set_cvar_float("mp_tkpunish",0.0)
return PLUGIN_CONTINUE
} 因为服务器是另外一个人建的,昨天和他联系了一下说服务器插件用的是amxmodx 0.16~~这个是我在http://www.amxmodx.org/forums/viewtopic.php?t=6373找的,可偶的英文很烂,哪位达人能帮忙汉化一下,在此谢过!
/* AMXMOD script - dod_tk_manager
*
*Team Killer manager for DOD - by Fractal (fractal323@comcast.net) and SidLuke (sidluke@o2.pl)
*Provides simple automated control over TKers
*
*Commands to forgive tks are any of "forgivetk", "forgive tk", "!forgivetk", "!forgive tk"
*(can be upper or lower case)
*
*
*Cvar settings (put in amx.cfg):
*-------------------------------
*amx_tk_limit <value> -number of TKs allowed before banning
*amx_tk_bantime <minutes> -how long to ban if limit exceeded (0=permanent)
*amx_tk_adminimmunity <0|1> -prevent admin from being kicked/banned for TKing
* (for admins with ADMIN_BAN access)
*amx_tk_forgivetype <0|1|2> -how to forgive, 0="say forgivetk", 1=Yes/No menu, 2=both
*amx_tk_usemapmemory <0|1> -use map specific TK memory (prevents TKers from
* resetting their counter by disconnecting/reconnecting)
*amx_tk_infomessages <0|1> -show information messages (chat text)
*amx_tk_usehostname <0|1> -use hostname in messages
*
*
*default settings
*----------------
*amx_tk_limit 5
*amx_tk_bantime 1440
*amx_tk_adminimmunity 1
*amx_tk_forgivetype 2
*amx_tk_usemapmemory 1
*amx_tk_infomessages 1
*amx_tk_usehostname 1
*
*/
#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <dodx>
#define TK_P_SLAY (1<<0)
#define TK_P_MIRROR_DMG (1<<1)
new Float:g_SpawnTime
new Float:g_LastAttackTime
new g_adminimmunity
new g_forgivetype
new g_TKlimit
new g_TKbantime
new g_infomessages
new g_servername
new g_player_authid
new g_player_authenticated
new g_TKcount
new g_FGmenu_killerid
new LastTKer = 0
new LastTKed = 0
new BeLastTKer = 0
new BeLastTKed = 0
/* main */
public plugin_init()
{
register_plugin("DoD TK Manager","1.0.0","Fractal&SidLuke")
register_event("ResetHUD","eResetHud","b")
register_cvar("amx_tk_limit","5")
register_cvar("amx_tk_bantime","1440")
register_cvar("amx_tk_adminimmunity","1")
register_cvar("amx_tk_forgivetype","2")
register_cvar("amx_tk_usemapmemory","1")
register_cvar("amx_tk_infomessages","1")
register_cvar("amx_tk_usehostname","1")
register_cvar("amx_tk_protection","ab")
register_cvar("amx_tk_multionetk","1")
register_cvar("amx_tk_meleeslay","1")
register_cvar("amx_tk_protectiontime","10.0")
register_clcmd("say","HandleSay")
register_clcmd("say_team","HandleSay")
register_concmd("amx_forgivetk","admin_forgivetk",ADMIN_BAN,"<new|old> : forgives most recent or least recent TK")
register_menucmd(register_menuid("Forgive"),1023,"actionFGMenu")
register_statsfwd(XMF_DEATH)
register_statsfwd(XMF_DAMAGE)
set_task(0.6,"load_settings")
return PLUGIN_CONTINUE
}
public client_connect(id)
{
g_player_authenticated = 0
return PLUGIN_CONTINUE
}
public client_putinserver(id)
{
get_user_authid(id,g_player_authid,39)
g_player_authenticated = 1
g_TKcount = 0
if (!get_cvar_num("amx_tk_usemapmemory") || is_user_bot(id))
return PLUGIN_CONTINUE
new TKfile
get_datadir(TKfile,63)
add(TKfile,63,"/%s.txt")
format(TKfile,63,TKfile,g_player_authid)
//fix for VALVE id problem
replace(TKfile,63,":","_")
replace(TKfile,63,":","_")
if (file_exists(TKfile))
{
new currmap
get_mapname(currmap,31)
new text
new a = 0
if (read_file(TKfile,1,text,31,a) && equali(currmap,text))
{
if (read_file(TKfile,2,text,31,a))
g_TKcount = str_to_num(text)
}
else
delete_file(TKfile)
}
return PLUGIN_CONTINUE
}
public client_disconnect(id)
{
if (!get_cvar_num("amx_tk_usemapmemory") || is_user_bot(id))
return PLUGIN_CONTINUE
if (g_player_authenticated && g_TKcount > 0)
{
new TKfile
get_datadir(TKfile,63)
add(TKfile,63,"/%s.txt")
format(TKfile,63,TKfile,g_player_authid)
replace(TKfile,63,":","_")
replace(TKfile,63,":","_")
new currmap
get_mapname(currmap,31)
write_file(TKfile,currmap,1)
new text
num_to_str(g_TKcount,text,7)
write_file(TKfile,text,2)
}
return PLUGIN_CONTINUE
}
public eResetHud(id){
g_SpawnTime = get_gametime()
return PLUGIN_CONTINUE
}
public client_damage(attacker,victim,damage,wpnindex,hitplace,TA){
if ( !TA || attacker==victim || ( get_user_flags(attacker)&ADMIN_IMMUNITY && g_adminimmunity ) )
return PLUGIN_CONTINUE
new name
get_user_name(attacker,name,31)
// spawn protection
if ( get_gametime() - g_SpawnTime < get_cvar_float("amx_tk_protectiontime") ){
new szCvar
get_cvar_string("amx_tk_protection",szCvar,7)
new flags = read_flags(szCvar)
if ( flags ){
if ( flags&TK_P_SLAY ){
set_task(0.5,"delayedkill",attacker)
set_hudmessage(255, 255, 255, 0.05, 0.575, 0, 3.0, 10.0, 0.1, 0.5, 8)
show_hudmessage(0,"%s^nSlayed for teammate attack after respawn", name)
log_message(" %s Slayed for teammate attack after respawn", name)
}
if ( flags&TK_P_MIRROR_DMG && is_user_alive(victim) ){
new oldHP = get_user_health( victim )
set_user_health( victim,oldHP + damage )
if ( is_user_alive(attacker) ){ // TK_P_SLAY off ?
oldHP = get_user_health( attacker )
set_user_health( attacker,oldHP - damage )
}
}
}
return PLUGIN_CONTINUE
}
if ( get_cvar_num("amx_tk_meleeslay") && xmod_is_melee_wpn(wpnindex) ){
set_task(0.5,"delayedkill",attacker)
set_hudmessage(255, 255, 255, 0.05, 0.575, 0, 3.0, 10.0, 0.1, 0.5, 8)
show_hudmessage(0,"%s^nSlayed for melee attack", name)
log_message(" %s Slayed for melee attack", name)
}
return PLUGIN_CONTINUE
}
public client_death(killer,victim,wpnindex,hitplace,TK)
{
if ( !TK || killer==victim || ( get_user_flags(killer)&ADMIN_IMMUNITY && g_adminimmunity ) )
return PLUGIN_CONTINUE
if ( get_cvar_num("amx_tk_multionetk") ){
if ( g_LastAttackTime == get_gametime() ){
//log("Ignoring TK (Multi TK)") // ??
return PLUGIN_CONTINUE
}
}
g_LastAttackTime = get_gametime()
TKPunish(killer, victim)
BeLastTKer = LastTKer
BeLastTKed = LastTKed
LastTKer = killer
LastTKed = victim
return PLUGIN_CONTINUE
}
public admin_forgivetk(id,level,cid)
{
if (!cmd_access(id,level,cid,2))
return PLUGIN_HANDLED
new text
read_argv(1,text,3)
if (equali(text,"new") == 0)
forgiveNewTK()
else if (equali(text,"old") == 0)
forgiveOldTK()
return PLUGIN_HANDLED
}
public HandleSay(id)
{
if (g_forgivetype==1)
return PLUGIN_CONTINUE
new text
read_argv(1,text,11)
if (forgivetk(text))
{
new menuid, keys
if (id == LastTKed)
{
// if they still have menu on screen then cancel it
if (get_user_menu(id,menuid,keys) && g_FGmenu_killerid==LastTKer)
client_cmd(id,"slot3")
forgiveNewTK()
}
else if (id == BeLastTKed)
{
if (get_user_menu(id,menuid,keys) && g_FGmenu_killerid==BeLastTKer)
client_cmd(id,"slot3")
forgiveOldTK()
}
}
return PLUGIN_CONTINUE
}
public load_settings()
{
g_TKlimit = get_cvar_num("amx_tk_limit")
g_TKbantime = get_cvar_num("amx_tk_bantime")
g_adminimmunity = get_cvar_num("amx_tk_adminimmunity")
g_forgivetype = get_cvar_num("amx_tk_forgivetype")
g_infomessages = get_cvar_num("amx_tk_infomessages")
if (get_cvar_num("amx_tk_usehostname"))
get_cvar_string("hostname",g_servername,31)
else
format(g_servername,31,"this server")
return PLUGIN_CONTINUE
}
forgivetk(text[])
{
if (containi(text,"forgivetk") == 0)
return 1
if (containi(text,"!forgivetk") == 0)
return 1
if (containi(text,"forgive tk") == 0)
return 1
if (containi(text,"!forgive tk") == 0)
return 1
return 0
}
TKPunish(killer, victim)
{
g_TKcount++
if (g_TKcount < 1)
return 0
new name, userid
get_user_name(killer,name,31)
if (g_TKcount < g_TKlimit)
{
set_hudmessage(255, 255, 255, 0.05, 0.575, 0, 3.0, 10.0, 0.1, 0.5, 8)
show_hudmessage(0,"%s^nTK warning %i of %i", name, g_TKcount, g_TKlimit)
log_message(" %s TK warning %i of %i", name, g_TKcount, g_TKlimit)
}
else if (g_TKcount == g_TKlimit)
{
set_task(0.5,"delayedkill",killer)
set_hudmessage(255, 255, 255, 0.05, 0.575, 0, 3.0, 10.0, 0.1, 0.5, 8)
show_hudmessage(0,"%s^nSlayed for violating %i TK warning", name, g_TKlimit)
log_message(" %s Slayed for violating %i TK warning", name, g_TKlimit)
}
else
{
set_task(0.5,"delayedkill",killer)
set_hudmessage(255, 0, 0, 0.05, 0.575, 0, 3.0, 11.0, 0.1, 0.5, 8)
if (g_adminimmunity && (get_user_flags(killer) & ADMIN_BAN))
{
show_hudmessage(0,"%s^nExceeded %i TK limit", name, g_TKlimit)
log_message(" %s Exceeded %i TK limit", name, g_TKlimit)
}
else
{
if ((g_TKbantime % 1440)==0)
{
show_hudmessage(0,"%s^nExceeded %i TK limit and is BANNED for %d hours", name, g_TKlimit, (g_TKbantime / 60))
log_message(" %s Exceeded %i TK limit and is BANNED for %d hours", name, g_TKlimit, (g_TKbantime / 60))
}
else if (g_TKbantime < 60)
{
show_hudmessage(0,"%s^nExceeded %i TK limit and is BANNED for %d minutes", name, g_TKlimit, (g_TKbantime % 1440))
log_message(" %s Exceeded %i TK limit and is BANNED for %d minutes", name, g_TKlimit, (g_TKbantime % 1440))
}
else
{
show_hudmessage(0,"%s^nExceeded %i TK limit and is BANNED for %d hours %d minutes", name, g_TKlimit, (g_TKbantime / 60), (g_TKbantime % 1440))
log_message(" %s Exceeded %i TK limit and is BANNED for %d hours %d minutes", name, g_TKlimit, (g_TKbantime / 60), (g_TKbantime % 1440))
}
userid = get_user_userid(killer)
set_task(0.5,"delayedkick",userid)
}
return PLUGIN_CONTINUE
}
if (g_infomessages)
{
client_print(0,print_chat," %i team kills will get you slayed", g_TKlimit)
if ((g_TKbantime % 1440)==0)
client_print(0,print_chat," %i team kills will get you a %d HOUR ban from %s",g_TKlimit + 1,(g_TKbantime / 60),g_servername)
else if (g_TKbantime < 60)
client_print(0,print_chat," %i team kills will get you a %d MINUTE ban from %s",g_TKlimit + 1,(g_TKbantime % 1440),g_servername)
else
client_print(0,print_chat," %i team kills will get you a %d HOUR %d MINUTE ban from %s",g_TKlimit + 1,(g_TKbantime / 60),(g_TKbantime % 1440),g_servername)
client_print(0,print_chat," Team killers can be forgiven by saying forgivetk")
}
if (g_forgivetype!=0)
{
new menuBody
format(menuBody,191,"Forgive %s's TK?^n^n1. Yes^n2. No^n^n3. Exit^n",name)
new keys = (1<<0)|(1<<1)|(1<<2)
g_FGmenu_killerid = killer
show_menu(victim,keys,menuBody,30)
}
return PLUGIN_CONTINUE
}
public actionFGMenu(id,key)
{
switch(key)
{
case 0:
{
g_TKcount]--
new NameV, NameK
get_user_name(id,NameV,31)
get_user_name(g_FGmenu_killerid,NameK,31)
set_hudmessage(0, 90, 235, 0.05, 0.675, 0, 3.0, 11.0, 0.1, 0.5, 9)
show_hudmessage(0,"%s has forgiven %s's TK.", NameV, NameK)
log_message(" %s has forgiven %s's TK.", NameV, NameK)
}
}
return PLUGIN_HANDLED
}
forgiveNewTK()
{
//these checks are to make sure we don't touch any numbers
//if the player doesn't exist (aka this TK was already forgiven)
if ( LastTKed == 0 || LastTKer == 0 )
return
g_TKcount--
new NameV
get_user_name(LastTKed,NameV,31)
new NameK
get_user_name(LastTKer,NameK,31)
set_hudmessage(0, 90, 235, 0.05, 0.675, 0, 3.0, 11.0, 0.1, 0.5, 9)
show_hudmessage(0,"%s has forgiven %s's TK.", NameV, NameK)
log_message(" %s has forgiven %s's TK.", NameV, NameK)
LastTKed = BeLastTKed
LastTKer = BeLastTKer
BeLastTKed = 0
BeLastTKer = 0
}
forgiveOldTK()
{
//these checks are to make sure we don't touch any numbers
//if the player doesn't exist (aka this TK was already forgiven)
if (BeLastTKed == 0 || BeLastTKer == 0)
return
g_TKcount--
new NameV
get_user_name(BeLastTKed,NameV,31)
new NameK
get_user_name(BeLastTKer,NameK,31)
set_hudmessage(0, 90, 235, 0.05, 0.675, 0, 3.0, 11.0, 0.1, 0.5, 9)
show_hudmessage(0,"%s has forgiven %s's TK.", NameV, NameK)
log_message(" %s has forgiven %s's TK.", NameV, NameK)
BeLastTKed = 0
BeLastTKer = 0
}
public delayedkill(id){
user_kill(id)
}
public delayedkick(userid){
server_cmd("banid %d.0 #%d",g_TKbantime,userid)
server_cmd("writeid")
server_cmd("kick #%d",userid)
} 顶一下
希望有高手帮我翻译一下!万分感激!
页:
[1]