DarkLink Posted June 25, 2011 Share Posted June 25, 2011 Ok guys, I wanna do the following: Gridlist with column players (I already have), now I want another column with state of player, like dead or alive.. For example: On server I would trigger the event on player die, and changes his state on grid from alive to dead. right? but now here is my question: i need to get the row of that player, so then I can do "GuiGridListSetItemText" and changes the string to dead on respective column. So how I can get the row on the grid list of that player died ? Can I search for his name on all the gridlist ? and then get his row ? with some function? Thanks guys! Link to comment
[DemoN] Posted June 25, 2011 Share Posted June 25, 2011 getAlivePlayers, getDeadPlayers getAlivePlayers getDeadPlayers try these functions... Link to comment
DarkLink Posted June 25, 2011 Author Share Posted June 25, 2011 getAlivePlayers, getDeadPlayers getAlivePlayers getDeadPlayers try these functions... yes thanks, that should help. but wasnt that my problem. after I get all the players dead, and all players alive. I need to change their string on state column, how do I get those players from the grid ? I need to get their row.. so I can set new text for them on state column did u understand my problem? thanks alot! Link to comment
will briggs Posted June 25, 2011 Share Posted June 25, 2011 Set a timer for when you want it to refresh... And look on the wiki for a refreshrate Link to comment
JR10 Posted June 25, 2011 Share Posted June 25, 2011 getAlivePlayers, getDeadPlayers yes thanks, that should help. but wasnt that my problem. after I get all the players dead, and all players alive. I need to change their string on state column, how do I get those players from the grid ? I need to get their row.. so I can set new text for them on state column did u understand my problem? thanks alot! All you need to do is make a timer that will get all players and and set his state in the gridlist. example: function getPlayerState(player) if getElementHealth(player) > 0 then return 'Alive' else return 'Dead' end end function refreshGridlist() for i, v in ipairs(getElementsByType('player')) do local row = guiGridListAddRow(gridList) guiGridListSetItemText(gridList, row, 1, getPlayerName(v), false, false) guiGridListSetItemText(gridList, row, 2, getPlayerState(v), false, false) end end Now edit gridList to your grid list variable and set a timer for refreshGridlist function. Good luck. Link to comment
DarkLink Posted June 25, 2011 Author Share Posted June 25, 2011 Thanks for ur help guys, and how many times I will set the timer to repeat? I mean its suppose to refresh till the resource end So almost like infinite times.. Link to comment
JR10 Posted June 25, 2011 Share Posted June 25, 2011 setTimer(refreshGridlist, 1000, 0) Link to comment
DarkLink Posted June 25, 2011 Author Share Posted June 25, 2011 Okay 0 is for infinite, thanks! didnt know Just one more question, here on ur code.. function refreshGridlist() for i, v in ipairs(getElementsByType('player')) do local row = guiGridListAddRow(gridList) guiGridListSetItemText(gridList, row, 1, getPlayerName(v), false, false) guiGridListSetItemText(gridList, row, 2, getPlayerState(v), false, false) end end This function will constantly add new lines (I mean rows..)..? And its suppose to changes the ones that are already made. I am not sure if u understand me Thanks! Link to comment
JR10 Posted June 25, 2011 Share Posted June 25, 2011 Oh you are right replace it with this: function refreshGridlist() guiGridListClear(gridList) for i, v in ipairs(getElementsByType('player')) do local row = guiGridListAddRow(gridList) guiGridListSetItemText(gridList, row, 1, getPlayerName(v), false, false) guiGridListSetItemText(gridList, row, 2, getPlayerState(v), false, false) end end Link to comment
DarkLink Posted June 25, 2011 Author Share Posted June 25, 2011 Oh you are right replace it with this: function refreshGridlist() guiGridListClear(gridList) for i, v in ipairs(getElementsByType('player')) do local row = guiGridListAddRow(gridList) guiGridListSetItemText(gridList, row, 1, getPlayerName(v), false, false) guiGridListSetItemText(gridList, row, 2, getPlayerState(v), false, false) end end Ahhhhh!!! So I need always to clear a grid if I want to change a single value. I though it was possible to get which players died from the grid and only change their state column on the grid. Okay now I get it.. I need to change everything, not possible to change individual rows. Thanks bro. Link to comment
JR10 Posted June 25, 2011 Share Posted June 25, 2011 No, you only need to clear the grid if you want to fill it again from scratch cleaing the grid list will clear every row in it which is needed in order not to have the players doubled because refreshGridlist will fill it from scratch. Link to comment
DarkLink Posted June 25, 2011 Author Share Posted June 25, 2011 No, you only need to clear the grid if you want to fill it again from scratch cleaing the grid list will clear every row in it which is needed in order not to have the players doubled because refreshGridlist will fill it from scratch. yes I understand that, so not possible to edit a single row.. when its the grid is filled with rows? right? thanks again Link to comment
JR10 Posted June 25, 2011 Share Posted June 25, 2011 It's possible, you just need to find the row and column then use guiGridListSetItemText EDIT: here is a way of editing one row function updatePlayerStateInGridlist() local rows = guiGridListGetRowCount(gridList) for i=0, rows do if guiGridListGetItemText(gridList, i, 1) == getPlayerName(getLocalPlayer()) then if getElementHealth(getLocalPlayer()) > 0 then guiGridListSetItemText(gridList, i, 2, 'Alive', false, false) else guiGridListSetItemText(gridList, i, 2, 'Dead', false, false) end end end end just set a timer for the function. Link to comment
DarkLink Posted June 25, 2011 Author Share Posted June 25, 2011 I understood, thanks alot bro. Thats exactly what I was trying to do, didnt know rows was a int starting from zero to number of rows.. Now I can make a for and search all the rows, just with a iteration for Didnt know ^^ thanks alot again ! 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