Xeno Posted January 1, 2012 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.
Castillo Posted January 1, 2012 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" )
bandi94 Posted January 1, 2012 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" )
Castillo Posted January 1, 2012 Posted January 1, 2012 What do you mean? P.S: Maybe try to explain what are you trying to do?
Xeno Posted January 1, 2012 Author 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.
Castillo Posted January 1, 2012 Posted January 1, 2012 I tested that script and it show's me, but I don't know if it'll show all players.
Xeno Posted January 1, 2012 Author 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
bandi94 Posted January 2, 2012 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)
Kenix Posted January 2, 2012 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 ...
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