125 lines
2.7 KiB
SourcePawn
125 lines
2.7 KiB
SourcePawn
/* Plugin Template generated by Pawn Studio */
|
|
|
|
#include <sourcemod>
|
|
#include <sdktools_functions>
|
|
|
|
new client_points[MAXPLAYERS];
|
|
new spec_points[MAXPLAYERS];
|
|
new Float:client_angels[MAXPLAYERS][3];
|
|
new Handle:cv_pointlimit, Handle:cv_speclimit;
|
|
|
|
public Plugin:myinfo =
|
|
{
|
|
name = "AFK4ever",
|
|
author = "Chefe",
|
|
description = "Simple AFK kicker",
|
|
version = "1.4",
|
|
url = "www.chefgaming.de"
|
|
}
|
|
|
|
public OnPluginStart()
|
|
{
|
|
CreateTimer(60.0, CheckClients, _, TIMER_REPEAT);
|
|
cv_pointlimit = CreateConVar("sm_afk_pointlimit", "50", "Set the maximum point limit a active player can have before he get kicked");
|
|
cv_speclimit = CreateConVar("sm_afk_speclimit", "100", "Set the maximum point limit a spectator can have before he get kicked");
|
|
HookEvent("player_activate", Event_PlayerConnect);
|
|
|
|
AutoExecConfig(true);
|
|
}
|
|
|
|
public Event_PlayerConnect(Handle:event, const String:name[], bool:dontBroadcast)
|
|
{
|
|
new uid = GetEventInt(event, "userid");
|
|
new client = GetClientOfUserId(uid);
|
|
|
|
client_points[client] = 0;
|
|
spec_points[client] = 0;
|
|
}
|
|
|
|
public Action:CheckClients(Handle:timer)
|
|
{
|
|
new i = 1;
|
|
while (i <= GetMaxClients())
|
|
{
|
|
if (IsClientInGame(i) && !IsClientBot(i) && !IsClientAdm(i) && !IsClientReplay(i))
|
|
{
|
|
if (IsClientActive(i) && IsPlayerAlive(i))
|
|
{
|
|
new Float:currentangels[3];
|
|
GetClientEyeAngles(i, currentangels);
|
|
|
|
if (currentangels[0] == client_angels[i][0] && currentangels[1] == client_angels[i][1] && currentangels[2] == client_angels[i][2])
|
|
{
|
|
client_points[i] = client_points[i]+10;
|
|
}
|
|
else if (client_points[i] > 0)
|
|
{
|
|
client_points[i] = client_points[i]-10;
|
|
}
|
|
|
|
spec_points[i] = 0;
|
|
client_angels[i] = currentangels;
|
|
|
|
if (client_points[i] >= GetConVarInt(cv_pointlimit))
|
|
{
|
|
PrintToChatAll("\x04%N\x01 kicked out of the game for been afk too long", i);
|
|
KickClient(i, "You have been kicked due beeing afk");
|
|
}
|
|
}
|
|
else if (!IsClientActive(i))
|
|
{
|
|
spec_points[i] = spec_points[i]+10;
|
|
|
|
if (spec_points[i] >= GetConVarInt(cv_speclimit))
|
|
{
|
|
PrintToChatAll("\x04%N\x01 kicked out of the game for been afk too long", i);
|
|
KickClient(i, "You have been kicked due beeing afk too long");
|
|
}
|
|
}
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
|
|
IsClientBot(client)
|
|
{
|
|
if (IsClientInGame(client))
|
|
{
|
|
new String:auth[255];
|
|
GetClientAuthString(client, auth, sizeof(auth));
|
|
|
|
if (strcmp(auth, "BOT", false) == 0)
|
|
{
|
|
return true;
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
IsClientActive(client)
|
|
{
|
|
new team = GetClientTeam(client);
|
|
|
|
if (team == 2 || team == 3)
|
|
{
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
IsClientAdm(client)
|
|
{
|
|
new AdminId:admid = GetUserAdmin(client);
|
|
if (admid != INVALID_ADMIN_ID)
|
|
{
|
|
return GetAdminFlag(admid, AdminFlag:Admin_Custom1);
|
|
}
|
|
else
|
|
{
|
|
return false;
|
|
}
|
|
} |