Jump to content

[HELP] How to insert teams after playerlist in scoreboard?


Turbe$Z

Recommended Posts

  • Scripting Moderators
5 hours ago, Turbo777 said:

I created a scoreboard script, and the playerlist working fine, but i dont know how to insert teams, and team players after the playerlist, like in the default scoreboard script.. :s 

Anyone can help me?

https://wiki.multitheftauto.com/wiki/GuiGridListSetItemText

bool guiGridListSetItemText ( element gridList, int rowIndex, int columnIndex, string text, bool section, bool number )

You're looking for that (if we're talking about GUI)

section: Determines if the item is a section

 

Edited by majqq
Link to comment

I dont know the way that you are inserting the players to the scoreboard, but i will give you an example including teams:

scoreboard_rows = {};

for i, player in pairs(getElementsByType("player")) do
    if not getPlayerTeam(player) then
        table.insert(scoreboard_rows, player);
    end
end

for i, team in pairs(getElementsByType("team")) do
    local team_players = getPlayersInTeam(team);
  
    if #team_players > 0 then
        table.insert(scoreboard_rows, team);
    
        for i, player in pairs(team_players) do
            table.insert(scoreboard_rows, player);
        end
    end
end

 

Link to comment
19 hours ago, TRtam said:

I dont know the way that you are inserting the players to the scoreboard, but i will give you an example including teams:


scoreboard_rows = {};

for i, player in pairs(getElementsByType("player")) do
    if not getPlayerTeam(player) then
        table.insert(scoreboard_rows, player);
    end
end

for i, team in pairs(getElementsByType("team")) do
    local team_players = getPlayersInTeam(team);
  
    if #team_players > 0 then
        table.insert(scoreboard_rows, team);
    
        for i, player in pairs(team_players) do
            table.insert(scoreboard_rows, player);
        end
    end
end

 

how to loop this table in dx?

Link to comment

Like this

addEventHandler("onClientRender", root,
    function()
        local scoreboard_rows = {};

        for i, player in pairs(getElementsByType("player")) do
            if not getPlayerTeam(player) then
                table.insert(scoreboard_rows, player);
            end
        end

        for i, team in pairs(getElementsByType("team")) do
            local team_players = getPlayersInTeam(team);
          
            if #team_players > 0 then
                table.insert(scoreboard_rows, team);
            
                for i, player in pairs(team_players) do
                    table.insert(scoreboard_rows, player);
                end
            end
        end

        for i, row in pairs(scoreboard_rows) do
            if getElementType(row) == "player" then
                -- draw your dx stuff here
            elseif getElementType(row) == "team" then
                -- draw your dx stuff here
            end
        end
    end
)
  • Thanks 1
Link to comment
3 hours ago, TRtam said:

Like this


addEventHandler("onClientRender", root,
    function()
        local scoreboard_rows = {};

        for i, player in pairs(getElementsByType("player")) do
            if not getPlayerTeam(player) then
                table.insert(scoreboard_rows, player);
            end
        end

        for i, team in pairs(getElementsByType("team")) do
            local team_players = getPlayersInTeam(team);
          
            if #team_players > 0 then
                table.insert(scoreboard_rows, team);
            
                for i, player in pairs(team_players) do
                    table.insert(scoreboard_rows, player);
                end
            end
        end

        for i, row in pairs(scoreboard_rows) do
            if getElementType(row) == "player" then
                -- draw your dx stuff here
            elseif getElementType(row) == "team" then
                -- draw your dx stuff here
            end
        end
    end
)

thank you :)

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