Advertisement
atheon

KCL

May 20th, 2013
3,245
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.49 KB | None | 0 0
  1. --Created by Atheon
  2. --You can find the thread at http://www.mpgh.net/forum/713-garrys-mod-hacks-cheats/669569-keypad-cracker-lua-v2.html#post8138844 for instructions on use
  3. --Please also post bugs/suggestions in this thread
  4.  
  5. local X = -50
  6. local Y = -100
  7.  
  8. local KeyPos = {
  9. {X+5, Y+100, 25, 25, -2.2, 3.45, 1.3, -0},
  10. {X+37.5, Y+100, 25, 25, -0.6, 1.85, 1.3, -0},
  11. {X+70, Y+100, 25, 25, 1.0, 0.25, 1.3, -0},
  12.  
  13. {X+5, Y+132.5, 25, 25, -2.2, 3.45, 2.9, -1.6},
  14. {X+37.5, Y+132.5, 25, 25, -0.6, 1.85, 2.9, -1.6},
  15. {X+70, Y+132.5, 25, 25, 1.0, 0.25, 2.9, -1.6},
  16.  
  17. {X+5, Y+165, 25, 25, -2.2, 3.45, 4.55, -3.3},
  18. {X+37.5, Y+165, 25, 25, -0.6, 1.85, 4.55, -3.3},
  19. {X+70, Y+165, 25, 25, 1.0, 0.25, 4.55, -3.3},
  20.  
  21. {X+5, Y+67.5, 50, 25, -2.2, 4.7, -0.3, 1.6},
  22. {X+60, Y+67.5, 35, 25, 0.3, 1.65, -0.3, 1.6}
  23. }
  24.  
  25. local function FindDisplayText(ent)
  26. if ent.GetDisplayText then
  27. return ent:GetDisplayText()
  28. else
  29. return ent.Entity:GetNetworkedInt("keypad_num")
  30. end
  31. end
  32.  
  33. local function FindStatus(ent)
  34. if ent.GetStatus then
  35. return ent:GetStatus()
  36. elseif ent.Entity:GetNetworkedBool("keypad_access") and ent.Entity:GetNetworkedBool("keypad_showaccess") then
  37. return 1
  38. elseif not ent.Entity:GetNetworkedBool("keypad_access") and ent.Entity:GetNetworkedBool("keypad_showaccess") then
  39. return 2
  40. else
  41. return 0
  42. end
  43. end
  44.  
  45. hook.Add("Think", "Somethingoranotherthatissomething", function()
  46. for k,v in pairs(player.GetAll()) do
  47. local kp = v:GetEyeTrace().Entity
  48. if IsValid(kp) and (string.find(kp:GetClass(), "keypad") and not(string.find(v:GetClass(), "cracker") or string.find(v:GetClass(), "checker"))) and v:EyePos():Distance(kp:GetPos()) <= 70 then
  49. kp.tempCode = kp.tempCode or ""
  50. kp.tempText = kp.tempText or ""
  51. kp.tempStatus = kp.tempStatus or 0
  52.  
  53. if (FindDisplayText(kp) != kp.tempText) or (FindStatus(kp) != kp.tempStatus) then
  54. kp.tempText = FindDisplayText(kp)
  55. kp.tempStatus = FindStatus(kp)
  56.  
  57. local tr = util.TraceLine({
  58. start = v:EyePos(),
  59. endpos = v:GetAimVector() * 32 + v:EyePos(),
  60. filter = v
  61. })
  62.  
  63. local pos = kp:WorldToLocal(tr.HitPos)
  64.  
  65. for i,p in pairs(KeyPos) do
  66. local x = (pos.y - p[5]) / (p[5] + p[6])
  67. local y = 1 - (pos.z + p[7]) / (p[7] + p[8])
  68.  
  69. if (x >= 0 and y >= 0 and x <= 1 and y <= 1) then
  70. if i == 11 then
  71. if kp.tempStatus == 1 then
  72. kp.code = kp.tempCode
  73. kp.tempCode = ""
  74. elseif kp.tempStatus == 2 then
  75. kp.tempCode = ""
  76. end
  77. elseif i == 10 then
  78. kp.tempCode = ""
  79. elseif i > 0 then
  80. kp.tempCode = kp.tempCode..i
  81. end
  82. end
  83. end
  84. end
  85. end
  86. end
  87. end)
  88.  
  89. hook.Add( "HUDPaint", "somethingoranotherthatissomethingelse", function()
  90. local e = LocalPlayer():GetEyeTrace().Entity
  91. if IsValid(e) and string.find(e:GetClass(), "keypad") then
  92. local text = e.code or "Not Found"
  93. draw.WordBox( 8, ScrW() / 2, ScrH() / 2, text, "Default", Color(50,50,75,100), Color(255,255,255,255) )
  94. end
  95.  
  96. for k,v in pairs(ents.GetAll()) do
  97. if IsValid(v) then
  98. if string.find(v:GetClass(), "keypad") and not(string.find(v:GetClass(), "cracker") or string.find(v:GetClass(), "checker")) then
  99. if v != e then
  100. local pos = v:GetPos():ToScreen()
  101. if IsValid(v) and v.code then
  102. draw.RoundedBox( 4, pos.x-5, pos.y-5, 20, 20, Color( 0, 255, 0, 150 ) )
  103. else
  104. draw.RoundedBox( 4, pos.x-5, pos.y-5, 20, 20, Color( 255, 0, 0, 150 ) )
  105. end
  106. end
  107. end
  108. end
  109. end
  110. end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement