~Funky~ Posted January 18, 2014 Share Posted January 18, 2014 Hola tengo esta gui de Stryp, lo que pasa es que al apretar Reproducir quiero que todos escuchen la cancion puesta pero no logro hacerlo funcionar D: porfa ayudenme D: Aca el Script Client: addEvent("onServerSendMusicList",true) addEvent("OEZI",true) VolumenC = 1 Canciones = { } ASDF = false sx , sy=guiGetScreenSize() addEventHandler("OEZI",root, function() local state = ( not guiGetVisible ( Ventana ) ) guiSetVisible ( Ventana, state ) showCursor ( state ) end) Ventana = guiCreateWindow(sx/2-230,sy/2-225,504,464,"Canciones",false) guiWindowSetSizable(Ventana, false) Lista = guiCreateGridList(9, 21, 485, 383, false, Ventana) guiGridListAddColumn(Lista, "ID", 0.1) guiGridListAddColumn(Lista, "Nombre", 0.5) guiGridListAddColumn(Lista, "Duracion", 0.2) Play = guiCreateButton(10, 404, 125, 22, "Reproducir", false, Ventana) Stop = guiCreateButton(135, 404, 125, 22, "Parar", false, Ventana) Volumen = guiCreateScrollBar(260, 404, 167, 22, false, false, Ventana) guiScrollBarSetScrollPosition(Volumen, 2.0) Cargar = guiCreateButton(10, 432, 256, 22, "Cargar canciones desde la Base de datos", false, Ventana) Repetir = guiCreateCheckBox(287, 427, 163, 27, "Repetir Cancion", false, false, Ventana) guiSetVisible(Ventana,false) function CargarDatos(b) if b ~= "left" then return end if source ~= Cargar then return end if guiGetEnabled(Cargar) then triggerServerEvent("onClientRequestMusicList",localPlayer) guiGridListClear(Lista) Canciones = nil if ASDF then destroyElement(ASDF) ASDF = false end destroyElement(Cargar) end end addEventHandler("onClientGUIClick",Cargar,CargarDatos) function GridCanciones(songs) Canciones = songs for k,song in ipairs(Canciones) do local row = guiGridListAddRow(Lista) guiGridListSetItemText(Lista,row,1,k,false,true) guiGridListSetItemText(Lista,row,2,song.name,false,false) guiGridListSetItemText(Lista,row,3,song.length,false,false) end guiSetEnabled(Play,true) end addEventHandler("onServerSendMusicList",root,GridCanciones) function Reproductor(b) if b ~= "left" then return end if source ~= Play then return end local selected = guiGridListGetSelectedItem(Lista) + 1 if selected > 0 then if not ASDF then ASDF = playSound(Canciones[selected].url,guiCheckBoxGetSelected(Repetir)) setSoundVolume(ASDF,Volumen) guiSetEnabled(Stop,true) guiSetEnabled(Play,false) end end end addEventHandler("onClientGUIClick",Play,Reproductor) function Parar(b) if b ~= "left" then return end if source ~= Stop then return end if ASDF then destroyElement(ASDF) ASDF = false guiSetEnabled(Play,true) guiSetEnabled(Stop,false) end end addEventHandler("onClientGUIClick",Stop,Parar) addEventHandler("onClientGUIScroll",Volumen, function() VolumenC=guiScrollBarGetScrollPosition(Volumen)/100 if ASDF then setSoundVolume(ASDF,VolumenC) end end) Server: Canciones = { } Canciones[1] = { name = "Los Picantes - Mamut Chiquitito", length = "04:22", url = "http://dc495.4shared.com/img/570535322/6a7a4ae0/dlink__2Fdownload_2F6DF4SbUs_3Ftsid_3D20140117-062138-6604aea4/preview.mp3", } Canciones[2] = { name = "Los Picantes - Falso Amor 'Maraca'", length = "06:01", url = "http://dc312.4shared.com/img/790339471/2cb89f8b/dlink__2Fdownload_2FA4JPoV4N_3Ftsid_3D20140117-062257-ef3182c/preview.mp3", } addEvent("onClientRequestMusicList",true) addEventHandler("onClientRequestMusicList",root, function() triggerClientEvent(source,"onServerSendMusicList",root,Canciones) end) function FactorPanel( thePlayer ) local acc = getPlayerAccount ( thePlayer ) if not isGuestAccount( acc ) then if isObjectInACLGroup ("user."..getAccountName ( acc ), aclGetGroup ( "Owner" ) ) then triggerClientEvent (thePlayer, "OEZI", thePlayer) end end end addEventHandler( 'onPlayerLogin', root, function() bindKey ( source, "F5", "down", FactorPanel ) end ) for k, i in ipairs( getElementsByType( 'player' )) do bindKey ( i, "F5", "down", FactorPanel ) end ayuda ): Link to comment
MTA Team 0xCiBeR Posted January 18, 2014 MTA Team Share Posted January 18, 2014 (edited) Cambia tu client-side por esto.: addEvent("onServerSendMusicList",true) addEvent("OEZI",true) VolumenC = 1 Canciones = { } ASDF = false sx , sy = guiGetScreenSize() addEventHandler("OEZI",root, function() local state = ( not guiGetVisible ( Ventana ) ) guiSetVisible ( Ventana, state ) showCursor ( state ) end) Ventana = guiCreateWindow(sx/2-230,sy/2-225,504,464,"Canciones",false) guiWindowSetSizable(Ventana, false) Lista = guiCreateGridList(9, 21, 485, 383, false, Ventana) guiGridListAddColumn(Lista, "ID", 0.1) guiGridListAddColumn(Lista, "Nombre", 0.5) guiGridListAddColumn(Lista, "Duracion", 0.2) Play = guiCreateButton(10, 404, 125, 22, "Reproducir", false, Ventana) Stop = guiCreateButton(135, 404, 125, 22, "Parar", false, Ventana) Volumen = guiCreateScrollBar(260, 404, 167, 22, false, false, Ventana) guiScrollBarSetScrollPosition(Volumen, 2.0) Cargar = guiCreateButton(10, 432, 256, 22, "Cargar canciones desde la Base de datos", false, Ventana) Repetir = guiCreateCheckBox(287, 427, 163, 27, "Repetir Cancion", false, false, Ventana) guiSetVisible(Ventana,false) function CargarDatos(b) if b ~= "left" then return end if source ~= Cargar then return end if guiGetEnabled(Cargar) then triggerServerEvent("onClientRequestMusicList",localPlayer) guiGridListClear(Lista) Canciones = nil if ASDF then destroyElement(ASDF) ASDF = false end destroyElement(Cargar) end end addEventHandler("onClientGUIClick",Cargar,CargarDatos) function GridCanciones(songs) Canciones = songs for k,song in ipairs(Canciones) do local row = guiGridListAddRow(Lista) guiGridListSetItemText(Lista,row,1,k,false,true) guiGridListSetItemText(Lista,row,2,song.name,false,false) guiGridListSetItemText(Lista,row,3,song.length,false,false) end guiSetEnabled(Play,true) end addEventHandler("onServerSendMusicList",root,GridCanciones) function Reproductor(b) if b ~= "left" then return end if source ~= Play then return end local selected = guiGridListGetSelectedItem(Lista) + 1 local x,y,z = getElementPosition(localPlayer) if selected > 0 then if not ASDF then ASDF = playSound3D(Canciones[selected].url,x,y,z,guiCheckBoxGetSelected(Repetir)) setSoundMaxDistance ( ASDF, 10000 ) setSoundVolume(ASDF,300) guiSetEnabled(Stop,true) guiSetEnabled(Play,false) end end end addEventHandler("onClientGUIClick",Play,Reproductor) function Parar(b) if b ~= "left" then return end if source ~= Stop then return end if ASDF then destroyElement(ASDF) ASDF = false guiSetEnabled(Play,true) guiSetEnabled(Stop,false) end end addEventHandler("onClientGUIClick",Stop,Parar) addEventHandler("onClientGUIScroll",Volumen, function() VolumenC=guiScrollBarGetScrollPosition(Volumen)/100 if ASDF then setSoundVolume(ASDF,VolumenC) end end) Edited January 18, 2014 by Guest Link to comment
~Funky~ Posted January 18, 2014 Author Share Posted January 18, 2014 Ciber no funciona ahora tampoco lo escucho yo :c Link to comment
MTA Team 0xCiBeR Posted January 18, 2014 MTA Team Share Posted January 18, 2014 Copialo denuevo. Link to comment
~Funky~ Posted January 18, 2014 Author Share Posted January 18, 2014 sigue sin escucharse para los demas ciber :c Link to comment
MTA Team 0xCiBeR Posted January 18, 2014 MTA Team Share Posted January 18, 2014 Ahora sí, copialo denuevo. Link to comment
~Funky~ Posted January 18, 2014 Author Share Posted January 18, 2014 Ciber yo lo esucho lo mas bien pero cuando le pregunto a los jugadores si lo escuchan me dice que no D: sera otro problema? Link to comment
MTA Team 0xCiBeR Posted January 18, 2014 MTA Team Share Posted January 18, 2014 Copiaste denuevo?.. Lo que hize fue cambiar de: playSound --A playSound3D --Y agregar setSoundMaxDistance No se que puede ser que no funcione.. PD: Copialo denuevo que cambie algo.... Link to comment
Sasu Posted January 18, 2014 Share Posted January 18, 2014 Tenes que hacer un trigger en el cliente enviando los datos (url, info, etc.) al server y luego lo envias al cliente para todos los jugadores y ahi haces playSound. Link to comment
MTA Team 0xCiBeR Posted January 18, 2014 MTA Team Share Posted January 18, 2014 Tenes que hacer un trigger en el cliente enviando los datos (url, info, etc.) al server y luego lo envias al cliente para todos los jugadores y ahi haces playSound. Tambien puedes usar ese metodo..Igualmente usando playSound3D tiene que funcionar.. Link to comment
Sasu Posted January 18, 2014 Share Posted January 18, 2014 Tenes que hacer un trigger en el cliente enviando los datos (url, info, etc.) al server y luego lo envias al cliente para todos los jugadores y ahi haces playSound. Tambien puedes usar ese metodo..Igualmente usando playSound3D tiene que funcionar.. No debido a que playSound3D o playSound no esta sincronizado con el server y solo se ejecutaria para el cliente que presiono el boton. Deberias saber eso. Link to comment
MTA Team 0xCiBeR Posted January 19, 2014 MTA Team Share Posted January 19, 2014 Tienes razón. Fail mio. Link to comment
Sasu Posted January 19, 2014 Share Posted January 19, 2014 Con respecto a este tema, intenta con esto: Cliente: addEvent("onServerSendMusicList",true) addEvent("OEZI",true) VolumenC = 1 Canciones = { } ASDF = false sx , sy=guiGetScreenSize() addEventHandler("OEZI",root, function() local state = ( not guiGetVisible ( Ventana ) ) guiSetVisible ( Ventana, state ) showCursor ( state ) end) Ventana = guiCreateWindow(sx/2-230,sy/2-225,504,464,"Canciones",false) guiWindowSetSizable(Ventana, false) Lista = guiCreateGridList(9, 21, 485, 383, false, Ventana) guiGridListAddColumn(Lista, "ID", 0.1) guiGridListAddColumn(Lista, "Nombre", 0.5) guiGridListAddColumn(Lista, "Duracion", 0.2) Play = guiCreateButton(10, 404, 125, 22, "Reproducir", false, Ventana) Stop = guiCreateButton(135, 404, 125, 22, "Parar", false, Ventana) Volumen = guiCreateScrollBar(260, 404, 167, 22, false, false, Ventana) guiScrollBarSetScrollPosition(Volumen, 2.0) Cargar = guiCreateButton(10, 432, 256, 22, "Cargar canciones desde la Base de datos", false, Ventana) Repetir = guiCreateCheckBox(287, 427, 163, 27, "Repetir Cancion", false, false, Ventana) guiSetVisible(Ventana,false) function CargarDatos(b) if b ~= "left" then return end if source ~= Cargar then return end if guiGetEnabled(Cargar) then triggerServerEvent("onClientRequestMusicList",localPlayer) guiGridListClear(Lista) Canciones = nil if ASDF then destroyElement(ASDF) ASDF = false end destroyElement(Cargar) end end addEventHandler("onClientGUIClick",Cargar,CargarDatos) function GridCanciones(songs) Canciones = songs for k,song in ipairs(Canciones) do local row = guiGridListAddRow(Lista) guiGridListSetItemText(Lista,row,1,k,false,true) guiGridListSetItemText(Lista,row,2,song.name,false,false) guiGridListSetItemText(Lista,row,3,song.length,false,false) end guiSetEnabled(Play,true) end addEventHandler("onServerSendMusicList",root,GridCanciones) function Reproductor(b) if b ~= "left" then return end if source ~= Play then return end local selected = guiGridListGetSelectedItem(Lista) + 1 if selected > 0 then if not ASDF then ASDF = playSound(Canciones[selected].url,guiCheckBoxGetSelected(Repetir)) triggerServerEvent("onSongStart", localPlayer, Canciones[selected].url, guiCheckBoxGetSelected(Repetir)) setSoundVolume(ASDF,Volumen) -- Creo que aqui te dara error puesto que 'Volumen' si no me equivoco devuelve un boolean. guiSetEnabled(Stop,true) guiSetEnabled(Play,false) end end end addEventHandler("onClientGUIClick",Play,Reproductor) addEvent("onClientSongStart", true) addEventHandler("onClientSongStart", root, function(url, repeatBool) ASDF = playSound(url, repeatBool) end) function Parar(b) if b ~= "left" then return end if source ~= Stop then return end if ASDF then destroyElement(ASDF) ASDF = false guiSetEnabled(Play,true) guiSetEnabled(Stop,false) end end addEventHandler("onClientGUIClick",Stop,Parar) addEventHandler("onClientGUIScroll",Volumen, function() VolumenC=guiScrollBarGetScrollPosition(Volumen)/100 if ASDF then setSoundVolume(ASDF,VolumenC) end end) Server: Canciones = { } Canciones[1] = { name = "Los Picantes - Mamut Chiquitito", length = "04:22", url = "http://dc495.4shared.com/img/570535322/6a7a4ae0/dlink__2Fdownload_2F6DF4SbUs_3Ftsid_3D20140117-062138-6604aea4/preview.mp3", } Canciones[2] = { name = "Los Picantes - Falso Amor 'Maraca'", length = "06:01", url = "http://dc312.4shared.com/img/790339471/2cb89f8b/dlink__2Fdownload_2FA4JPoV4N_3Ftsid_3D20140117-062257-ef3182c/preview.mp3", } addEvent("onClientRequestMusicList",true) addEventHandler("onClientRequestMusicList",root, function() triggerClientEvent(source,"onServerSendMusicList",root,Canciones) end) addEvent("onSongStart", true) addEventHandler("onSongStart", root, function(url, repeatBool) if url then if repeatBool == nil then repeatBool = false end triggerClientEvent("onClientStartSong", root) end end) function FactorPanel( thePlayer ) local acc = getPlayerAccount ( thePlayer ) if not isGuestAccount( acc ) then if isObjectInACLGroup ("user."..getAccountName ( acc ), aclGetGroup ( "Owner" ) ) then triggerClientEvent (thePlayer, "OEZI", thePlayer) end end end addEventHandler( 'onPlayerLogin', root, function() bindKey ( source, "F5", "down", FactorPanel ) end ) for k, i in ipairs( getElementsByType( 'player' )) do bindKey ( i, "F5", "down", FactorPanel ) end Link to comment
Recommended Posts