K4stic Posted March 16, 2013 Posted March 16, 2013 help pls it's refresh only the userPanelGrid1 and no refresh the userPanelGrid2 function playerGridUpdate() if (alreadyHandled) then return false end for key,player in pairs(getElementsByType("player")) do local row = guiGridListAddRow(userPanelGrid1) local row2 = guiGridListAddRow(userPanelGrid2) guiGridListSetItemText(userPanelGrid1, row, playerCol, getPlayerName(player), false, false) guiGridListSetItemText(userPanelGrid2, row2, playerCol2, getPlayerName(player), false, false) end alreadyHandled = true end function playerGridJoinUpdate() if (tostring(guiGetText(userPanelEdit2)) == "") then local row = guiGridListAddRow(userPanelGrid1) local row2 = guiGridListAddRow(userPanelGrid2) guiGridListSetItemText(userPanelGrid1, row, playerCol, getPlayerName(source), false, false) guiGridListSetItemText(userPanelGrid2, row2, playerCol2, getPlayerName(source), false, false) end end addEventHandler("onClientPlayerJoin", root, playerGridJoinUpdate) function playerGridQuitUpdate() local count = guiGridListGetRowCount(userPanelGrid1) for i = 0, count do local item = guiGridListGetItemText(userPanelGrid1, i, 1) if (item == getPlayerName(source)) then guiGridListRemoveRow(userPanelGrid1, i) guiGridListRemoveRow(userPanelGrid2, i) end end end addEventHandler("onClientPlayerQuit", root, playerGridQuitUpdate) function playerGridRenameUpdate(old, new) local count = guiGridListGetRowCount(userPanelGrid1) for i = 0, count do local item = guiGridListGetItemText(userPanelGrid1, i, 1) local item = guiGridListGetItemText(userPanelGrid2, i, 1) if (item == old) or (item1 == old) then guiGridListSetItemText(userPanelGrid1, i, 1, new, false, false) guiGridListSetItemText(userPanelGrid2, i, 1, new, false, false) end end end addEventHandler("onClientPlayerChangeNick", root, playerGridRenameUpdate) playerGridUpdate()
K4stic Posted March 16, 2013 Author Posted March 16, 2013 This is better than timer, timer make server lag
iPrestege Posted March 16, 2013 Posted March 16, 2013 no errors Are sure about the grid name? try again change you're nick i can't see any error in the code .
PaiN^ Posted March 16, 2013 Posted March 16, 2013 Sorry to interrupt, But you can refresh players by adding the refresh to the open panel function, Like this : function getAllPlayers ( ) for key,player in pairs(getElementsByType("player")) do local row = guiGridListAddRow(userPanelGrid1) local row2 = guiGridListAddRow(userPanelGrid2) guiGridListSetItemText(userPanelGrid1, row, playerCol, getPlayerName(player), false, false) guiGridListSetItemText(userPanelGrid2, row2, playerCol2, getPlayerName(player), false, false) end end bindKey ( 'F2', 'down', function ( ) for key,player in ipairs ( getElementsByType ( 'player' ) ) do if guiGetVisible ( yourWindowName ) then guiSetVisible ( yourWindowName, false ) showCursor ( false ) guiGridListClear ( userPanelGrid1 ) guiGridListClear ( userPanelGrid1 ) else guiSetVisible ( yourWindowName, true ) showCursor ( true ) getAllPlayers ( ) end end end )
K4stic Posted March 16, 2013 Author Posted March 16, 2013 #Pai_[N] can i use the also "onClientRender" to refresh grid list?
iPrestege Posted March 16, 2013 Posted March 16, 2013 #Pai_[N] can i use the also "onClientRender" to refresh grid list? maybe you can try like this : addEventHandler("onClientRender", root, function () if(guiGetVisible(Widnow)~=false)then -- the what fuck you wan't end end )
K4stic Posted March 16, 2013 Author Posted March 16, 2013 i know how use it i ask only if i can use it to refresh Grid list's
PaiN^ Posted March 16, 2013 Posted March 16, 2013 I really don't know S: , Never used onClientRender before !
iPrestege Posted March 16, 2013 Posted March 16, 2013 i know how use it i ask only if i can use it to refresh Grid list's Hmm... i think you can try it what you will lost if you try ?
K4stic Posted March 16, 2013 Author Posted March 16, 2013 nothing thats good Thx you Guys for Help you are best
K4stic Posted March 16, 2013 Author Posted March 16, 2013 will test it in 1 hour because now i must go
iPrestege Posted March 16, 2013 Posted March 16, 2013 will test it in 1 hour because now i must go no problem .
K4stic Posted March 16, 2013 Author Posted March 16, 2013 (edited) Guys Officialy i can say because i test it! Now you can use "onClientRender" To refresh your Grid list's this is my example of my code: addEventHandler("onClientRender", root, function() guiGridListClear( userPanelGrid1 ) guiGridListClear( userPanelGrid2 ) for key,player in pairs(getElementsByType("player")) do local row = guiGridListAddRow(userPanelGrid1) local row2 = guiGridListAddRow(userPanelGrid2) guiGridListSetItemText(userPanelGrid1, row, playerCol, getPlayerName(player), false, false) guiGridListSetItemText(userPanelGrid2, row2, playerCol2, getPlayerName(player), false, false) end end ) this is useful to no use Timers and server have LAG so Try it Edited March 16, 2013 by Guest
K4stic Posted March 16, 2013 Author Posted March 16, 2013 Other problem now i can't click on player's names
Castillo Posted March 16, 2013 Posted March 16, 2013 Of course not, if you are clearing/adding items every render, you won't be able to click any of them. What you must do is: load them when the resource starts, then when a player joins/leaves/changes nick, update him on the grid list, this has been already asked on other topics, search for them.
PaiN^ Posted March 16, 2013 Posted March 16, 2013 Sorry to interrupt, But you can refresh players by adding the refresh to the open panel function, Like this : function getAllPlayers ( ) for key,player in pairs(getElementsByType("player")) do local row = guiGridListAddRow(userPanelGrid1) local row2 = guiGridListAddRow(userPanelGrid2) guiGridListSetItemText(userPanelGrid1, row, playerCol, getPlayerName(player), false, false) guiGridListSetItemText(userPanelGrid2, row2, playerCol2, getPlayerName(player), false, false) end end bindKey ( 'F2', 'down', function ( ) for key,player in ipairs ( getElementsByType ( 'player' ) ) do if guiGetVisible ( yourWindowName ) then guiSetVisible ( yourWindowName, false ) showCursor ( false ) guiGridListClear ( userPanelGrid1 ) guiGridListClear ( userPanelGrid1 ) else guiSetVisible ( yourWindowName, true ) showCursor ( true ) getAllPlayers ( ) end end end ) @Solidsnake14 : Does my code above work ?
Castillo Posted March 16, 2013 Posted March 16, 2013 No, it doesn't make much sense the opening part.
K4stic Posted March 16, 2013 Author Posted March 16, 2013 so this is ok? function getgridlist() guiGridListClear( userPanelGrid1 ) guiGridListClear( userPanelGrid2 ) for key,player in pairs(getElementsByType("player")) do local row = guiGridListAddRow(userPanelGrid1) local row2 = guiGridListAddRow(userPanelGrid2) guiGridListSetItemText(userPanelGrid1, row, playerCol, getPlayerName(player), false, false) guiGridListSetItemText(userPanelGrid2, row2, playerCol2, getPlayerName(player), false, false) end end addEventHandler("onClientPlayerJoin", root, getgridlist) addEventHandler("onClientPlayerQuit", root, getgridlist) addEventHandler("onClientPlayerChangeNick", root, getgridlist)
Castillo Posted March 16, 2013 Posted March 16, 2013 There's no need to clear it all, you can just update the player that actually left/joined/changed nick. Search on the forums, there's a script for this.
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