Advertisement
Guest User

Untitled

a guest
Mar 17th, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.47 KB | None | 0 0
  1. timer.Create("AskForRank",5,0,function()
  2.  
  3. local tbl = {}
  4. for v,i in pairs(player.GetAll()) do
  5. if not i:IsBot() and not i:GetDataValue("rank") then
  6. table.insert(tbl,i:SteamID())
  7. end
  8. end
  9.  
  10. if table.Count(tbl)>0 then
  11.  
  12. net.Start("SS.AskForRank")
  13. net.WriteTable(tbl)
  14. net.SendToServer()
  15.  
  16. end
  17.  
  18.  
  19. end)
  20.  
  21. net.Receive("SS.AskForRank",function()
  22.  
  23. local tbl = net.ReadTable()
  24. for v,i in pairs(tbl) do
  25.  
  26. local ply = SS:FindSteamID(i.steamid)
  27. if ply and IsValid(ply) then
  28. ply:SetDataValue("rank",i.value)
  29. print(ply,ply:GetDataString("rank"))
  30. end
  31.  
  32. end
  33.  
  34.  
  35. end)
  36.  
  37. SS.Joined = false
  38. local queue = {}
  39.  
  40. net.Receive("SS.SendVariable",function()
  41.  
  42. local steamid = net.ReadString()
  43.  
  44. local tbl = net.ReadTable()
  45. local key = tbl.key
  46. local val = tbl.val
  47.  
  48. SS:GiveVariable(steamid,key,val)
  49.  
  50. end)
  51.  
  52. function SS:GiveVariable(steamid,key,val,times)
  53.  
  54. local ply = SS:FindSteamID(steamid)
  55. if not ply or not IsValid(ply) then
  56. table.insert(queue,{
  57. steamid = steamid,
  58. key = key,
  59. val = val,
  60. times = times and (times+1) or 1
  61. })
  62. return
  63. end
  64.  
  65. print(ply,key,val)
  66. ply:SetDataValue(key,val)
  67.  
  68. end
  69. local max = 20//wanna make sure it can get through safely.. if not chuck it
  70. timer.Create("VariableQueue",.5,0,function()//do one every .5 seconds
  71. local e = queue
  72. queue = {}//empty
  73. for v,i in pairs(e) do
  74. if i.times>max then continue end//chuck it
  75. SS:GiveVariable(i.steamid,i.key,i.val,i.times)
  76. end
  77. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement