PDA

View Full Version : AFK Manager


Asran
08-10-2008, 10:08
Hi,

I just wanted to know if you could post your AFK Manager version plz, I don't want to use the original version made by VEN which requires a free admin slot because I thnik this is a waste... I know that yours doest not need it. thank you.

Cheers!

bmann_420
08-10-2008, 14:16
Its in teh 4.0 beta.

Asran
08-10-2008, 15:16
I don't know how to write a plugin :cry:

Asran
08-10-2008, 15:40
I don't know how to write a plugin :cry:

//AFK Manager
register_event("TeamInfo", "event_spectate", "a", "2=UNASSIGNED", "2=SPECTATOR")
register_event("TeamInfo", "event_playteam", "a", "2=TERRORIST", "2=CT")
set_task(float(AFK_CHECK_INTERVAL), "task_afk_check2", _, _, _, "b")

and:

//----------------------------------------------------------------------------------------------------------
//AFK Manager by VEN
//----------------------------------------------------------------------------------------------------------
g_connected[id] = true

if (get_playersnum(1) <= g_maxplayers - get_pcvar_num(amx_reservation) || get_pcvar_num(afkcheck_allow) || (!(is_user_bot(id))))
return PLUGIN_CONTINUE

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 (get_user_flags(i)&get_immune_access_flag())
continue

get_user_team(i, tchar, 1)
if (((tchar[0] == 'U' && get_user_time(i, 1) > get_pcvar_num(immune_time)) || tchar[0] == 'S') && (!candidatetime || g_specgametime[i] < candidatetime)) {
candidatetime = g_specgametime[i]
candidate = i
}
}

if (candidate) {
chat_msg(candidate, g_spec_kick_chat)
client_kick(candidate)
return PLUGIN_CONTINUE
}

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[i] = 0
g_origin[i] = origin
continue
}

afktime = g_afktime[i]
if (afktime >= get_pcvar_num(max_afktime) && afktime > candidatetime) {
candidatetime = afktime
candidate = i
}
}

if (candidate) {
chat_msg(candidate, g_afk_kick_chat)
client_kick(candidate)
}

return PLUGIN_CONTINUE
}
public task_afk_check2() {

if(!get_pcvar_num(afkcheck_allow))
return

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[i] += AFK_CHECK_INTERVAL
if (g_afktime[i] < get_pcvar_num(max_afktime))
allafk = false
}
else {
g_afktime[i] = 0
g_origin[i] = 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)
}
}
}

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)
}

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, "%L", LANG_PLAYER, text, name)
}

stock client_kick(id, const reason[] = "") {
server_cmd("kick #%d ^"%L^"", get_user_userid(id), reason)
server_exec()
}

stock user_to_spec(id) {
user_kill(id, 1)
engclient_cmd(id, "jointeam", "6")
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Player Spawn Event
//============================================= ============================================= ================
public event_fm_DispatchSpawned(id) {

if(HasPermGod[id])
fm_set_user_godmode(id,1)

if(HasPermNoclip[id])
fm_set_user_noclip(id,1)

if ( get_pcvar_num(deadchat)==1 ) {
if (is_user_connected(id) && fm_get_speak(id) != SPEAK_MUTED )
fm_set_speak(id, SPEAK_NORMAL)
}
return PLUGIN_CONTINUE
}

bmann_420
08-10-2008, 15:55
I dont know what your asking?

I thought you wanted the super with the afk

Brad
08-10-2008, 16:17
Happy not being you in this thread, bmann.

bmann_420
08-10-2008, 16:18
lol, why ty very much their brad

Asran
08-10-2008, 16:36
I just need the afk manager plugin you revised and not the entire amx_super ... :wink:

bmann_420
08-10-2008, 17:01
I dont have it

Brad
08-11-2008, 08:53
Asran, I've written another AFK management type plugin. It's called, Bad Camper (http://forums.alliedmods.net/showthread.php?t=18452). Might be something you'd like.

Asran
08-12-2008, 11:02
hi, thanks for your suggestion but I just need a simple afk manager plugin...

bmann_420
08-15-2008, 12:37
Sorry I lost my internet for a while, and im on it at work. If I can I might have it somewhere when i segregated it to add it to the super, ill see when I get some time k? :D

Asran
08-15-2008, 15:20
Oki ! thanks anyway