Jump to content

MP3 Panel


Recommended Posts

Hello people, I'm make this mp3 panel just testing but it seems that it doesn't work, I tried with debugscript 3 to see if there are any errors, but nothing, here is my code, The playing sound part is working but Pausing it or Stopping it doesnt work.

Client:

function playOne() 
    if source == music.Button[3] then 
        local row = guiGridListGetSelectedItem(music.Gridlist[1]) 
        if row == 0 then 
            local currentPlaying = playSound("sounds/nwa.mp3") 
            setSoundVolume(currentPlaying, 0.5) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", guiRoot, playOne) 
  
function pauseOne() 
    if source == music.Button[2] then 
        if row == 0 then 
            setSoundPaused(currentPlaying, true) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", guiRoot, pauseOne) 
  
function stopOne() 
    if source == music.Button[1] then 
        if row == 0 then 
            stopSound(currentPlaying) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", guiRoot, stopOne) 
  
local currentlyPlaying 
  
function playSec() 
    if source == music.Button[3] then 
        local row = guiGridListGetSelectedItem(music.Gridlist[1]) 
        if row == 1 then 
            local currentlyPlaying = playSound("sounds/tremor.mp3") 
            setSoundVolume(currentlyPlaying, 0.5) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", guiRoot, playSec) 
  
function pauseSec() 
    if source == music.Button[2] then 
        if row == 1 then 
            setSoundPaused(currentlyPlaying, true) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", guiRoot, pauseSec) 
  
function stopSec() 
    if source == music.Button[1] then 
        if row == 1 then 
            stopSound(currentlyPlaying) 
        end 
    end 
end 
addEventHandler("onClientGUIClick", guiRoot, stopSec) 

Edited by Guest
Link to comment
  • MTA Team

I see.

In the pause/stop functions you use the variable row, but it will never have any value inside it.

Missing:

local row = guiGridListGetSelectedItem(music.Gridlist[1]) 

Here:

function pauseOne() 
    if source == music.Button[2] then 
        if row == 0 then 

Link to comment
I see.

In the pause/stop functions you use the variable row, but it will never have any value inside it.

Missing:

local row = guiGridListGetSelectedItem(music.Gridlist[1]) 

Here:

function pauseOne() 
    if source == music.Button[2] then 
        if row == 0 then 

WARNING: client.lua: Bad 'sound/player' pointer @ 'setSoundpaused'(1) 
WARNING: client.lua: Bad argument @ 'stopSound' [Expected sound at argument 1, got nil] 

Link to comment
  • MTA Team
local currentPlaying = playSound("sounds/nwa.mp3") 

The variable currentPlaying is not global. You can't access it in other functions unless your remove "local".

Replace with:

currentPlaying = playSound("sounds/nwa.mp3") 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...