Jump to content

[HELP]Account Name In GridList


Seba500PLK

Recommended Posts

hi

I know I need to use the trigger, but do not know how

    
--Client 
  local tab = {} 
   local tabpanel = {} 
   local label = {} 
   local button = {} 
   local edit = {} 
  
local player = localPlayer 
  
function gridlist() 
  
local screenWidth, screenHeight = guiGetScreenSize() 
window1 = guiCreateWindow(screenWidth * 0.24, screenHeight * 0.2, 771, 457, "TEST", false) 
guiWindowSetSizable(window1, false) 
guiSetVisible(window1,false) 
  
  
  
accountGrid = guiCreateGridList(9, 23, 249, 228, false, window1) 
guiGridListSetSelectionMode(accountGrid, 2) 
  
  
  
end 
addEventHandler("onClientResourceStart", resourceRoot, gridlist) 
  
  
  
  addEventHandler("onClientResourceStart",resourceRoot, 
function() 
    if not isElement(window1) then gridlist() end 
    bindKey ( "F3", "down", openGui ) 
end ) 
  
function openGui() 
    if not isElement(window1) then gridlist() end 
    if not guiGetVisible(window1) then 
        --stats() 
        guiSetVisible ( window1, true ) 
        showCursor(true) 
    else 
        guiSetVisible ( window1, false ) 
        showCursor(false) 
    end 
    end 
  
function gridacc () 
    --Create the grid list element 
    --local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) 
    --Create a players column in the list 
    local column = guiGridListAddColumn( accountGrid, "Player", 0.85 ) 
    if ( column ) then --If the column has been created, fill it with players 
        for id, player in ipairs(getElementsByType("player")) do 
            local row = guiGridListAddRow ( accountGrid ) 
            guiGridListSetItemText ( accountGrid, row, column, getPlayerName( player ), false, false ) 
        end 
    end 
end 
 addEventHandler ( "onClientResourceStart", getResourceRootElement(), gridacc ) 
  

Link to comment

What did I do wrong?

  
--Client 
function gridacc (acc) 
    --Create the grid list element 
    --local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) 
    --Create a players column in the list 
    local column = guiGridListAddColumn( accountGrid, "Player", 0.85 ) 
    if ( column ) then --If the column has been created, fill it with players 
        for id, player in ipairs(getElementsByType("player")) do 
            local row = guiGridListAddRow ( accountGrid ) 
            guiGridListSetItemText ( accountGrid, row, column, acc( player ), false, false ) 
        end 
    end 
end 
 addEventHandler ( "onClientResourceStart", getResourceRootElement(), gridacc ) 
 addEvent("updateGuis", true) 
 addEventHandler("updateGuis", root, gridacc) 

  
--Server 
function update(client) 
local who = getPlayerFromName (client); 
local account = getPlayerAccount( who ); 
triggerClientEvent ( "updateGuis", getRootElement(), getAccountName ( account ) ) 
end 

Link to comment

--Client

--Client 
function gridacc (account) 
     local playerList = guiCreateGridList ( 0.80, 0.10, 0.15, 0.60, true ) 
    local column = guiGridListAddColumn( playerList, "Player", 0.85 ) 
    if ( column ) then 
            local row = guiGridListAddRow ( playerList ) 
            guiGridListSetItemText(playerList, row, column, account, false, false ) 
        end 
    end 
addEvent("onAccountsSend",true) 
addEventHandler("onAccountsSend",root, gridacc) 
addEventHandler ( 'onClientResourceStart', resourceRoot, gridacc ) 

---server

addEventHandler('onPlayerLogin',root, 
function ( ) 
 for _, account in pairs( getAccounts( ) ) do 
 account = getAccountName( account ) 
 triggerClientEvent( 'onAccountsSend',root, account ) 
  end 
end 
) 

Make sure your logged in before start the script .

Edited @

Edited by Guest
Link to comment
addEventHandler('onPlayerLogin',root, 
function ( ) 
local accounts = {} 
 for _, account in pairs( getAccounts( ) ) do 
 account = getAccountName( account ) 
 table.insert(accounts, account) 
  end 
 triggerClientEvent( 'onAccountsSend',root, accounts ) 
end 
) 

Don't trigger it for every player :roll:

Link to comment
addEventHandler('onPlayerLogin',root, 
function ( ) 
local accounts = {} 
 for _, account in pairs( getAccounts( ) ) do 
 account = getAccountName( account ) 
 table.insert(accounts, account) 
  end 
 triggerClientEvent( 'onAccountsSend',root, accounts ) 
end 
) 

Don't trigger it for every player :roll:

grid show:

Payer

____________________________

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