y543685085 发表于 2008-11-8 01:52:37

望高手帮忙改改插件 人满自动KICK玩家

这是论坛上发的 人满自动KICK玩家的插件

希望高人帮忙改下 人满自动KICK NO-SXE玩家,并且把NO-SXE玩家转移到指定的服务器,这样可以保证多F的人气 .

希望高手帮忙 谢谢..

/* AMX Mod X
*   Full Server Idler Kicker (+last AFK to Spec)
*
* (c) Copyright 2006 by VEN
*
* This file is provided as is (no warranties)
*
*   DESCRIPTION
*       The concept of this plugin is "don't clean the full server from idlers unless
*       new connection try". By idlers i mean HLTV/unassigned/spectator/AFK users.
*       I created this plugin because i don't like the goal of all other plugins that
*       deal with idelrs using the conditions which is strictly based on the idle time.
*       This plugin isn't using the idle time as primary condition. So how it work?
*       Let's say the new user is trying to connect to the full server. Normally he
*       would be kicked unless he have a slot reservation access, but this plugin
*       able to clean the slot for this user if it will find the idler on the server.
*       Firstly it will try to find and kick HLTV (this can be disabled). Secondly -
*       the most idle unassigned/spectator user. Though the plugin will never kick
*       a client with immunity access (this can be configured) or the user who is just
*       connected and still unassigned - it will "immune" him for a few seconds
*       (this can be configured). And lastly the plugin will try to find and kick
*       the most idle alive AFK player (min. idle time that required to mark a player
*       as AFK can be configured). Also as a bonus feature the plugin able to detect
*       when all alive players in the same team are AFK. Usually it would be just
*       a single AFK player who is the only one alive player in a team. In this case
*       to avoid waiting/seaching AFK player(s) by other player(s) the plugin will move
*       him/them to the spectators. Later such AFK users can be kicked from Spectators
*       following the steeps that listed above. Requirement for full server kicker are
*       at least one free reserverved slot (controlled by amx_reservation AMXX's CVAR).
*/
#include <amxmodx>
#define PLUGIN_NAME "Full Server Idler Kicker"
#define PLUGIN_VERSION "0.1"
#define PLUGIN_AUTHOR "VEN"
// OPTIONS BELOW
// 定义那些权限的人可以旁观
#define IMMUNE_SPEC_ACCESS ADMIN_VOTE
// connected user's unassigned kick immunity time
#define IMMUNE_TIME_AFTER_CONNECT 5
#define MIN_AFK_TIME 20// I use this incase stupid admins accidentally set mp_afktime to something silly.
#define CHECK_FREQ 5
//不动的时间检测的间隔
#define AFK_CHECK_INTERVAL 8
// 最大允许不动时间(秒)
#define MAX_ALLOWED_AFK_TIME 60
// 是否开启对HLTV的检测
#define HLTV_KICK
#if defined HLTV_KICK
new const g_hltv_kick_reason[] = "Sorry, HLTV isn't allowed on the full server"
#endif
// 被kick人显示的信息
new const g_spec_kick_reason[] = "不好意思,服务器已满,不可以有旁观的!"
new const g_afk_kick_reason[]= "你已经被kick,因为你在服务器人满的时候不动的时间超过所限制的时间!"
// 把玩家转换到旁观,显示信息
new const g_afktospec_reason[] = "\y你已经被转移^n 到旁观!"
// 显示的信息! 可以自己定义!
new const g_spec_kick_chat[] = " %s 已经被kick,因为他在服务器人满的时候旁观!"
new const g_afk_kick_chat[]= " %s 已经被kick,因为他在服务器人满的时候不动,超过服务器所限制的确时间!"
new const g_afktospec_chat[] = " %s 已经被转换到了旁观,因为他在服务器人满的时候不动,超过服务器所限制的确时间!"
new g_oldangles
//new g_afktime
new bool:g_spawned = {true, ...}
// OPTIONS ABOVE
new const g_teamname[] = {"TERRORIST", "CT"}
#define MAX_PLAYERS 32
new bool:g_connected
new g_origin
new g_afktime
new g_specgametime
new g_maxplayers
new g_pcvar_reservation
public plugin_init() {
register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR)
register_event("TeamInfo", "event_spectate", "a", "2=UNASSIGNED", "2=SPECTATOR")
register_event("TeamInfo", "event_playteam", "a", "2=TERRORIST", "2=CT")
register_cvar("mp_afktime", "10") // 多长时间不动丢出C4.
register_cvar("mp_afkminplayers", "1") // at least this many players on the server
set_task(float(CHECK_FREQ),"checkPlayers",_,_,_,"b")
register_event("ResetHUD", "playerSpawned", "be")
g_maxplayers = get_maxplayers()
g_pcvar_reservation = get_cvar_pointer("amx_reservation")
set_task(float(AFK_CHECK_INTERVAL), "task_afk_check", _, _, _, "b")
}
public client_connect(id) {
g_connected = true
if (get_playersnum(1) <= g_maxplayers - get_pcvar_num(g_pcvar_reservation))
return
#if defined HLTV_KICK
if (is_user_hltv(id)) {
client_kick(id, g_hltv_kick_reason)
return
}
#endif
static players, num, i, tchar
new candidate, candidatetime
get_players(players, num, "b")
for (new x; x < num; ++x) {
i = players
#if defined IMMUNE_SPEC_ACCESS
if (get_user_flags(i) & IMMUNE_SPEC_ACCESS)
   continue
#endif
if (is_user_hltv(i)) {
#if defined HLTV_KICK
   client_kick(i, g_hltv_kick_reason)
   return
#else
   continue
#endif
}
get_user_team(i, tchar, 1)
if (((tchar == 'U' && get_user_time(i, 1) > IMMUNE_TIME_AFTER_CONNECT) || tchar == 'S') && (!candidatetime || g_specgametime < candidatetime)) {
   candidatetime = g_specgametime
   candidate = i
}
}
if (candidate) {
chat_msg(candidate, g_spec_kick_chat)
client_kick(candidate, g_spec_kick_reason)
return
}
static origin, afktime
get_players(players, num, "a")
for (new x; x < num; ++x) {
i = players
get_user_origin(i, origin)
if (!is_user_afk(i, origin)) {
   g_afktime = 0
   g_origin = origin
   continue
}
afktime = g_afktime
if (afktime >= MAX_ALLOWED_AFK_TIME && afktime > candidatetime) {
   candidatetime = afktime
   candidate = i
}
}
if (candidate) {
chat_msg(candidate, g_afk_kick_chat)
client_kick(candidate, g_afk_kick_reason)
}
}
public checkPlayers() {
for (new i = 1; i <= get_maxplayers(); i++) {
if (is_user_alive(i) && is_user_connected(i) && !is_user_bot(i) && !is_user_hltv(i) && g_spawned) {
   new newangle
   get_user_origin(i, newangle)
   if ( newangle == g_oldangles && newangle == g_oldangles && newangle == g_oldangles ) {
    g_afktime += CHECK_FREQ
    check_afktime(i)
   } else {
    g_oldangles = newangle
    g_oldangles = newangle
    g_oldangles = newangle
    g_afktime = 0
   }
}
}
return PLUGIN_HANDLED
}
check_afktime(id) {
new numplayers = get_playersnum()
new minplayers = get_cvar_num("mp_afkminplayers")
   
if (numplayers >= minplayers) {
new maxafktime = get_cvar_num("mp_afktime")
if (maxafktime < MIN_AFK_TIME) {
   maxafktime = MIN_AFK_TIME
   set_cvar_num("mp_afktime", MIN_AFK_TIME)
}
if (g_afktime > maxafktime) {
   new name
   get_user_name(id, name, 31)
   client_cmd(id,"drop weapon_c4 ")
}
}
}
public client_putinserver(id) {
g_afktime = 0
return PLUGIN_HANDLED
}
public playerSpawned(id) {
g_spawned = false
new sid
sid = id
set_task(0.75, "delayedSpawn",_, sid, 1) // Give the player time to drop to the floor when spawning
return PLUGIN_HANDLED
}
public delayedSpawn(sid[]) {
get_user_origin(sid, g_oldangles])
g_spawned] = true
return PLUGIN_HANDLED
}
public task_afk_check() {
static players, num, i, bool:allafk, origin
for (new a; a < 2; ++a) {
get_players(players, num, "ae", g_teamname)
allafk = true
for (new x; x < num; ++x) {
   i = players
   get_user_origin(i, origin)
   if (is_user_afk(i, origin)) {
    g_afktime += AFK_CHECK_INTERVAL
    if (g_afktime < MAX_ALLOWED_AFK_TIME)
   allafk = false
   }
   else {
    g_afktime = 0
    g_origin = origin
    allafk = false
   }
}
if (!allafk)
   continue
for (new x; x < num; ++x) {
   i = players
   chat_msg(i, g_afktospec_chat)
   user_to_spec(i, g_afktospec_reason)
}
}
}
public event_spectate() {
new id = read_data(1)
if (g_connected && !g_specgametime)
g_specgametime = floatround(get_gametime())
}
public event_playteam() {
new id = read_data(1)
if (g_connected)
clear_vars(id)
}
public client_disconnect(id) {
g_connected = false
clear_vars(id)
}
clear_vars(id) {
g_origin = 0
g_origin = 0
g_origin = 0
g_afktime = 0
g_specgametime = 0
}
bool:is_user_afk(id, const origin) {
return (origin == g_origin && origin == g_origin)
}
chat_msg(id, const text[]) {
static name
get_user_name(id, name, 31)
client_print(0, print_chat, text, name)
}
stock client_kick(id, const reason[] = "") {
server_cmd("kick #%d ^"%s^"", get_user_userid(id), reason)
server_exec()
}
stock user_to_spec(id, const reason[] = "") {
user_kill(id, 1)
engclient_cmd(id, "jointeam", "6")
show_menu(id, 1023, reason)
}

y543685085 发表于 2008-11-12 02:25:58

回复: 望高手帮忙改改插件 人满自动KICK玩家

没人帮帮我吗 ?......
页: [1]
查看完整版本: 望高手帮忙改改插件 人满自动KICK玩家