Negriukas Posted July 3, 2014 Posted July 3, 2014 (edited) 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 July 3, 2014 by Guest
MTA Team botder Posted July 3, 2014 MTA Team Posted July 3, 2014 if row == 0 then Shouldn't it be row == 1? end) Why is there a ")" at the end?
Negriukas Posted July 3, 2014 Author Posted July 3, 2014 if row == 0 then Shouldn't it be row == 1? end) Why is there a ")" at the end? Row == 0 to get the first row row == 1 to get the second row, etc..
MTA Team botder Posted July 3, 2014 MTA Team Posted July 3, 2014 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
Negriukas Posted July 3, 2014 Author Posted July 3, 2014 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]
Negriukas Posted July 3, 2014 Author Posted July 3, 2014 It's clear -.- WARNING: client.lua:15: Bad 'sound/player' pointer @ 'setSoundPaused'(1) WARNING: client.lua:24: Bad argument @ 'stopSound' [Expected sound at argument 1, got nil]
MTA Team botder Posted July 3, 2014 MTA Team Posted July 3, 2014 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")
Negriukas Posted July 5, 2014 Author Posted July 5, 2014 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") Thanks
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now