Advertisement
Mister_Stefan

manele

Feb 9th, 2021
152
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Global Variables
  2. const hitgroup = ['Head', 'Neck', 'Pelvis', 'Body', 'Thorax', 'Chest', 'Upper chest', 'Left thigh', 'Right thigh', 'Left calf', 'Right calf', 'Left foot', 'Right foot', 'Left hand', 'Right hand', 'Left upper arm', 'Left forearm', 'Right upper arm', 'Right forearm'];
  3.  
  4. const activeLogs = [];
  5.  
  6. const ragebotTarget = {};
  7.  
  8. UI.AddSubTab(["Config", "SUBTAB_MGR"], "Hitlogs");
  9. UIpath = ["Config", "SUBTAB_MGR", "Hitlogs", "SHEET_MGR", "Hitlogs"];
  10. destination = "Config", "SUBTAB_MGR", "Hitlogs", "SHEET_MGR", "Hitlogs";
  11. UI.AddColorPicker(UIpath, "Color");
  12.  
  13. //Check if color is unset
  14. var color = UI.GetColor([destination, "Color"]);
  15. if (color[0] === 0 && color[1] === 0 && color[2] === 0 && color[3] === 0)
  16.     UI.SetColor("MISC", "JAVASCRIPT", "Script Items", "Hitlog Color", [255, 0, 0, 255]);
  17.  
  18.  
  19. /**
  20. * Description returns width of multi colored text lines
  21. * @param {array}   lines  (0 == color, 1 == text);
  22. */
  23.  
  24. function getMultiColorTextSize(lines) {
  25.     var w = 0;
  26.     for (var x = 0; x < lines.length; x++) {
  27.         w += Render.TextSize(lines[x][1], 8)[0];
  28.     }
  29.     return w;
  30. }
  31.  
  32. /**
  33. * Description draws Multiple text with different color
  34. * @param {int}      x      x cords
  35. * @param {number}   y      y cords
  36. * @param {array}   lines  (0 == color, 1 == text);
  37. */
  38. function drawMultiColorText(x, y, lines) {
  39.     var x_pad = 0;
  40.     for (var i = 0; i < lines.length; i++) {
  41.         const line = lines[i];
  42.         const text = line[1];
  43.         var color = line[0];
  44.         if (typeof line[0] == "number") {
  45.             color = UI.GetColor([destination, "Color"]);
  46.         }
  47.         Render.String(x + x_pad, y, 0, text, color, 8);
  48.         const w = Render.TextSize(text, 8)[0];
  49.         x_pad += w;
  50.     }
  51. }
  52.  
  53.  
  54. /**
  55. * Description Displays the log detail on screen
  56. * @param {int}      count      Index of the log.
  57. * @param {number}   layer      Log Details .
  58. */
  59. function showLog(count, layer) {
  60.     const text = layer.text;
  61.     const w = getMultiColorTextSize(text);
  62.     const expiry = Global.Realtime() < layer.delay;
  63.     const y = 45 + (42 * (count - 1));
  64.     const h = 12;
  65.     const logW = (w < 150) ? 150 : (w + 15);
  66.     const speed = 3;
  67.     const layerSize = 15;
  68.  
  69.     layer.firstLayer = expiry ? Math.min(layer.firstLayer + logW * 0.025, logW + layerSize) : Math.max(layer.firstLayer - speed, 0);
  70.     layer.secondLayer = expiry ? Math.min(layer.secondLayer + logW * 0.015, logW) : Math.max(layer.secondLayer - 2 * speed, 0);
  71.     var color = UI.GetColor([destination, "Color"]);
  72.     Render.FilledRect(layer.firstLayer - layer.firstLayer, y, layer.firstLayer, h + 20, color);
  73.     Render.FilledRect(layer.secondLayer - layer.secondLayer, y, layer.secondLayer, h + 20, [16, 0, 0, 255]);
  74.  
  75.     drawMultiColorText(layer.secondLayer - logW + 5, y + 3 + 6, text);
  76.     activeLogs[count] = layer;
  77.     if (layer.secondLayer === 0) {
  78.         activeLogs.splice(count, 1);
  79.     }
  80. }
  81.  
  82. function onDraw() {
  83.     for (var x = 0; x < activeLogs.length; x++) {
  84.         showLog(x, activeLogs[x]);
  85.     }
  86. }
  87.  
  88. function onRagebotFire() {
  89.     ragebotTarget[Entity.GetName(Event.GetInt("target_index"))] = {
  90.         hitgroup: hitgroup[Event.GetInt("hitbox")],
  91.         hc: Event.GetInt("hitchance"),
  92.         safepoint: Event.GetInt("safepoint"),
  93.         exploit: Event.GetInt("exploit")
  94.     }
  95. }
  96.  
  97. function onPlayerHurt() {
  98.     const attacker = Entity.GetEntityFromUserID(Event.GetInt("attacker"));
  99.     const victim = Entity.GetEntityFromUserID(Event.GetInt("userid"));
  100.     const victimName = Entity.GetName(victim);
  101.     if (attacker === Entity.GetLocalPlayer() && victim !== Entity.GetLocalPlayer()) {
  102.         const target = ragebotTarget[victimName];
  103.         if (target != null) {
  104.             const hitMessage = [
  105.                 [[255, 255, 255, 255], "Hit "],
  106.                 [0, victimName.substring(0, 28)],
  107.                 [[255, 255, 255, 255], " in the "],
  108.                 [0, target.hitgroup],
  109.                 [[255, 255, 255, 255], " for "],
  110.                 [0, Event.GetInt("dmg_health").toString()],
  111.                 [[255, 255, 255, 255], " damage ("],
  112.                 [0, Event.GetInt("health") + " health remaining"],
  113.                 [[255, 255, 255, 255], ")"]
  114.             ];
  115.             activeLogs.push({
  116.                     text: hitMessage,
  117.                     delay: Global.Realtime() + 5,
  118.                     firstLayer: 0,
  119.                     secondLayer: 0
  120.                 }
  121.             );
  122.         }
  123.     }
  124. }
  125.  
  126.  
  127. //Register Callbacks
  128. Global.RegisterCallback("Draw", "onDraw");
  129. Global.RegisterCallback("ragebot_fire", "onRagebotFire");
  130. Global.RegisterCallback("player_hurt", "onPlayerHurt");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement