XeRo Posted July 28, 2015 Share Posted July 28, 2015 PlayerClan = guiCreateLabel(6, 96, 170, 24, "Clan:", false, UserPanel) guiSetFont(PlayerClan, "default-bold-small") addEventHandler("onClientResourceStart",getRootElement(), function() if getElementsByType("team") then guiSetText(PlayerClan,"Clan:",getTeamName ( team )) end end ) Link to comment
Dealman Posted July 28, 2015 Share Posted July 28, 2015 getElementsByType returns a table, therefore you need to loop through them. You'll want to read about for loops. Here's 2 examples on how you can do it; local allTeams = getElementsByType("team") if(allTeams) then -- If allTeams is not false or nil, then continue for key, value in ipairs(allTeams) do outputChatBox("Team #"..tostring(key)..": "..tostring(value)) -- Will output like this; "Team #1: BlueTeam", "Team #2: RedTeam" end else outputChatBox("Failed to retrieve teams!") -- If allTeams returned false or nil, this will be output. end -- Alternatively you can write it like this, but it's generally better to use if statements to catch errors and let the user know what went wrong. for key, value in ipairs(getElementsByType("team")) do local teamName = getTeamName(value) -- This will get the team name for each team in the table. outputChatBox(tostring(teamName)) -- You can use tostring in case it would return false or nil. end 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