pa3ck Posted October 30, 2013 Posted October 30, 2013 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.
Cadell Posted October 31, 2013 Posted October 31, 2013 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
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