Hello.
Thanks for the plugin Brad, it works great on my server, although i have a few minor problems with it.
First problem is that a player won't get kicked from spec as if he had an immunity or something. The chat message abouth him being kicked appears every seconds, yet he stays on a server. I have altered the source though for a plugin to switch AFK to spec insted of kicking him, but it doesn't seem to be an issue.
But just in case, here's the altered part of a code:
Code:
public handle_time_elapsed(id, eventType)
{
new warningFlag = get_pcvar_num(g_cvar_immunityWarning);
new maxSeconds, elapsedSeconds, eventImmunity, showWarning;
if (eventType == EVENT_JOIN)
{
maxSeconds = get_pcvar_num(g_cvar_joinTime);
elapsedSeconds = g_timeJoin[id];
eventImmunity = has_flag(id, g_joinImmunity);
showWarning = eventImmunity ? warningFlag & EVENT_JOIN : 1;
}
else if (eventType == EVENT_SPEC)
{
maxSeconds = get_pcvar_num(g_cvar_specTime);
elapsedSeconds = g_timeSpec[id];
eventImmunity = has_flag(id, g_specImmunity);
showWarning = eventImmunity ? warningFlag & EVENT_SPEC : 1;
}
else if (eventType == EVENT_AFK)
{
maxSeconds = get_pcvar_num(g_cvar_afkTime);
elapsedSeconds = g_timeAFK[id];
eventImmunity = has_flag(id, g_afkImmunity);
showWarning = eventImmunity ? warningFlag & EVENT_AFK : 1;
}
else return;
new warningStartSeconds = maxSeconds - get_pcvar_num(g_cvar_warningTime);
if (elapsedSeconds >= maxSeconds && eventType == EVENT_AFK)
{
// if players have immunity for this event abort
if (eventImmunity) return;
// get the correct message formats for this event type
new msgReason[32], msgAnnounce[32];
switch (eventType)
{
case EVENT_AFK:
{
copy(msgReason, 31, "KICK_AFK_REASON");
copy(msgAnnounce, 31, "KICK_AFK_ANNOUNCE");
}
}
new maxTime[128];
get_time_length(id, maxSeconds, timeunit_seconds, maxTime, 127);
new kick2ip[32];
get_pcvar_string(g_cvar_kick2ip, kick2ip, sizeof(kick2ip)-1);
client_cmd(id,"kill; wait; jointeam 6");
g_timeAFK[id] = 0;
// announce the kick to the rest of the world
new players[32], playerCnt;
get_players(players, playerCnt, "c");
new playerName[32];
get_user_name(id, playerName, 31);
new playerID;
for (new playerIdx = 0; playerIdx < playerCnt; playerIdx++)
{
playerID = players[playerIdx];
get_time_length(playerID, maxSeconds, timeunit_seconds, maxTime, 127);
client_print(playerID, print_chat, "[PBK] %L", playerID, msgAnnounce, playerName, maxTime);
}
}
else if (elapsedSeconds >= maxSeconds)
{
// if players have immunity for this event abort
if (eventImmunity) return;
// get the correct message formats for this event type
new msgReason[32], msgAnnounce[32];
switch (eventType)
{
case EVENT_JOIN:
{
copy(msgReason, 31, "KICK_JOIN_REASON");
copy(msgAnnounce, 31, "KICK_JOIN_ANNOUNCE");
}
case EVENT_SPEC:
{
copy(msgReason, 31, "KICK_SPEC_REASON");
copy(msgAnnounce, 31, "KICK_SPEC_ANNOUNCE");
}
}
new maxTime[128];
get_time_length(id, maxSeconds, timeunit_seconds, maxTime, 127);
new kick2ip[32];
get_pcvar_string(g_cvar_kick2ip, kick2ip, sizeof(kick2ip)-1);
if (kick2ip[0] == 0)
{
// kick the player into the nether
server_cmd("kick #%d %L", get_user_userid(id), id, msgReason, maxTime);
}
else
{
// kick the player into another server
new kick2port[16];
get_pcvar_string(g_cvar_kick2port, kick2port, sizeof(kick2port)-1);
client_cmd(id, "connect %s:%s", kick2ip, kick2port);
}
// announce the kick to the rest of the world
new players[32], playerCnt;
get_players(players, playerCnt, "c");
new playerName[32];
get_user_name(id, playerName, 31);
new playerID;
for (new playerIdx = 0; playerIdx < playerCnt; playerIdx++)
{
playerID = players[playerIdx];
get_time_length(playerID, maxSeconds, timeunit_seconds, maxTime, 127);
client_print(playerID, print_chat, "[PBK] %L", playerID, msgAnnounce, playerName, maxTime);
}
// log the kick
new logFlags = get_pcvar_num(g_cvar_log);
if (logFlags)
{
get_time_length(0, maxSeconds, timeunit_seconds, maxTime, 127);
new logText[128];
format(logText, 127, "%L", LANG_SERVER, msgAnnounce, "", maxTime);
// remove the single space that not providing a name added
trim(logText);
create_log_entry(id, "PBK", logFlags, logText);
}
}
Could it be that the client somehow blocks the connect command, as i'm using kick2ip feature?
*edit*
Apparently it does, so if anyone experiencing this problems using kick2ip feature, try changing this part of the code:
Code:
client_cmd(id, "connect %s:%s", kick2ip, kick2port);
into this:
Code:
client_cmd(id, "Connect %s:%s", kick2ip, kick2port);
And another problem that's been reported to me by a few players is that sometimes a "ghost player" appears in game. He is invisible, you can't see him on a scoreboard, but the round won't end untill he's dead. I mean if this ghost player is a terrorist, and CT's have killed every other terrorist, they have to come to a T's spawn, find this invisible player somehow and kill him in order for a round to end.
Now i'm not 100% positive that it's PBK that causing this bug, but i haven't seen it happening untill i installed PBK, and i remember playing on another server that used PBK as well, and this bug happend there too. It is rare, but it might get pretty annoying if there's no admin on a server to kick this ghost.
But, anyway, this plugin seems to be the best AFK manager out here nonetheless, thanks again.