Advertisement
Guest User

Untitled

a guest
Oct 31st, 2014
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.20 KB | None | 0 0
  1.  
  2. local CONFIG = {}
  3. CONFIG.Ranks = {"moderator"}
  4. CONFIG.VIPRanks = {"donator","vip"}
  5. CONFIG.SlotsReserverd = 2
  6.  
  7. hook.Add("PlayerInitialSpawn","GiveSlot",function(ply)
  8. ply.PlayTime = CurTime()
  9. timer.Simple(3,function()
  10. if(table.HasValue(CONFIG.Ranks,ply:GetUserGroup()) || table.HasValue(CONFIG.VIPRanks,ply:GetUserGroup())) then
  11. file.CreateDir("customRSlot")
  12. if(table.HasValue(CONFIG.Ranks,ply:GetUserGroup())) then
  13. file.Write("customRSlot/"..ply:SteamID64()..".txt","vip")
  14. else
  15. file.Write("customRSlot/"..ply:SteamID64()..".txt","supervip")
  16. end
  17. else
  18. file.Delete("customRSlot/"..ply:SteamID64())
  19. end
  20. end)
  21. end)
  22.  
  23. local function sortByPlayTime(a,b)
  24. return a.PlayTime - CurTime() < b.PlayTime - CurTime()
  25. end
  26.  
  27. hook.Add("CheckPassword","ReserverSlot",function(id,ip,pass,clpass,name)
  28. if(#player.GetAll() >= game.MaxPlayers() - CONFIG.SlotsReserverd) then
  29.  
  30. if(file.Read("customRSlot/"..id..".txt") == nil) then
  31. return false,"Reserved slot."
  32.  
  33. else
  34. if(#player.GetAll() == GetConVar("maxplayers")) then
  35. local tbl = table.sort( player.GetAll(), sortByPlayTime )
  36. for k,v in pairs(tbl) do
  37. if(file.Read("customRSlot/"..v:SteamID64()..".txt") != nil && (file.Read("customRSlot/"..v:SteamID64()..".txt") == "vip" || file.Read("customRSlot/"..v:SteamID64()..".txt") == "supervip")) then
  38. table.RemoveByValue(tbl,v)
  39. end
  40. end
  41. table.Random(tbl):Kick("Kicked for a slot for a donator")
  42. end
  43. end
  44. end
  45. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement