local font = renderCreateFont("arial", 10, 12)
local memory = require "memory"
local ffi = require 'ffi'
local func = ffi.cast("void(__thiscall*)(void*, float, float, float, float, float*, float*)", 0x514970)
local this = ffi.cast("void*", 0xB6F028)
function getAmmoInClip()
local pointer = getCharPointer(playerPed)
local weapon = getCurrentCharWeapon(playerPed)
local slot = getWeapontypeSlot(weapon)
local cweapon = pointer + 0x5A0
local current_cweapon = cweapon + slot * 0x1C
return memory.getuint32(current_cweapon + 0x8)
end
function main()
while true do
wait(0)
local sw, sh = getScreenResolution()
local ammoinclip = getAmmoInClip()
if isKeyDown(0x02) then
local barWidth = (ammoinclip) * 5
local text = tostring(ammoinclip)
local textWidth = #text * 6
local textHeight = 20
local posX, posY = convert3DCoordsToScreen(get_crosshair_position())
renderDrawBox(posX - barWidth / 2, posY + 30, barWidth, textHeight, 0xFF000000)
renderFontDrawText(font, text, posX - textWidth / 2, posY + 30, -1)
end
end
end
function get_crosshair_position()
local vec_out = ffi.new("float[3]")
local tmp_vec = ffi.new("float[3]")
func(this, 15.0, tmp_vec[0], tmp_vec[1], tmp_vec[2], tmp_vec, vec_out)
return vec_out[0], vec_out[1], vec_out[2]
end