Advertisement
Guest User

Untitled

a guest
Nov 24th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.94 KB | None | 0 0
  1. script_name('CrossHairHack')
  2. script_author('FYP')
  3. script_moonloader(019)
  4. script_description('Get the latest MoonLoader updates from http://blast.hk/moonloader/')
  5. local memory = require 'memory'
  6.  
  7.  
  8. --- Config
  9. alwaysVisible = false -- default: false
  10. useTexture = true -- default: true
  11. crosshairSize = 72 -- default: 72
  12. crosshairColor = {r = 130, g = 235, b = 125, a = 255} -- default: 130, 235, 125, 255
  13. cheatToggle = 'CHH' -- default: CHH
  14. activated = false -- default: false
  15. showGameCrosshairInstantly = false -- default: false
  16.  
  17.  
  18. --- Main
  19. function main()
  20. if showGameCrosshairInstantly then
  21. showCrosshairInstantlyPatch(true)
  22. end
  23.  
  24. while true do
  25. if isPlayerPlaying(playerHandle) and isCharOnFoot(playerPed) then
  26.  
  27. if testCheat(cheatToggle) then
  28. activated = not activated
  29. end
  30.  
  31. if activated then
  32. local camMode = getActiveCamMode()
  33. local camAiming = (camMode == 53 or camMode == 7 or camMode == 8 or camMode == 51)
  34. if alwaysVisible or not (camAiming and (showGameCrosshairInstantly or getCameraTransitionState() ~= 1))
  35. then
  36. local weap = getCurrentCharWeapon(playerPed)
  37. local slot = getWeapontypeSlot(weap)
  38. if slot >= 2 and slot <= 7 then
  39. drawCustomCrosshair(weap == 34 or weap == 35 or weap == 36)
  40. end
  41. end
  42. end
  43.  
  44. end
  45. wait(0)
  46. end
  47. end
  48.  
  49.  
  50. --- Events
  51. function onExitScript()
  52. if showGameCrosshairInstantly then
  53. showCrosshairInstantlyPatch(false)
  54. end
  55. end
  56.  
  57.  
  58. --- Functions
  59. function drawCustomCrosshair(center)
  60. local chx, chy
  61. if center then
  62. local szx, szy = getScreenResolution()
  63. chx, chy = convertWindowScreenCoordsToGameScreenCoords(szx / 2, szy / 2)
  64. else
  65. chx, chy = getCrosshairPosition()
  66. end
  67. if useTexture then
  68. if not crosshairTexture then
  69. loadTextureDictionary('hud')
  70. crosshairTexture = loadSprite('siteM16')
  71. end
  72. local chw, chh = getCrosshairSize(crosshairSize / 4)
  73. useRenderCommands(true)
  74. drawCrosshairSprite(chx - chw / 2, chy - chh / 2, chw, chh)
  75. drawCrosshairSprite(chx + chw / 2, chy - chh / 2, -chw, chh)
  76. drawCrosshairSprite(chx - chw / 2, chy + chh / 2, chw, -chh)
  77. drawCrosshairSprite(chx + chw / 2, chy + chh / 2, -chw, -chh)
  78. else
  79. local chw, chh = getCrosshairSize(crosshairSize / 2)
  80. local r, g, b, a = crosshairColor.r, crosshairColor.g, crosshairColor.b, crosshairColor.a
  81. drawRect(chx, chy, 1.0, chh, r, g, b, a)
  82. drawRect(chx, chy, chh, 1.0, r, g, b, a)
  83. end
  84. end
  85.  
  86. function drawCrosshairSprite(x, y, w, h)
  87. local r, g, b, a = crosshairColor.r, crosshairColor.g, crosshairColor.b, crosshairColor.a
  88. setSpritesDrawBeforeFade(true)
  89. drawSprite(crosshairTexture, x, y, w, h, r, g, b, a)
  90. end
  91.  
  92. function getCrosshairPosition()
  93. local chOff1 = memory.getfloat(0xB6EC10)
  94. local chOff2 = memory.getfloat(0xB6EC14)
  95. local szx, szy = getScreenResolution()
  96. return convertWindowScreenCoordsToGameScreenCoords(szx * chOff2, szy * chOff1)
  97. end
  98.  
  99. function getCrosshairSize(size)
  100. return convertWindowScreenCoordsToGameScreenCoords(size, size)
  101. end
  102.  
  103. function getCamera()
  104. return 0x00B6F028
  105. end
  106.  
  107. function getCameraTransitionState()
  108. return memory.getint8(getCamera() + 0x58)
  109. end
  110.  
  111. function getActiveCamMode()
  112. local activeCamId = memory.getint8(getCamera() + 0x59)
  113. return getCamMode(activeCamId)
  114. end
  115.  
  116. function getCamMode(id)
  117. local cams = getCamera() + 0x174
  118. local cam = cams + id * 0x238
  119. return memory.getint16(cam + 0x0C)
  120. end
  121.  
  122. function showCrosshairInstantlyPatch(enable)
  123. if enable then
  124. if not patch_showCrosshairInstantly then
  125. patch_showCrosshairInstantly = memory.read(0x0058E1D9, 1, true)
  126. end
  127. memory.write(0x0058E1D9, 0xEB, 1, true)
  128. elseif patch_showCrosshairInstantly ~= nil then
  129. memory.write(0x0058E1D9, patch_showCrosshairInstantly, 1, true)
  130. patch_showCrosshairInstantly = nil
  131. end
  132. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement