Lua mp3

Lo_Smite

Участник
Автор темы
56
9
Версия MoonLoader
.026-beta
У меня появился вопрос. Как сделать чтобы в игре проигрывался звук?
Т.е в папке мунладера я создал допустим папку sounds и в ней файл что.mp3. Как мне его проиграть в самп?

На примере если просто ввести команду на /c. Т.е. на команду сервера. Буду благодарен
 
Решение
Юзай https://blast.hk/wiki/lua:audiostream?s[]=sound
Там всё есть.


будет проигрываться каждые 10 сек

Lua:
 function main()
     if not isSampLoaded() or not isSampfuncsLoaded() then return end
     while not isSampAvailable() do wait(0) end

     local audio = loadAudioStream("moonloader/sound/plyus_org-z_uk-u_edomleniya-1.mp3")
     sampRegisterChatCommand("play", cmd_bot)

             while true do
                 wait(0)
                 if isPlayerPlaying(playerHandle) and enabled then

                 setAudioStreamState(audio, 1)

                 setAudioStreamVolume(audio, 100)
                     printStringNow('AKTIVIROVAN', 1000)
                 wait(10000)
             end
end
end

function cmd_bot(arg)...

Volgus_King

Активный
155
115
Юзай https://blast.hk/wiki/lua:audiostream?s[]=sound
Там всё есть.


будет проигрываться каждые 10 сек

Lua:
 function main()
     if not isSampLoaded() or not isSampfuncsLoaded() then return end
     while not isSampAvailable() do wait(0) end

     local audio = loadAudioStream("moonloader/sound/plyus_org-z_uk-u_edomleniya-1.mp3")
     sampRegisterChatCommand("play", cmd_bot)

             while true do
                 wait(0)
                 if isPlayerPlaying(playerHandle) and enabled then

                 setAudioStreamState(audio, 1)

                 setAudioStreamVolume(audio, 100)
                     printStringNow('AKTIVIROVAN', 1000)
                 wait(10000)
             end
end
end

function cmd_bot(arg)
    enabled = not enabled
    if enabled then
        sampAddChatMessage(string.format("[%s]: Активирован", thisScript().name), 0x40FF40)
        sampAddChatMessage(" {818ccd} АВТОР {f9bca4}  VOLGUS KING", -1)
        sampAddChatMessage(" {818ccd} КАНАЛ на YOUTUBE {f9bca4}  youtube.com/volguskingplay", -1)
        memory.setuint8(7634870, 1)
        memory.setuint8(7635034, 1)
        memory.fill(7623723, 144, 8)
        memory.fill(5499528, 144, 6)
    else
        sampAddChatMessage(string.format("[%s]: Деактивирован", thisScript().name), 0xFF4040)
        thisScript():reload()
        memory.setuint8(7634870, 0)
        memory.setuint8(7635034, 0)
        memory.hex2bin('5051FF1500838500', 7623723, 8)
        memory.hex2bin('0F847B010000', 5499528, 6)
    end
end

если нужно сделать чтобы чисто при вводе в чат при /c (говорил шепотом) проигрывался звук то

Lua:
script_name("")
script_authors("Volgus_King")
script_version("1")
script_dependencies()

local sampev = require "samp.events"
local memory = require 'memory'














function main()
if not isSampLoaded() or not isSampfuncsLoaded() then return end
while not isSampAvailable() do wait(0) end


sampRegisterChatCommand("play", cmd_bot)

while true do
wait(0)
end
end

function sampev.onServerMessage(_, text)
     if text:match("..говорит шепотом..") then
         local audio = loadAudioStream("moonloader/sound/plyus_org-z_uk-u_edomleniya-1.mp3")
        setAudioStreamState(audio, 1)

     end
end

function cmd_bot(arg)
    enabled = not enabled
    if enabled then
        sampAddChatMessage(string.format("[%s]: Активирован", thisScript().name), 0x40FF40)
        sampAddChatMessage(" {818ccd} АВТОР {f9bca4}  VOLGUS KING", -1)
        sampAddChatMessage(" {818ccd} КАНАЛ на YOUTUBE {f9bca4}  youtube.com/volguskingplay", -1)
        memory.setuint8(7634870, 1)
        memory.setuint8(7635034, 1)
        memory.fill(7623723, 144, 8)
        memory.fill(5499528, 144, 6)
    else
        sampAddChatMessage(string.format("[%s]: Деактивирован", thisScript().name), 0xFF4040)
        thisScript():reload()
        memory.setuint8(7634870, 0)
        memory.setuint8(7635034, 0)
        memory.hex2bin('5051FF1500838500', 7623723, 8)
        memory.hex2bin('0F847B010000', 5499528, 6)
    end
end