local samp = require('samp.events')
local enable = true
function main()
repeat wait(100) until isSampAvailable()
while true do wait(500) end
end
function samp.onShowDialog(id, style, title, button1, button2, text)
if not enable then return end
if button1 == "Купить" and text:find("В наличии:") then
local count = text:match("В наличии:%s*(%d+)")
if count then
lua_thread.create(function()
sampSendDialogResponse(id, 1, 0, count)
end)
end
end
end