Jump to content

Getting all players in a team


Xeno

Recommended Posts

Posted

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.

Posted

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" ) 

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted
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" ) 

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

Posted

What do you mean?

P.S: Maybe try to explain what are you trying to do?

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

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.

Posted

I tested that script and it show's me, but I don't know if it'll show all players.

San Andreas Utopia RPG (SAUR) Owner & Developer.

560x95_FFFFFF_FF9900_000000_000000.png

Education is the most powerful weapon which you can use to change the world.

Posted

Congradulations! Guru! :D

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

Posted

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) 

Ingame Name : |DGT|Puma

DGT Clan Server 24/7 Owner/Scripter

MultiGameMode in progress :

n-560x95_FFFFFF_FFFFFF_0283C4_000000.png

Posted

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

...

http://vk.com/the_kenix

Вопросы задавайте на форуме, не пишите мне в личку.

Please don't pm me.

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