Belzebub

sorting.lua

Mar 5th, 2021 (edited)
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.48 KB | None | 0 0
  1. for i, ply in ipairs(members) do
  2.     ply.online = IsMemberOnline(ply.name)
  3.     ply.playtime = ply.online and (ply.playtime + RefreshTime) or 0
  4.     ply.offline_time = ply.online and 0 or (ply.offline_time + RefreshTime)
  5. end
  6.  
  7. table.sort(members, function(ply1, ply2)
  8.     if ply1.online and not ply2.online then
  9.         return true
  10.     end
  11.  
  12.     if ply1.online and ply2.online then
  13.         return ply1.playtime > ply2.playtime
  14.     else
  15.         return ply1.offline_time > ply2.offline_time
  16.     end
  17.  
  18.     return false
  19. end)
Add Comment
Please, Sign In to add comment