Jump to content

Another small noob problem D:


drk

Recommended Posts

hi all.

im making a script when you double click in a gridlist element it plays the sound.

It is playing the song but it starts all the songs. Why?

the code is

function clickPlaySound() 
    local selectedRow, selectedCol = guiGridListGetSelectedItem(gui['list']); 
    local song = guiGridListGetItemData(gui['list'],selectedRow, selectedCol) 
     if isElement(currentSound) then destroyElement(currentSound) end; 
    currentSound = playSound(song,false); 
end; 
addEventHandler('onClientGUIDoubleClick',gui['list'],clickPlaySound,false); 

I've tried with:

addEventHandler('onClientGUIDoubleClick',root, 
 function() 
  if source == gui['list'] then 
   local theRow, theCol = guiGridListGetSelectedItem(gui['list']); 
   if row and col and row ~= -1 and col ~= -1 then 
    local song = guiGridListGetItemData(source, theRow, theCol); --i've changed source to gui['list'] and dont work too. 
    if isElement(currentSound) then destroyElement(currentSound) end; 
    currentSound = playSound(song,false); 
  end; 
end); 

but don't work too. can any one help me ?

Link to comment
addEventHandler('onClientGUIDoubleClick',root, 
    function() 
    if (source == gui['list']) then 
        local row, col = guiGridListGetSelectedItem(source) 
        if (row and col and row ~= -1 and col ~= -1) then 
            local song = guiGridListGetItemData(source, row, col) 
            if isElement(currentSound) then destroyElement(currentSound) end 
            currentSound = playSound(song,false) 
        end 
    end 
end) 

Link to comment
Guest
This topic is now closed to further replies.
  • Recently Browsing   0 members

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