Jump to content

some Help in Teams :(


^Dev-PoinT^

Recommended Posts

Posted

Give this line to your code.

ouputChatBox ( "teamBlue: ".. tostring ( teamBlue ).. "; teamRed: ".. tostring ( teamRed) ) 

What does it output?

Posted

no thing and debguscript nothing To how about use getElementByType (team)?

teamRed = createTeam ( "Red", 255, 0, 0 ) 
teamBlue = createTeam ( "Blue", 0, 0, 255 ) 
  
function balanceTeams ( ) 
    local RedCount = countPlayersInTeam ( teamBlue ) 
    local BlueCount = countPlayersInTeam ( teamRed ) 
    if RedCount ~= BlueCount then 
        if RedCount > BlueCount then 
            setPlayerTeam ( source , teamBlue ) 
         elseif RedCount < BlueCount then 
            setPlayerTeam ( source , teamRed ) 
         end 
         outputChatBox ( "You've been moved to the "..getTeamName ( getPlayerTeam ( source ) ):lower ( ).." team!", source ) 
         ouputChatBox ( "teamBlue: ".. tostring ( teamBlue ).. "; teamRed: ".. tostring ( teamRed) ) 
    end 
end 
addEventHandler ( "onPlayerJoin", getRootElement ( ), balanceTeams ) 

Posted
teamRed = createTeam ( "Red", 255, 0, 0 ) 
teamBlue = createTeam ( "Blue", 0, 0, 255 ) 
  
function balanceTeams ( ) 
    local RedCount = countPlayersInTeam ( teamBlue ) 
    local BlueCount = countPlayersInTeam ( teamRed ) 
    if RedCount ~= BlueCount then 
        if RedCount > BlueCount then 
            setPlayerTeam ( source , teamBlue ) 
         elseif RedCount < BlueCount then 
            setPlayerTeam ( source , teamRed ) 
         end 
         outputChatBox ( "You've been moved to the "..getTeamName ( getPlayerTeam ( source ) ):lower ( ).." team!", source ) 
         outputChatBox ( "teamBlue: ".. tostring ( teamBlue ).. "; teamRed: ".. tostring ( teamRed) ) -- You had ouputChatBox 
    end 
end 
addEventHandler ( "onPlayerJoin", getRootElement ( ), balanceTeams ) 

Posted
teamRed = createTeam ( "Red", 255, 0, 0 ) 
teamBlue = createTeam ( "Blue", 0, 0, 255 ) 
  
function balanceTeams () 
    local RedCount = countPlayersInTeam ( teamBlue ) 
    local BlueCount = countPlayersInTeam ( teamRed ) 
    if RedCount ~= BlueCount then 
        if RedCount > BlueCount then 
            setPlayerTeam ( source , teamBlue ) 
         elseif RedCount < BlueCount then 
            setPlayerTeam ( source , teamRed ) 
         end 
    else 
            setPlayerTeam ( source , teamRed ) 
    end 
outputChatBox ( "You've been moved to the "..getTeamName (getPlayerTeam(source)):lower ().." team!", source ) 
end 
addEventHandler ("onPlayerJoin", root, balanceTeams) 

Posted

Tapl see what he say

=======

teams.lua:3: Bad argument @' countPlayersInTeam

teams.lua:3: Bad argument @' getTeamName

attempt to index a boolean value

=========

soldSnake14 dos not setThe Team see the Pic

an3m1.com_13211308691.png

Posted
teamRed = createTeam ( "Red", 255, 0, 0 ) 
teamBlue = createTeam ( "Blue", 0, 0, 255 ) 
  
function balanceTeams () 
    local RedCount = countPlayersInTeam(teamRed) 
    local BlueCount = countPlayersInTeam(teamBlue) 
    if RedCount ~= BlueCount then 
        if RedCount > BlueCount then 
            setPlayerTeam ( source , teamBlue ) 
         elseif RedCount < BlueCount then 
            setPlayerTeam ( source , teamRed ) 
         end 
    else 
            setPlayerTeam ( source , teamRed ) 
    end 
outputChatBox ( "You've been moved to the "..getTeamName (getPlayerTeam(source)):lower ().." team!", source ) 
end 
addEventHandler ("onPlayerJoin", root, balanceTeams) 

Posted

Your script may have some bugs if you restart it with players playing at the time. To prevent it, use this code, please.

teamRed = createTeam ( "Red", 255, 0, 0 ) 
teamBlue = createTeam ( "Blue", 0, 0, 255 ) 
  
function balanceTeams ( player ) 
    if source then player = source end 
    local RedCount = countPlayersInTeam(teamRed) 
    local BlueCount = countPlayersInTeam(teamBlue) 
    if RedCount ~= BlueCount then 
        if RedCount > BlueCount then 
            setPlayerTeam ( player, teamBlue ) 
         elseif RedCount < BlueCount then 
            setPlayerTeam ( player, teamRed ) 
         end 
    else 
            setPlayerTeam ( player, teamRed ) 
    end 
outputChatBox ( "You've been moved to the "..getTeamName (getPlayerTeam(player)):lower ().." team!", player ) 
end 
addEventHandler ("onPlayerJoin", root, balanceTeams) 
  
for i, v in ipairs ( getElementsByType ( "player" ) ) do balanceTeams ( v ) end 

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