Jump to content

Gridlist Problem


Khalil

Recommended Posts

Posted

Hello.

I made a gridlist to get all players in the server. I do the command to open the gui and it looks fine. I close the gui, and open it again, then I find three of the same player on the gridlist, I don't know what to do, here's the code:

function showGUI ( ) 
        local tostate = not guiGetVisible ( win ) 
        guiSetVisible ( win, tostate ) 
        showCursor ( tostate ) 
for index, player in ipairs ( getElementsByType ( 'player' ) ) do 
 if ( player ~= localPlayer ) then 
  guiGridListSetItemText ( gridList, guiGridListAddRow ( gridList ), 1, getPlayerName ( player ), false, false ) 
 end 
end 
end 
addCommandHandler("aj",showGUI) 

Level 3 admin on RRC:RPG.

560x95.png

Posted
function showGUI ( ) 
        local tostate = not guiGetVisible ( win ) 
        guiSetVisible ( win, tostate ) 
        showCursor ( tostate ) 
       guiGridListClear(gridList) 
for index, player in ipairs ( getElementsByType ( 'player' ) ) do 
 if ( player ~= localPlayer ) then 
  guiGridListSetItemText ( gridList, guiGridListAddRow ( gridList ), 1, getPlayerName ( player ), false, false ) 
 end 
end 
end 
addCommandHandler("aj",showGUI) 

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

Posted

Works fine thanks :)

Also, when a player leaves the server, the gridlist should automatically refresh, how do I do that?

Level 3 admin on RRC:RPG.

560x95.png

Posted
  
function refreshGUI() 
  
 guiGridListClear(gridList) 
for index, player in ipairs ( getElementsByType ( 'player' ) ) do 
 if ( player ~= localPlayer ) then 
  guiGridListSetItemText ( gridList, guiGridListAddRow ( gridList ), 1, getPlayerName ( player ), false, false ) 
 end 
end 
  
end 
  
  
  
addEventHandler( "onClientPlayerQuit", getRootElement(), refreshGUI )  

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

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