Forum
 
  CS2D
 CS2D  Scripts
 
Scripts  Herausfinden ob jemand AFK ist
 Herausfinden ob jemand AFK ist Herausfinden ob jemand AFK ist
 Herausfinden ob jemand AFK ist
3 replies 
  1
 1  
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
2
3
4
5
6
7
8
9
10
11
12
13
14
-- optional minTime - minimum idle time in seconds
-- returns table with AFK players, IDs are stored as values
function getPlayersAfk(minTime)
   local afkPlayers = {}
   local minTime = minTime or tonumber(game("mp_idletime"))
   local players = players(0, "table")
   for i = 1, #players do
      if player(players[i], "idle") > minTime then
         table.insert(afkPlayers, players[i])
      end
   end
   return afkPlayers
end
 mp_idletime is the regular server setting to control the idle timer. If minTime is not set by you, the default time will be compared.
 mp_idletime is the regular server setting to control the idle timer. If minTime is not set by you, the default time will be compared. player has the "idle" parameter and returns time in seconds. However, it is defined as "idle: idle time (no movement) in seconds" so I think it will trigger on any dead player/spectator, even when they actively chat.
 player has the "idle" parameter and returns time in seconds. However, it is defined as "idle: idle time (no movement) in seconds" so I think it will trigger on any dead player/spectator, even when they actively chat.Not tested, up to you
 
 --- Tut mir Leid, ich dachte du hättest die Frage auf Englisch gestellt...
 
  
  ich muss mal schauen ob die specs auch als idle gelten wenn sie nichts machen
So oder so wäre es aber besser Zeile 6 einfach zu ersetzen durch
local players = player(0,"tableliving")
So werden überhaupt nur lebende Spieler überprüft.
 
  1
 1  
 
 Offline
 Offline