Avir14 Posted August 25, 2023 Share Posted August 25, 2023 (edited) 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 August 25, 2023 by Avir14 edited Link to comment
Shady1 Posted August 25, 2023 Share Posted August 25, 2023 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
Avir14 Posted August 25, 2023 Author Share Posted August 25, 2023 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
_SAXI_ Posted August 26, 2023 Share Posted August 26, 2023 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
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now