Advertisement
Laine_prikol

NEWORK

Jul 29th, 2017
367
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 6.86 KB | None | 0 0
  1. script_name('hBAR')
  2. script_author('hnnssy and Laine_prikol')
  3. require("config.hbarcfg")
  4. local memory = require "memory"
  5. local weapons = {
  6.     FIST = 0,
  7.     BRASSKNUCKLES = 1,
  8.     GOLFCLUB = 2,
  9.     NIGHTSTICK = 3,
  10.     KNIFE = 4,
  11.     BASEBALLBAT = 5,
  12.     SHOVEL = 6,
  13.     POOLCUE = 7,
  14.     KATANA = 8,
  15.     CHAINSAW = 9,
  16.     PURPLEDILDO = 10,
  17.     WHITEDILDO = 11,
  18.     WHITEVIBRATOR = 12,
  19.     SILVERVIBRATOR = 13,
  20.     FLOWERS = 14,
  21.     CANE = 15,
  22.     GRENADE = 16,
  23.     TEARGAS = 17,
  24.     MOLOTOV = 18,
  25.     COLT45 = 22,
  26.     SILENCED = 23,
  27.     DESERTEAGLE = 24,
  28.     SHOTGUN = 25,
  29.     SAWNOFFSHOTGUN = 26,
  30.     COMBATSHOTGUN = 27,
  31.     UZI = 28,
  32.     MP5 = 29,
  33.     AK47 = 30,
  34.     M4 = 31,
  35.     TEC9 = 32,
  36.     RIFLE = 33,
  37.     SNIPERRIFLE = 34,
  38.     ROCKETLAUNCHER = 35,
  39.     HEATSEEKER = 36,
  40.     FLAMETHROWER = 37,
  41.     MINIGUN = 38,
  42.     SATCHELCHARGE = 39,
  43.     DETONATOR = 40,
  44.     SPRAYCAN = 41,
  45.     FIREEXTINGUISHER = 42,
  46.     CAMERA = 43,
  47.     NIGHTVISION = 44,
  48.     THERMALVISION = 45,
  49.     PARACHUTE = 46
  50. }
  51.  
  52. local id = weapons
  53. weapons.names = {
  54.     [id.FIST] = 'Fist',
  55.     [id.BRASSKNUCKLES] = 'Brass Knuckles',
  56.     [id.GOLFCLUB] = 'Golf Club',
  57.     [id.NIGHTSTICK] = 'Nightstick',
  58.     [id.KNIFE] = 'Knife',
  59.     [id.BASEBALLBAT] = 'Baseball Bat',
  60.     [id.SHOVEL] = 'Shovel',
  61.     [id.POOLCUE] = 'Pool Cue',
  62.     [id.KATANA] = 'Katana',
  63.     [id.CHAINSAW] = 'Chainsaw',
  64.     [id.PURPLEDILDO] = 'Purple Dildo',
  65.     [id.WHITEDILDO] = 'Dildo',
  66.     [id.WHITEVIBRATOR] = 'Vibrator',
  67.     [id.SILVERVIBRATOR] = 'Silver Vibrator',
  68.     [id.FLOWERS] = 'Flowers',
  69.     [id.CANE] = 'Cane',
  70.     [id.GRENADE] = 'Grenade',
  71.     [id.TEARGAS] = 'Tear Gas',
  72.     [id.MOLOTOV] = 'Molotov Cocktail',
  73.     [id.COLT45] = '9mm',
  74.     [id.SILENCED] = 'Silenced 9mm',
  75.     [id.DESERTEAGLE] = 'Desert Eagle',
  76.     [id.SHOTGUN] = 'Shotgun',
  77.     [id.SAWNOFFSHOTGUN] = 'Sawnoff Shotgun',
  78.     [id.COMBATSHOTGUN] = 'Combat Shotgun',
  79.     [id.UZI] = 'Micro Uzi',
  80.     [id.MP5] = 'MP5',
  81.     [id.AK47] = 'AK-47',
  82.     [id.M4] = 'M4',
  83.     [id.TEC9] = 'Tec-9',
  84.     [id.RIFLE] = 'Country Rifle',
  85.     [id.SNIPERRIFLE] = 'Sniper Rifle',
  86.     [id.ROCKETLAUNCHER] = 'RPG',
  87.     [id.HEATSEEKER] = 'HS Rocket',
  88.     [id.FLAMETHROWER] = 'Flamethrower',
  89.     [id.MINIGUN] = 'Minigun',
  90.     [id.SATCHELCHARGE] = 'Satchel Charge',
  91.     [id.DETONATOR] = 'Detonator',
  92.     [id.SPRAYCAN] = 'Spraycan',
  93.     [id.FIREEXTINGUISHER] = 'Fire Extinguisher',
  94.     [id.CAMERA] = 'Camera',
  95.     [id.NIGHTVISION] = 'Night Vis Goggles',
  96.     [id.THERMALVISION] = 'Thermal Goggles',
  97.     [id.PARACHUTE] = 'Parachute'
  98. }
  99.  
  100. function getAmmoInClip()
  101.   local struct = getCharPointer(playerPed)
  102.   local prisv = struct + 0x0718
  103.   local prisv = memory.getint8(prisv, false)
  104.   local prisv = prisv * 0x1C
  105.   local prisv2 = struct + 0x5A0
  106.   local prisv2 = prisv2 + prisv
  107.   local prisv2 = prisv2 + 0x8
  108.   local ammo = memory.getint32(prisv2, false)
  109.   return ammo
  110. end
  111.  
  112. --- Config
  113. istate = true
  114.  
  115.  
  116. --- Main
  117. function main()
  118.   while not isSampAvailable() do wait(1000) end
  119.   initialize()
  120.   while true do
  121.     wait(0)
  122.     if isPlayerPlaying(playerHandle) and istate then
  123.       local posX, posY = getScreenResolution()
  124.       if not isCharInAnyCar(playerPed) then
  125.         drawOnfootBar()
  126.       else
  127.         drawInCarBar()
  128.       end
  129.     end
  130.   end
  131. end
  132.  
  133. function initialize()
  134.    displayHud(false)
  135.   ifont = renderCreateFont(cfg_font_name, 12, cfg_flags)
  136.   fontWeapon = renderCreateFont(cfg_font_name, 9, cfg_flags)
  137.   fontOther = renderCreateFont(cfg_font_name, 8, cfg_flags)
  138. end
  139.  
  140. function drawOnfootBar()
  141.   local playerID, playerName, playerPing, playerHP, playerAP, playerLvl, playerMoney,
  142.     playerWeapon, playerAmmo, playerInterior = getPlayerOnFootInfo()
  143.   local playerposX, playerposY, playerposZ = getCharCoordinates(playerPed)
  144.   local clips = getAmmoInClip()
  145.   local havewant, wantlevel = storeWantedLevel(playerPed)
  146.   local text = string.format("HP: %d | Armor %d", playerHP, playerAP)
  147.       if havewant == true then
  148.       local textMoney = string.format("$%d | Wanted: %d", playerMoney, wantlevel)
  149.       else
  150.       local textMoney = string.format("$%d", playerMoney)
  151.       end
  152.   local textWeapon = string.format("Weapon: %s %d/%d", weapons.names[playerWeapon],clips, playerAmmo)
  153.   local textInfo = string.format("ID: %d | Ping: %d | Score: %d", playerID, playerPing,playerLvl)
  154.   local screenW, screenH = getScreenResolution()
  155.   local fontlen = renderGetFontDrawTextLength(ifont, text)
  156.   local posX = math.ceil((screenW / 2) - (fontlen / 2))
  157.   renderFontDrawText(ifont, text, posX + 460, screenH - 870, cfg_text_color)
  158.   renderFontDrawText(ifont, textMoney, posX + 460, screenH - 850, cfg_text_color)
  159.   renderFontDrawText(fontWeapon, textWeapon, posX + 460, screenH - 830, cfg_text_color)
  160.     renderFontDrawText(fontOther, textInfo, posX + 460, screenH - 810, cfg_text_color)
  161. end
  162.  
  163. function drawInCarBar()
  164.   local playerID, playerName, playerPing, playerHP, playerAP, playerLvl, playerMoney,
  165.     playerWeapon, playerAmmo, vehHP, vehID = getPlayerInCarInfo()
  166.   local playerposX, playerposY, playerposZ = getCharCoordinates(playerPed)
  167.   local havewant, wantlevel = storeWantedLevel(playerPed)
  168.    local clips = getAmmoInClip()
  169.   local text = string.format("HP/Veh: %d/%d | Armor %d", playerHP, vehHP, playerAP)
  170.   local textMoney = string.format("$%d", playerMoney)
  171.   local textWeapon = string.format("Weapon: %s %d/%d", weapons.names[playerWeapon],clips, playerAmmo)
  172.   local textInfo = string.format("ID: %d | Ping: %d | Score: %d | Wanted: %d", playerID, playerPing,playerLvl,wantlevel)
  173.   local screenW, screenH = getScreenResolution()
  174.   local fontlen = renderGetFontDrawTextLength(ifont, text)
  175.   local posX = math.ceil((screenW / 2) - (fontlen / 2))
  176.   renderFontDrawText(ifont, text, posX + 460, screenH - 870, cfg_text_color)
  177.   renderFontDrawText(ifont, textMoney, posX + 460, screenH - 850, cfg_text_color)
  178.   renderFontDrawText(fontWeapon, textWeapon, posX + 460, screenH - 830, cfg_text_color)
  179.     renderFontDrawText(fontOther, textInfo, posX + 460, screenH - 810, cfg_text_color)
  180. end
  181.  
  182.  
  183.  
  184. --- Functions
  185. function getPlayerOnFootInfo()
  186.   local _, playerID = sampGetPlayerIdByCharHandle(playerPed)
  187.   local playerHP = getCharHealth(playerPed)
  188.   local playerWeapon = getCurrentCharWeapon(playerPed)
  189.  
  190.   return playerID,
  191.     sampGetPlayerNickname(playerID),
  192.     sampGetPlayerPing(playerID),
  193.     playerHP,
  194.     getCharArmour(playerPed),
  195.     sampGetPlayerScore(playerID),
  196.     getPlayerMoney(playerHandle),
  197.     playerWeapon,
  198.     getAmmoInCharWeapon(playerPed, playerWeapon),
  199.     getActiveInterior()
  200. end
  201.  
  202. function getPlayerInCarInfo()
  203.   local _, playerID = sampGetPlayerIdByCharHandle(playerPed)
  204.   local playerHP = getCharHealth(playerPed)
  205.   local playerWeapon = getCurrentCharWeapon(playerPed)
  206.   local playerCar = storeCarCharIsInNoSave(playerPed)
  207.   local _, vehId = sampGetVehicleIdByCarHandle(playerCar)
  208.  
  209.   return playerID,
  210.     sampGetPlayerNickname(playerID),
  211.     sampGetPlayerPing(playerID),
  212.     playerHP,
  213.     getCharArmour(playerPed),
  214.     sampGetPlayerScore(playerID),
  215.     getPlayerMoney(playerHandle),
  216.     playerWeapon,
  217.     getAmmoInCharWeapon(playerPed, playerWeapon),
  218.     getCarHealth(playerCar),
  219.     vehId
  220. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement