Advertisement
Guest User

Untitled

a guest
Feb 8th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.07 KB | None | 0 0
  1.  
  2. if(SERVER) then
  3.  
  4. net.Receive("weapon_smg1", function(len, cl)
  5.  
  6. local which = net.ReadUInt(4);
  7.  
  8. local t = net.ReadTable();
  9. local a = function(bool, msg)
  10. if(not bool) then print(msg or "assertion failed"); debug.Trace(); end
  11. end
  12.  
  13. print(which);
  14. PrintTable(t);
  15. print(len / 8);
  16.  
  17. if(which == 0) then
  18.  
  19. a(t.t == t);
  20. a(t[1] == "a");
  21. a(t[2] == "b");
  22. a(t[3] == true);
  23. a(t[4] == 3.14);
  24. a(t[7] == Vector(1,2,3));
  25. a(t[8] == Angle(3,4,2));
  26. a(t.q == Matrix{ { 1,1,1,1 }, { 1,1,1,1 }, { 1,1,1,1 }, { 1,1,1,1 } });
  27. a(t.cc == "cc");
  28.  
  29. elseif(which == 1) then
  30.  
  31. t = t[1];
  32.  
  33. a(t ~= nil);
  34.  
  35. a(t.t == t);
  36. a(t[1] == "a");
  37. a(t[2] == "b");
  38. a(t[3] == true);
  39. a(t[4] == 3.14);
  40. a(t[7] == Vector(1,2,3));
  41. a(t[8] == Angle(3,4,2));
  42. a(t.q == Matrix{ { 1,1,1,1 }, { 1,1,1,1 }, { 1,1,1,1 }, { 1,1,1,1 } });
  43. a(t.cc == "cc");
  44.  
  45. elseif(which == 2) then
  46.  
  47. for k,v in pairs(t) do
  48.  
  49. assert(k == v, tostring(k) .. " ~= " .. tostring(v));
  50.  
  51. end
  52.  
  53. end
  54. print"\n"
  55.  
  56. end)
  57.  
  58. else
  59.  
  60. local t = {};
  61. t.t = t;
  62. t[1] = "a"
  63. t[2] = "b";
  64. t[3] = true;
  65. t[4] = 3.14;
  66. t[7] = Vector(1,2,3);
  67. t[8] = Angle(3,4,2);
  68. t.q = Matrix{ { 1,1,1,1 }, { 1,1,1,1 }, { 1,1,1,1 }, { 1,1,1,1 } };
  69. t.cc = "cc";
  70. print(t.q);
  71.  
  72. print("recursive1", pcall(function()
  73. net.Start"weapon_smg1"
  74.  
  75. net.WriteUInt(0, 4);
  76. net.WriteTable(t);
  77.  
  78.  
  79. net.SendToServer()
  80. end));
  81.  
  82.  
  83. print("recursive2", pcall(function()
  84. net.Start"weapon_smg1"
  85.  
  86. net.WriteUInt(1, 4);
  87.  
  88. net.WriteTable{t}
  89.  
  90. net.SendToServer();
  91. end));
  92.  
  93.  
  94. print("2=2", pcall(function()
  95. net.Start"weapon_smg1"
  96.  
  97. net.WriteUInt(2, 4);
  98.  
  99. net.WriteTable{[2] = 2, [3] = 3, [4.14141414] = 4.14141414};
  100.  
  101. net.SendToServer();
  102. end));
  103.  
  104.  
  105. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement