Jump to content

x[ERROR]x getPlayerTeam


Avir14

Recommended Posts

i want to get the number of player in the team of player

function showTeamFunction ( command,source )
local playerTeam = getPlayerTeam ( source ) 
        if ( playerTeam ) then
                local players = getPlayersInTeam ( playerTeam ) 
                for playerKey, playerValue in ipairs ( players ) do
                        outputChatBox ( getPlayerName(playerValue) )
                end
        end
end

addCommandHandler ( "showTeam", showTeamFunction )

ERROR IN LINE 3 >>> https://img.onl/SG7tLX

 

Edited by Avir14
edited
Link to comment
4 hours ago, Avir14 said:

i want to get the number of player in the team of player

function showTeamFunction ( command,source )
local playerTeam = getPlayerTeam ( source ) 
        if ( playerTeam ) then
                local players = getPlayersInTeam ( playerTeam ) 
                for playerKey, playerValue in ipairs ( players ) do
                        outputChatBox ( getPlayerName(playerValue) )
                end
        end
end

addCommandHandler ( "showTeam", showTeamFunction )

ERROR IN LINE 3 >>> https://img.onl/SG7tLX

 

function showTeamFunction(command, source)
    -- Check if the source (player element) is valid
    if not source or getElementType(source) ~= "player" then
        outputChatBox("Invalid player source.")
        return
    end
    
    local playerTeam = getPlayerTeam(source)
    
    if playerTeam then
        local players = getPlayersInTeam(playerTeam)
        for playerKey, playerValue in ipairs(players) do
            outputChatBox(getPlayerName(playerValue))
        end
    else
        outputChatBox("You are not in a team.")
    end
end

addCommandHandler("showTeam", showTeamFunction)

 

Link to comment
17 hours ago, Shady1 said:
function showTeamFunction(command, source)
    -- Check if the source (player element) is valid
    if not source or getElementType(source) ~= "player" then
        outputChatBox("Invalid player source.")
        return
    end
    
    local playerTeam = getPlayerTeam(source)
    
    if playerTeam then
        local players = getPlayersInTeam(playerTeam)
        for playerKey, playerValue in ipairs(players) do
            outputChatBox(getPlayerName(playerValue))
        end
    else
        outputChatBox("You are not in a team.")
    end
end

addCommandHandler("showTeam", showTeamFunction)

 

not working this happens in the chat why >>> 
Invalid player source.
Link to comment

Try this:

function showTeamFunction(source)
    local playerTeam = getPlayerTeam ( source ) 
    if ( playerTeam ) then
            local players = getPlayersInTeam ( playerTeam ) 
            for playerKey, playerValue in ipairs ( players ) do
                    outputChatBox ( getPlayerName(playerValue) )
            end
    end
end
    
addCommandHandler ( "showTeam", showTeamFunction )

 

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