Raised This Month: $ Target: $400
 0% 

AFK Manager


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Asran
Member
Join Date: Aug 2007
Location: France
Old 08-10-2008 , 15:40   Re: AFK Manager
Reply With Quote #4

I don't know how to write a plugin

Quote:
//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:

Quote:
//----------------------------------------------------------------------------------------------------------
//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
}
__________________
Asran is offline
 



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 19:40.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode