Jump to content

guiGridListGetSelectedItem


pa3ck

Recommended Posts

Good evening, I've some problems with guiGridListGetSelectedItem. My code is:

  
        addEventHandler('onClientGUIClick', button1, function()  
        local tp = guiGridListGetItemText ( gridlist, guiGridListGetSelectedItem ( gridlist ), 1 ) 
        local selp = getPlayerFromName(tp) 
            if (source == button1) then  
                if selp then 
                    guiSetVisible(panelEHealth, true) 
                    guiBringToFront(panelEHealth) 
                    guiSetText(panelEdit, "") 
                    addEventHandler('onClientGUIClick', panelEButton, function() if source == panelEButton then hp =  guiGetText (panelEdit) hpp = tonumber(hp)  guiSetVisible(panelEHealth, false) triggerServerEvent("sethp", getRootElement(), tp, selp, thePlayer, hpp) end end)  
                else 
                    outputChatBox('Select a player to set his health.', 255, 0, 0) 
                end 
            end 
        end) 
  

My problem is, it works, but when I click on a player, then select an other player, both of their health power will be changed, I don't know why. So it will update the selected row but it keeps the previous player too.

Link to comment
  addEventHandler('onClientGUIClick', button1, function() 
        local tp = guiGridListGetItemText ( gridlist, guiGridListGetSelectedItem ( gridlist ), 1 ) 
        local selp = getPlayerFromName(tp) 
            if (source == button1) then 
                if ( guiGridListGetSelectedItem ( gridlist ) ~= -1 ) then 
                if selp then 
                    guiSetVisible(panelEHealth, true) 
                    guiBringToFront(panelEHealth) 
                    guiSetText(panelEdit, "") 
                    addEventHandler('onClientGUIClick', panelEButton, function() if source == panelEButton then hp =  guiGetText (panelEdit) hpp = tonumber(hp)  guiSetVisible(panelEHealth, false) triggerServerEvent("sethp", getRootElement(), tp, selp, thePlayer, hpp) end end) 
                else 
                    outputChatBox('Select a player to set his health.', 255, 0, 0) 
                end 
            end 
            end 
        end) 

try this i think it will work good now

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...