Jump to content

[HELP] refresh guiGridList with Players?


PlayAkoya

Recommended Posts

Hi,

i have created a guiGridList and would like the players are always updated.

If I choose a player disappears always marking.

After updating always disappears My choice and that must not happen?

function refreshGridList() 
  
    if isElement(newGridlist) then 
        guiGridListClear(newGridlist) 
        for id, player in ipairs (getElementsByType ("player")) do  
            local row = guiGridListAddRow(newGridlist) 
            guiGridListSetItemText(newGridlist, row, column, getPlayerName(player), false, false) 
        end 
    end 
end 
  
function createGridList() 
  
    newGridlist = guiCreateGridList(0.50, 0.50, 0.20, 0.30, true) 
    column = guiGridListAddColumn(newGridlist, "Players", 0.85) 
    if (column) then 
        for id, player in ipairs(getElementsByType("player")) do 
            local row = guiGridListAddRow(newGridlist) 
            guiGridListSetItemText(newGridlist, row, column, getPlayerName(player), false, false) 
        end 
    end 
    getGridListTimer = setTimer(refreshGridList, 500, -1) 
    guiGridListSetSortingEnabled(newGridlist, false) 
end 

I hope someone can help me how to truly important to me!

Link to comment
function refreshGridList() 
     if isElement(newGridlist) then 
        guiGridListClear(newGridlist) 
        for _, player in pairs (getElementsByType ("player")) do 
            local row = guiGridListAddRow(newGridlist) 
            guiGridListSetItemText(newGridlist, row, column, getPlayerName(player), false, false) 
        end 
    end 
end 
addEventHandler("onClientPlayerJoin", root, refreshGridList) 
addEventHandler("onClientPlayerQuit", root, refreshGridList) 
  
function createGridList() 
     newGridlist = guiCreateGridList(0.50, 0.50, 0.20, 0.30, true) 
    column = guiGridListAddColumn(newGridlist, "Players", 0.85) 
    if (column) then 
        refreshGridList() 
    end 
    guiGridListSetSortingEnabled(newGridlist, false) 
end 

Or, you can add rows when a client joins and remove rows when a client disconnects.

Link to comment
You can use this and be sure to replace gridList and column with your.
function updateList(old, new) 
    if eventName == "onClientPlayerJoin"  then 
        local row = guiGridListAddRow(gridList) 
        guiGridListSetItemText(gridList, row, column, getPlayerName(source), false, false) 
    elseif eventName == "onClientPlayerQuit"  then 
        for i=0, guiGridListGetRowCount(gridList) do 
            if guiGridListGetItemText(gridList, i, column) == getPlayerName(source) then 
                guiGridListRemoveRow(gridList, i) 
            end 
        end 
    elseif eventName == "onClientPlayerChangeNick"  then 
        for i=0, guiGridListGetRowCount(gridList) do 
            if guiGridListGetItemText(gridList, i, column) == old then 
                guiGridListSetItemText(gridList, i, column, new, false, false) 
            end 
        end 
    end 
end 
addEventHandler("onClientPlayerJoin", root, updateList) 
addEventHandler("onClientPlayerQuit", root, updateList) 
addEventHandler("onClientPlayerChangeNick", root, updateList) 

Though you need to do -1 for guiGridListGetRowCount as i didn't do this the time i posted this code, it still work anyway.

Link to comment

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