搜索
查看: 3290|回复: 8

急需此插件,谁能帮一下,谢谢!服务器人满自动踢不动

[复制链接]
发表于 2008-11-2 21:00:54 | 显示全部楼层 |阅读模式 来自 中国–山西–晋城
服务器人满自动kick不动的玩家!
人满自动kick旁观玩家!
T拿C4的长时间不动自动丢出C4!(新增加)
当服务器人不满的情况下,会自动把玩家转移到旁观!!
插件里面有注释中文!
可以参照中文修改!
可以旁观的管理员权限!

[color="Red"]源码如下,但发现在1.76b或1.76c下编译完,加载后不起作用.并且加载后.OP通道不能使用,进入时提示"Sorry, HLTV isn't allowed on the full server等"提示. 能不能修改成人不满时也起作用? 且不影响OP通道使用?[PHP]/* 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[] = "[iT无间度] %s 已经被kick,因为他在服务器人满的时候旁观!"
new const g_afk_kick_chat[]  = "[iT无间度] %s 已经被kick,因为他在服务器人满的时候不动,超过服务器所限制的确时间!"
new const g_afktospec_chat[] = "[iT无间度] %s 已经被转换到了旁观,因为他在服务器人满的时候不动,超过服务器所限制的确时间!"

new g_oldangles[33][3]
//new g_afktime[33]
new bool:g_spawned[33] = {true, ...}
// OPTIONS ABOVE

new const g_teamname[2][] = {"TERRORIST", "CT"}

#define MAX_PLAYERS 32
new bool:g_connected[MAX_PLAYERS + 1]
new g_origin[MAX_PLAYERS + 1][3]
new g_afktime[MAX_PLAYERS + 1]
new g_specgametime[MAX_PLAYERS + 1]

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[id] = 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[32], num, i, tchar[2]
        new candidate, candidatetime
        get_players(players, num, "b")
        for (new x; x < num; ++x) {
                i = players[x]

#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[0] == 'U' && get_user_time(i, 1) > IMMUNE_TIME_AFTER_CONNECT) || tchar[0] == '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[3], afktime
        get_players(players, num, "a")
        for (new x; x < num; ++x) {
                i = players[x]
                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[3]
                        get_user_origin(i, newangle)

                        if ( newangle[0] == g_oldangles[0] && newangle[1] == g_oldangles[1] && newangle[2] == g_oldangles[2] ) {
                                g_afktime += CHECK_FREQ
                                check_afktime(i)
                        } else {
                                g_oldangles[0] = newangle[0]
                                g_oldangles[1] = newangle[1]
                                g_oldangles[2] = newangle[2]
                                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[id] > maxafktime) {
                        new name[32]
                        get_user_name(id, name, 31)
                        client_cmd(id,"drop weapon_c4 ")
                }
        }
}
public client_putinserver(id) {
        g_afktime[id] = 0
        return PLUGIN_HANDLED
}

public playerSpawned(id) {
        g_spawned[id] = false
        new sid[1]
        sid[0] = 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[0], g_oldangles[sid[0]])
        g_spawned[sid[0]] = true
        return PLUGIN_HANDLED
}
public task_afk_check() {
        static players[32], num, i, bool:allafk, origin[3]
        for (new a; a < 2; ++a) {
                get_players(players, num, "ae", g_teamname[a])
                allafk = true
                for (new x; x < num; ++x) {
                        i = players[x]
                        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[x]
                        chat_msg(i, g_afktospec_chat)
                        user_to_spec(i, g_afktospec_reason)
                }
        }
}

public event_spectate() {
        new id = read_data(1)
        if (g_connected[id] && !g_specgametime[id])
                g_specgametime[id] = floatround(get_gametime())
}

public event_playteam() {
        new id = read_data(1)
        if (g_connected[id])
                clear_vars(id)
}

public client_disconnect(id) {
        g_connected[id] = false
        clear_vars(id)
}

clear_vars(id) {
        g_origin[id][0] = 0
        g_origin[id][1] = 0
        g_origin[id][2] = 0
        g_afktime[id] = 0
        g_specgametime[id] = 0
}

bool:is_user_afk(id, const origin[3]) {
        return (origin[0] == g_origin[id][0] && origin[1] == g_origin[id][1])
}

chat_msg(id, const text[]) {
        static name[32]
        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)
}

[/PHP]

谁能帮一下忙.谢谢!
 楼主| 发表于 2008-11-4 18:38:13 | 显示全部楼层 来自 中国–山西–晋城

回复: 急需此插件,谁能帮一下,谢谢!服务器人满自动踢不动

:confused:
回复

使用道具 举报

发表于 2008-11-5 02:08:07 | 显示全部楼层 来自 中国–福建–漳州

回复: 急需此插件,谁能帮一下,谢谢!服务器人满自动踢不动

Sorry, HLTV isn't allowed on the full server 的原因是服务器的破解问题。部分服务器的破解会把所有盗版玩家的AUTHID认为是HLTV,从而出现这个问题。你可以把对HLTV的检测去掉,也可以找其它的破解版本。去掉HLTV检测的方法是把 #define HLTV_KICK 这一行注释掉,重新编译插件。
回复

使用道具 举报

 楼主| 发表于 2008-11-6 13:51:32 | 显示全部楼层 来自 中国–山西–晋城

回复: 急需此插件,谁能帮一下,谢谢!服务器人满自动踢不动

Post by Rulzy
Sorry, HLTV isn't allowed on the full server 的原因是服务器的破解问题。部分服务器的破解会把所有盗版玩家的AUTHID认为是HLTV,从而出现这个问题。你可以把对HLTV的检测去掉,也可以找其它的破解版本。去掉HLTV检测的方法是把 #define HLTV_KICK 这一行注释掉,重新编译插件。


按你说的做了,不再提示HLTV这行,但是插件没有明显效果啊? 在1.76b下.也不自动踢除不动玩家,20秒后也不会扔掉C4...都测试过了.无效啊..急需这个插件啊:sweat:
回复

使用道具 举报

发表于 2008-11-6 15:00:07 | 显示全部楼层 来自 中国–四川–南充–阆中市

回复: 急需此插件,谁能帮一下,谢谢!服务器人满自动踢不动



试试这个吧!

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注个册吧

×
回复

使用道具 举报

发表于 2008-11-6 15:05:05 | 显示全部楼层 来自 中国–四川–南充–阆中市

回复: 急需此插件,谁能帮一下,谢谢!服务器人满自动踢不动

无需任何参数~~~直接加载。好像不能T人但是能扔出c4~o(∩_∩)o...哈哈
回复

使用道具 举报

 楼主| 发表于 2008-11-6 23:46:24 | 显示全部楼层 来自 中国–山西–晋城

回复: 急需此插件,谁能帮一下,谢谢!服务器人满自动踢不动

Post by hezhijun22
http://www.dt-club.net/forum/attachment.php?aid=17936

试试这个吧!


这个和我发的一样样的嘛!  不起作用....不能自动踢除不动者为观众,不能在人满的时候规定时间踢除不动者. 也没有相应提示:cold:
回复

使用道具 举报

发表于 2008-11-7 08:59:04 | 显示全部楼层 来自 中国–广东–潮州

回复: 急需此插件,谁能帮一下,谢谢!服务器人满自动踢不动

這個好象以前有人發過了
回复

使用道具 举报

 楼主| 发表于 2008-11-7 11:14:46 | 显示全部楼层 来自 中国–山西–晋城

回复: 急需此插件,谁能帮一下,谢谢!服务器人满自动踢不动

:cold:    找不到能用的啊
回复

使用道具 举报

游客
回复
您需要登录后才可以回帖 登录 | 注个册吧

快速回复 返回顶部 返回列表