K4stic Posted March 16, 2013 Share 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() Link to comment
iPrestege Posted March 16, 2013 Share Posted March 16, 2013 What about use set timer? Link to comment
K4stic Posted March 16, 2013 Author Share Posted March 16, 2013 This is better than timer, timer make server lag Link to comment
iPrestege Posted March 16, 2013 Share Posted March 16, 2013 Ok,Any error? debugscript 3 | = ? Link to comment
iPrestege Posted March 16, 2013 Share 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 . Link to comment
PaiN^ Posted March 16, 2013 Share 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 ) Link to comment
K4stic Posted March 16, 2013 Author Share Posted March 16, 2013 #Pai_[N] can i use the also "onClientRender" to refresh grid list? Link to comment
iPrestege Posted March 16, 2013 Share 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 ) Link to comment
K4stic Posted March 16, 2013 Author Share Posted March 16, 2013 i know how use it i ask only if i can use it to refresh Grid list's Link to comment
PaiN^ Posted March 16, 2013 Share Posted March 16, 2013 I really don't know S: , Never used onClientRender before ! Link to comment
iPrestege Posted March 16, 2013 Share 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 ? Link to comment
K4stic Posted March 16, 2013 Author Share Posted March 16, 2013 nothing thats good Thx you Guys for Help you are best Link to comment
iPrestege Posted March 16, 2013 Share Posted March 16, 2013 Lol?Does it work? show it here Link to comment
K4stic Posted March 16, 2013 Author Share Posted March 16, 2013 will test it in 1 hour because now i must go Link to comment
iPrestege Posted March 16, 2013 Share Posted March 16, 2013 will test it in 1 hour because now i must go no problem . Link to comment
K4stic Posted March 16, 2013 Author Share 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 Link to comment
PaiN^ Posted March 16, 2013 Share Posted March 16, 2013 That's great, Thanx for the info Link to comment
K4stic Posted March 16, 2013 Author Share Posted March 16, 2013 Other problem now i can't click on player's names Link to comment
Castillo Posted March 16, 2013 Share 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. Link to comment
PaiN^ Posted March 16, 2013 Share 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 ? Link to comment
Castillo Posted March 16, 2013 Share Posted March 16, 2013 No, it doesn't make much sense the opening part. Link to comment
K4stic Posted March 16, 2013 Author Share 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) Link to comment
Castillo Posted March 16, 2013 Share 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. Link to comment
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