isa_Khamdan Posted September 11, 2013 Share Posted September 11, 2013 Hello , I have a GUI Grid list and I want to load player names in it okay so this code works but there is one problem with it The names get duplicates for example a player Names " King " his name will show in Grid list two Times like this King King So can anyone tell me how to fix this? else I want to make it refresh every few minutes if it's possible Thanks. clientsideResourceStart = function() if column then for id,playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow(GUIEditor_Grid[1]) guiGridListSetItemText(GUIEditor_Grid[1], row, column, getPlayerName(playeritem), false, false) end end end addEventHandler("onClientResourceStart", getRootElement(), clientsideResourceStart) Link to comment
ZL|LuCaS Posted September 11, 2013 Share Posted September 11, 2013 Hello ,I have a GUI Grid list and I want to load player names in it okay so this code works but there is one problem with it The names get duplicates for example a player Names " King " his name will show in Grid list two Times like this King King So can anyone tell me how to fix this? else I want to make it refresh every few minutes if it's possible Thanks. clientsideResourceStart = function() if column then for id,playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow(GUIEditor_Grid[1]) guiGridListSetItemText(GUIEditor_Grid[1], row, column, getPlayerName(playeritem), false, false) end end end addEventHandler("onClientResourceStart", getRootElement(), clientsideResourceStart) complete codig! Link to comment
isa_Khamdan Posted September 11, 2013 Author Share Posted September 11, 2013 Hello ,I have a GUI Grid list and I want to load player names in it okay so this code works but there is one problem with it The names get duplicates for example a player Names " King " his name will show in Grid list two Times like this King King So can anyone tell me how to fix this? else I want to make it refresh every few minutes if it's possible Thanks. clientsideResourceStart = function() if column then for id,playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow(GUIEditor_Grid[1]) guiGridListSetItemText(GUIEditor_Grid[1], row, column, getPlayerName(playeritem), false, false) end end end addEventHandler("onClientResourceStart", getRootElement(), clientsideResourceStart) complete codig! Rest of the code doesn't have anything about the Grid list and here is the window and the grid list GUIEditor_Window[1] = guiCreateWindow(355, 104, 227, 457, "Transfer Money", false) guiWindowSetSizable(GUIEditor_Window[1], false) guiSetProperty(GUIEditor_Window[1], "CaptionColour", "FFFF0000") GUIEditor_Grid[1] = guiCreateGridList(9, 71, 208, 243, false, GUIEditor_Window[1]) guiGridListSetSelectionMode(GUIEditor_Grid[1], 2) column = guiGridListAddColumn(GUIEditor_Grid[1], "Player List", 1) Link to comment
Castillo Posted September 11, 2013 Share Posted September 11, 2013 addEventHandler("onClientResourceStart", getRootElement(), clientsideResourceStart) Change that, to this: addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart ) If you leave it on getRootElement, then it'll trigger the function everytime a resource is started. Link to comment
isa_Khamdan Posted September 11, 2013 Author Share Posted September 11, 2013 addEventHandler("onClientResourceStart", getRootElement(), clientsideResourceStart) Change that, to this: addEventHandler ( "onClientResourceStart", resourceRoot, clientsideResourceStart ) If you leave it on getRootElement, then it'll trigger the function everytime a resource is started. Thanks a lot Else : Can you view my thread that I posted before about jail system , You helped me to fix the timer but I am still stuck with the text and it's been long and I still didn't figure out how to do it so can you please help me to fix it Link to comment
isa_Khamdan Posted September 11, 2013 Author Share Posted September 11, 2013 Hmm there still one problem the Names will never get updated How can I make them refresh if a player joined the server or if someone changed his nick. Link to comment
Castillo Posted September 11, 2013 Share Posted September 11, 2013 Use the events: onClientPlayerJoin onClientPlayerQuit onClientPlayerChangeNick Link to comment
isa_Khamdan Posted September 11, 2013 Author Share Posted September 11, 2013 Use the events:onClientPlayerJoin onClientPlayerQuit onClientPlayerChangeNick Hmm I know how to use these events but how can I make the grid list refresh the player names? Link to comment
Castillo Posted September 12, 2013 Share Posted September 12, 2013 A easy way is just clearing the gridlist and add the players everytime a player joins/quits/changes nicks. Or you can also loop the grid list items and see if any matches the player that quitted/changed nick. Link to comment
isa_Khamdan Posted September 13, 2013 Author Share Posted September 13, 2013 A easy way is just clearing the gridlist and add the players everytime a player joins/quits/changes nicks.Or you can also loop the grid list items and see if any matches the player that quitted/changed nick. Thanks a lot Link to comment
isa_Khamdan Posted September 13, 2013 Author Share Posted September 13, 2013 Is this right? function Refresh () guiGridListClear ( GUIEditor_Grid[1] ) if column then for id,playeritem in ipairs(getElementsByType("player")) do local row = guiGridListAddRow(GUIEditor_Grid[1]) guiGridListSetItemText(GUIEditor_Grid[1], row, column, getPlayerName(playeritem), false, false) end end end addEventHandler ( "onClientPlayerJoin", getRootElement(), Refresh ) addEventHandler ( "onClientPlayerQuit", getRootElement(), Refresh ) addEventHandler ( "onClientPlayerChangeNick", getRootElement(), Refresh ) Link to comment
Castillo Posted September 13, 2013 Share Posted September 13, 2013 Yes, that should work. 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