local Audio = {}
function Audio:new()
local private
local public
private = {}
private.base = "тут твой base"
function private:createFile(path)
local dirPath = path:gsub(path:match("[^\\]*$"), "")
if not doesDirectoryExist(dirPath) then
createDirectory(dirPath)
end
local f, err = io.open(path, "wb")
f:write(private.base)
f:close()
end
function private:getAudio(path)
private:createFile(path)
return assert(loadAudioStream(path), "все пошло по пизде")
end
private.audio = private:getAudio(("крутой_трек.mp3"):format(getWorkingDirectory()))
public = {}
function public:play()
setAudioStreamState(private.audio, 1)
setAudioStreamVolume(private.audio, 100)
end
setmetatable(public, self)
self.__index = self
return public
end
local audio = Audio:new()
addEventHandler("onWindowMessage", function(msg, wparam, lparam)
if not isPauseMenuActive() then
if (msg == 0x100) or (msg == 0x101) then
if (wparam == 113) then
consumeWindowMessage(true, true)
if (msg == 0x101) then
audio:play()
end
end
end
end
end)