XZTablets

ic3wolf ESP

Jul 9th, 2020 (edited)
368
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.87 KB | None | 0 0
  1. local Players = game:GetService'Players';
  2. local RunService = game:GetService'RunService';
  3. local HttpService = game:GetService'HttpService';
  4. local LocalPlayer = Players.LocalPlayer;
  5. local Camera = workspace.CurrentCamera;
  6.  
  7. local uESP = {
  8. 'Made by ic3w0lf';
  9. Enabled = true;
  10. Settings = {
  11. Box3D = true;
  12. DrawBox = true;
  13. DrawDistance = true;
  14. DrawNames = true;
  15. DrawTracers = true;
  16. MaxDistance = 10000;
  17. RefreshRate = 100;
  18. TextSize = 18;
  19. TextOutline = true;
  20. VisibilityCheck = false;
  21.  
  22. TeamColor = Color3.new(0, 1, 0);
  23. EnemyColor = Color3.new(1, 0, 0);
  24. };
  25. RenderList = {};
  26. RenderingCache = {};
  27. LastTick = 0;
  28. };
  29.  
  30. local Active = {};
  31.  
  32. shared.ESPAPIName = shared.ESPAPIName or HttpService:GenerateGUID(false);
  33.  
  34. local function Set(t, i, v)
  35. t[i] = v;
  36. end
  37.  
  38. local function Combine(...)
  39. local Output = {};
  40. for i, v in pairs{...} do
  41. if typeof(v) == 'table' then
  42. table.foreach(v, function(i, v)
  43. Output[i] = v;
  44. end)
  45. end
  46. end
  47. return Output
  48. end
  49.  
  50. function NewDrawing(InstanceName)
  51. local Instance = Drawing.new(InstanceName);
  52. return (function(Properties)
  53. for i, v in pairs(Properties) do
  54. pcall(Set, Instance, i, v);
  55. end
  56. return Instance;
  57. end)
  58. end
  59.  
  60. function IsTeam(Player)
  61. if Player == LocalPlayer then return true; end
  62. if Player.Neutral and LocalPlayer.Neutral then
  63. return true;
  64. end
  65. if Player.TeamColor == LocalPlayer.TeamColor then
  66. return true;
  67. end
  68. return false;
  69. end
  70.  
  71. local DrawingTypes = {
  72. Text = true;
  73. Line = true;
  74. Square = true;
  75. Circle = true;
  76. Triangle = true;
  77. Image = true;
  78. }
  79.  
  80. function CleanDrawings(Table, Cache)
  81. Cache = Cache or {};
  82. if Cache[Table] or typeof(Table) ~= 'table' then return end
  83. Cache[Table] = true;
  84. for i, v in pairs(Table) do
  85. if typeof(v) == 'table' then
  86. local mt = getmetatable(v);
  87. if mt and DrawingTypes[mt.__type] then
  88. v:Remove();
  89. end
  90. end
  91. CleanDrawings(v, Cache);
  92. end
  93. end
  94.  
  95. local Box = {};
  96.  
  97. local Colors = {
  98. Color3.new(1, 0, 0);
  99. Color3.new(0, 1, 0);
  100. Color3.new(0, 0, 1);
  101. Color3.new(1, 0, 1);
  102. Color3.new(1, 1, 0);
  103. Color3.new(0, 1, 1);
  104. }
  105.  
  106. function Box.new(Instance)
  107. local Box = {
  108. Instance = Instance;
  109. Cache = {};
  110. Lines = {};
  111. Was3D = uESP.Settings.Box3D;
  112. };
  113.  
  114. function Box:Update(Properties) -- a lot of shorthand code im sorry
  115. local Properties = Properties or {};
  116.  
  117. local Lines = self.Lines or {};
  118. local Instance = (self.Instance.ClassName == 'Model') and self.Instance or ((self.Instance.Parent.ClassName == 'Model') and self.Instance.Parent or self.Instance);
  119.  
  120. if Instance == nil then
  121. self:Remove();
  122. end
  123.  
  124. local Color = Properties.Color or Color3.new(1, 1, 1);
  125.  
  126. local Properties = Combine({
  127. Transparency = 1;
  128. Thickness = 3;
  129. Color = Color;
  130. Visible = true;
  131. }, Properties);
  132.  
  133. local Position, Size;
  134.  
  135. if Instance.ClassName == 'Model' then
  136. Position, Size = Instance:GetBoundingBox();
  137. elseif Instance:IsA'BasePart' then
  138. Position, Size = Instance.CFrame, Instance.Size;
  139. else
  140. return;
  141. end
  142.  
  143. if not uESP.Settings.Box3D and self.Was3D then
  144. self.Was3D = false;
  145. CleanDrawings(Lines);
  146. Lines = {};
  147. elseif uESP.Settings.Box3D and not self.Was3D then
  148. self.Was3D = true;
  149. CleanDrawings(Lines);
  150. Lines = {};
  151. end
  152.  
  153. if Size.X < 16 and Size.Y < 16 and Size.Z < 16 then
  154. if uESP.Settings.Box3D then
  155. local Positions = {};
  156.  
  157. Size = Size / 2;
  158. local Minimum, Maximum = -Size, Size
  159.  
  160. local Corners = { -- https://www.unknowncheats.me/forum/counterstrike-global-offensive/175021-3d-box-esp.html
  161. [0] = CFrame.new(Minimum.x, Minimum.y, Minimum.z);
  162. [1] = CFrame.new(Minimum.x, Maximum.y, Minimum.z);
  163. [2] = CFrame.new(Maximum.x, Maximum.y, Minimum.z);
  164. [3] = CFrame.new(Maximum.x, Minimum.y, Minimum.z);
  165. [4] = CFrame.new(Minimum.x, Minimum.y, Maximum.z);
  166. [5] = CFrame.new(Minimum.x, Maximum.y, Maximum.z);
  167. [6] = CFrame.new(Maximum.x, Maximum.y, Maximum.z);
  168. [7] = CFrame.new(Maximum.x, Minimum.y, Maximum.z);
  169. }
  170.  
  171. for i, v in pairs(Corners) do
  172. local SP = Camera:WorldToViewportPoint((Position * v).p);
  173. Positions[i] = Vector2.new(SP.X, SP.Y);
  174. end
  175.  
  176. for i = 1, 4 do
  177. Lines[i] = Lines[i] or {};
  178.  
  179. Lines[i][1] = Lines[i][1] or NewDrawing'Line'(Properties);
  180. Lines[i][2] = Lines[i][2] or NewDrawing'Line'(Properties);
  181. Lines[i][3] = Lines[i][3] or NewDrawing'Line'(Properties);
  182.  
  183. Lines[i][1].Color = Color;
  184. Lines[i][2].Color = Color;
  185. Lines[i][3].Color = Color;
  186.  
  187. Lines[i][1].From = Positions[i - 1];
  188. Lines[i][1].To = Positions[i % 4];
  189.  
  190. Lines[i][2].From = Positions[i - 1];
  191. Lines[i][2].To = Positions[i + 3];
  192.  
  193. Lines[i][3].From = Positions[i + 3];
  194. Lines[i][3].To = Positions[i % 4 + 4];
  195. end
  196. else
  197. local Positions = {};
  198.  
  199. Size = Size / 2;
  200. local Minimum, Maximum = -Size, Size
  201.  
  202. local Corners = {
  203. CFrame.new(Maximum.x, Maximum.y, 0);
  204. CFrame.new(-Maximum.x, Maximum.y, 0);
  205. CFrame.new(Minimum.x, Minimum.y, 0);
  206. CFrame.new(-Minimum.x, Minimum.y, 0);
  207. }
  208.  
  209. for i, v in pairs(Corners) do
  210. local SP = Camera:WorldToViewportPoint((Position * v).p);
  211. Positions[i] = Vector2.new(SP.X, SP.Y);
  212. end
  213.  
  214. Lines[1] = Lines[1] or {};
  215. -- these stupid [1]'s are there because i'm too lazy to make a check if box is 2d or 3d even tho its easy/shrug
  216. Lines[1][1] = Lines[1][1] or NewDrawing'Line'(Properties);
  217. Lines[1][2] = Lines[1][2] or NewDrawing'Line'(Properties);
  218. Lines[1][3] = Lines[1][3] or NewDrawing'Line'(Properties);
  219. Lines[1][4] = Lines[1][4] or NewDrawing'Line'(Properties);
  220.  
  221. Lines[1][1].Color = Color;
  222. Lines[1][2].Color = Color;
  223. Lines[1][3].Color = Color;
  224. Lines[1][4].Color = Color;
  225.  
  226. Lines[1][1].From = Positions[1];
  227. Lines[1][1].To = Positions[2];
  228.  
  229. Lines[1][2].From = Positions[2];
  230. Lines[1][2].To = Positions[3];
  231.  
  232. Lines[1][3].From = Positions[3];
  233. Lines[1][3].To = Positions[4];
  234.  
  235. Lines[1][4].From = Positions[4];
  236. Lines[1][4].To = Positions[1];
  237. end
  238.  
  239. self.Lines = Lines;
  240. end
  241. end
  242.  
  243. function Box:SetVisible(boolean)
  244. for i, v in pairs(self.Lines) do
  245. for _, Line in pairs(v) do
  246. Line.Visible = boolean;
  247. end
  248. end
  249. end
  250.  
  251. function Box:Remove()
  252. for i, v in pairs(self.Lines) do
  253. for _, Line in pairs(v) do
  254. Line.Visible = false;
  255. Line:Remove();
  256. end
  257. end
  258.  
  259. self.Update = function () end;
  260. end
  261.  
  262. return setmetatable(Box, {
  263. __tostring = function()
  264. return 'Box';
  265. end;
  266. });
  267. end
  268.  
  269. function uESP:Toggle()
  270. self.Enabled = not self.Enabled;
  271. end
  272.  
  273. function uESP:UpdateSetting(Key, Value)
  274. if Settings[Key] ~= nil and typeof(Settings[Key]) == typeof(Value) then -- prevent setting shit like boolean to integer
  275. Settings[Key] = Value;
  276. end
  277. end
  278.  
  279. function uESP:AddToRenderList(Instance, ...)
  280. if typeof(Instance) ~= 'Instance' then return end
  281. if not Instance:IsA'BasePart' then return end
  282.  
  283. rawset(self.RenderList, Instance, {...});
  284. end
  285.  
  286. function uESP:DrawInstance(Instance, Properties)
  287. Properties = Properties or {};
  288.  
  289. --
  290. end
  291.  
  292. function uESP:DrawPlayer(Player)
  293. if Active[Player] then return false; end -- prevent retarded clones of drawings
  294.  
  295. Active[Player] = true;
  296.  
  297. local Character = Player.Character;
  298.  
  299. if not Character or not Character:IsDescendantOf(workspace) then return end
  300. if Player == LocalPlayer then return end;
  301.  
  302. local Cache = uESP.RenderingCache[Character] or {};
  303.  
  304. Cache.Box = Cache.Box or Box.new(Character);
  305. Cache.NameTag = Cache.NameTag or NewDrawing'Text'{
  306. Center = true;
  307. Outline = uESP.Settings.TextOutline;
  308. Size = uESP.Settings.TextSize;
  309. Visible = true;
  310. };
  311. Cache.DistanceTag = Cache.DistanceTag or NewDrawing'Text'{
  312. Center = true;
  313. Outline = uESP.Settings.TextOutline;
  314. Size = uESP.Settings.TextSize;
  315. Visible = true;
  316. };
  317. Cache.Tracer = Cache.Tracer or NewDrawing'Line'{
  318. Transparency = 1;
  319. Thickness = 2;
  320. };
  321.  
  322. uESP.RenderingCache[Character] = Cache;
  323.  
  324. if uESP.Enabled and Player.Character:FindFirstChild'Head' then
  325. local Head = Character.Head;
  326. local Humanoid = Character:FindFirstChildOfClass'Humanoid';
  327. if Head then
  328. local ScreenPosition, Visible = Camera:WorldToViewportPoint(Head.Position + Vector3.new(0, Head.Size.Y / 2, 0));
  329. local Color = not Player.Neutral and Player.TeamColor.Color or (IsTeam(Player) and uESP.Settings.TeamColor or uESP.Settings.EnemyColor);
  330.  
  331. if Humanoid and Humanoid.Health < 1 then
  332. Visible = false;
  333. end
  334.  
  335. if Visible then
  336. if uESP.Settings.DrawNames then
  337. LocalPlayer.NameDisplayDistance = 0;
  338. Cache.NameTag.Color = Color;
  339. Cache.NameTag.Position = Vector2.new(ScreenPosition.X, ScreenPosition.Y);
  340. Cache.NameTag.Text = Player.Name;
  341. Cache.NameTag.Visible = true;
  342. else
  343. LocalPlayer.NameDisplayDistance = 100;
  344. Cache.NameTag.Visible = false;
  345. end
  346. if uESP.Settings.DrawDistance then
  347. Cache.DistanceTag.Color = Color3.new(1, 1, 1);
  348. Cache.DistanceTag.Position = Vector2.new(ScreenPosition.X, ScreenPosition.Y + (Cache.NameTag.TextBounds.Y));
  349. Cache.DistanceTag.Text = '[' .. math.floor(ScreenPosition.Z) .. ' Studs]';
  350. Cache.DistanceTag.Visible = true;
  351. else
  352. Cache.DistanceTag.Visible = false;
  353. end
  354. if uESP.Settings.DrawTracers then
  355. Cache.Tracer.From = Vector2.new(Camera.ViewportSize.X / 2, Camera.ViewportSize.Y / 2);
  356. Cache.Tracer.To = Vector2.new(ScreenPosition.X, ScreenPosition.Y);
  357. Cache.Tracer.Color = Color;
  358. Cache.Tracer.Visible = true;
  359. else
  360. Cache.Tracer.Visible = false;
  361. end
  362. if ScreenPosition.Z >= 1.5 then
  363. Cache.Box:SetVisible(true);
  364. else
  365. Cache.Box:SetVisible(false);
  366. end
  367. Cache.Box:Update({Color = Color});
  368. else
  369. Cache.NameTag.Visible = false;
  370. Cache.DistanceTag.Visible = false;
  371. Cache.Tracer.Visible = false;
  372. Cache.Box:SetVisible(false);
  373. end
  374. end
  375. else
  376. Cache.NameTag.Visible = false;
  377. Cache.DistanceTag.Visible = false;
  378. Cache.Tracer.Visible = false;
  379. Cache.Box:SetVisible(false);
  380. end
  381.  
  382. uESP.RenderingCache[Character] = Cache;
  383. Active[Player] = false;
  384. end
  385.  
  386. function uESP:Draw()
  387. if uESP.Settings.RefreshRate > 1 and (tick() - uESP.LastTick) <= (uESP.Settings.RefreshRate / 1000) then
  388. return;
  389. end
  390.  
  391. for i, v in pairs(Players:GetPlayers()) do
  392. uESP:DrawPlayer(v);
  393. end
  394. for i, v in pairs(self.RenderList) do
  395. uESP:DrawInstance(i, v);
  396. end
  397.  
  398. for i, v in pairs(self.RenderingCache) do -- Remove trash
  399. if not i:IsDescendantOf(game) then
  400. CleanDrawings(self.RenderingCache[i]);
  401. self.RenderingCache[i] = nil;
  402. end
  403. end
  404. end
  405.  
  406. function uESP:Unload()
  407. RunService:UnbindFromRenderStep(shared.ESPAPIName);
  408. CleanDrawings(uESP.RenderingCache);
  409. uESP = {};
  410. end
  411.  
  412. pcall(function() shared.uESP:Unload() end);
  413.  
  414. wait(1/4);
  415.  
  416. shared.uESP = uESP;
  417.  
  418. RunService:BindToRenderStep(shared.ESPAPIName, 1, function()
  419. uESP:Draw();
  420. end);
Add Comment
Please, Sign In to add comment