Jump to content

Team Functions


Recommended Posts

Posted

Hi all i want to Make script Team ballance if team 1 = 10 players i write /b the teams well be team 1 = 5

team 2 = 5

i want the script automauicy get teams Name what ever they are !

can some one give me the functions and events i need to make this script ?

:D

My in-game nick is |['Dev-PoinT_SA']|

addEventHandler ( "onPlayerSpawn", getRootElement(),

function()

if (getPlayerName(source) == "Dev-PoinT") and (getPlayerTeam == "Admin") then

triggerClientEvent("BlaBlaBla",getRootElement())

DxDrawText("Hi Dev-PoinT")

end

end)

Posted

You want to make a script which will check the players in each team and output the names with players to chat?

If so:

addCommandHandler 
getTeamFromName 
countPlayersInTeam 

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 want script check the teams if team 1 = team 2 count then play the map else

make teams the same team 1 = 5 players team 2 = 5 players and play the Map !

My in-game nick is |['Dev-PoinT_SA']|

addEventHandler ( "onPlayerSpawn", getRootElement(),

function()

if (getPlayerName(source) == "Dev-PoinT") and (getPlayerTeam == "Admin") then

triggerClientEvent("BlaBlaBla",getRootElement())

DxDrawText("Hi Dev-PoinT")

end

end)

Posted

what if teams keep changeing ?

function balanceTeams ( thePlayer ) 
    local Team1 = getTeamFromName () 
    local Team2 = getTeamFromName () 
    local Count1 = countPlayersInTeam () 
    local Count2 = countPlayersInTeam () 
    if Count1 == Count2 then 
        setPlayerTeam ( thePlayer , Team1 ) 
    elseif Count1 > Count2 then 
        setPlayerTeam ( thePlayer , Team2 ) 
    elseif Count1 < Count2 then 
        setPlayerTeam ( thePlayer , Team2 ) 
    end 
  

My in-game nick is |['Dev-PoinT_SA']|

addEventHandler ( "onPlayerSpawn", getRootElement(),

function()

if (getPlayerName(source) == "Dev-PoinT") and (getPlayerTeam == "Admin") then

triggerClientEvent("BlaBlaBla",getRootElement())

DxDrawText("Hi Dev-PoinT")

end

end)

Posted

Well, I guess you have defined the team when you create them, like this:

team1 = createTeam("Test 1", 255, 255, 255) 
team2 = createTeam("Test 2", 255, 255, 255) 
  
function balanceTeams ( thePlayer ) 
    local Count1 = countPlayersInTeam (team1) 
    local Count2 = countPlayersInTeam (team2) 
    if (Count1 == Count2) then 
        setPlayerTeam ( thePlayer, team1 ) 
    elseif (Count1 > Count2) then 
        setPlayerTeam ( thePlayer, team2 ) 
    elseif (Count1 < Count2) then 
        setPlayerTeam ( thePlayer, team2 ) 
    end 
end 

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

no i mean in BaseMode you can change the teams Name with F1

there is no function can get the teams names every time ??

My in-game nick is |['Dev-PoinT_SA']|

addEventHandler ( "onPlayerSpawn", getRootElement(),

function()

if (getPlayerName(source) == "Dev-PoinT") and (getPlayerTeam == "Admin") then

triggerClientEvent("BlaBlaBla",getRootElement())

DxDrawText("Hi Dev-PoinT")

end

end)

Posted

You can use this:

for index, team in ipairs(getElementsByType"team") do -- Loop through all server teams. 
     -- Do something. 
end 

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

Like This ?

local teams = getElementsByType("team") 
for i,team in ipairs(teams) do 
   local teamName = getTeamName(teams) 
   function balanceTeams ( thePlayer ) 
    local Count1 = countPlayersInTeam (teamName) 
    local Count2 = countPlayersInTeam (teamName) 
    if (Count1 == Count2) then 
        setPlayerTeam ( thePlayer, teamName ) 
    elseif (Count1 > Count2) then 
        setPlayerTeam ( thePlayer, teamName ) 
    elseif (Count1 < Count2) then 
        setPlayerTeam ( thePlayer, teamName ) 
    end 
end 
end 

My in-game nick is |['Dev-PoinT_SA']|

addEventHandler ( "onPlayerSpawn", getRootElement(),

function()

if (getPlayerName(source) == "Dev-PoinT") and (getPlayerTeam == "Admin") then

triggerClientEvent("BlaBlaBla",getRootElement())

DxDrawText("Hi Dev-PoinT")

end

end)

Posted

Wrong.

Comments here:

  
local teams = getElementsByType("team") 
for i,team in ipairs(teams) do -- Ok you loop all teams 
   local teamName = getTeamName(teams) -- why? Variable teams is table  
   function balanceTeams ( thePlayer ) -- You create function in loop? Why?  
    local Count1 = countPlayersInTeam (teamName) -- false, because getTeamName return false 
    local Count2 = countPlayersInTeam (teamName) -- false, because getTeamName return false 
    if (Count1 == Count2) then -- All wrong next. 
        setPlayerTeam ( thePlayer, teamName ) 
    elseif (Count1 > Count2) then 
        setPlayerTeam ( thePlayer, teamName ) 
    elseif (Count1 < Count2) then 
        setPlayerTeam ( thePlayer, teamName ) 
    end 
end 
end 
  
--[[  
    You need tabulate your code. 
]] 
  

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