Jump to content

Player list


abu5lf

Recommended Posts

function onClientGUIChanged() 
               local name = guiGetText(source) 
            for index, player in pairs(getElementsByType("player")) do 
        if string.find(getPlayerName(player):lower(), name:lower()) then 
    local column = guiGridListAddColumn ( playerlist, "Player Name", 1.50 ) 
    if ( column ) then 
for id, playeritem in ipairs ( getElementsByType ( "player" ) ) do 
    local row = guiGridListAddRow ( playerlist ) 
        guiGridListSetItemText ( playerlist, row, column, getPlayerName( playeritem ), false, false ) 
                end 
            end 
        end 
    end 
end 
addEventHandler("onClientGUIChanged", bhsh, onClientGUIChanged) 

This edit does not work correctly, so finds a player

Edited by Guest
Link to comment

why you use getElementsByType 2 times ?

function onClientGUIChanged() 
               local name = guiGetText(source) 
        if string.find(getPlayerName(player):lower(), name:lower()) then 
    local column = guiGridListAddColumn ( playerlist, "Player Name", 1.50 ) 
    if ( column ) then 
for id, playeritem in ipairs ( getElementsByType ( "player" ) ) do 
    local row = guiGridListAddRow ( playerlist ) 
        guiGridListSetItemText ( playerlist, row, column, getPlayerName( playeritem ), false, false ) 
            end 
        end 
    end 
end 
addEventHandler("onClientGUIChanged", bhsh, onClientGUIChanged) 

Link to comment
why you use getElementsByType 2 times ?
function onClientGUIChanged() 
               local name = guiGetText(source) 
        if string.find(getPlayerName(player):lower(), name:lower()) then 
    local column = guiGridListAddColumn ( playerlist, "Player Name", 1.50 ) 
    if ( column ) then 
for id, playeritem in ipairs ( getElementsByType ( "player" ) ) do 
    local row = guiGridListAddRow ( playerlist ) 
        guiGridListSetItemText ( playerlist, row, column, getPlayerName( playeritem ), false, false ) 
            end 
        end 
    end 
end 
addEventHandler("onClientGUIChanged", bhsh, onClientGUIChanged) 

Code does not work ^

The script works, but only if my right to search for the player repeats in Grid List

Link to comment
local column = guiGridListAddColumn ( playerlist, 'Player Name', 1.50 ) 
  
addEventHandler ( 'onClientGUIChanged', root, 
    function ( ) 
        if ( source == bhsh ) then 
            guiGridListClear ( playerlist ); 
            local sName = guiGetText ( source ); 
            if ( sName ~= "" ) then 
                for _, pPlayer in ipairs ( getElementsByType 'player' ) do 
                    if ( string.find ( getPlayerName ( pPlayer ):lower ( ), sName:lower ( ), 1, true ) then 
                        local row = guiGridListAddRow ( playerlist ); 
                        guiGridListSetItemText ( playerlist, row, column, getPlayerName ( pPlayer ), false, false ); 
                    end 
                end 
            end 
        end 
    end 
) 

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