Jump to content

[HELP]Account Name In GridList


Seba500PLK

Recommended Posts

Posted

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 ) 
  

Posted

You can use elementData to store the the player's account name when he log in. And update it on the events: onPlayerQuit/onPlayerLogout.

And then only use getElementData function to get the account name of the player.

Please do not PM me with scripting related question nor support, use the forums instead.

Posted

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 

Posted

You could try this.

function update(thePreviousAccount, theCurrentAccount) 
triggerClientEvent ( "updateGuis", getRootElement(), theCurrentAccount ) 
end 
addEventHandler("onPlayerLogin", root, update) 

s.epicrow.com:22003.png

Posted (edited)

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

- New , Kill System

- New, GameMode Intro

- Leve / Exp System

- New nametag showing style

- New , Hud For Players

- Skin Selection from SA-MP

- Money System / Buy Weapons

- Drop Weapons

- New, Flood System

- New , Group Assign

- Gun license For Weapons

- Random Rule System For Money

Posted
logged and grid just shows :

Player

________________________

Copy My Post again

Login - > start the script .

- New , Kill System

- New, GameMode Intro

- Leve / Exp System

- New nametag showing style

- New , Hud For Players

- Skin Selection from SA-MP

- Money System / Buy Weapons

- Drop Weapons

- New, Flood System

- New , Group Assign

- Gun license For Weapons

- Random Rule System For Money

Posted
0.o in grid: AbbSS

what is it?

what do you mean ?

it's get all the accounts in the server and add them to the gridlist as you want .

- New , Kill System

- New, GameMode Intro

- Leve / Exp System

- New nametag showing style

- New , Hud For Players

- Skin Selection from SA-MP

- Money System / Buy Weapons

- Drop Weapons

- New, Flood System

- New , Group Assign

- Gun license For Weapons

- Random Rule System For Money

Posted

Change Server to this ,

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

- New , Kill System

- New, GameMode Intro

- Leve / Exp System

- New nametag showing style

- New , Hud For Players

- Skin Selection from SA-MP

- Money System / Buy Weapons

- Drop Weapons

- New, Flood System

- New , Group Assign

- Gun license For Weapons

- Random Rule System For Money

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

Posted
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

____________________________

Posted

Bad argument @ 'guiGridListSetItemText'[Expected string at argument 4, got resource-data]

Bad argument @ 'guiGridListSetItemText'[Expected string at argument 4, got table]

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