Jump to content

Players in the server


S3Nn4oXx

Recommended Posts

  toni012899 said:
Firstly show your code.

To get full online player list (with nickname) use this:

for i,player in ipairs(getElementsByType("player")) do 
    getPlayerNametagText(player) 
end 

Note: This is just an example!

  
gridlist = guiCreateGridList(565, 309, 249, 268, false) 
        guiGridListAddColumn(gridlist, "Players", 0.9)   
  

This is the gridlist script how to add the players to this gridlist?

Link to comment
function fillTable() 
    playerTable = {} 
    for i,player in ipairs(getElementsByType("player")) do 
        table.insert(playerTable,getPlayerNametagText(player)) 
    end 
    for k,v in pairs(playerTable) do 
        local row = guiGridListAddRow(gridlist) 
        guiGridListSetItemText(gridlist, row,1, tostring(v[1]), false, false) 
    end 
end 

Link to comment
  S3Nn4oXx said:
Not working
function addPlayersToGridlist() 
    guiGridListClear(gridlist) 
    for index, players in pairs(getElementsByType("player")) do  
        local row = guiGridListAddRow(gridlist) 
        local name = getPlayerName(players) 
        guiGridListSetItemText(gridlist, row,1, name, false, false) 
   end 
end 

Link to comment
  
 function ChokingSystem() 
      local screenW, screenH = guiGetScreenSize() 
        Window = guiCreateWindow((screenW - 329) / 2, (screenH - 227) / 2, 329, 227, "Choking System @SpRoXx", false) 
        guiWindowSetSizable(Window, false) 
  
        StartC = guiCreateButton(238, 187, 82, 31, "StartC", false, Window) 
        guiSetProperty(StartC, "NormalTextColour", "FFAAAAAA") 
        gridlist = guiCreateGridList(10, 41, 176, 174, false, Window) 
        guiGridListAddColumn(gridlist, "Players", 0.9) 
        label = guiCreateLabel(216, 41, 94, 37, "Select a player", false, Window) 
        guiSetFont(label, "default-bold-small") 
        StopC = guiCreateButton(238, 146, 82, 31, "StopC", false, Window) 
        guiSetProperty(StopC, "NormalTextColour", "FFAAAAAA")  
        CloseB = guiCreateButton(238, 105, 82, 31, "Close", false, Window) 
        guiSetProperty(CloseB, "NormalTextColour", "FFAAAAAA")     
        showCursor(true) 
        addEventHandler ( "onClientGUIClick", CloseB, closeL, false ) 
 end 
addCommandHandler("c", ChokingSystem) 
  
  
function fillTable() 
    playerTable = {} 
    for i,player in ipairs(getElementsByType("player")) do 
        table.insert(playerTable,getPlayerNametagText(player)) 
    end 
    for k,v in pairs(playerTable) do 
        local row = guiGridListAddRow(gridlist) 
        guiGridListSetItemText(gridlist, row,1, tostring(v[1]), false, false) 
    end 
end  
  
function closeL( button ) 
    if button == "left" then 
    guiSetVisible(Window ,false) 
    showCursor(false) 
    end 
end 
addEventHandler ( "onClientGUIClick", CloseB, closeL, false ) 
  

No Debug but the players doesn't appear in the gridlist

Link to comment

lol

addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        local screenW, screenH = guiGetScreenSize() 
        Window = guiCreateWindow((screenW - 329) / 2, (screenH - 227) / 2, 329, 227, "Choking System @SpRoXx", false) 
        guiWindowSetSizable(Window, false) 
        guiSetAlpha(Window, 1.00) 
        guiSetVisible(Window, false) 
         
        gridlist = guiCreateGridList(10, 41, 176, 174, false, Window) 
        guiGridListAddColumn(gridlist, "Players", 0.9) 
        label = guiCreateLabel(216, 41, 94, 37, "Select a player", false, Window) 
        guiSetFont(label, "default-bold-small") 
         
        StartC = guiCreateButton(238, 187, 82, 31, "StartC", false, Window) 
        StopC = guiCreateButton(238, 146, 82, 31, "StopC", false, Window) 
        CloseB = guiCreateButton(238, 105, 82, 31, "Close", false, Window) 
         
        buttons = {StartC,StopC,CloseB} 
         
        for i,v in pairs (buttons) do 
            guiSetProperty(v, "NormalTextColour", "FFAAAAAA") 
        end      
        -- Events 
    addEventHandler ( "onClientGUIClick", CloseB, closeL, false ) 
end 
) 
  
function openPanel() 
if ( guiGetVisible(Window) ) then 
        guiSetVisible(Window, false ) 
        showCursor( false ) 
    else 
        guiSetVisible(Window, true ) 
        showCursor( true ) 
        addPlayersToGridlist() 
    end 
end 
addCommandHandler("c", openPanel) 
  
  
function addPlayersToGridlist() 
    guiGridListClear(gridlist) 
    for index, players in pairs(getElementsByType("player")) do 
        local row = guiGridListAddRow(gridlist) 
        local name = getPlayerName(players) 
        guiGridListSetItemText(gridlist, row,1, name, false, false) 
   end 
end 
  
  
function closeL( buttons,state ) 
    if button == "left" and state == "up" then 
        guiSetVisible(Window ,false) 
        showCursor(false) 
    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...