Jump to content

how to get alive players in team ?


Recommended Posts

Hi Guys ,,

I have A simple Question

How Can Get Alive Players In Team ??

i Want make script Calculate the points of teams

it's benefit?

  
local myteam = createTeam("mtasa.com") 
local players = getPlayersInTeam(myteam) 
local aliveplayers = getAlivePlayers(players) 
  

>>> i don't think xD >>> noob

sorry i'am noob ,,

and sorry for my english LoL :mrgreen:

Link to comment
local myteam = createTeam("mtasa.com") 
  
function getAlivePlayersInTeam(theTeam) 
local players = getPlayersInTeam(theTeam) 
for i,v in pairs(players) do 
if getElementHealth(v) >= 1 then 
    end 
end 
return players 
end 

With that function you can do getAlivePlayersInTeam(myteam) and it should return a table with the alive players in the desired team.

Link to comment
local myteam = createTeam("mtasa.com") 
  
function getAlivePlayersInTeam(theTeam) 
local players = getPlayersInTeam(theTeam) 
for i,v in pairs(players) do 
if getElementHealth(v) >= 1 then 
    end 
end 
return players 
end 

With that function you can do getAlivePlayersInTeam(myteam) and it should return a table with the alive players in the desired team.

clearly needs some fixes, also imo tis better to use built in functions if aviable.

local myteam = createTeam("mtasa.com") 
  
function getAlivePlayersInTeam(theTeam) 
local table = { } 
local players = getPlayersInTeam(theTeam) 
for i,v in pairs(players) do 
if not isPedDead(v) then 
    table[#table+1]=v 
    end 
end 
return table 
end 

Link to comment

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