1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88
| #include <sourcemod> #include <sdktools>
new KickLookOnPlayer[MAXPLAYERS+1]; new Handle:kickPlayerTimer[MAXPLAYERS+1] = INVALID_HANDLE;
public Plugin:myinfo= { name = "踢出闲置超时玩家", author = "笨蛋海绵", description = "踢出闲置超时玩家", version = "5.0.0", url = "QQ群:133102253" }
public OnPluginStart() { HookEvent("player_team", Event_PlayerTeam); }
public Action:Event_PlayerTeam(Handle:event, const String:name[], bool:dontBroadcast) { new Client = GetClientOfUserId( GetEventInt(event, "userid" )); new oldteam = GetEventInt(event, "oldteam"); new newteam = GetEventInt(event, "team"); new bool:disconnect = GetEventBool(event, "disconnect"); if (IsValidPlayer(Client) && !disconnect && oldteam != 0) { if(!IsFakeClient(Client)) { if (newteam == 1 && IsClientInGame(Client) && IsPlayerAlive(Client)) { KickLookOnPlayer[Client] = 0; kickPlayerTimer[Client] = CreateTimer(1.0, Timer_KickLookOnPlayer, Client, TIMER_REPEAT); } } } return Plugin_Continue;
}
public Action:Timer_KickLookOnPlayer(Handle:timer, any:Client) { new kicktime; kicktime = 100; if (IsClientInGame(Client) && IsValidPlayer(Client) && !IsFakeClient(Client) && GetClientTeam(Client) == 1 && IsAdminPlayer(Client) == false) { KickLookOnPlayer[Client]++; if (KickLookOnPlayer[Client] >= kicktime) { KickClient(Client, "不允许挂机,被自动踢出,求生之路2联机群:133102253"); KickLookOnPlayer[Client] = 0; KillTimer(timer); } else { PrintHintText(Client, "你正在观看游戏, %d 秒后将被踢出房间 \n按下鼠标左键 或 输入 !join 进入游戏", kicktime - KickLookOnPlayer[Client]); } } else KickLookOnPlayer[Client] = 0, KillTimer(timer); }
stock bool:IsValidPlayer(Client, bool:AllowBot = true, bool:AllowDeath = true) { if (Client < 1 || Client > MaxClients) return false; if (!IsClientConnected(Client) || !IsClientInGame(Client)) return false; if (!AllowBot) { if (IsFakeClient(Client)) return false; }
if (!AllowDeath) { if (!IsPlayerAlive(Client)) return false; } return true; }
stock bool:IsAdminPlayer(Client) { return GetUserFlagBits(Client) ? true : false; }
|