|
发表于 2005-10-20 09:36:49
|
显示全部楼层
|阅读模式
来自 中国–北京–北京–朝阳区
- /*
- *
- * Author: BlackFlagg based on Cheesy Peteza generic AFK kicker
- * Date: 06-July-2004
- *
- *
- * Description: Drop bomb when player is AFK for 30 secs
- *
- * Cvars:
- * mp_afktime 20 Time a player is allowed to be AFK in seconds before they drop bomb
- * They time is only accumulated while they are alive.
- * mp_afkminplayers 1 Minimum number of players required .
- *
- *
- * Requirements: AMXModX
- *
- *
- */
- #include <amxmodx>
- #define MIN_AFK_TIME 20 // I use this incase stupid admins accidentally set mp_afktime to something silly.
- #define CHECK_FREQ 5 // This is also the warning message frequency.
- new g_oldangles[33][3]
- new g_afktime[33]
- new bool:g_spawned[33] = {true, ...}
- public plugin_init() {
- register_plugin("AFK Bomb Drop","1.0","BlackFlagg")
- register_cvar("afk_version", "1.0a", FCVAR_SERVER|FCVAR_EXTDLL|FCVAR_SPONLY)
- register_cvar("mp_afktime", "20") // Drop bomb if AFK longer than this time
- 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")
- }
- 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[i]) {
- new newangle[3]
- get_user_origin(i, newangle)
- if ( newangle[0] == g_oldangles[i][0] && newangle[1] == g_oldangles[i][1] && newangle[2] == g_oldangles[i][2] ) {
- g_afktime[i] += CHECK_FREQ
- check_afktime(i)
- } else {
- g_oldangles[i][0] = newangle[0]
- g_oldangles[i][1] = newangle[1]
- g_oldangles[i][2] = newangle[2]
- g_afktime[i] = 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) {
- log_amx("cvar mp_afktime %i is too low. Minimum value is %i.", 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
- }
复制代码
mp_afktime 30 //设订多少秒不动仍出C4
mp_afkminplayers 1 //最少需要几位玩家开启此功能 |
|