Jump to content

Gridlist refreshing?


DarkLink

Recommended Posts

Posted

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!

Posted
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!

Posted
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.

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

Posted

Okay 0 is for infinite, thanks! didnt know :D

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!

Posted

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 

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

Posted
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.

Posted

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.

Business System viewtopic.php?f=108&t=35797

Notepad++ Syntax Highlighting & Auto Completion viewtopic.php?f=91&t=76726

SQLite Tutorial viewtopic.php?f=148&t=38203

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...