LukisLT Posted December 21, 2012 Share Posted December 21, 2012 Hey guys, i've got some strange problem into my script( old version of script ) i just made a new gui for it, and added some extra images... to make it look nicer, and more enjoyable. But, after i done that small change, the music player does not open at all, and shows me some error, that's it's not even in that line.. Client : local volume = 1 --Default Song Volume local guiShowing = false --Hide/Open local currentPlaying = nil --Coming with the next update. local state = nil --State Playing / Not Playing function stopGTAradio() setRadioChannel(0) cancelEvent() end addEventHandler("onClientPlayerRadioSwitch",getRootElement(),stopGTAradio) addEventHandler("onClientPlayerVehicleEnter",getRootElement(),stopGTAradio) ------------------------------------------------------------------------------- GUIEditor = { label = {}, scrollbar = {}, } musicplayerGUI = {}, musicplayer = {} musicplayerGUI.window = guiCreateWindow(340, 195, 494, 578, "FNF// - Music Player 1.3", false) guiWindowSetSizable(musicplayerGUI.window, false) musicplayer.logo1 = guiCreateStaticImage(10, 559, 475, 9, "Img/tab.png", false, musicplayerGUI.window) musicplayerGUI.grid = guiCreateGridList(128, 315, 350, 225, false, musicplayerGUI.window) guiGridListAddColumn(musicplayerGUI.grid, "Songs list", 0.9) for i = 1, 2 do guiGridListAddRow(musicplayerGUI.grid) end guiGridListSetItemText(musicplayerGUI.grid, 0, 1, "-", false, false) guiGridListSetItemText(musicplayerGUI.grid, 1, 1, "-", false, false) GUIEditor.scrollbar[1] = guiCreateScrollBar(328, 18, 18, 189, false, false, musicplayerGUI.grid) musicplayerGUI.button2 = guiCreateButton(21, 376, 97, 25, "Stop", false, musicplayerGUI.window) musicplayerGUI.button3 = guiCreateButton(20, 515, 97, 25, "Close", false, musicplayerGUI.window) musicplayerGUI.button1 = guiCreateButton(21, 325, 97, 25, "Play", false, musicplayerGUI.window) musicplayerGUI.logo2 = guiCreateStaticImage(262, 45, 212, 220, "Img/logo.png", false, musicplayerGUI.window) musicplayerGUI.label1 = guiCreateLabel(32, 66, 160, 17, "Hey laddies and gentleman..!", false, musicplayerGUI.window) guiSetFont(musicplayerGUI.label1, "default-bold-small") musicplayerGUI.label2 = guiCreateLabel(32, 83, 160, 17, "To play music in the player", false, musicplayerGUI.window) guiSetFont(musicplayerGUI.label2, "default-bold-small") musicplayerGUI.label3 = guiCreateLabel(32, 100, 160, 17, "Select the song from the list", false, musicplayerGUI.window) guiSetFont(musicplayerGUI.label3, "default-bold-small") musicplayerGUI.label4 = guiCreateLabel(32, 117, 160, 17, "And hit PLAY! < Enjoy >", false, musicplayerGUI.window) guiSetFont(musicplayerGUI.label4, "default-bold-small") musicplayerGUI.label5 = guiCreateLabel(314, 288, 160, 17, "Visit : [url=http://WWW.FNF-MTA.TK]http://WWW.FNF-MTA.TK[/url]", false, musicplayerGUI.window) guiSetFont(musicplayerGUI.label5, "default-bold-small") musicplayerGUI.volumeBar = guiCreateScrollBar(10, 469, 112, 17, true, false, musicplayerGUI.window) guiScrollBarSetScrollPosition(musicplayerGUI.volumeBar, 100.0) musicplayerGUI.label6 = guiCreateLabel(42, 434, 46, 15, "Volume", false, musicplayerGUI.window) guiSetFont(GUIEditor.label[6], "default-bold-small") guiScrollBarSetScrollPosition (musicPlayerGUI.volumeBar, volume*100) guiWindowSetMovable (musicplayerGUI.window, true) guiWindowSetSizable (musicplayerGUI.window, false) guiSetVisible (musicplayerGUI.window, false) -- Some Events -- addEventHandler ( "onClientGUIDoubleClick", musicplayerGUI.grid, onGuiClick, true) -- DoubleCLickPlaySong addEventHandler ( "onClientGUIDoubleClick", musicplayerGUI.grid, stopGTAradio, true) -- StartMusicTurnOffRadio addEventHandler ( "onClientGUIClick", musicplayerGUI.button1, onGuiClick, true) addEventHandler ( "onClientGUIClick", musicplayerGUI.button2, onGuiClick, true) addEventHandler ( "onClientGUIClick", musicplayerGUI.button3, onGuiClick,true) -- Events End -- stationsNames = {} stations = {} function showGui () if guiShowing then guiShowing = false guiSetVisible (musicplayerGUI.window, false) showCursor (false) else guiShowing = true guiSetVisible (musicplayerGUI.window, true) showCursor (true) end end addCommandHandler("startmusic",showGui) bindKey("f3","down","startmusic") function onGuiClick (button, state, x,y) if source == musicplayerGUI.button1 and state == "up" then --play button local selected = guiGridListGetSelectedItem (musicplayerGUI.grid) if selected then local stationName = guiGridListGetItemText (musicplayerGUI.grid, selected, musicplayerGUI.column) if stationName then if currentPlaying then stopSound (currentPlaying) end currentPlaying = playSound (stations[stationName]) setSoundVolume (currentPlaying, volume) state = "play" else outputChatBox ("[Music Player]: Cant Strean This Song") end elseif state == "pause" and isSoundPaused(currentPlaying) then setSoundPaused (currentPlaying, false) end end if source == musicplayerGUI.button2 and state == "up" then --pause button if isSoundPaused (currentPlaying) == false then setSoundPaused (currentPlaying, true) end end if source == musicplayerGUI.button3 and state == "up" then -- 3d local selected = guiGridListGetSelectedItem (musicPlayerGUI.grid) if selected then local stationName = guiGridListGetItemText (musicplayerGUI.grid, selected, musicplayerGUI.column) if stationName then triggerServerEvent ("onClientRadioCreate", getLocalPlayer(), getLocalPlayer(), stationName) end end end if source == musicplayerGUI.button3 and state == "up" then -- close showGui () end if source == musicplayerGUI.grid and state == "up" then -- grid list click local selected = guiGridListGetSelectedItem (musicplayerGUI.grid) if selected then local stationName = guiGridListGetItemText (musicplayerGUI.grid, selected, musicplayerGUI.column) if stationName then if currentPlaying then stopSound (currentPlaying) end currentPlaying = playSound (stations[stationName]) setSoundVolume (currentPlaying, volume) else outputChatBox ("[Music Player]: This Song Is Offline, Please report to admin") end end end end function OnScroll(Scrolled) if source == musicplayerGUI.volumeBar then volume = guiScrollBarGetScrollPosition (source) / 100 if currentPlaying then setSoundVolume (currentPlaying, volume) end end end addEventHandler("onClientGUIScroll",getRootElement(),OnScroll) function onRadioCreate (x,y,z,path) local sound = playSound3D (path, x,y,z) setSoundVolume (sound, volume) setSoundMaxDistance (sound, 20) end addEvent ("onNewRadioCreate", true) addEventHandler ("onNewRadioCreate", getRootElement(), onRadioCreate) function onStart () triggerServerEvent ("requestForRadios", getLocalPlayer(), getLocalPlayer()) end addEventHandler ("onClientResourceStart", getResourceRootElement(getThisResource()), onStart) function onJoin (radia, names, st) for k,v in ipairs(radia) do local sound = playSound3D (v[4], v[1], v[2], v[3]) setSoundVolume (sound, volume/100) setSoundMaxDistance (sound, 20) end stationsNames = names stations = st for k,v in ipairs(stationsNames) do local row = guiGridListAddRow ( musicPlayerGUI.grid ) guiGridListSetItemText ( musicplayerGUI.grid, row, musicplayerGUI.column, v, false, false ) end end addEvent ("sendAllRadios", true) addEventHandler ("sendAllRadios", getRootElement(), onJoin) Error's at line's : 37 and 20, hope some1 could help me to fix this. ERRORS : line 37 : @ bad argument @ ' addEventHandler ' expected function at argument 3 got nil ERRORS : line 20 : unexpected symbol near *=* ... final result : Loading script failed.. but script is actually loaded, just not opening with my bind button.. Thanks for reading/replying! Link to comment
Castillo Posted December 21, 2012 Share Posted December 21, 2012 Here: musicplayerGUI = {}, Try removing that COMMA. Link to comment
LukisLT Posted December 21, 2012 Author Share Posted December 21, 2012 (edited) Gui opened, but this time, not loading any of my componenets .. Thats include : labels, buttons, scrollbars img's.. etc. and showing error this time ERROR : lua:21: attemt to index global 'musicplayerGUI' (a nil value) EDIT : the bind key bugged too, opened, only once i started the script, but not closing with they bind key. Edited December 21, 2012 by Guest Link to comment
Castillo Posted December 21, 2012 Share Posted December 21, 2012 Mind posting the exact line? not the number, but the script line itself. Link to comment
LukisLT Posted December 21, 2012 Author Share Posted December 21, 2012 musicplayerGUI.window = guiCreateWindow(340, 195, 494, 578, "FNF// - Music Player 1.3", -- Line 21 guiSetFont(musicplayerGUI.label1, "default-bold-small") -- Line 37 But what does it have with my errors i get? Link to comment
Castillo Posted December 21, 2012 Share Posted December 21, 2012 Well, it's saying "musicplayerGUI" table does not exist, but that script you posted has it. Link to comment
LukisLT Posted December 21, 2012 Author Share Posted December 21, 2012 Anyway to solve this problem? Link to comment
Castillo Posted December 21, 2012 Share Posted December 21, 2012 You either removed the table musicplayerGUI or didn't read the error correctly, because I copied it, removed the comma I told you in my first reply and worked, then there was another small error. local volume = 1 --Default Song Volume local guiShowing = false --Hide/Open local currentPlaying = nil --Coming with the next update. local state = nil --State Playing / Not Playing function stopGTAradio() setRadioChannel(0) cancelEvent() end addEventHandler("onClientPlayerRadioSwitch",getRootElement(),stopGTAradio) addEventHandler("onClientPlayerVehicleEnter",getRootElement(),stopGTAradio) ------------------------------------------------------------------------------- GUIEditor = { label = {}, scrollbar = {}, } musicplayerGUI = {} musicplayer = {} musicplayerGUI.window = guiCreateWindow(340, 195, 494, 578, "FNF// - Music Player 1.3", false) guiWindowSetSizable(musicplayerGUI.window, false) musicplayer.logo1 = guiCreateStaticImage(10, 559, 475, 9, "Img/tab.png", false, musicplayerGUI.window) musicplayerGUI.grid = guiCreateGridList(128, 315, 350, 225, false, musicplayerGUI.window) guiGridListAddColumn(musicplayerGUI.grid, "Songs list", 0.9) for i = 1, 2 do guiGridListAddRow(musicplayerGUI.grid) end guiGridListSetItemText(musicplayerGUI.grid, 0, 1, "-", false, false) guiGridListSetItemText(musicplayerGUI.grid, 1, 1, "-", false, false) GUIEditor.scrollbar[1] = guiCreateScrollBar(328, 18, 18, 189, false, false, musicplayerGUI.grid) musicplayerGUI.button2 = guiCreateButton(21, 376, 97, 25, "Stop", false, musicplayerGUI.window) musicplayerGUI.button3 = guiCreateButton(20, 515, 97, 25, "Close", false, musicplayerGUI.window) musicplayerGUI.button1 = guiCreateButton(21, 325, 97, 25, "Play", false, musicplayerGUI.window) musicplayerGUI.logo2 = guiCreateStaticImage(262, 45, 212, 220, "Img/logo.png", false, musicplayerGUI.window) musicplayerGUI.label1 = guiCreateLabel(32, 66, 160, 17, "Hey laddies and gentleman..!", false, musicplayerGUI.window) guiSetFont(musicplayerGUI.label1, "default-bold-small") musicplayerGUI.label2 = guiCreateLabel(32, 83, 160, 17, "To play music in the player", false, musicplayerGUI.window) guiSetFont(musicplayerGUI.label2, "default-bold-small") musicplayerGUI.label3 = guiCreateLabel(32, 100, 160, 17, "Select the song from the list", false, musicplayerGUI.window) guiSetFont(musicplayerGUI.label3, "default-bold-small") musicplayerGUI.label4 = guiCreateLabel(32, 117, 160, 17, "And hit PLAY! < Enjoy >", false, musicplayerGUI.window) guiSetFont(musicplayerGUI.label4, "default-bold-small") musicplayerGUI.label5 = guiCreateLabel(314, 288, 160, 17, "Visit : [url=http://WWW.FNF-MTA.TK]http://WWW.FNF-MTA.TK[/url]", false, musicplayerGUI.window) guiSetFont(musicplayerGUI.label5, "default-bold-small") musicplayerGUI.volumeBar = guiCreateScrollBar(10, 469, 112, 17, true, false, musicplayerGUI.window) guiScrollBarSetScrollPosition(musicplayerGUI.volumeBar, 100.0) musicplayerGUI.label6 = guiCreateLabel(42, 434, 46, 15, "Volume", false, musicplayerGUI.window) guiSetFont(musicplayerGUI.label6, "default-bold-small") guiScrollBarSetScrollPosition (musicplayerGUI.volumeBar, volume*100) guiWindowSetMovable (musicplayerGUI.window, true) guiWindowSetSizable (musicplayerGUI.window, false) guiSetVisible (musicplayerGUI.window, false) addEventHandler ( "onClientResourceStart", resourceRoot, function ( ) -- Some Events -- addEventHandler ( "onClientGUIDoubleClick", musicplayerGUI.grid, onGuiClick, true) -- DoubleCLickPlaySong addEventHandler ( "onClientGUIDoubleClick", musicplayerGUI.grid, stopGTAradio, true) -- StartMusicTurnOffRadio addEventHandler ( "onClientGUIClick", musicplayerGUI.button1, onGuiClick, true) addEventHandler ( "onClientGUIClick", musicplayerGUI.button2, onGuiClick, true) addEventHandler ( "onClientGUIClick", musicplayerGUI.button3, onGuiClick,true) -- Events End -- end ) stationsNames = {} stations = {} function showGui () if guiShowing then guiShowing = false guiSetVisible (musicplayerGUI.window, false) showCursor (false) else guiShowing = true guiSetVisible (musicplayerGUI.window, true) showCursor (true) end end addCommandHandler("startmusic",showGui) bindKey("f3","down","startmusic") function onGuiClick (button, state, x,y) if source == musicplayerGUI.button1 and state == "up" then --play button local selected = guiGridListGetSelectedItem (musicplayerGUI.grid) if selected then local stationName = guiGridListGetItemText (musicplayerGUI.grid, selected, musicplayerGUI.column) if stationName then if currentPlaying then stopSound (currentPlaying) end currentPlaying = playSound (stations[stationName]) setSoundVolume (currentPlaying, volume) state = "play" else outputChatBox ("[Music Player]: Cant Strean This Song") end elseif state == "pause" and isSoundPaused(currentPlaying) then setSoundPaused (currentPlaying, false) end end if source == musicplayerGUI.button2 and state == "up" then --pause button if isSoundPaused (currentPlaying) == false then setSoundPaused (currentPlaying, true) end end if source == musicplayerGUI.button3 and state == "up" then -- 3d local selected = guiGridListGetSelectedItem (musicPlayerGUI.grid) if selected then local stationName = guiGridListGetItemText (musicplayerGUI.grid, selected, musicplayerGUI.column) if stationName then triggerServerEvent ("onClientRadioCreate", getLocalPlayer(), getLocalPlayer(), stationName) end end end if source == musicplayerGUI.button3 and state == "up" then -- close showGui () end if source == musicplayerGUI.grid and state == "up" then -- grid list click local selected = guiGridListGetSelectedItem (musicplayerGUI.grid) if selected then local stationName = guiGridListGetItemText (musicplayerGUI.grid, selected, musicplayerGUI.column) if stationName then if currentPlaying then stopSound (currentPlaying) end currentPlaying = playSound (stations[stationName]) setSoundVolume (currentPlaying, volume) else outputChatBox ("[Music Player]: This Song Is Offline, Please report to admin") end end end end function OnScroll(Scrolled) if source == musicplayerGUI.volumeBar then volume = guiScrollBarGetScrollPosition (source) / 100 if currentPlaying then setSoundVolume (currentPlaying, volume) end end end addEventHandler("onClientGUIScroll",getRootElement(),OnScroll) function onRadioCreate (x,y,z,path) local sound = playSound3D (path, x,y,z) setSoundVolume (sound, volume) setSoundMaxDistance (sound, 20) end addEvent ("onNewRadioCreate", true) addEventHandler ("onNewRadioCreate", getRootElement(), onRadioCreate) function onStart () triggerServerEvent ("requestForRadios", getLocalPlayer(), getLocalPlayer()) end addEventHandler ("onClientResourceStart", getResourceRootElement(getThisResource()), onStart) function onJoin (radia, names, st) for k,v in ipairs(radia) do local sound = playSound3D (v[4], v[1], v[2], v[3]) setSoundVolume (sound, volume/100) setSoundMaxDistance (sound, 20) end stationsNames = names stations = st for k,v in ipairs(stationsNames) do local row = guiGridListAddRow ( musicPlayerGUI.grid ) guiGridListSetItemText ( musicplayerGUI.grid, row, musicplayerGUI.column, v, false, false ) end end addEvent ("sendAllRadios", true) addEventHandler ("sendAllRadios", getRootElement(), onJoin) Link to comment
LukisLT Posted December 21, 2012 Author Share Posted December 21, 2012 Thanks, guis working fine.. just some extra error in lines : 88 and 123... and not loading my song from my file, once i try to press " play " it just says, song is offline, but there is no song loaded at all... Link to comment
LukisLT Posted December 21, 2012 Author Share Posted December 21, 2012 Fixed, Thanks Solid for your help! Link to comment
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