local font = renderCreateFont('Consolas', 12, 5)
local warningFont = renderCreateFont('EuropaNuovaBold', 18, 5)
local memory = require 'memory'
local state = false
local weaponsData = {
[24] = 3, -- Deagle
[28] = 20, -- Uzi
[26] = 2, -- Sawnoff Shotgun
[31] = 10, -- M4
}
function main()
while not isSampAvailable() do wait(100) end
sampRegisterChatCommand('ptr', function ()
state = not state
end)
while true do
wait(0)
if (isKeyDown(0x01) or isKeyDown(0x02)) and state and not isFistInHand() then
local AmmoInClip = getAmmoInClip()
local weapon = getCurrentCharWeapon(1)
local ammo = getAmmoInCharWeapon(1, weapon)
local posX, posY = getCrosshairPositionOnScreen()
local color = {0xFFFFFFFF, 0xFFFF0000}
local minBullets = 0
if weaponsData[weapon] then
minBullets = weaponsData[weapon]
end
local textColor = AmmoInClip >= minBullets and color[1] or color[2]
local text = string.format("%d-%d", ammo-AmmoInClip, AmmoInClip)
local length = renderGetFontDrawTextLength(font, text)
renderFontDrawText(font, text, posX-length/2, posY-40, textColor)
if AmmoInClip < minBullets then
renderFontDrawText(warningFont, "Перезарядись!", posX-75, posY-205, 0xFFFF0000)
end
end
end
end
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 getCrosshairPositionOnScreen()
local resolutionX, resolutionY = getScreenResolution()
local onScreenX = resolutionX * 0.5299999714
local onScreenY = resolutionY * 0.3658
return onScreenX, onScreenY
end
function isFistInHand()
local weapon = getCurrentCharWeapon(playerPed)
return weapon == 0
end