Xeno Posted January 1, 2012 Share Posted January 1, 2012 I have a problem with getting all the players in a team... Here is my code: local team = getTeamFromName("Aliens") local players = getPlayersInTeam (team) dxDrawText ( "Team:", 175, screenHeight - 98, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) dxDrawText ( "Team:"..players.."", 175, screenHeight - 100, screenWidth, screenHeight, tocolor ( 255, 0, 0, 255 ), 1, "pricedown" ) The debug says: Attempt to concentrate local "players" (a table value) I would appreciate if you helped me. Link to comment
Castillo Posted January 1, 2012 Share Posted January 1, 2012 I guess you want to count the players, if so, use this: local team = getTeamFromName("Aliens") local players = countPlayersInTeam(team) dxDrawText ( "Team:", 175, screenHeight - 98, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) dxDrawText ( "Team:".. tostring(players) .."", 175, screenHeight - 100, screenWidth, screenHeight, tocolor ( 255, 0, 0, 255 ), 1, "pricedown" ) Link to comment
TAPL Posted January 1, 2012 Share Posted January 1, 2012 (edited) .. Edited January 1, 2012 by Guest Link to comment
bandi94 Posted January 1, 2012 Share Posted January 1, 2012 local text="" local team = getTeamFromName("Aliens") local players = getPlayersInTeam (team) dxDrawText ( "Team:", 175, screenHeight - 98, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) for i,v in pairs (players) do text=text.." , "..getPlayerName(v) end dxDrawText ( "Team:"..text, 175, screenHeight - 100, screenWidth, screenHeight, tocolor ( 255, 0, 0, 255 ), 1, "pricedown" ) Link to comment
Xeno Posted January 1, 2012 Author Share Posted January 1, 2012 It does not display the player name. Link to comment
Castillo Posted January 1, 2012 Share Posted January 1, 2012 What do you mean? P.S: Maybe try to explain what are you trying to do? Link to comment
Xeno Posted January 1, 2012 Author Share Posted January 1, 2012 I'm trying to make it display all the players names that are in the team. Sorry, I didn't make it very clear lol. Link to comment
Castillo Posted January 1, 2012 Share Posted January 1, 2012 I tested that script and it show's me, but I don't know if it'll show all players. Link to comment
Xeno Posted January 1, 2012 Author Share Posted January 1, 2012 Congradulations! Guru! And ill test it again... local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) function createText ( ) local text="" local team = getTeamFromName("Aliens") local players = getPlayersInTeam (team) dxDrawText ( "Team:", 175, screenHeight - 98, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) for i,v in pairs (players) do text=text.." , "..getPlayerName(v) end function HandleTheRendering ( ) addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. end addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering) That is my full script Link to comment
bandi94 Posted January 2, 2012 Share Posted January 2, 2012 you forgot an "end" local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) function createText ( ) local text="" local team = getTeamFromName("Aliens") local players = getPlayersInTeam (team) dxDrawText ( "Team:", 175, screenHeight - 98, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) for i,v in pairs (players) do text=text.." , "..getPlayerName(v) end end function HandleTheRendering ( ) addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. end addEventHandler ( "onClientResourceStart", resourceRoot, HandleTheRendering) Link to comment
Kenix Posted January 2, 2012 Share Posted January 2, 2012 More better and it should working: local screenWidth, screenHeight = guiGetScreenSize ( ) -- Get the screen resolution (width and height) function createText ( ) local team = getTeamFromName( "Aliens" ) if team then dxDrawText ( "Team:\n"..table.concat( getPlayersInTeam ( team ),"\n" ), 175, screenHeight - 98, screenWidth, screenHeight, tocolor ( 0, 0, 0, 255 ), 1.02, "pricedown" ) end end addEventHandler ( "onClientRender", root, createText ) -- keep the text visible with onClientRender. Example draw: Team: Player1 Player2 ... 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