Welcome to PlagueFest.com! Log in or Sign up to interact with the Plague Fest community.
  1. Welcome Guest! to interact with the community and gain access to all the site's features.

kicked by console

Discussion in Help Desk started by LadyMoOnLiGht, Jun 24, 2011

  1. Oct 10, 2010
    Posts
    how do you prevent donors/admins from being kicked
    by console when long time in spectator?

    what plugin do this?
  2. Dec 7, 2010
    Posts
    Kyle has written our afk spectator kick program. It does not kick Admins or Donators even if they are in AFK spectate for long periods.
  3. Oct 10, 2010
    Posts
    nothing public?

    so i need wait till mani is updated -.-
  4. Apr 9, 2007
    Posts
    Code:
    #pragma semicolon 1
    
    /* Includes */
    #include <sourcemod>
    
    /* Defines */
    #define PLUGIN_VERSION			"1.3b"
    #define PLUGIN_DESCRIPTION		"A better AFK Manager."
    
    /* Globals */
    new bool:g_bValidClient[MAXPLAYERS+1][2];
    new bool:g_bUseMaxClients;
    
    new Float:g_fClientAbsAngles[MAXPLAYERS+1][3];
    new Float:g_fClientAbsOrigin[MAXPLAYERS+1][3];
    
    new g_iFailedChecks[MAXPLAYERS+1];
    new g_iMaxVisibleClients;
    
    /* Plugin Information */
    public Plugin:myinfo =
    {
    name 		=		"AFK Manager",			// http://www.youtube.com/watch?v=GQQhibVx5eE&hd=1#t=3s
    author		=		"Kyle Sanderson",
    description	=         PLUGIN_DESCRIPTION,
    version		=         PLUGIN_VERSION,
    url			=		"http://SourceMod.net"
    };
    
    public OnPluginStart()
    {
    new Handle:hTemp;
    if((hTemp = FindConVar("sv_visiblemaxplayers")) != INVALID_HANDLE)
    {
    HookConVarChange(hTemp, OnVisibleMaxChange);
    
    if((g_iMaxVisibleClients = GetConVarInt(hTemp)) == -1)
    {
    g_bUseMaxClients = true;
    }
    
    CloseHandle(hTemp);
    }
    else
    {
    LogError("Warning. Unable to find sv_maxvisibleplayers. Using MaxClients instead.");
    g_bUseMaxClients = true;
    }
    }
    
    public OnVisibleMaxChange(Handle:convar, const String:oldValue[], const String:newValue[])
    {
    if(g_bUseMaxClients && (g_iMaxVisibleClients = GetConVarInt(convar)) != -1)
    {
    g_bUseMaxClients = false;
    }
    else
    {
    if(!g_bUseMaxClients)
    {
    g_bUseMaxClients = true;
    }
    }
    }
    
    public OnClientPostAdminCheck(client)
    {
    g_bValidClient[client][0] = !IsFakeClient(client);
    g_bValidClient[client][1] = !CheckCommandAccess(client, "Dvander is awesome.", ADMFLAG_RESERVATION, true);
    }
    
    public OnClientDisconnect_Post(client)
    {	
    if(g_bValidClient[client][0])
    {
    if(g_iFailedChecks[client])
    {
    g_iFailedChecks[client] = 0;
    }
    g_bValidClient[client][0] = false;
    }
    }
    
    public OnMapStart()
    {
    CreateTimer(10.0, RunData, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
    }
    
    public Action:RunData(Handle:Timer)
    {
    GetData();
    ProcessData();
    return Plugin_Handled;
    }
    
    public GetData()
    {
    new bool:Failed[2];
    decl Float:Temp[3];
    for(new i = 1; i <= MaxClients; i++)
    {
    if(g_bValidClient[i][0] && IsPlayerAlive(i))
    {
    GetClientAbsOrigin(i, Temp);
    for(new q; q < 3; q++)
    {
    if(Temp[q] == g_fClientAbsOrigin[i][q])
    {
    if(!Failed[0])
    {
    Failed[0] = true;
    }
    continue;
    }
    Failed[0] = false;
    break;
    }
    
    for(new k; k < 3; k++)
    {
    g_fClientAbsOrigin[i][k] = Temp[k];
    }
    
    GetClientAbsAngles(i, Temp);
    for(new q; q < 3; q++)
    {
    if(Temp[q] == g_fClientAbsAngles[i][q])
    {
    if(!Failed[1])
    {
    Failed[1] = true;
    }
    continue;
    }
    Failed[1] = false;
    break;
    }
    
    for(new k; k < 3; k++)
    {
    g_fClientAbsAngles[i][k] = Temp[k];
    }
    
    if(Failed[0] && Failed[1])
    {
    g_iFailedChecks[i]++;
    }
    else
    {
    if(g_iFailedChecks[i])
    {
    g_iFailedChecks[i] = 0;
    }
    }
    continue;
    }
    
    if(g_iFailedChecks[i])
    {
    g_iFailedChecks[i] = 0;
    }
    }
    }
    
    public ProcessData()
    {
    switch(g_bUseMaxClients)
    {
    case 0:
    {
    if(g_iMaxVisibleClients <= GetClientCount(false))
    {
    KickLongestConnTime();
    }
    }
    
    case 1:
    {
    if(MaxClients <= GetClientCount(false))
    {
    KickLongestConnTime();
    }
    }
    }
    
    
    for(new i = 1; i <= MaxClients; i++)
    {
    if(g_bValidClient[i][0] && g_iFailedChecks[i])
    {
    switch(g_iFailedChecks[i])
    {
    case 20, 21, 22, 23:
    {
    PrintToChat(i, "\x04[AFK Manager]\x03 Warning: You will be moved to spectate in \x04%i\x03 seconds.", (24 - g_iFailedChecks[i]) * 10);
    }
    
    case 24:
    {	
    PrintToChat(i, "\x04[AFK Manager]\x03 You've been moved to Spectator.");
    ChangeClientTeam(i, 1);
    }
    }
    continue;
    }
    }
    }
    
    public KickLongestConnTime()
    {
    new Temp[2], Longest;
    for(new i = 1; i <= MaxClients; i++)
    {
    if(g_bValidClient[i][0] && g_bValidClient[i][1] && g_iFailedChecks[i] && IsClientObserver(i))
    {
    Temp[0] = RoundToFloor(GetClientTime(i));
    if(Temp[0] > Longest > 666)
    {
    Temp[0] = Longest;
    Temp[1] = i;
    }
    }
    }
    
    if(Temp[1])
    {
    PrintToChatAll("\x04[AFK Manager]\x03 Kicking %N (Reserved Slot).", Temp[1]);
    KickClient(Temp[1], "Reserved Slot. Become a Donor at PlagueFest.com");
    }
    }
    http://pastie.org/private/svc3tvbgiupob6l7czjcyw

    This is newer then what's on the servers, if someone wants to update it.
  5. Oct 10, 2010
    Posts
    wow,
    thank you a lot

    we can replace mani more and more
  6. Oct 10, 2010
    Posts
    i keep get kicked by console,
    even trough i have this awesome plugin installed

    on the other side i can get in spec for hours on pF servers

    cannot understand why
  7. Jun 4, 2006
    Posts
    Maybe Kyle's new version is busted, we're still using an older one on our servers. :geek:
  8. Oct 10, 2010
    Posts
    i think kyle provides a solution by putting this in server.cfg

    mp_disable_autokick
    mp_autokick 0

    need to test this tomorrow
  9. Apr 9, 2007
    Posts
    omg :weep:

    Code:
    #pragma semicolon 1
    
    /* Includes */
    #include <sourcemod>
    
    /* Defines */
    #define PLUGIN_VERSION			"1.5b"
    #define PLUGIN_DESCRIPTION		"A better AFK Manager."
    
    /* Globals */
    new bool:g_bValidClient[MAXPLAYERS+1][2];
    new bool:g_bUseMaxClients;
    
    new Float:g_fClientAbsAngles[MAXPLAYERS+1][3];
    new Float:g_fClientAbsOrigin[MAXPLAYERS+1][3];
    
    new g_iFailedChecks[MAXPLAYERS+1];
    new g_iMaxVisibleClients;
    
    /* Plugin Information */
    public Plugin:myinfo =
    {
    name 		=		"AFK Manager",			// http://www.youtube.com/watch?v=GQQhibVx5eE&hd=1#t=3s
    author		=		"Kyle Sanderson",
    description	=         PLUGIN_DESCRIPTION,
    version		=         PLUGIN_VERSION,
    url			=		"http://SourceMod.net"
    };
    
    public OnPluginStart()
    {
    new Handle:hTemp;
    if((hTemp = FindConVar("sv_visiblemaxplayers")) != INVALID_HANDLE)
    {
    HookConVarChange(hTemp, OnVisibleMaxChange);
    
    if((g_iMaxVisibleClients = GetConVarInt(hTemp)) == -1)
    {
    g_bUseMaxClients = true;
    }
    
    CloseHandle(hTemp);
    }
    else
    {
    LogError("Warning. Unable to find sv_maxvisibleplayers. Using MaxClients instead.");
    g_bUseMaxClients = true;
    }
    
    RegAdminCmd("sm_clearafks", ClearAFKs, ADMFLAG_CUSTOM4, "Clears AFK People.");
    
    for(new i = 1; i <= MaxClients; i++)
    {
    if(IsClientInGame(i))
    {
    OnClientPostAdminCheck(i);
    }
    }
    }
    
    public Action:ClearAFKs(client, args)
    {
    new Count;
    ReplyToCommand(client, "\x04[AFK Manager]\x03 Watch Output.");
    for(new i = 1; i <= MaxClients; i++)
    {
    if(g_bValidClient[i][0] && g_bValidClient[i][1] && IsClientObserver(i))
    {
    if(RoundToFloor(GetClientTime(i)) > 666)
    {
    PrintToChatAll("\x04[AFK Manager]\x03 Kicking %N (Reserved Slot).", i);
    KickClient(i, "Reserved Slot. Become a Donor at PlagueFest.com");
    Count++;
    }
    }
    }
    
    switch(Count)
    {
    case 0:
    {
    LogAction(client, -1, "Tried to clear AFKs but no one was kicked.");
    ReplyToCommand(client, "\x04[AFK Manager]\x03 No one was kicked. For shame!");
    }
    
    case 1:
    {
    LogAction(client, -1, "Cleared 1 AFK.");
    ReplyToCommand(client, "\x04[AFK Manager]\x03 1 AFK was kicked. For shame!", Count);
    }
    
    default:
    {
    LogAction(client, -1, "Cleared %i AFKs.", Count);
    ReplyToCommand(client, "\x04[AFK Manager]\x03 %i AFKs were kicked. For shame!", Count);
    }
    }
    
    return Plugin_Handled;
    }
    
    public OnVisibleMaxChange(Handle:convar, const String:oldValue[], const String:newValue[])
    {
    if(g_bUseMaxClients && (g_iMaxVisibleClients = GetConVarInt(convar)) != -1)
    {
    g_bUseMaxClients = false;
    }
    else
    {
    if(!g_bUseMaxClients)
    {
    g_bUseMaxClients = true;
    }
    }
    }
    
    public OnClientPostAdminCheck(client)
    {
    g_bValidClient[client][0] = !IsFakeClient(client);
    g_bValidClient[client][1] = !CheckCommandAccess(client, "Dvander is awesome.", ADMFLAG_RESERVATION, true);
    }
    
    public OnClientDisconnect_Post(client)
    {	
    if(g_bValidClient[client][0])
    {
    if(g_iFailedChecks[client])
    {
    g_iFailedChecks[client] = 0;
    }
    g_bValidClient[client][0] = false;
    }
    }
    
    public OnMapStart()
    {
    CreateTimer(5.0, RunData, _, TIMER_REPEAT | TIMER_FLAG_NO_MAPCHANGE);
    }
    
    public Action:RunData(Handle:Timer)
    {
    HandleInGameAFKs();
    HandleSpectators();
    }
    
    public HandleInGameAFKs()
    {
    new Failed = 2;
    decl Float:Temp[3];
    for(new i = 1; i <= MaxClients; i++)
    {
    if(g_bValidClient[i][0] && IsPlayerAlive(i))
    {
    Failed = 2;
    GetClientAbsOrigin(i, Temp);
    for(new q; q < 3; q++)
    {
    if(!Failed)
    {
    g_fClientAbsOrigin[i][q] = Temp[q];
    continue;
    }
    
    switch((Temp[q] == g_fClientAbsOrigin[i][q]))
    {
    case 1:
    {
    if(!Failed)
    {
    Failed = 1;
    }
    }
    
    default:
    {
    Failed = 0;
    }
    }
    
    g_fClientAbsOrigin[i][q] = Temp[q];
    }
    
    if(!Failed)
    {
    if(g_iFailedChecks[i])
    {
    g_iFailedChecks[i] = 0;
    }
    continue;
    }
    
    GetClientAbsAngles(i, Temp);
    for(new q; q < 3; q++)
    {
    if(!Failed)
    {
    g_fClientAbsAngles[i][q] = Temp[q];
    continue;
    }
    
    switch((Temp[q] == g_fClientAbsAngles[i][q]))
    {
    case 1:
    {
    if(!Failed)
    {
    Failed = 1;
    }
    }
    
    default:
    {
    Failed = 0;
    }
    }
    
    g_fClientAbsAngles[i][q] = Temp[q];
    }
    
    if(Failed)
    {
    switch(++g_iFailedChecks[i])
    {
    case 20, 21, 22, 23:
    {
    PrintToChat(i, "\x04[AFK Manager]\x03 Warning: You will be moved to spectate in \x04%i\x03 seconds.", (24 - g_iFailedChecks[i]) * 5);
    }
    
    case 24:
    {
    PrintToChat(i, "\x04[AFK Manager]\x03 You've been moved to Spectator.");
    ChangeClientTeam(i, 1);
    g_iFailedChecks[i] = 0;
    }
    }
    }
    else
    {
    if(g_iFailedChecks[i])
    {
    g_iFailedChecks[i] = 0;
    }
    }
    
    continue;
    }
    
    if(g_iFailedChecks[i])
    {
    g_iFailedChecks[i] = 0;
    }
    }
    }
    
    public HandleSpectators()
    {
    switch(g_bUseMaxClients)
    {
    case 0:
    {
    if((g_iMaxVisibleClients - 4) <= GetClientCount(false))
    {
    KickLongestConnTime();
    }
    }
    
    case 1:
    {
    if((MaxClients - 4) <= GetClientCount(false))
    {
    KickLongestConnTime();
    }
    }
    }
    }
    
    stock KickLongestConnTime()
    {
    new ClientIndex, Longest[2];
    for(new i = 1; i <= MaxClients; i++)
    {
    if(g_bValidClient[i][0] && g_bValidClient[i][1] && IsClientObserver(i) && (Longest[0] = RoundToFloor(GetClientTime(i)) > Longest[1] > 666))
    {
    Longest[1] = Longest[0];
    ClientIndex = i;
    }
    }
    
    if(ClientIndex)
    {
    PrintToChatAll("\x04[AFK Manager]\x03 Kicking %N (Reserved Slot).", ClientIndex);
    KickClient(ClientIndex, "Reserved Slot. Become a Donor at PlagueFest.com");
    }
    }
    http://pastie.org/pr...3we6ugmbom6135w

    Changed:
    Removed the SDKTools dependency.
    Added a sm_clearafks command (Thanks to Mckay and Akademikz).
    This tries to keep 4 slots free at all times.
    Optimized the loops a bit.
    Changed it to check every 5s instead of every 10s.


    If it's missing on a server, message Secondary (Or Haplo)!